zoujiajian 1 yıl önce
ebeveyn
işleme
5b927df305

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

@@ -31,4 +31,6 @@ public interface CorpKfService {
 	String getUrl(String openKfId, String scene) throws Exception;
 
 	void transCustomer(String followId, String toFollowId, Integer transNum, List<String> transUserIds) throws Exception;
+
+	List<CorpKfAccount> getCorpKfAccountByUId(long cmsUserId);
 }

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

@@ -270,7 +270,7 @@ public class CorpKfServiceImpl implements CorpKfService {
 	@Override
 	public void transCustomer(String followId, String toFollowId, Integer transNum, List<String> transUserIds) throws Exception {
 		List<CorpKfAccountFollow> corpKfAccountFollows = corpKfAccountFollowMapper.selectList(Wrappers.lambdaQuery(CorpKfAccountFollow.class)
-				.apply(" and JSON_CONTAINS(user_id_list,'\"%s\"')", followId));
+				.apply(String.format("JSON_CONTAINS(user_id_list,'\"%s\"')", followId)));
 		List<String> openKfIds = new ArrayList<>();
 		for (CorpKfAccountFollow corpKfAccountFollow : corpKfAccountFollows) {
 			String userIdList = corpKfAccountFollow.getUserIdList();
@@ -309,4 +309,24 @@ public class CorpKfServiceImpl implements CorpKfService {
 			wxCorpOps.transCorpKfSessionToServicer(corpId, corpKfServicerSessionRecord.getOpenKfId(), toFollowId, corpKfServicerSessionRecord.getExternalUserid(), 3);
 		}
 	}
+
+	@Override
+	public List<CorpKfAccount> getCorpKfAccountByUId(long cmsUserId) {
+		List<CorpKfAccount> corpKfAccounts = corpKfAccountMapper.selectList(null);
+		List<String> followIds = corpFollowMapper.selectList(Wrappers.lambdaQuery(CorpFollow.class)
+				.eq(CorpFollow::getCmsUserId, cmsUserId)).stream().map(CorpFollow::getUserid).collect(Collectors.toList());
+
+		return corpKfAccounts.stream().filter(account -> {
+			String openKfId = account.getOpenKfId();
+			for (String followId : followIds) {
+				Integer selectCount = corpKfAccountFollowMapper.selectCount(Wrappers.lambdaQuery(CorpKfAccountFollow.class)
+						.eq(CorpKfAccountFollow::getOpenKfId, openKfId)
+						.apply(String.format("JSON_CONTAINS(user_id_list,'\"%s\"')", followId)));
+				if (selectCount > 0) {
+					return true;
+				}
+			}
+			return false;
+		}).collect(Collectors.toList());
+	}
 }

+ 11 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/wxkf/CorpKfController.java

@@ -225,8 +225,18 @@ public class CorpKfController {
 	@GetMapping("/get/duty/{openKfId}")
 	public Result<List<CorpKfDutyServicersStatusView>> getDutyFollowByOpenKfId(@PathVariable String openKfId) throws Exception {
 		long cmsUserId = StpUtil.getLoginIdAsLong();
-		List<CorpKfDutyServicersStatusView> dutyStatuses= corpKfService.getDutyFollowByOpenKfId(cmsUserId, openKfId);
+		List<CorpKfDutyServicersStatusView> dutyStatuses = corpKfService.getDutyFollowByOpenKfId(cmsUserId, openKfId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(dutyStatuses);
 	}
 
+	/**
+	 * 目前用户值班微信客服
+	 */
+	@GetMapping("/get/duty/accounts")
+	public Result<List<CorpKfAccount>> getCorpKfAccountByUId() {
+		long cmsUserId = StpUtil.getLoginIdAsLong();
+		List<CorpKfAccount> corpKfAccounts = corpKfService.getCorpKfAccountByUId(cmsUserId);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(corpKfAccounts);
+	}
+
 }