Selaa lähdekoodia

Merge remote-tracking branch 'origin/pre' into pre

# Conflicts:
#	netflix-common/src/main/java/com/cyksj/common/constant/Constant.java
zoujiajian 2 viikkoa sitten
vanhempi
sitoutus
802a127e65

+ 2 - 1
netflix-dao/src/main/java/com/cyksj/model/request/corp/CorpFollowContact.java

@@ -15,6 +15,7 @@ public class CorpFollowContact {
 	/**
 	 * 配置id
 	 */
+	@JsonProperty("config_id")
 	private String configId;
 
 	/**
@@ -118,4 +119,4 @@ public class CorpFollowContact {
 	}
 
 
-}
+}

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/corp/CorpFollowDynamicConfigService.java

@@ -15,5 +15,7 @@ public interface CorpFollowDynamicConfigService {
 
 	String createCorpFollowActiveCode(List<String> followIds, List<Integer> userIndxList, String state, Boolean isDuty) throws Exception;
 
+	String updateNormalCorpFollowActiveCode(String codeStr, List<String> followIds, List<Integer> userIndxList, String state) throws Exception;
+
 	void updateCorpFollowActiveCode(String oldMarkTag, String markTag) throws Exception;
 }

+ 34 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowDynamicConfigServiceImpl.java

@@ -97,6 +97,40 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 		return Jsons.toJson(codeList);
 	}
 
+	@Override
+	public String updateNormalCorpFollowActiveCode(String codeStr, List<String> followIds, List<Integer> userIndxList, String state) throws Exception {
+		List<CorpFollowActiveCodeDto> codeList = Jsons.parseList(codeStr, CorpFollowActiveCodeDto.class);
+		if (codeList == null || codeList.size() != 1 || StrUtil.isBlank(codeList.get(0).getConfigId())) {
+			throw BusinessRuntimeException.getInstance("普通活码配置异常,无法更新");
+		}
+
+		List<SysCorpFollowView> corpFollowServiceDtos = beanSearcher.searchAll(SysCorpFollowView.class, MapUtils.builder().build());
+		String serviceNames = null;
+		if (corpFollowServiceDtos != null) {
+			serviceNames = corpFollowServiceDtos.stream()
+					.filter(cs -> userIndxList.contains(Integer.parseInt(cs.getSid().toString())))
+					.map(SysCorpFollowView::getShowName)
+					.collect(Collectors.joining(","));
+		}
+		if (StrUtil.isEmpty(serviceNames)) {
+			throw BusinessRuntimeException.getInstance("存在被删除的客服,请刷新页面重试");
+		}
+
+		CorpFollowActiveCodeDto codeDto = codeList.get(0);
+		CorpFollowContact contact = new CorpFollowContact();
+		contact.setConfigId(codeDto.getConfigId());
+		contact.setUser(followIds);
+		contact.setState(state);
+		contact.setRemark("客服活动活码");
+		contact.setSkip_verify(true);
+		wxCorpOps.updateCorpFollowContactConfig(contact);
+
+		codeDto.setFollowIds(followIds.toString());
+		codeDto.setUserIndxList(userIndxList.toString());
+		codeDto.setServiceNames(serviceNames);
+		return Jsons.toJson(codeList);
+	}
+
 	@Override
 	public void updateCorpFollowActiveCode(String oldMarkTag, String markTag) throws Exception {
 		CorpTag corpTag = corpTagMapper.selectOne(Wrappers.lambdaQuery(CorpTag.class)

+ 8 - 1
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowServiceImpl.java

@@ -149,7 +149,14 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 
 		//重新构建活码配置
 		if (isReCreateAcCode) {
-			String code_str = corpFollowDynamicConfigService.createCorpFollowActiveCode(up_followStrList, upUserIndxList, Constant.AC_CODE_KEY + activeCode.getId(), up_isDuty);
+			String code_str;
+			if (Boolean.TRUE.equals(db_isDuty) || Boolean.TRUE.equals(up_isDuty)) {
+				// 值班模式为一人一码,编辑时允许重新新增配置。
+				code_str = corpFollowDynamicConfigService.createCorpFollowActiveCode(up_followStrList, upUserIndxList, Constant.AC_CODE_KEY + activeCode.getId(), up_isDuty);
+			} else {
+				// 普通模式始终复用原 config_id,避免编辑产生新的企业微信活码。
+				code_str = corpFollowDynamicConfigService.updateNormalCorpFollowActiveCode(dbActiveCode.getCodeStr(), up_followStrList, upUserIndxList, Constant.AC_CODE_KEY + activeCode.getId());
+			}
 			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));

+ 2 - 1
netflix-service/src/main/java/com/cyksj/service/corp/impl/WxCorpOpsImpl.java

@@ -327,7 +327,8 @@ public class WxCorpOpsImpl implements WxCorpOps {
 		String body = IoKit.toString(res.body());
 		JSONObject jsonObject = Jsons.parseObject(body, JSONObject.class);
 		if (jsonObject.getInt("errcode") != 0) {
-			throw BusinessRuntimeException.getInstance("更新客服活码失败");
+			log.error("更新客服活码失败, request:{}, response:{}", Jsons.toJson(corpFollowContact), body);
+			throw BusinessRuntimeException.getInstance("更新客服活码失败: " + jsonObject.getStr("errmsg") + "[" + jsonObject.getInt("errcode") + "]");
 		}
 	}