zoujiajian 1 年間 前
コミット
3ff51bd21c

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/request/corp/kf/CorpKfDutyReq.java

@@ -23,4 +23,9 @@ public class CorpKfDutyReq {
 	 * 是否修改单个
 	 */
 	private Boolean isUpdateSingle = false;
+
+	/**
+	 * 删除ids
+	 */
+	private List<Long> delIds;
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/corp/kf/CorpKfService.java

@@ -22,7 +22,7 @@ public interface CorpKfService {
 
 	void setKfAccountRuleOrAutoReply(CorpKfAccountSessionConfig CorpKfAccountSessionConfig);
 
-	void setKfDuty(CorpKfDutyReq dutyReq);
+	void setKfDuty(CorpKfDutyReq dutyReq) throws Exception;
 
 	void servicerCommute(long cmsUserId, String openKfId, Boolean status) throws Exception;
 

+ 38 - 1
netflix-service/src/main/java/com/cyksj/service/corp/kf/impl/CorpKfServiceImpl.java

@@ -114,7 +114,7 @@ public class CorpKfServiceImpl implements CorpKfService {
 	}
 
 	@Override
-	public void setKfDuty(CorpKfDutyReq dutyReq) {
+	public void setKfDuty(CorpKfDutyReq dutyReq) throws Exception {
 		String openKfId = dutyReq.getOpenKfId();
 		List<CorpKfAccountFollow> dutyList = dutyReq.getDutyList();
 		//非单个 删除其他设置
@@ -133,6 +133,43 @@ public class CorpKfServiceImpl implements CorpKfService {
 			duty.setOpenKfId(openKfId);
 			corpKfAccountFollowMapper.insert(duty);
 		});
+
+		//需要删除的值班
+		if (CollUtil.isNotEmpty(dutyReq.getDelIds())) {
+			corpKfAccountFollowMapper.deleteBatchIds(dutyReq.getDelIds());
+		}
+
+		//将账号下所有值班人员重新设置
+		List<CorpKfAccountFollow> corpKfAccountFollows = corpKfAccountFollowMapper.selectList(Wrappers.lambdaQuery(CorpKfAccountFollow.class)
+				.eq(CorpKfAccountFollow::getOpenKfId, openKfId));
+		//无需值班
+		if (corpKfAccountFollows.isEmpty()) {
+			return;
+		}
+		//值班的客服
+		Set<String> thisDutyFollows = new HashSet<>();
+		for (CorpKfAccountFollow corpKfAccountFollow : corpKfAccountFollows) {
+			thisDutyFollows.addAll(Jsons.parseList(corpKfAccountFollow.getUserIdList(), String.class));
+		}
+		//接待人员列表
+		CorpKfServicerResp corpKfServicerResp = wxCorpOps.getKfServicerList(yhlxWxCorpConfig.getCorpId(), openKfId);
+		List<CorpKfServicerResp.CorpKfServicer> servicerList = corpKfServicerResp.getServicerList();
+		List<String> delDutyFollowIds = new ArrayList<>();
+		for (CorpKfServicerResp.CorpKfServicer corpKfServicer : servicerList) {
+			String userid = corpKfServicer.getUserid();
+			if (userid != null) {
+				if (!thisDutyFollows.contains(userid)) {
+					delDutyFollowIds.add(userid);
+				}
+			}
+		}
+		if (thisDutyFollows.size() > 0) {
+			wxCorpOps.addCorpKfServicer(openKfId, thisDutyFollows);
+		}
+
+		if (delDutyFollowIds.size() > 0) {
+			wxCorpOps.delCorpKfServicer(openKfId, delDutyFollowIds);
+		}
 	}
 
 	@Override