|
|
@@ -19,6 +19,7 @@ import com.cyksj.service.corp.CorpFollowDynamicConfigService;
|
|
|
import com.cyksj.service.corp.CorpFollowService;
|
|
|
import com.cyksj.service.corp.WxCorpOps;
|
|
|
import com.cyksj.service.mange.cms.CmsUserManager;
|
|
|
+import com.cyksj.service.sys.SysCorpServiceRelateService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -51,6 +52,8 @@ public class CorpFollowServiceImpl implements CorpFollowService {
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
+ private final SysCorpServiceRelateService sysCorpServiceRelateService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public void postActiveCode(Long adminId, CorpFollowActiveCode activeCode) throws Exception {
|
|
|
@@ -59,11 +62,13 @@ public class CorpFollowServiceImpl implements CorpFollowService {
|
|
|
activeCode.setOperator(cmsUser.getNickname());
|
|
|
}
|
|
|
Boolean isDuty = Optional.ofNullable(activeCode.getIsDuty()).orElse(false);
|
|
|
- List<String> followIds = activeCode.getFollowIds();
|
|
|
- if (CollUtil.isEmpty(followIds)) {
|
|
|
+ List<Integer> userIndxList = activeCode.getUserIndxList();
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(userIndxList)) {
|
|
|
throw BusinessRuntimeException.getInstance("请选择对应客服");
|
|
|
}
|
|
|
- activeCode.setFollowStr(Jsons.toJson(followIds));
|
|
|
+ activeCode.setFollowStr(Jsons.toJson(userIndxList));
|
|
|
+ List<String> followStrList = sysCorpServiceRelateService.getFollowIdsByRelateIds(userIndxList);
|
|
|
activeCode.setMarkTag(activeCode.getMarkTag().trim());
|
|
|
String text = activeCode.getText();
|
|
|
if (StrUtil.isNotBlank(text) && text.length() > 4000) {
|
|
|
@@ -83,9 +88,9 @@ public class CorpFollowServiceImpl implements CorpFollowService {
|
|
|
}
|
|
|
if (!isDuty) {
|
|
|
//生成一个活码 一个客服或多个客服
|
|
|
- codeStr = corpFollowDynamicConfigService.createCorpFollowActiveCode(followIds, Constant.AC_CODE_KEY + activeCode.getId(), isDuty);
|
|
|
+ codeStr = corpFollowDynamicConfigService.createCorpFollowActiveCode(followStrList, userIndxList, Constant.AC_CODE_KEY + activeCode.getId(), isDuty);
|
|
|
} else {
|
|
|
- codeStr = corpFollowDynamicConfigService.createCorpFollowActiveCode(followIds, Constant.AC_CODE_KEY + activeCode.getId(), isDuty);
|
|
|
+ codeStr = corpFollowDynamicConfigService.createCorpFollowActiveCode(followStrList, userIndxList, Constant.AC_CODE_KEY + activeCode.getId(), isDuty);
|
|
|
}
|
|
|
activeCode.setCodeStr(codeStr);
|
|
|
corpFollowActiveCodeMapper.updateById(activeCode);
|
|
|
@@ -102,22 +107,23 @@ public class CorpFollowServiceImpl implements CorpFollowService {
|
|
|
throw BusinessRuntimeException.getInstance("对应的数据已不存在");
|
|
|
}
|
|
|
String db_followStr = dbActiveCode.getFollowStr();
|
|
|
- List<String> up_corpFollows = activeCode.getFollowIds();
|
|
|
- if (CollUtil.isEmpty(up_corpFollows)) {
|
|
|
+ List<Integer> upUserIndxList = activeCode.getUserIndxList();
|
|
|
+ if (CollUtil.isEmpty(upUserIndxList)) {
|
|
|
throw BusinessRuntimeException.getInstance("请选择对应客服");
|
|
|
}
|
|
|
- activeCode.setFollowStr(Jsons.toJson(up_corpFollows));
|
|
|
+ activeCode.setFollowStr(Jsons.toJson(upUserIndxList));
|
|
|
+ List<String> up_followStrList = sysCorpServiceRelateService.getFollowIdsByRelateIds(upUserIndxList);
|
|
|
if (StrUtil.isEmpty(activeCode.getMarkTag())) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入标签");
|
|
|
}
|
|
|
- List<String> db_followIds = Jsons.parseList(db_followStr, String.class);
|
|
|
+ List<Integer> db_followIds = Jsons.parseList(db_followStr, Integer.class);
|
|
|
Boolean isReCreateAcCode = false;
|
|
|
Boolean isUpdateAcCode = false;
|
|
|
- if (db_followIds.size() != up_corpFollows.size()) {
|
|
|
+ if (db_followIds.size() != upUserIndxList.size()) {
|
|
|
isReCreateAcCode = true;
|
|
|
}
|
|
|
if (!isReCreateAcCode) {
|
|
|
- for (String upFollowId : up_corpFollows) {
|
|
|
+ for (Integer upFollowId : upUserIndxList) {
|
|
|
if (!db_followIds.contains(upFollowId)) {
|
|
|
isReCreateAcCode = true;
|
|
|
break;
|
|
|
@@ -143,7 +149,7 @@ public class CorpFollowServiceImpl implements CorpFollowService {
|
|
|
|
|
|
//重新构建活码配置
|
|
|
if (isReCreateAcCode) {
|
|
|
- String code_str = corpFollowDynamicConfigService.createCorpFollowActiveCode(up_corpFollows, Constant.AC_CODE_KEY + activeCode.getId(), up_isDuty);
|
|
|
+ String code_str = corpFollowDynamicConfigService.createCorpFollowActiveCode(up_followStrList, upUserIndxList, Constant.AC_CODE_KEY + activeCode.getId(), up_isDuty);
|
|
|
activeCode.setCodeStr(code_str);
|
|
|
Set<String> keys = redisService.keys(RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getNameFormat(activeCode.getId(), "*"));
|
|
|
redisService.del(keys.toArray(String[]::new));
|