社区服务报名取消
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.srs.web.controller.staff;
|
||||
|
||||
import com.srs.common.annotation.Anonymous;
|
||||
import com.srs.common.annotation.Log;
|
||||
import com.srs.common.annotation.RepeatSubmit;
|
||||
import com.srs.common.core.controller.BaseController;
|
||||
@@ -29,6 +30,7 @@ import java.util.Map;
|
||||
* @author chc
|
||||
* @date 2024-07-16
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/staff/OneStopRegistrationRecord")
|
||||
@Api(value = "一站式社区模块-社区活动-报名记录管理", tags = "一站式社区模块-社区活动-报名记录管理")
|
||||
@@ -39,7 +41,6 @@ public class SrsStaffOneStopRegistrationRecordController extends BaseController
|
||||
/**
|
||||
* 查询一站式社区模块-社区活动-报名记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('staff:OneStopRegistrationRecord:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询一站式社区模块-社区活动-报名记录列表")
|
||||
public TableDataInfo list(SrsStaffOneStopRegistrationRecord srsStaffOneStopRegistrationRecord) {
|
||||
@@ -109,7 +110,6 @@ public class SrsStaffOneStopRegistrationRecordController extends BaseController
|
||||
|
||||
/**
|
||||
* 删除一站式社区模块-社区活动-报名记录
|
||||
* 补充详细路径 /delete 知无涯
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('staff:OneStopRegistrationRecord:remove')")
|
||||
@Log(title = "一站式社区模块-社区活动-报名记录", businessType = BusinessType.DELETE)
|
||||
@@ -119,6 +119,26 @@ public class SrsStaffOneStopRegistrationRecordController extends BaseController
|
||||
return toAjax(srsStaffOneStopRegistrationRecordService.deleteSrsStaffOneStopRegistrationRecordByRecordIds(recordIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消报名 - 学生取消自己的社区活动报名
|
||||
*/
|
||||
@Log(title = "一站式社区模块-社区活动-取消报名", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/cancelRegistration/{recordId}")
|
||||
@ApiOperation("取消社区活动报名")
|
||||
@RepeatSubmit(interval = 1000, message = "请求过于频繁")
|
||||
public AjaxResult cancelRegistration(@PathVariable("recordId") Long recordId) {
|
||||
System.out.println("DEBUG: Controller cancelRegistration method called with recordId: " + recordId);
|
||||
try {
|
||||
AjaxResult result = srsStaffOneStopRegistrationRecordService.cancelRegistration(recordId);
|
||||
System.out.println("DEBUG: Service method completed successfully");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
System.out.println("DEBUG: Exception in Controller: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getDepartmentReservationCount")
|
||||
@ApiOperation("统计各部门预约功能房数量")
|
||||
public AjaxResult getDepartmentReservationCount(
|
||||
|
||||
@@ -91,4 +91,12 @@ public interface ISrsStaffOneStopRegistrationRecordService extends IService<SrsS
|
||||
public List<Map<String, Object>> getRoomUsageStatistics(String startTime,String endTime,String role,String borrower,Integer auditStatus,String rtDepar);
|
||||
|
||||
int resetAuditStatus(Integer id);
|
||||
|
||||
/**
|
||||
* 取消报名 - 学生取消自己的社区活动报名
|
||||
*
|
||||
* @param recordId 报名记录ID
|
||||
* @return 结果
|
||||
*/
|
||||
com.srs.common.core.domain.AjaxResult cancelRegistration(Long recordId);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
|
||||
import com.srs.staff.mapper.SrsStaffOneStopRegistrationRecordMapper;
|
||||
import com.srs.staff.domain.SrsStaffOneStopRegistrationRecord;
|
||||
import com.srs.staff.service.ISrsStaffOneStopRegistrationRecordService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -26,6 +28,8 @@ import com.srs.staff.service.ISrsStaffOneStopRegistrationRecordService;
|
||||
*/
|
||||
@Service
|
||||
public class SrsStaffOneStopRegistrationRecordServiceImpl extends ServiceImpl<SrsStaffOneStopRegistrationRecordMapper, SrsStaffOneStopRegistrationRecord> implements ISrsStaffOneStopRegistrationRecordService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SrsStaffOneStopRegistrationRecordServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SrsStaffOneStopRegistrationRecordMapper srsStaffOneStopRegistrationRecordMapper;
|
||||
|
||||
@@ -279,4 +283,85 @@ public class SrsStaffOneStopRegistrationRecordServiceImpl extends ServiceImpl<Sr
|
||||
public int resetAuditStatus(Integer id) {
|
||||
return srsStaffOneStopRegistrationRecordMapper.updateAuditStatusToPending(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消报名 - 学生取消自己的社区活动报名
|
||||
*
|
||||
* @param recordId 报名记录ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public com.srs.common.core.domain.AjaxResult cancelRegistration(Long recordId) {
|
||||
log.info("开始执行取消报名方法,recordId: {}", recordId);
|
||||
try {
|
||||
// 1. 查询报名记录
|
||||
SrsStaffOneStopRegistrationRecord record = srsStaffOneStopRegistrationRecordMapper.selectSrsStaffOneStopRegistrationRecordByRecordId(recordId);
|
||||
if (record == null) {
|
||||
return com.srs.common.core.domain.AjaxResult.error("报名记录不存在");
|
||||
}
|
||||
|
||||
// 2. 查询关联的活动信息
|
||||
if (record.getActivityId() == null) {
|
||||
return com.srs.common.core.domain.AjaxResult.error("报名记录中活动ID为空");
|
||||
}
|
||||
SrsStaffOneStopCommunityActivities activity = srsStaffOneStopCommunityActivitiesMapper.selectSrsStaffOneStopCommunityActivitiesByActivityId(record.getActivityId());
|
||||
if (activity == null) {
|
||||
return com.srs.common.core.domain.AjaxResult.error("活动不存在");
|
||||
}
|
||||
|
||||
// 3. 检查是否在报名截止时间前
|
||||
java.util.Date now = new java.util.Date();
|
||||
if (activity.getSignUpEndTime() != null && now.after(activity.getSignUpEndTime())) {
|
||||
return com.srs.common.core.domain.AjaxResult.error("报名已截止,无法取消报名");
|
||||
}
|
||||
|
||||
// 5. 检查报名状态(只有待审核或已通过的可以取消)
|
||||
if (record.getAuditStatus() != null && record.getAuditStatus() == 2) {
|
||||
return com.srs.common.core.domain.AjaxResult.error("报名已被拒绝,无需取消");
|
||||
}
|
||||
|
||||
// 6. 删除报名记录
|
||||
int result = srsStaffOneStopRegistrationRecordMapper.deleteSrsStaffOneStopRegistrationRecordByRecordId(recordId);
|
||||
|
||||
if (result > 0) {
|
||||
// 7. 发送取消报名通知
|
||||
sendCancelNotice(record, activity);
|
||||
return com.srs.common.core.domain.AjaxResult.success("取消报名成功");
|
||||
} else {
|
||||
return com.srs.common.core.domain.AjaxResult.error("取消报名失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("取消报名失败", e);
|
||||
return com.srs.common.core.domain.AjaxResult.error("取消报名失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送取消报名通知
|
||||
* @param record 报名记录对象
|
||||
* @param activity 活动对象
|
||||
*/
|
||||
private void sendCancelNotice(SrsStaffOneStopRegistrationRecord record, SrsStaffOneStopCommunityActivities activity) {
|
||||
try {
|
||||
// 检查必要参数是否为空
|
||||
if (record == null || activity == null || record.getJobNumber() == null || activity.getActivityTheme() == null) {
|
||||
log.warn("发送取消报名通知失败:参数为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建取消报名通知消息内容
|
||||
String content = String.format(
|
||||
"【活动报名通知】\n" +
|
||||
"您已成功取消报名活动【%s】\n" +
|
||||
"如需重新报名,请在报名截止时间前重新提交申请。",
|
||||
activity.getActivityTheme()
|
||||
);
|
||||
|
||||
// 通过企业微信工具类发送消息
|
||||
weChatUtil.sendTextMessage(record.getJobNumber(), content);
|
||||
} catch (Exception e) {
|
||||
// 记录发送失败日志,但不影响主流程
|
||||
log.error("发送取消报名企业微信消息失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<result property="activityImgs" column="activity_imgs"/>
|
||||
<result property="activePackage" column="active_package"/>
|
||||
<collection property="oneStopRegistrationRecords" column="{activityId=activity_id}"
|
||||
javaType="java.util.ArrayList" select="selectSrsStaffOneStopRegistrationRecordByRecordId"/>
|
||||
javaType="java.util.ArrayList" select="selectSrsStaffOneStopRegistrationRecordByActivityId"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="SrsStaffOneStopRegistrationRecord" id="SrsStaffOneStopRegistrationRecordResult">
|
||||
@@ -37,7 +37,7 @@
|
||||
<result property="jobNumber" column="job_number"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectSrsStaffOneStopRegistrationRecordByRecordId" resultMap="SrsStaffOneStopRegistrationRecordResult">
|
||||
<select id="selectSrsStaffOneStopRegistrationRecordByActivityId" resultMap="SrsStaffOneStopRegistrationRecordResult">
|
||||
select *
|
||||
from srs_staff_one_stop_registration_record
|
||||
<where>
|
||||
|
||||
Reference in New Issue
Block a user