Forráskód Böngészése

修改客服值班,同步值班获客链接;奈飞同步装置确认更新;开启会话存档状态

zoujiajian 2 éve
szülő
commit
02f04a17e7

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/SysCorpFollowView.java

@@ -54,6 +54,12 @@ public class SysCorpFollowView {
 	@DbIgnore
 	List<SysCorpFollowRelateView> subList;
 
+	/**
+	 * 是否开启企业会话
+	 */
+	@DbIgnore
+	private Boolean isOpen = false;
+
 	public String getShowName() {
 		StringBuilder sb = new StringBuilder();
 		sb.append(name).append("(").append(followName).append(")");

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/corp/CorpCustomerAcquisitionLinkService.java

@@ -19,4 +19,9 @@ public interface CorpCustomerAcquisitionLinkService extends IService<CorpCustome
     void del(Long id) throws Exception;
 
     void handleCorpLinkSchedulerJob() throws Exception;
+
+    /**
+     * 同步值班客服
+     */
+    void syncDutyLinkUrl() throws Exception;
 }

+ 20 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpCustomerAcquisitionLinkServiceImpl.java

@@ -1,15 +1,18 @@
 package com.cyksj.service.corp.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
+import com.cyksj.mapper.SysCorpFollowRelateMapper;
 import com.cyksj.mapper.corp.CorpCustomerAcquisitionLinkMapper;
 import com.cyksj.mapper.corp.CorpCustomerAcquisitionLinkPopularizeMapper;
 import com.cyksj.model.entity.CorpCustomerAcquisitionLink;
 import com.cyksj.model.entity.CorpCustomerAcquisitionLinkPopularize;
+import com.cyksj.model.entity.SysCorpFollowRelate;
 import com.cyksj.model.request.corp.link.Range;
 import com.cyksj.model.request.corp.link.WxCpLinkAdd;
 import com.cyksj.model.request.corp.link.WxCpLinkAddResp;
@@ -26,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * @author chan
@@ -42,6 +46,8 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
 
     private final SysCorpServiceRelateService sysCorpServiceRelateService;
 
+    private final SysCorpFollowRelateMapper sysCorpFollowRelateMapper;
+
     @Override
     @Transactional(rollbackFor = Throwable.class)
     public void add(CorpCustomerAcquisitionLink corpCustomerAcquisitionLink) throws Exception {
@@ -126,4 +132,18 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
         //立即执行客服值班定时任务
         XxlJobUtil.executeMarkDynamicRuleTagJob(XxlJobInfo.getExecuteTaskInstance(Constant.CORP_LINK_JOB_ID, StrUtil.EMPTY).toString());
     }
+
+    @Override
+    public void syncDutyLinkUrl() throws Exception {
+        //获取目前可用值班客服
+        List<SysCorpFollowRelate> sysCorpFollowRelates = sysCorpFollowRelateMapper.selectList(Wrappers.lambdaQuery(SysCorpFollowRelate.class)
+                .eq(SysCorpFollowRelate::getStatus, 1)
+                .eq(SysCorpFollowRelate::getDeleted, 1));
+        List<String> userIds = sysCorpFollowRelates.stream().map((e) -> e.getId().toString()).collect(Collectors.toList());
+        if (CollUtil.isNotEmpty(userIds)) {
+            this.update(Wrappers.lambdaUpdate(CorpCustomerAcquisitionLink.class)
+                    .set(CorpCustomerAcquisitionLink::getUserList, Jsons.toJson(userIds))
+                    .eq(CorpCustomerAcquisitionLink::getIsDuty, 1));
+        }
+    }
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/relation/GroupRelationFrontService.java

@@ -38,7 +38,7 @@ public interface GroupRelationFrontService {
 	/**
 	 * 获取车票账号登录 验证码
 	 */
-	String getAiVerifyCode(Long userId, Long relationId, Integer type) throws Exception;
+	String getAiVerifyCode(Long userId, Long relationId, Integer type, Boolean sync) throws Exception;
 
 
 	void checkGroupsAvailParkingNum(Long skuId, Long groupsId, Integer availableParkingNum, Integer maxNum);

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/relation/GroupsRelationNetflixService.java

@@ -17,4 +17,6 @@ public interface GroupsRelationNetflixService {
 	JSONObject setNetflixPin(Long relationId, long userId);
 
 	Integer getPinStatus(String taskId) throws Exception;
+
+	Boolean confirmUpdate(String nfUrl);
 }

+ 14 - 4
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -34,6 +34,7 @@ import com.cyksj.service.mail.MailService;
 import com.cyksj.service.mange.coupon.CouponCommonService;
 import com.cyksj.service.midjourney.MidjourneyAccountService;
 import com.cyksj.service.relation.GroupRelationFrontService;
+import com.cyksj.service.relation.GroupsRelationNetflixService;
 import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.service.user.UserLoginRecordService;
 import com.ejlchina.searcher.BeanSearcher;
@@ -124,6 +125,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 
 	private final GoodsDonQaRelateMapper goodsDonQaRelateMapper;
 
+	private final GroupsRelationNetflixService groupsRelationNetflixService;
+
 	@Override
 	public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account) {
 		User u = userMapper.selectById(userId);
@@ -496,7 +499,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 	}
 
 	@Override
-	public String getAiVerifyCode(Long userId, Long relationId, Integer type) throws Exception {
+	public String getAiVerifyCode(Long userId, Long relationId, Integer type, Boolean sync) throws Exception {
 		List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
 		RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder().field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
 				.field(RenewalView::getRelationId, relationId).build());
@@ -540,7 +543,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		if (execute.getStatus() != HttpStatus.HTTP_OK) {
 			throw BusinessRuntimeException.getInstance("获取验证码异常,请联系客服...");
 		}
-		String code = getDifferentGoodsCode(renewalView.getGoodsId(), execute.body(), type);
+		String code = getDifferentGoodsCode(renewalView.getGoodsId(), execute.body(), type, sync);
 		GroupsRelationLoginCodeRecord record = new GroupsRelationLoginCodeRecord();
 		record.setUserId(userId);
 		record.setRelationId(relationId);
@@ -738,7 +741,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		return expiryTickets;
 	}
 
-	public String getDifferentGoodsCode(Long goodsId, String body, Integer type) {
+	public String getDifferentGoodsCode(Long goodsId, String body, Integer type, Boolean sync) {
 		String code = null;
 		//奈飞
 		if (goodsId == 1) {
@@ -755,7 +758,14 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 					}
 				}
 				if (StrUtil.isNotBlank(code)) {
-					return urlPref + code;
+					String url = urlPref + code;
+					//非点击装置同步更新按钮 直接返回链接
+					if (!sync) return url;
+					//失败返回验证链接
+					if (!groupsRelationNetflixService.confirmUpdate(url)) {
+						return url;
+					}
+					return StrUtil.EMPTY;
 				}
 			}
 			if (type != null && type == 1 && StrUtil.isEmpty(code)) {

+ 21 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupsRelationNetflixServiceImpl.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.relation.impl;
 
+import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
@@ -116,4 +117,24 @@ public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixSe
 		Integer status = data.getInt("status");
 		return status;
 	}
+
+	@Override
+	public Boolean confirmUpdate(String nfUrl) {
+		JSONObject params = new JSONObject();
+		params.putOpt("url", nfUrl);
+		//确认更新点击
+		String url = Constant.ZHAOJU_MOVIES + "/netflix_set/netflix_primary_action";
+		try {
+			cn.hutool.http.HttpResponse execute = HttpUtil
+					.createPost(url)
+					.body(params.toString(), "application/json")
+					.setConnectionTimeout(30000)
+					.setReadTimeout(30000)
+					.execute();
+			JSONObject resp = Jsons.parseObject(execute.body(), JSONObject.class);
+			return resp.getBool("success");
+		} catch (Exception e) {
+		}
+		return false;
+	}
 }

+ 2 - 2
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -617,9 +617,9 @@ public class GroupRelationController {
      * 读取车票账号登录验证码
      */
     @GetMapping("/get/verifyCode/{relationId}")
-    public Result<String> getAiVerifyCode(@PathVariable Long relationId, Integer type) throws Exception {
+    public Result<String> getAiVerifyCode(@PathVariable Long relationId, Integer type, @RequestParam(defaultValue = "0") Boolean sync) throws Exception {
         long userId = StpUserUtil.getLoginIdAsLong();
-        return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getAiVerifyCode(userId, relationId, type));
+        return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getAiVerifyCode(userId, relationId, type, sync));
     }
 
     /**

+ 8 - 0
netflix-web/src/main/java/com/cyksj/web/controller/sys/SysConfigController.java

@@ -26,6 +26,7 @@ import com.cyksj.model.entity.SysConfig;
 import com.cyksj.model.entity.SysConfigChangeRecord;
 import com.cyksj.model.views.HelpQuestionClassificationView;
 import com.cyksj.redis.RedisService;
+import com.cyksj.service.corp.CorpCustomerAcquisitionLinkService;
 import com.cyksj.service.sys.SysConfigChangeRecordService;
 import com.cyksj.service.sys.SysConfigService;
 import com.cyksj.web.util.StpUserUtil;
@@ -69,6 +70,8 @@ public class SysConfigController {
 
 	private final CpsUserAdRecordMapper cpsUserAdRecordMapper;
 
+	private final CorpCustomerAcquisitionLinkService corpCustomerAcquisitionLinkService;
+
 	@GetMapping("/get")
 	public Result<SysConfig> get(String key) {
 		SysConfig sysConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, key).last(" limit 1"));
@@ -113,6 +116,11 @@ public class SysConfigController {
 
 		sysConfigService.updateById(sysConfig);
 
+		//同步获客值班客服
+		if (Constant.serviceKeys.get(0).equals(sysConfig.getSysKey())) {
+			corpCustomerAcquisitionLinkService.syncDutyLinkUrl();
+		}
+
 		if (changeRecord.getChangeCsImg()) {
 			//立即执行客服值班定时任务
 			XxlJobUtil.executeMarkDynamicRuleTagJob(XxlJobInfo.getExecuteTaskInstance(Constant.CORP_LINK_JOB_ID, StrUtil.EMPTY).toString());

+ 12 - 1
netflix-web/src/main/java/com/cyksj/web/controller/sys/SysCorpFollowController.java

@@ -1,5 +1,6 @@
 package com.cyksj.web.controller.sys;
 
+import cn.hutool.core.collection.CollUtil;
 import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
@@ -8,6 +9,7 @@ import com.cyksj.model.request.sys.SysCorpFollowReq;
 import com.cyksj.model.views.SysCorpFollowView;
 import com.cyksj.model.views.SysCorpMasterFollowView;
 import com.cyksj.service.corp.CorpService;
+import com.cyksj.service.corp.WxCorpOps;
 import com.cyksj.service.sys.SysCorpFollowService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.util.MapUtils;
@@ -43,6 +45,10 @@ public class SysCorpFollowController {
 
 	private final HttpServletRequest request;
 
+	private final WxCorpOps wxCorpOps;
+
+	private final YHLXWxCorpConfig corpConfig;
+
 	/**
 	 * 新增客服
 	 */
@@ -74,11 +80,16 @@ public class SysCorpFollowController {
 	 * 客服列表
 	 */
 	@GetMapping("/get")
-	public Result<List<SysCorpFollowView>> get() {
+	public Result<List<SysCorpFollowView>> get() throws Exception {
+		List<String> res = wxCorpOps.getPermitUserList(corpConfig.getCorpId(), null);
 		List<SysCorpFollowView> sysCorpFollowViews = beanSearcher.searchAll(SysCorpFollowView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
 		sysCorpFollowViews.forEach(e->{
 			Integer num = corpUserFollowRelationMapper.selectNumOfCorpuserByFollowId(e.getFollowId());
 			e.setNumOfCorpUser(num);
+			//是否开启企业会话
+			if (CollUtil.isNotEmpty(res) && res.contains(e.getFollowId())) {
+				e.setIsOpen(true);
+			}
 		});
 		return GatewayResponse.SUCCESS.newBuilder().toResult(sysCorpFollowViews);
 	}