|
@@ -37,11 +37,38 @@ public class TransferApplyController {
|
|
|
private TransferApplyService service;
|
|
|
@Autowired
|
|
|
private MqService mqService;
|
|
|
+ /** 转人工申请,受理转人工-受理申请标识 */
|
|
|
+ private final static String TransferApplyAgree = "0";
|
|
|
+ /** 转人工申请,受理转人工-拒绝申请标识 */
|
|
|
+ private final static String TransferApplyNotAgree = "1";
|
|
|
+ /** 转人工申请,受理转人工-结束标识 */
|
|
|
+ private final static String TransferApplyClose = "0";
|
|
|
+ /** 转人工申请,受理转人工-未结束标识 */
|
|
|
+ private final static String TransferApplyNotClose = "1";
|
|
|
|
|
|
/** 创建数据 */
|
|
|
@ApiOperation("创建数据")
|
|
|
@PostMapping("")
|
|
|
public Object save(@RequestBody @Valid TransferApply data) {
|
|
|
+ // 查询是否有申请但是未受理的数据
|
|
|
+ QueryWrapper checkHasAppplyNotAgreeQw = new QueryWrapper<>();
|
|
|
+ checkHasAppplyNotAgreeQw.eq("user_id", data.getUser_id());
|
|
|
+ checkHasAppplyNotAgreeQw.eq("is_agree", TransferApplyNotAgree);
|
|
|
+ Map hasApplyNotAgree = service.getMap(checkHasAppplyNotAgreeQw);
|
|
|
+ if (null != hasApplyNotAgree) {
|
|
|
+ // 抛出异常并发送mq提醒客服人员
|
|
|
+ mqService.sendMsgToAdminForApplyCreate(hasApplyNotAgree);
|
|
|
+ throw new CustomizationException(ExceptionEnum.APPLY_NOT_AGREE);
|
|
|
+ }
|
|
|
+ // 查询是否有申请但是受理中的数据
|
|
|
+ QueryWrapper checkHasApplyNotCloseQw = new QueryWrapper<>();
|
|
|
+ checkHasApplyNotCloseQw.eq("user_id", data.getUser_id());
|
|
|
+ checkHasApplyNotCloseQw.eq("is_agree", TransferApplyAgree);
|
|
|
+ checkHasApplyNotCloseQw.eq("is_close", TransferApplyNotClose);
|
|
|
+ Map hasApplyNotClose = service.getMap(checkHasApplyNotCloseQw);
|
|
|
+ if (null != hasApplyNotClose) {
|
|
|
+ throw new CustomizationException(ExceptionEnum.APPLY_NOT_ClOSE);
|
|
|
+ }
|
|
|
this.service.save(data);
|
|
|
QueryWrapper qw = new QueryWrapper<>();
|
|
|
qw.eq("id", data.getId());
|
|
@@ -56,6 +83,22 @@ public class TransferApplyController {
|
|
|
@ApiOperation("修改数据")
|
|
|
@PostMapping("/{id}")
|
|
|
public Object update(@PathVariable long id, @RequestBody TransferApply data) {
|
|
|
+ // 如果是受理申请,需要查看,除该数据外.当前申请的用户 是否有已被受理 且 未关闭 的转人工申请.
|
|
|
+ // 如果有: 则无法受理当前申请, 需要将之前 受理且未关闭的申请先关闭后再受理
|
|
|
+ String is_agree = data.getIs_agree();
|
|
|
+ if (TransferApplyAgree.equals(is_agree)) {
|
|
|
+ TransferApply oldData = this.service.getById(id);
|
|
|
+ QueryWrapper checkHasApplyAgreeNotCloseQw = new QueryWrapper<>();
|
|
|
+ checkHasApplyAgreeNotCloseQw.ne("id", id);
|
|
|
+ checkHasApplyAgreeNotCloseQw.eq("user_id", oldData.getUser_id());
|
|
|
+ checkHasApplyAgreeNotCloseQw.eq("is_agree", TransferApplyAgree);
|
|
|
+ checkHasApplyAgreeNotCloseQw.eq("is_close", TransferApplyNotClose);
|
|
|
+ Long applyAgreeNotCloseNum = service.count(checkHasApplyAgreeNotCloseQw);
|
|
|
+ if (applyAgreeNotCloseNum > 0) {
|
|
|
+ throw new CustomizationException(ExceptionEnum.NEED_CLOSE_OTHER_APPLYS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
QueryWrapper qw = new QueryWrapper<>();
|
|
|
qw.eq("id", id);
|
|
|
Long num = this.service.count(qw);
|
|
@@ -64,7 +107,11 @@ public class TransferApplyController {
|
|
|
}
|
|
|
data.setId(id);
|
|
|
this.service.updateById(data);
|
|
|
- Object newData = this.service.getById(id);
|
|
|
+ TransferApply newData = this.service.getById(id);
|
|
|
+ // 如果审核通过了, 则需要给申请人发送mq消息.申请人需要知道是谁跟自己对话
|
|
|
+ if (newData.getIs_agree().equals(TransferApplyAgree)) {
|
|
|
+ mqService.sendMsgToApplicant(newData);
|
|
|
+ }
|
|
|
return ResponseFormat.success(newData);
|
|
|
}
|
|
|
|
|
@@ -76,6 +123,7 @@ public class TransferApplyController {
|
|
|
Long skip = null, limit = null;
|
|
|
Map map = new HashMap();
|
|
|
QueryWrapper qw = new QueryWrapper<>();
|
|
|
+ qw.orderByDesc("is_close");
|
|
|
/** 参数处理处理 */
|
|
|
for (String key : allParams.keySet()) {
|
|
|
Object value = allParams.get(key);
|
|
@@ -92,7 +140,10 @@ public class TransferApplyController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /** 分页处理 */
|
|
|
+ /**
|
|
|
+ * 分页处理
|
|
|
+ * TODO: 需要返回用户名称,客服名称
|
|
|
+ */
|
|
|
if (null != skip && null != limit) {
|
|
|
IPage page = new Page<>(skip, limit);
|
|
|
IPage pageResult = service.page(page, qw);
|