Parcourir la source

获客链接客服值班;订单ip信息记录

zoujiajian il y a 2 ans
Parent
commit
dd2653b78d
28 fichiers modifiés avec 301 ajouts et 413 suppressions
  1. 6 2
      netflix-common/src/main/java/com/cyksj/common/util/StringUtil.java
  2. 0 19
      netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowDutyRelateMapper.java
  3. 0 13
      netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowServiceRelateMapper.java
  4. 19 0
      netflix-dao/src/main/java/com/cyksj/model/dto/CorpFollowServiceDto.java
  5. 2 0
      netflix-dao/src/main/java/com/cyksj/model/dto/YhServiceDto.java
  6. 5 0
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpCustomerAcquisitionLink.java
  7. 0 42
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowDutyRelate.java
  8. 0 27
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowServiceRelate.java
  9. 4 0
      netflix-dao/src/main/java/com/cyksj/model/entity/OrderDon.java
  10. 4 0
      netflix-dao/src/main/java/com/cyksj/model/request/OrderPayRequest.java
  11. 0 21
      netflix-dao/src/main/resources/mapper/CorpFollowDutyRelateMapper.xml
  12. 1 1
      netflix-service/src/main/java/com/cyksj/service/corp/CorpCustomerAcquistionService.java
  13. 0 2
      netflix-service/src/main/java/com/cyksj/service/corp/CorpFollowService.java
  14. 4 0
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpCustomerAcquisitionLinkServiceImpl.java
  15. 48 5
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpCustomerAcquistionServiceImpl.java
  16. 25 202
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowActiveCodeFrontServiceImpl.java
  17. 22 13
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowDynamicConfigServiceImpl.java
  18. 7 47
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowServiceImpl.java
  19. 0 3
      netflix-service/src/main/java/com/cyksj/service/mange/cms/CmsUserManager.java
  20. 6 0
      netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java
  21. 4 0
      netflix-service/src/main/java/com/cyksj/service/sys/SysConfigService.java
  22. 94 2
      netflix-service/src/main/java/com/cyksj/service/sys/impl/SysConfigServiceImpl.java
  23. 1 2
      netflix-web/src/main/java/com/cyksj/web/controller/channel/ChannelController.java
  24. 9 3
      netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java
  25. 14 3
      netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CmsCorpFollowActiveCodeController.java
  26. 8 0
      netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java
  27. 18 1
      netflix-web/src/main/java/com/cyksj/web/controller/register/RegisterController.java
  28. 0 5
      netflix-web/src/main/java/com/cyksj/web/controller/sys/SysConfigController.java

+ 6 - 2
netflix-common/src/main/java/com/cyksj/common/util/StringUtil.java

@@ -2,12 +2,12 @@ package com.cyksj.common.util;
 
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.http.HttpResponse;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
@@ -482,7 +482,11 @@ public final class StringUtil {
 			return "unknown";
 		}
 		try {
-			String rspStr = HttpUtil.get("http://whois.pconline.com.cn/ipJson.jsp?ip=" + ip + "&json=true");
+			String url = String.format("http://whois.pconline.com.cn/ipJson.jsp?ip=%s" + "&json=true", ip);
+			HttpResponse<String> send = J11HttpC
+					.custom().ofGet().url(url)
+					.send(HttpResponse.BodyHandlers.ofString());
+			String rspStr = send.body();
 			if (StrUtil.isEmpty(rspStr)) {
 				return "unknown";
 			}

+ 0 - 19
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowDutyRelateMapper.java

@@ -1,19 +0,0 @@
-package com.cyksj.mapper.corp;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.cyksj.model.entity.CorpFollowDutyRelate;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 项目名: yhlxj2
- * 文件名: CorpFollowDutyRelateMapper
- * 创建者: JavaZou
- * 创建时间:2023/10/9 17:20
- */
-public interface CorpFollowDutyRelateMapper extends BaseMapper<CorpFollowDutyRelate> {
-	List<CorpFollowDutyRelate> selectCorpFollowRelate(@Param("list") List<String> followIds, @Param("isWeekend") Boolean isWeekend);
-
-	List<CorpFollowDutyRelate> selectTodayDutyRelate(@Param("list") List<String> followIds, @Param("type") Integer type);
-}

+ 0 - 13
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowServiceRelateMapper.java

@@ -1,13 +0,0 @@
-package com.cyksj.mapper.corp;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.cyksj.model.entity.CorpFollowServiceRelate;
-
-/**
- * 项目名: yhlxj
- * 文件名: CorpFollowServiceRelateMapper
- * 创建者: JavaZou
- * 创建时间:2023/10/11 9:49
- */
-public interface CorpFollowServiceRelateMapper extends BaseMapper<CorpFollowServiceRelate> {
-}

+ 19 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/CorpFollowServiceDto.java

@@ -0,0 +1,19 @@
+package com.cyksj.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: CorpFollowServiceDto
+ * 创建者: JavaZou
+ * 创建时间:2023/12/21 10:15
+ */
+@Getter
+@Setter
+public class CorpFollowServiceDto {
+
+	private String name;
+
+	private String followId;
+}

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/YhServiceDto.java

@@ -47,6 +47,8 @@ public class YhServiceDto {
 		private Integer index;
 
 		private String url;
+
+		private String followId;
 	}
 
 	public Boolean isBetween(LocalTime currentTime) {

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpCustomerAcquisitionLink.java

@@ -37,6 +37,11 @@ public class CorpCustomerAcquisitionLink extends BaseEntity {
      */
     private String userList;
 
+    /**
+     * 客服选择
+     */
+    private String chooseDutyUsers;
+
 
     /**
      * 是否为无验证

+ 0 - 42
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowDutyRelate.java

@@ -1,42 +0,0 @@
-package com.cyksj.model.entity;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * 项目名: yhlxj2
- * 文件名: CorpFollowDutyRelate
- * 创建者: JavaZou
- * 创建时间:2023/10/9 17:19
- */
-@Getter
-@Setter
-public class CorpFollowDutyRelate extends BaseEntity{
-
-	/**
-	 * 企业微信客服id
-	 */
-	private String followId;
-
-
-	/**
-	 * 企业微信客服名称
-	 */
-	private String followName;
-
-	/**
-	 * 值班客服名称
-	 */
-	private String serviceName;
-
-	private Integer st;
-
-	private Integer et;
-
-	private Integer indexTag;
-
-	/**
-	 * 1工作日,2.周六,3周末
-	 */
-	private Integer type;
-}

+ 0 - 27
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowServiceRelate.java

@@ -1,27 +0,0 @@
-package com.cyksj.model.entity;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * 项目名: yhlxj
- * 文件名: CorpFollowServiceRelate
- * 创建者: JavaZou
- * 创建时间:2023/10/11 9:48
- */
-@Getter
-@Setter
-public class CorpFollowServiceRelate extends BaseEntity{
-
-	/**
-	 * 企业微信客服id
-	 */
-	private String followId;
-
-	private String followName;
-
-	/**
-	 * 值班客服名称
-	 */
-	private String serviceName;
-}

+ 4 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/OrderDon.java

@@ -280,6 +280,10 @@ public class OrderDon extends BaseEntity implements Serializable {
      */
     private String phone;
 
+    private String ip;
+
+    private String location;
+
     public enum Status {
         /**
          * 订单状态

+ 4 - 0
netflix-dao/src/main/java/com/cyksj/model/request/OrderPayRequest.java

@@ -146,4 +146,8 @@ public class OrderPayRequest {
      * 下单手机号
      */
     private String phone;
+
+    private String ip;
+
+    private String location;
 }

+ 0 - 21
netflix-dao/src/main/resources/mapper/CorpFollowDutyRelateMapper.xml

@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.cyksj.mapper.corp.CorpFollowDutyRelateMapper">
-
-
-    <select id="selectCorpFollowRelate" resultType="com.cyksj.model.entity.CorpFollowDutyRelate">
-        select st,et,index from corp_follow_duty_relate where follow_id in
-        <foreach collection="list" item="item" open="(" separator="," close=")">
-            #{item}
-        </foreach> and is_weekend is ${isWeekend} group by st,et,index
-    </select>
-
-    <select id="selectTodayDutyRelate" resultType="com.cyksj.model.entity.CorpFollowDutyRelate">
-        select st,et from corp_follow_duty_relate where follow_id in
-        <foreach collection="list" item="item" open="(" separator="," close=")">
-            #{item}
-        </foreach>
-        and type = #{type} group by st,et order by st
-    </select>
-</mapper>

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

@@ -9,7 +9,7 @@ public interface CorpCustomerAcquistionService {
     /**
      * 获取获客链接
      */
-    String getUrlByLinkId(Long linkId);
+    String getUrlByLinkId(Long linkId) throws Exception;
 
     /**
      * 存储广告平台标识

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

@@ -14,6 +14,4 @@ public interface CorpFollowService{
 	void upActiveCode(CorpFollowActiveCode activeCode) throws Exception;
 
 	void deleteActiveCodeById(Long id) throws Exception;
-
-	void syncActiveCodeFollowRelate(String config) throws Exception;
 }

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

@@ -42,6 +42,8 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
         WxCpLinkAddResp wxCpLinkAddResp = corpOps.customerAcquisitionCreateLink(null, wxCpLinkAdd);
         corpCustomerAcquisitionLink.setUrl(wxCpLinkAddResp.getLink().getUrl());
         corpCustomerAcquisitionLink.setLinkId(wxCpLinkAddResp.getLink().getLinkId());
+
+        corpCustomerAcquisitionLink.setChooseDutyUsers(corpCustomerAcquisitionLink.getUserList());
         this.save(corpCustomerAcquisitionLink);
     }
 
@@ -65,6 +67,8 @@ public class CorpCustomerAcquisitionLinkServiceImpl extends ServiceImpl<CorpCust
             corpCustomerAcquisitionLink.setMsgId(0l);
         }
 
+        corpCustomerAcquisitionLink.setChooseDutyUsers(corpCustomerAcquisitionLink.getUserList());
+
         this.updateById(corpCustomerAcquisitionLink);
     }
 

+ 48 - 5
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpCustomerAcquistionServiceImpl.java

@@ -1,23 +1,30 @@
 package com.cyksj.service.corp.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.json.JSONObject;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import cn.hutool.json.JSONUtil;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.snowflake.Sequence;
-import com.cyksj.common.util.StringUtil;
-import com.cyksj.mapper.channel.ChannelPopularizeMapper;
+import com.cyksj.common.util.Jsons;
 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.request.corp.link.Range;
+import com.cyksj.model.request.corp.link.WxCpLinkUpd;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpCustomerAcquistionService;
+import com.cyksj.service.corp.WxCorpOps;
+import com.cyksj.service.sys.SysConfigService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * @author chan
  * @date 2023/11/28 14:59
@@ -36,15 +43,51 @@ public class CorpCustomerAcquistionServiceImpl implements CorpCustomerAcquistion
 
     private final CorpCustomerAcquisitionLinkMapper corpCustomerAcquisitionLinkMapper;
 
+    private final SysConfigService sysConfigService;
+
+    private final WxCorpOps corpOps;
+
 
     @Override
-    public String getUrlByLinkId(Long linkId) {
+    public String getUrlByLinkId(Long linkId) throws Exception {
         CorpCustomerAcquisitionLinkPopularize corpCustomerAcquisitionLinkPopularize = corpCustomerAcquisitionLinkPopularizeMapper.selectById(linkId);
         Long customerAcquistionLinkId = corpCustomerAcquisitionLinkPopularize.getCustomerAcquistionLinkId();
         CorpCustomerAcquisitionLink corpCustomerAcquisitionLink = corpCustomerAcquisitionLinkMapper.selectById(customerAcquistionLinkId);
         if (corpCustomerAcquisitionLink == null) {
             throw BusinessRuntimeException.getInstance("获客链接不存在.");
         }
+        List<String> dutyServices = sysConfigService.getDutyServices();
+        //值班
+        if (CollUtil.isNotEmpty(dutyServices)) {
+            String userList = corpCustomerAcquisitionLink.getUserList();
+
+            List<String> users = Jsons.parseList(userList, String.class);
+
+            String chooseDutyUsers = corpCustomerAcquisitionLink.getChooseDutyUsers();
+            if (chooseDutyUsers == null) {
+                chooseDutyUsers = userList;
+            }
+            List<String> chooseUserList = Jsons.parseList(chooseDutyUsers, String.class);
+
+            Set<String> fitUsers = dutyServices.stream().filter(e -> users.contains(e)).collect(Collectors.toSet());
+            if (CollUtil.isNotEmpty(fitUsers) && (fitUsers.size() != chooseUserList.size() || !chooseUserList.containsAll(fitUsers))) {
+
+                corpCustomerAcquisitionLink.setChooseDutyUsers(Jsons.toJson(fitUsers));
+
+                //更新获客链接
+                WxCpLinkUpd wxCpLinkUpd = new WxCpLinkUpd();
+                wxCpLinkUpd.setLinkName(corpCustomerAcquisitionLink.getLinkName());
+                wxCpLinkUpd.setLinkId(corpCustomerAcquisitionLink.getLinkId());
+                wxCpLinkUpd.setSkipVerify(corpCustomerAcquisitionLink.getSkipVerify());
+                Range range = new Range();
+                range.setUserList(JSONUtil.parseArray(corpCustomerAcquisitionLink.getChooseDutyUsers()).toList(String.class));
+                wxCpLinkUpd.setRange(range);
+
+                corpOps.customerAcquisitionUpdateLink(null, wxCpLinkUpd);
+            }
+
+        }
+
         return corpCustomerAcquisitionLink.getUrl();
     }
 

+ 25 - 202
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowActiveCodeFrontServiceImpl.java

@@ -5,30 +5,22 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.cyksj.common.constant.Constant;
+import cn.hutool.json.JSONUtil;
 import com.cyksj.common.util.Jsons;
-import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.mapper.corp.CorpFollowActiveCodeClickRecordMapper;
 import com.cyksj.mapper.corp.CorpFollowActiveCodeMapper;
-import com.cyksj.mapper.corp.CorpFollowDutyRelateMapper;
 import com.cyksj.model.dto.CorpFollowActiveCodeDto;
-import com.cyksj.model.dto.YhServiceDto;
 import com.cyksj.model.entity.CorpFollowActiveCode;
 import com.cyksj.model.entity.CorpFollowActiveCodeClickRecord;
-import com.cyksj.model.entity.SysConfig;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpFollowActiveCodeFrontService;
+import com.cyksj.service.sys.SysConfigService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
-import java.time.DayOfWeek;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
-import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -44,13 +36,11 @@ public class CorpFollowActiveCodeFrontServiceImpl implements CorpFollowActiveCod
 
 	private final CorpFollowActiveCodeMapper corpFollowActiveCodeMapper;
 
-	private final CorpFollowDutyRelateMapper corpFollowDutyRelateMapper;
-
 	private final CorpFollowActiveCodeClickRecordMapper corpFollowActiveCodeClickRecordMapper;
 
 	private final RedisService redisService;
 
-	private final SysConfigMapper sysConfigMapper;
+	private final SysConfigService sysConfigService;
 
 	@Override
 	public String getCorpActiveQrCode(Long acId) throws Exception {
@@ -88,169 +78,41 @@ public class CorpFollowActiveCodeFrontServiceImpl implements CorpFollowActiveCod
 		//星期五-->星期六 星期六--->星期天 星期天-->星期一
 		//值班
 		if (corpFollowActiveCode.getIsDuty()) {
-//			if (activeCodeDtos.size() == 1) {
-//				CorpFollowActiveCodeDto corpFollowActiveCodeDto = activeCodeDtos.get(0);
-//				qrCode = corpFollowActiveCodeDto.getQrCode();
-//				redisService.set(activeCodeKey, qrCode, RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getTimeout());
-//				return qrCode;
-//			}
-//			List<CorpFollowDutyRelate> corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//					.le(CorpFollowDutyRelate::getSt, hour)
-//					.ge(CorpFollowDutyRelate::getEt, hour)
-//					.eq(CorpFollowDutyRelate::getType, type));
-//			if (CollUtil.isNotEmpty(corpFollowDutyRelates)) {
-//				qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);
-//				redisService.set(activeCodeKey, qrCode, RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getTimeout());
-//				return qrCode;
-//			}
-//			Integer index;
-//			//未在时间期间
-//			//若在当天之前
-//			//若在当天之后 寻找下日值班客服
-//			List<CorpFollowDutyRelate> todayCorpFollowDuty = corpFollowDutyRelateMapper.selectTodayDutyRelate(followIds, type);
-//			if (CollUtil.isEmpty(todayCorpFollowDuty)) {
-//				List<CorpFollowDutyRelate> dutyRelateList = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//						.ne(CorpFollowDutyRelate::getType, type));
-//				Integer fType = type;
-//				//优化获取下一个工作日 客服
-//				List<CorpFollowDutyRelate> collect = dutyRelateList.stream().filter(data -> data.getType() > fType).collect(Collectors.toList());
-//				if (CollUtil.isEmpty(collect)) {
-//					collect = dutyRelateList;
-//				}
-//				collect.sort(Comparator.comparing(CorpFollowDutyRelate::getSt));
-//				qrCode = getActiveQrCode(collect, activeCodeDtos);
-//				redisService.set(activeCodeKey, qrCode, RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getTimeout());
-//				return qrCode;
-//			}
-//			CorpFollowDutyRelate relate = todayCorpFollowDuty.get(0);
-//			Integer st = relate.getSt();
-//			Integer et = relate.getEt();
-//			//当天
-//			if (hour < st) {
-//				qrCode = getActiveQrCode(corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//						.eq(CorpFollowDutyRelate::getSt, st)
-//						.eq(CorpFollowDutyRelate::getEt, et)
-//						.eq(CorpFollowDutyRelate::getType, type)), activeCodeDtos);
-//				redisService.set(activeCodeKey, qrCode, RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getTimeout());
-//				return qrCode;
-//			}
-//			//下一天
-//			CorpFollowDutyRelate corpFollowDutyRelate = todayCorpFollowDuty.get(todayCorpFollowDuty.size() - 1);
-//			Integer f_et = corpFollowDutyRelate.getEt();
-//			//如果是周五-->周六 周六下午-->周日 周日下午-->周一
-//			if (hour > f_et) {
-//				if (week == Week.FRIDAY) {
-//					index = 3;
-//					corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//							.eq(CorpFollowDutyRelate::getIndexTag, index)
-//							.in(CorpFollowDutyRelate::getFollowId, followIds));
-//					if (CollUtil.isEmpty(corpFollowDutyRelates)) {
-//						index = 4;
-//						corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//								.eq(CorpFollowDutyRelate::getIndexTag, index)
-//								.in(CorpFollowDutyRelate::getFollowId, followIds));
-//					}
-//					qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);
-//				} else if (week == Week.SATURDAY) {
-//					index = 5;
-//					corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//							.eq(CorpFollowDutyRelate::getIndexTag, index)
-//							.in(CorpFollowDutyRelate::getFollowId, followIds));
-//					if (CollUtil.isEmpty(corpFollowDutyRelates)) {
-//						index = 6;
-//						corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//								.eq(CorpFollowDutyRelate::getIndexTag, index)
-//								.in(CorpFollowDutyRelate::getFollowId, followIds));
-//					}
-//					qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);
-//				}else {
-//					index = 1;
-//					corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//							.eq(CorpFollowDutyRelate::getIndexTag, index)
-//							.in(CorpFollowDutyRelate::getFollowId, followIds));
-//					if (CollUtil.isEmpty(corpFollowDutyRelates)) {
-//						index = 2;
-//						corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//								.eq(CorpFollowDutyRelate::getIndexTag, index)
-//								.in(CorpFollowDutyRelate::getFollowId, followIds));
-//					}
-//					qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);
-//				}
-//				redisService.set(activeCodeKey, qrCode, RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getTimeout());
-//				return qrCode;
-//			}
-//			//兜底
-//			log.info("当前时间:{}客户通过活动acId:{}未到获取客服活码,进行兜底", DateTime.now(), acId);
-//			corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-//					.in(CorpFollowDutyRelate::getFollowId, followIds));
-//			qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);
-//			redisService.set(activeCodeKey, qrCode, RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getTimeout());
-//			return qrCode;
 			qrCode = getDutyServiceCode(activeCodeDtos);
 			return qrCode;
 		}
 		return null;
 	}
 
-
-//	public String getActiveQrCode(List<CorpFollowDutyRelate> corpFollowDutyRelates, List<CorpFollowActiveCodeDto> activeCodeDtos) {
-//		Integer randNum = 0;
-//		if (corpFollowDutyRelates.size() > 1) {
-//			randNum = RandomUtil.randomInt(corpFollowDutyRelates.size());
-//		}
-//		for (CorpFollowActiveCodeDto activeCodeDto : activeCodeDtos) {
-//			if (activeCodeDto.getFollowIds().contains(corpFollowDutyRelates.get(randNum).getFollowId())) {
-//				return activeCodeDto.getQrCode();
-//			}
-//		}
-//		//兜底
-//		randNum = RandomUtil.randomInt(activeCodeDtos.size());
-//		CorpFollowActiveCodeDto activeCodeDto = activeCodeDtos.get(randNum);
-//		return activeCodeDto.getQrCode();
-//	}
-
 	/**
 	 * 获取对应值班客服的二维码
 	 */
 	public String getDutyServiceCode(List<CorpFollowActiveCodeDto> activeCodeDtos) {
-		SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
-				.eq(SysConfig::getSysKey, Constant.serviceKeys.get(0))
-				.last("limit 1"));
-		// 用当前日期时间创建一个 LocalDateTime 对象
-		LocalDateTime now = LocalDateTime.now();
-
-		// 获取当前时间
-		LocalTime currentTime = now.toLocalTime();
-		CorpFollowActiveCodeDto activeCodeDto = null;
-
-		if (sysConfig != null) {
-			String sysValue = sysConfig.getSysValue();
-			if (StrUtil.isNotEmpty(sysValue)) {
+		List<String> dutyServices = sysConfigService.getDutyServices();
+		String chooseFollowId = null;
+		//值班
+		if (CollUtil.isNotEmpty(dutyServices)) {
+			List<String> collectFollow = new ArrayList<>();
+			activeCodeDtos.stream().forEach(e -> {
 				try {
-					List<YhServiceDto> yhServiceDtos = Jsons.parseList(sysValue, YhServiceDto.class);
-					Map<String, List<YhServiceDto>> dutyServices = yhServiceDtos.stream().collect(Collectors.groupingBy(YhServiceDto::getSign));
-					DayOfWeek currentDayOfWeek = now.getDayOfWeek();
-					List<YhServiceDto> workdayService = dutyServices.get("workday");
-
-					if (CollUtil.isNotEmpty(workdayService)) {
-						List<YhServiceDto> saturdayService = dutyServices.get("Saturday");
-						List<YhServiceDto> sundayServices = dutyServices.get("Sunday");
-
-						List<YhServiceDto> carryServices = getDutyService(currentDayOfWeek, workdayService, saturdayService, sundayServices);
-						//获取值班客服
-						YhServiceDto dutyServiceCode = getDutyServiceCode(carryServices, workdayService, saturdayService, sundayServices, currentDayOfWeek, currentTime);
-						if (CollUtil.isNotEmpty(dutyServiceCode.getSelect())) {
-							List<String> collect_follow = activeCodeDtos.stream().map(CorpFollowActiveCodeDto::getServiceNames).collect(Collectors.toList());
-							YhServiceDto.CustomerServiceDto customerServiceDto = dutyServiceCode.getSelect().parallelStream().filter(select -> collect_follow.contains(select.getName())).findAny().get();
-							if (customerServiceDto != null) {
-								activeCodeDto = activeCodeDtos.stream().filter(active -> active.getServiceNames().equals(customerServiceDto.getName())).findFirst().get();
-							}
-						}
-					}
-				} catch (Exception e) {
+					collectFollow.addAll(JSONUtil.parseArray(e.getFollowIds()).toList(String.class));
+				} catch (Exception ex) {
+					System.out.println(ex.getMessage());
 				}
+			});
+			List<String> collect = dutyServices.stream().filter(fid -> collectFollow.contains(fid)).collect(Collectors.toList());
+			if (CollUtil.isNotEmpty(collect)) {
+				chooseFollowId = collect.get(RandomUtil.randomInt(collect.size()));
 			}
 		}
+
+		CorpFollowActiveCodeDto activeCodeDto = null;
+		if (chooseFollowId != null) {
+			log.info("寻找合适值班客服:{}", chooseFollowId);
+			final String csFollowId = chooseFollowId;
+			activeCodeDto = activeCodeDtos.stream().filter(active -> active.getFollowIds().contains(csFollowId)).findFirst().get();
+		}
+
 		if (activeCodeDto == null) {
 			//兜底
 			Integer randNum = RandomUtil.randomInt(activeCodeDtos.size());
@@ -259,43 +121,4 @@ public class CorpFollowActiveCodeFrontServiceImpl implements CorpFollowActiveCod
 		}
 		return activeCodeDto.getQrCode();
 	}
-
-	/**
-	 * 获取工作日
-	 */
-	public YhServiceDto getDutyServiceCode(List<YhServiceDto> carryServices, List<YhServiceDto> workday, List<YhServiceDto> saturday, List<YhServiceDto> sunday, DayOfWeek currentDayOfWeek, LocalTime currentTime) {
-		return carryServices.parallelStream().filter(time -> time.isBetween(currentTime)).findAny().orElseGet(() -> {
-			return carryServices.stream().filter(time -> time.isAfter(currentTime)).findAny().orElseGet(() -> {
-				// 如果没有下一个时间段,获取下一个工作时间段的开始时间
-				DayOfWeek nextWorkDay = getNextWorkDay(currentDayOfWeek);
-				List<YhServiceDto> nextServices = getDutyService(nextWorkDay, workday, saturday, sunday);
-				//获取下一天的早时
-				return nextServices.get(0);
-			});
-		});
-	}
-
-	/**
-	 * 返回明天星期几 用户获取对应周期工作客服
-	 */
-	private static DayOfWeek getNextWorkDay(DayOfWeek currentDay) {
-		// 如果当前是周五,下一个工作日是周一;否则,是当前星期的下一天
-		if (currentDay == java.time.DayOfWeek.FRIDAY) {
-			return java.time.DayOfWeek.SATURDAY;
-		}
-		if (currentDay == DayOfWeek.SATURDAY) {
-			return DayOfWeek.SUNDAY;
-		}
-		return DayOfWeek.MONDAY;
-	}
-
-	private List<YhServiceDto> getDutyService(DayOfWeek nextWorkDay, List<YhServiceDto> workday, List<YhServiceDto> saturday, List<YhServiceDto> sunday) {
-		if (nextWorkDay == DayOfWeek.SATURDAY) {
-			return Optional.ofNullable(saturday).orElse(Optional.ofNullable(sunday).orElse(workday));
-		}
-		if (nextWorkDay == DayOfWeek.SUNDAY) {
-			return Optional.ofNullable(sunday).orElse(workday);
-		}
-		return workday;
-	}
 }

+ 22 - 13
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowDynamicConfigServiceImpl.java

@@ -3,16 +3,17 @@ package com.cyksj.service.corp.impl;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
+import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.mapper.corp.CorpFollowConfigMapper;
-import com.cyksj.mapper.corp.CorpFollowDutyRelateMapper;
-import com.cyksj.mapper.corp.CorpFollowServiceRelateMapper;
 import com.cyksj.mapper.corp.CorpTagMapper;
 import com.cyksj.model.dto.CorpFollowActiveCodeDto;
+import com.cyksj.model.dto.CorpFollowServiceDto;
 import com.cyksj.model.entity.CorpFollowConfig;
-import com.cyksj.model.entity.CorpFollowServiceRelate;
 import com.cyksj.model.entity.CorpTag;
+import com.cyksj.model.entity.SysConfig;
 import com.cyksj.model.request.corp.CorpFollowContact;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
 import com.cyksj.service.corp.WxCorpOps;
@@ -39,12 +40,10 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 
 	private final CorpFollowConfigMapper corpFollowConfigMapper;
 
-	private final CorpFollowDutyRelateMapper corpFollowDutyRelateMapper;
-
-	private final CorpFollowServiceRelateMapper serviceRelateMapper;
-
 	private final CorpTagMapper corpTagMapper;
 
+	private final SysConfigMapper sysConfigMapper;
+
 	@Override
 	public String corpFollowContactConfig(CorpFollowContact corpFollowContact) throws Exception {
 		String body = wxCorpOps.corpFollowContactConfig(corpFollowContact);
@@ -65,6 +64,12 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 	@Override
 	public String createCorpFollowActiveCode(List<String> followIds, String state, Boolean isDuty) throws Exception {
 		List<CorpFollowActiveCodeDto> codeList = new ArrayList<>();
+		SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
+				.eq(SysConfig::getSysKey, Constant.serviceKeys.get(1)).last("limit 1"));
+		List<CorpFollowServiceDto> corpFollowServiceDtos = null;
+		if (sysConfig != null && StrUtil.isNotBlank(sysConfig.getSysValue())) {
+			corpFollowServiceDtos = Jsons.parseList(sysConfig.getSysValue(), CorpFollowServiceDto.class);
+		}
 		Integer type = 1;
 		if (!isDuty) {
 			//不是值班 多人生成一个二维码
@@ -72,21 +77,25 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 			if (followIds.size() > 1) {
 				type = 2;
 			}
-			String serviceNames = serviceRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowServiceRelate.class)
-					.in(CorpFollowServiceRelate::getFollowId, followIds)).stream().map(CorpFollowServiceRelate::getServiceName).collect(Collectors.joining(","));
+			String serviceNames = null;
+			if (corpFollowServiceDtos != null) {
+				serviceNames = corpFollowServiceDtos.stream().filter(cs -> followIds.contains(cs.getFollowId())).map(CorpFollowServiceDto::getName).collect(Collectors.joining(","));
+			}
 			if (StrUtil.isEmpty(serviceNames)) {
 				throw BusinessRuntimeException.getInstance("存在被删除的客服,请刷新页面重试");
 			}
 			CorpFollowActiveCodeDto corpFollowActiveCodeDto = createCorpFollowActiveCode(followIds, state, type, serviceNames);
 			codeList.add(corpFollowActiveCodeDto);
 		} else {
-			Map<String, List<CorpFollowServiceRelate>> collect = serviceRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowServiceRelate.class)
-					.in(CorpFollowServiceRelate::getFollowId, followIds)).stream().collect(Collectors.groupingBy(CorpFollowServiceRelate::getFollowId));
-			if (collect.keySet().size() != followIds.size()) {
+			Map<String, List<CorpFollowServiceDto>> csMap = null;
+			if (corpFollowServiceDtos != null) {
+				csMap = corpFollowServiceDtos.stream().filter(cs -> followIds.contains(cs.getFollowId())).collect(Collectors.groupingBy(CorpFollowServiceDto::getFollowId));
+			}
+			if (csMap == null || csMap.keySet().size() != followIds.size()) {
 				throw BusinessRuntimeException.getInstance("存在被删除的客服,请刷新页面重试");
 			}
 			for (String followId : followIds) {
-				CorpFollowActiveCodeDto corpFollowActiveCodeDto = createCorpFollowActiveCode(List.of(followId), state, type, collect.get(followId).get(0).getServiceName());
+				CorpFollowActiveCodeDto corpFollowActiveCodeDto = createCorpFollowActiveCode(List.of(followId), state, type, csMap.get(followId).get(0).getName());
 				codeList.add(corpFollowActiveCodeDto);
 			}
 		}

+ 7 - 47
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowServiceImpl.java

@@ -1,16 +1,18 @@
 package com.cyksj.service.corp.impl;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
-import com.cyksj.mapper.corp.*;
-import com.cyksj.model.dto.YhServiceDto;
-import com.cyksj.model.entity.*;
+import com.cyksj.mapper.corp.CorpFollowActiveCodeMapper;
+import com.cyksj.mapper.corp.CorpTagGroupMapper;
+import com.cyksj.mapper.corp.CorpTagMapper;
+import com.cyksj.model.entity.CmsUser;
+import com.cyksj.model.entity.CorpFollowActiveCode;
+import com.cyksj.model.entity.CorpTag;
+import com.cyksj.model.entity.CorpTagGroup;
 import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
@@ -41,10 +43,6 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 
 	private final CorpFollowDynamicConfigService corpFollowDynamicConfigService;
 
-	private final CorpFollowDutyRelateMapper corpFollowDutyRelateMapper;
-
-	private final CorpFollowServiceRelateMapper corpFollowServiceRelateMapper;
-
 	private final WxCorpOps wxCorpOps;
 
 	private final CorpTagMapper corpTagMapper;
@@ -184,42 +182,4 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 					.eq(CorpTagGroup::getGroupId, corpTag.getGroupId()));
 		}
 	}
-
-	@Override
-	public void syncActiveCodeFollowRelate(String config) throws Exception {
-		if (StrUtil.isEmpty(config)) {
-			return;
-		}
-		corpFollowDutyRelateMapper.delete(null);
-		List<YhServiceDto> yhServiceDtos = Jsons.parseList(config, YhServiceDto.class);
-		yhServiceDtos.forEach(data -> {
-			DateTime stTime = DateUtil.parse(data.getStartTime(), "HH:mm");
-			int st = stTime.hour(true);
-			DateTime etTime = DateUtil.parse(data.getEndTime(), "HH:mm");
-			int et = etTime.hour(true);
-			List<YhServiceDto.CustomerServiceDto> select = data.getSelect();
-			select.forEach(cs -> {
-				String name = cs.getName();
-				CorpFollowDutyRelate relate = new CorpFollowDutyRelate();
-				CorpFollowServiceRelate corpFollowServiceRelate = corpFollowServiceRelateMapper.selectOne(Wrappers.lambdaQuery(CorpFollowServiceRelate.class)
-						.eq(CorpFollowServiceRelate::getServiceName, name).last("limit 1"));
-				if (corpFollowServiceRelate != null) {
-					relate.setFollowId(corpFollowServiceRelate.getFollowId());
-					relate.setFollowName(corpFollowServiceRelate.getFollowName());
-					relate.setServiceName(name);
-					relate.setSt(st);
-					relate.setEt(et);
-					Integer index = data.getIndex();
-					relate.setIndexTag(index);
-					//1工作日,2.周六,3周末
-					Integer type = index <= 2 ? 1 : index <= 4 ? 2 : 3;
-					relate.setType(type);
-					corpFollowDutyRelateMapper.insert(relate);
-				}
-			});
-		});
-		//清除客服活码缓存
-		Set<String> keys = redisService.keys(RedisService.key.CORP_FOLLOW_ACTIVE_CODE_CLEAN_KEY.getNameFormat("*"));
-		redisService.del(keys.toArray(String[]::new));
-	}
 }

+ 0 - 3
netflix-service/src/main/java/com/cyksj/service/mange/cms/CmsUserManager.java

@@ -7,7 +7,6 @@ import com.cyksj.mapper.manage.cms.CmsMenuMapper;
 import com.cyksj.mapper.manage.cms.CmsRoleMapper;
 import com.cyksj.mapper.manage.cms.CmsUserMapper;
 import com.cyksj.mapper.manage.cms.CmsUserRoleMapper;
-import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
 import com.cyksj.model.entity.CmsMenu;
 import com.cyksj.model.entity.CmsRole;
 import com.cyksj.model.entity.CmsUser;
@@ -44,8 +43,6 @@ public class CmsUserManager {
 
 	private final CmsUserRoleMapper cmsUserRoleMapper;
 
-	private final UserDistributeMapper userDistributeMapper;
-
 	private final UserBusinessRateService userBusinessRateService;
 
 	private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();

+ 6 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -346,6 +346,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		/* 生成订单 */
 		String donNo = SEQUENCE.nextId().toString();
 		OrderDon orderDon = new OrderDon();
+		orderDon.setIp(payRequest.getIp());
+		orderDon.setLocation(payRequest.getLocation());
+
 		orderDon.setIsDp(false);
 		if (isNoLogin != null && isNoLogin) {
 			orderDon.setIsNoLogin(true);
@@ -918,6 +921,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		/* 生成订单 */
 		String donNo = SEQUENCE.nextId().toString();
 		OrderDon orderDon = new OrderDon();
+		orderDon.setIp(payRequest.getIp());
+		orderDon.setLocation(payRequest.getLocation());
+
 		orderDon.setOrderNo(donNo);
 		orderDon.setOpenId(payOpenId);
 		orderDon.setYhsId(yhsId);

+ 4 - 0
netflix-service/src/main/java/com/cyksj/service/sys/SysConfigService.java

@@ -3,6 +3,8 @@ package com.cyksj.service.sys;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.cyksj.model.entity.SysConfig;
 
+import java.util.List;
+
 /**
  * @author chan
  * @date 2022/10/20 10:07 AM
@@ -14,4 +16,6 @@ public interface SysConfigService extends IService<SysConfig> {
 	 * @param type wx\zfb
 	 */
 	String getDefaultShopConfigByType(String type);
+
+	List<String> getDutyServices();
 }

+ 94 - 2
netflix-service/src/main/java/com/cyksj/service/sys/impl/SysConfigServiceImpl.java

@@ -1,18 +1,28 @@
 package com.cyksj.service.sys.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.RandomUtil;
+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.util.Jsons;
 import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.model.dto.DefaultShopConfig;
+import com.cyksj.model.dto.YhServiceDto;
 import com.cyksj.model.entity.ShopConfig;
 import com.cyksj.model.entity.SysConfig;
 import com.cyksj.service.sys.SysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.time.DayOfWeek;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.List;
+import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * @author chan
@@ -43,12 +53,94 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper,SysConfig>
 		}
 		return getShopIdByType(type);
 	}
-
-
 	public String getShopIdByType(String type) {
 		if ("wx".equals(type)) {
 			return ShopConfig.WX_DEFAULT_APP_ID;
 		}
 		return ShopConfig.ZFB_DEFAULT_APP_ID;
 	}
+
+
+	@Override
+	public List<String> getDutyServices() {
+		SysConfig sysConfig = this.getOne(Wrappers.lambdaQuery(SysConfig.class)
+				.eq(SysConfig::getSysKey, Constant.serviceKeys.get(0))
+				.last("limit 1"));
+		// 用当前日期时间创建一个 LocalDateTime 对象
+		LocalDateTime now = LocalDateTime.now();
+
+		// 获取当前时间
+		LocalTime currentTime = now.toLocalTime();
+
+		if (sysConfig != null) {
+			String sysValue = sysConfig.getSysValue();
+			if (StrUtil.isNotEmpty(sysValue)) {
+				try {
+					List<YhServiceDto> yhServiceDtos = Jsons.parseList(sysValue, YhServiceDto.class);
+					Map<String, List<YhServiceDto>> dutyServices = yhServiceDtos.stream().collect(Collectors.groupingBy(YhServiceDto::getSign));
+					DayOfWeek currentDayOfWeek = now.getDayOfWeek();
+					List<YhServiceDto> workdayService = dutyServices.get("workday");
+
+					if (CollUtil.isNotEmpty(workdayService)) {
+						List<YhServiceDto> saturdayService = dutyServices.get("Saturday");
+						List<YhServiceDto> sundayServices = dutyServices.get("Sunday");
+
+						List<YhServiceDto> carryServices = getDutyService(currentDayOfWeek, workdayService, saturdayService, sundayServices);
+						//获取值班客服
+						YhServiceDto dutyServiceCode = getDutyServiceCode(carryServices, workdayService, saturdayService, sundayServices, currentDayOfWeek, currentTime);
+						if (CollUtil.isNotEmpty(dutyServiceCode.getSelect())) {
+							return dutyServiceCode.getSelect().stream().filter(e -> StrUtil.isNotBlank(e.getFollowId())).map(YhServiceDto.CustomerServiceDto::getFollowId).collect(Collectors.toList());
+						}
+					}
+				} catch (Exception e) {
+				}
+			}
+		}
+		return null;
+	}
+
+
+
+	/**
+	 * 返回明天星期几 用户获取对应周期工作客服
+	 */
+	private static DayOfWeek getNextWorkDay(DayOfWeek currentDay) {
+		// 如果当前是周五,下一个工作日是周一;否则,是当前星期的下一天
+		if (currentDay == java.time.DayOfWeek.FRIDAY) {
+			return java.time.DayOfWeek.SATURDAY;
+		}
+		if (currentDay == DayOfWeek.SATURDAY) {
+			return DayOfWeek.SUNDAY;
+		}
+		return DayOfWeek.MONDAY;
+	}
+
+	private List<YhServiceDto> getDutyService(DayOfWeek nextWorkDay, List<YhServiceDto> workday, List<YhServiceDto> saturday, List<YhServiceDto> sunday) {
+		if (nextWorkDay == DayOfWeek.SATURDAY) {
+			return Optional.ofNullable(saturday).orElse(Optional.ofNullable(sunday).orElse(workday));
+		}
+		if (nextWorkDay == DayOfWeek.SUNDAY) {
+			return Optional.ofNullable(sunday).orElse(workday);
+		}
+		return workday;
+	}
+
+
+	/**
+	 * 获取工作日
+	 */
+	public YhServiceDto getDutyServiceCode(List<YhServiceDto> carryServices, List<YhServiceDto> workday, List<YhServiceDto> saturday, List<YhServiceDto> sunday, DayOfWeek currentDayOfWeek, LocalTime currentTime) {
+		List<YhServiceDto> collect = carryServices.stream().filter(time -> time.isBetween(currentTime)).collect(Collectors.toList());
+		if (CollUtil.isEmpty(collect)) {
+			collect = carryServices.stream().filter(time -> time.isAfter(currentTime)).collect(Collectors.toList());
+			if (CollUtil.isEmpty(collect)) {
+				// 如果没有下一个时间段,获取下一个工作时间段的开始时间
+				DayOfWeek nextWorkDay = getNextWorkDay(currentDayOfWeek);
+				List<YhServiceDto> nextServices = getDutyService(nextWorkDay, workday, saturday, sunday);
+				//获取下一天的早时
+				return nextServices.get(0);
+			}
+		}
+		return collect.get(RandomUtil.randomInt(collect.size()));
+	}
 }

+ 1 - 2
netflix-web/src/main/java/com/cyksj/web/controller/channel/ChannelController.java

@@ -24,7 +24,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.util.List;
 
 /**
@@ -101,7 +100,7 @@ public class ChannelController {
      * 橙子建站带参跳转获客链接
      */
     @GetMapping("/customerAcquistion")
-    public void customerAcquistion(String projectid, String clickid, String callback, Long linkId) throws IOException {
+    public void customerAcquistion(String projectid, String clickid, String callback, Long linkId) throws Exception {
         log.info("橙子建站带参跳转获客链接 projectid:{} clickid:{},callback:{}",projectid, clickid, callback);
 
         String key = corpCustomerAcquistionService.saveClickid(projectid, clickid, callback, linkId);

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

@@ -121,11 +121,17 @@ public class GroupRelationController {
     }
 
     @PostMapping("/post/renewal")
-    public Result<OrderDon> renewal(@RequestBody OrderPayRequest request) throws Exception {
+    public Result<OrderDon> renewal(@RequestBody OrderPayRequest payRequest) throws Exception {
         long userId = StpUserUtil.getLoginIdAsLong();
-        request.setUserId(userId);
+        payRequest.setUserId(userId);
+
+        String ip = ServletUtil.getClientIP(request);
+        String location = StringUtil.getRealAddressByIP(ip);
+
+        payRequest.setIp(ip);
+        payRequest.setLocation(location);
 
-        OrderDon orderDon = orderDonService.renewal(request);
+        OrderDon orderDon = orderDonService.renewal(payRequest);
         return GatewayResponse.SUCCESS.newBuilder().toResult(orderDon);
     }
 

+ 14 - 3
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CmsCorpFollowActiveCodeController.java

@@ -3,6 +3,7 @@ package com.cyksj.web.controller.manage.corp;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.constant.Constant;
 import com.cyksj.common.util.Jsons;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
@@ -10,6 +11,7 @@ import com.cyksj.mapper.OrderDonMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.mapper.corp.CorpWelcomeTemplateMapper;
 import com.cyksj.mapper.manage.coupon.CouponMapper;
+import com.cyksj.model.dto.CorpFollowServiceDto;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.model.request.corp.CorpFollowContact;
@@ -20,6 +22,7 @@ import com.cyksj.model.views.CorpFollowActiveCodeView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
 import com.cyksj.service.corp.CorpFollowService;
+import com.cyksj.service.sys.SysConfigService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.param.Operator;
@@ -64,6 +67,8 @@ public class CmsCorpFollowActiveCodeController {
 
 	private final CorpWelcomeTemplateMapper corpWelcomeTemplateMapper;
 
+	private final SysConfigService sysConfigService;
+
 	private final HttpServletRequest request;
 
 	/**
@@ -91,9 +96,15 @@ public class CmsCorpFollowActiveCodeController {
 	 * 可选客服配置
 	 */
 	@GetMapping("/get/available/follow")
-	public Result<List<CorpFollowServiceRelate>> getAvailableFollow() {
-		List<CorpFollowServiceRelate> corpFollowServiceRelates = beanSearcher.searchAll(CorpFollowServiceRelate.class, MapUtils.flatBuilder(request.getParameterMap()).build());
-		return GatewayResponse.SUCCESS.newBuilder().toResult(corpFollowServiceRelates);
+	public Result<List<CorpFollowServiceDto>> getAvailableFollow() throws Exception {
+		SysConfig config = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+				.eq(SysConfig::getSysKey, Constant.serviceKeys.get(1)).last("limit 1"));
+		if (config == null || StrUtil.isEmpty(config.getSysValue())) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		String sysValue = config.getSysValue();
+		List<CorpFollowServiceDto> corpFollowServiceDtos = Jsons.parseList(sysValue, CorpFollowServiceDto.class);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(corpFollowServiceDtos);
 	}
 
 	/**

+ 8 - 0
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.codec.Base64;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
+import cn.hutool.extra.servlet.ServletUtil;
 import cn.hutool.json.JSONObject;
 import com.alipay.api.response.AlipayFundTransCommonQueryResponse;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -11,6 +12,7 @@ import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.IoKit;
 import com.cyksj.common.util.Jsons;
+import com.cyksj.common.util.StringUtil;
 import com.cyksj.common.util.Xmls;
 import com.cyksj.config.zfb.BaseZfbConfig;
 import com.cyksj.config.zfb.ZfbProductCode;
@@ -133,6 +135,12 @@ public class OrderController {
         payRequest.setUserId(userId);
         log.info("{}[start] params:{}", methodName, payRequest);
 
+        String ip = ServletUtil.getClientIP(request);
+        String location = StringUtil.getRealAddressByIP(ip);
+
+        payRequest.setIp(ip);
+        payRequest.setLocation(location);
+
         OrderDon orderDon = orderDonService.submit(payRequest);
 
         //无登录订单 预留手机号免登录

+ 18 - 1
netflix-web/src/main/java/com/cyksj/web/controller/register/RegisterController.java

@@ -22,6 +22,7 @@ import com.cyksj.model.response.AliPayTradeStatus;
 import com.cyksj.model.views.AppleIdCountryOrAreaDataView;
 import com.cyksj.model.views.CouponUserView;
 import com.cyksj.service.register.RegisterOrderDonService;
+import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
@@ -37,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.OutputStream;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -62,6 +64,8 @@ public class RegisterController {
 
     private final CouponSkuMapper couponSkuMapper;
 
+    private final UserBindRelationService userBindRelationService;
+
     @PostMapping
     public Result<RegisterOrderDon> register(@RequestBody RegisterReq req) throws Exception {
         long userId = StpUserUtil.getLoginIdAsLong();
@@ -163,8 +167,9 @@ public class RegisterController {
     @GetMapping("/get")
     public Result<SearchResult<RegisterOrderDon>> get(){
         long userId = StpUserUtil.getLoginIdAsLong();
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
         SearchResult<RegisterOrderDon> search = beanSearcher.search(RegisterOrderDon.class, MapUtils.flatBuilder(request.getParameterMap())
-                .field(RegisterOrderDon::getUserId,userId).op(Operator.Equal)
+                .field(RegisterOrderDon::getUserId, userIdList).op(Operator.InList)
                 .build());
         search.getDataList().forEach(data->{
             if (data.getAppleIsAutoType() && (data.getStatus() == RegisterOrderDon.Status.noPayment || data.getStatus() == RegisterOrderDon.Status.close)) {
@@ -176,6 +181,18 @@ public class RegisterController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
 
+    @GetMapping("/get/status/{orderId}")
+    public Result<RegisterOrderDon> getOrderStatusById(@PathVariable Long orderId) {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+        RegisterOrderDon registerOrderDon = beanSearcher.searchFirst(RegisterOrderDon.class, MapUtils.flatBuilder(request.getParameterMap())
+                .field(RegisterOrderDon::getUserId, userIdList).op(Operator.InList)
+                .field(RegisterOrderDon::getId, orderId)
+                .selectExclude(RegisterOrderDon::getApplePwdId, RegisterOrderDon::getCountryOrArea, RegisterOrderDon::getRemark)
+                .build());
+        return GatewayResponse.SUCCESS.newBuilder().toResult(registerOrderDon);
+    }
+
     @PutMapping("/put")
     public Result<String> update(@RequestBody RegisterOrderDon req){
         if (req.getId() == null) {

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

@@ -89,11 +89,6 @@ public class SysConfigController {
 			}
 		}
 
-		if (Constant.serviceKeys.get(0).equals(sysConfig.getSysKey())) {
-			//同步活码客服关联配置
-			corpFollowService.syncActiveCodeFollowRelate(sysConfig.getSysValue());
-		}
-
 		sysConfigChangeRecordService.changeRecord(adminId, sysConfig.getSysKey(), byId.getSysValue(), sysConfig.getSysValue());
 
 		sysConfigService.updateById(sysConfig);