|
|
@@ -9,14 +9,8 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.config.corp.YHLXWxCorpConfig;
|
|
|
import com.cyksj.mapper.corp.CorpFollowMapper;
|
|
|
-import com.cyksj.mapper.corp.kf.CorpKfAccountFollowDutyStatusMapper;
|
|
|
-import com.cyksj.mapper.corp.kf.CorpKfAccountFollowMapper;
|
|
|
-import com.cyksj.mapper.corp.kf.CorpKfAccountMapper;
|
|
|
-import com.cyksj.mapper.corp.kf.CorpKfAccountSessionConfigMapper;
|
|
|
-import com.cyksj.model.entity.CorpFollow;
|
|
|
-import com.cyksj.model.entity.CorpKfAccount;
|
|
|
-import com.cyksj.model.entity.CorpKfAccountFollow;
|
|
|
-import com.cyksj.model.entity.CorpKfAccountSessionConfig;
|
|
|
+import com.cyksj.mapper.corp.kf.*;
|
|
|
+import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.kf.*;
|
|
|
import com.cyksj.model.request.corp.kf.CorpKfDutyReq;
|
|
|
import com.cyksj.model.views.CorpKfDutyServicersStatusView;
|
|
|
@@ -58,6 +52,8 @@ public class CorpKfServiceImpl implements CorpKfService {
|
|
|
|
|
|
private final CorpFollowMapper corpFollowMapper;
|
|
|
|
|
|
+ private final CorpKfServicerSessionRecordMapper corpKfServicerSessionRecordMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void addKfAccount(CorpKfAccount corpKfAccount) throws Exception {
|
|
|
WxCpKfAccountAdd wxCpKfAccountAdd = new WxCpKfAccountAdd();
|
|
|
@@ -259,4 +255,49 @@ public class CorpKfServiceImpl implements CorpKfService {
|
|
|
public String getUrl(String openKfId, String scene) throws Exception {
|
|
|
return wxCorpOps.getUrl(openKfId, scene);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转接客服
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void transCustomer(String followId, String toFollowId) throws Exception {
|
|
|
+ List<CorpKfAccountFollow> corpKfAccountFollows = corpKfAccountFollowMapper.selectList(Wrappers.lambdaQuery(CorpKfAccountFollow.class)
|
|
|
+ .apply(" and JSON_CONTAINS(user_id_list,'\"%s\"')", followId));
|
|
|
+ List<String> openKfIds = new ArrayList<>();
|
|
|
+ for (CorpKfAccountFollow corpKfAccountFollow : corpKfAccountFollows) {
|
|
|
+ String userIdList = corpKfAccountFollow.getUserIdList();
|
|
|
+ List<String> followIds = Jsons.parseList(userIdList, String.class);
|
|
|
+ followIds.remove(followIds);
|
|
|
+ followIds.add(toFollowId);
|
|
|
+ corpKfAccountFollowMapper.updateById(corpKfAccountFollow);
|
|
|
+ if (!openKfIds.contains(corpKfAccountFollow.getOpenKfId())) {
|
|
|
+ openKfIds.add(corpKfAccountFollow.getOpenKfId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CorpKfServicerSessionRecord> corpKfServicerSessionRecords = corpKfServicerSessionRecordMapper.selectList(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getServiceState, 0));
|
|
|
+
|
|
|
+ String corpId = yhlxWxCorpConfig.getCorpId();
|
|
|
+ //添加对应客服
|
|
|
+ for (String openKfId : openKfIds) {
|
|
|
+ CorpKfServicerResp corpKfServicerResp = wxCorpOps.getKfServicerList(yhlxWxCorpConfig.getCorpId(), openKfId);
|
|
|
+ List<CorpKfServicerResp.CorpKfServicer> servicerList = corpKfServicerResp.getServicerList();
|
|
|
+ Set<String> dutyFollowIds = new HashSet<>();
|
|
|
+ for (CorpKfServicerResp.CorpKfServicer corpKfServicer : servicerList) {
|
|
|
+ String userid = corpKfServicer.getUserid();
|
|
|
+ if (userid != null) {
|
|
|
+ dutyFollowIds.add(userid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!dutyFollowIds.isEmpty()) {
|
|
|
+ dutyFollowIds.remove(followId);
|
|
|
+ dutyFollowIds.add(toFollowId);
|
|
|
+ wxCorpOps.addCorpKfServicer(openKfId, dutyFollowIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (CorpKfServicerSessionRecord corpKfServicerSessionRecord : corpKfServicerSessionRecords) {
|
|
|
+ //调用微信客服接口 变更会话状态
|
|
|
+ wxCorpOps.transCorpKfSessionToServicer(corpId, corpKfServicerSessionRecord.getOpenKfId(), toFollowId, corpKfServicerSessionRecord.getExternalUserid());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|