Преглед изворни кода

欢迎语附件文本、落地页客服二维码

zoujiajian пре 2 година
родитељ
комит
b6b0c39ab0
21 измењених фајлова са 282 додато и 80 уклоњено
  1. 4 1
      netflix-common/src/main/java/com/cyksj/common/constant/Constant.java
  2. 0 0
      netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowActiveCodeClickRecordMapper.java
  3. 1 1
      netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowDutyRelateMapper.java
  4. 13 0
      netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowServiceRelateMapper.java
  5. 3 0
      netflix-dao/src/main/java/com/cyksj/model/dto/YhServiceDto.java
  6. 2 0
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollow.java
  7. 23 2
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowActiveCode.java
  8. 1 1
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowDutyRelate.java
  9. 27 0
      netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowServiceRelate.java
  10. 2 2
      netflix-dao/src/main/java/com/cyksj/model/views/CorpActiveCodeGoodsOrderView.java
  11. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/CorpActiveCodeOrderView.java
  12. 18 3
      netflix-dao/src/main/java/com/cyksj/model/views/CorpFollowActiveCodeView.java
  13. 1 1
      netflix-service/src/main/java/com/cyksj/redis/RedisService.java
  14. 1 1
      netflix-service/src/main/java/com/cyksj/service/corp/CorpFollowDynamicConfigService.java
  15. 1 1
      netflix-service/src/main/java/com/cyksj/service/corp/CorpFollowService.java
  16. 58 9
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java
  17. 9 9
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowActiveCodeFrontServiceImpl.java
  18. 15 8
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowDynamicConfigServiceImpl.java
  19. 71 33
      netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowServiceImpl.java
  20. 28 7
      netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CmsCorpFollowActiveCodeController.java
  21. 3 0
      netflix-web/src/main/java/com/cyksj/web/controller/sys/SysConfigController.java

+ 4 - 1
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -174,7 +174,10 @@ public interface Constant {
 	 */
 	String CN_CYS = "¥";
 
-	String DY_CS_CODE_KEY = "抖音免费设备";
+	/**
+	 * 活码临时使用
+	 */
+	String ACTIVE_CODE_TEMP_KEY = "active_code_temp_key";
 
 	List<String> DY_CUS = List.of("QiuDaoYuBuGuoQi.", "YinHeLuXiangJuSheBeiShouQian");
 

+ 0 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowActiveCodeClickRecord.java → netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpFollowActiveCodeClickRecordMapper.java


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

@@ -15,5 +15,5 @@ import java.util.List;
 public interface CorpFollowDutyRelateMapper extends BaseMapper<CorpFollowDutyRelate> {
 	List<CorpFollowDutyRelate> selectCorpFollowRelate(@Param("list") List<String> followIds, @Param("isWeekend") Boolean isWeekend);
 
-	List<CorpFollowDutyRelate> selectTodayDutyRelate(@Param("followIds") List<String> followIds, @Param("type") Integer type);
+	List<CorpFollowDutyRelate> selectTodayDutyRelate(@Param("list") List<String> followIds, @Param("type") Integer type);
 }

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

@@ -0,0 +1,13 @@
+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> {
+}

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

@@ -1,5 +1,6 @@
 package com.cyksj.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,6 +19,7 @@ public class YhServiceDto {
 
 	private String endTime;
 
+	@JsonProperty("indx")
 	private Integer index;
 
 	private List<CustomerServiceDto> select;
@@ -30,6 +32,7 @@ public class YhServiceDto {
 
 		private String img;
 
+		@JsonProperty("indx")
 		private Integer index;
 
 		private String url;

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollow.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.entity;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -9,6 +10,7 @@ import java.io.Serializable;
  * @date 2022/3/14 下午7:23
  */
 @Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
 public class CorpFollow extends BaseEntity implements Serializable {
 
     private Long wxCorpId;

+ 23 - 2
netflix-dao/src/main/java/com/cyksj/model/entity/CorpFollowActiveCode.java

@@ -1,8 +1,14 @@
 package com.cyksj.model.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.cyksj.model.request.corp.Attachments;
+import com.ejlchina.searcher.bean.DbIgnore;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * 项目名: yhlxj
  * 文件名: CorpFollowActiveCode
@@ -13,15 +19,30 @@ import lombok.Setter;
 @Setter
 public class CorpFollowActiveCode extends BaseEntity{
 
+	@TableField(exist = false)
+	@DbIgnore
+	private List<CorpFollow> followList;
+
 	/**
 	 * 客服
 	 */
 	private String followStr;
 
 	/**
-	 * 欢迎语
+	 * 欢迎语内容 文本、附件
+	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private String text;
+
+	@TableField(exist = false)
+	@DbIgnore
+	private List<Attachments> attachments;
+
+	/**
+	 * 附件字符串
 	 */
-	private String welcomeStr;
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private String attachmentsStr;
 
 	/**
 	 * 活码

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

@@ -33,7 +33,7 @@ public class CorpFollowDutyRelate extends BaseEntity{
 
 	private Integer et;
 
-	private Integer index;
+	private Integer indexTag;
 
 	/**
 	 * 1工作日,2.周六,3周末

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

@@ -0,0 +1,27 @@
+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;
+}

+ 2 - 2
netflix-dao/src/main/java/com/cyksj/model/views/CorpActiveCodeGoodsOrderView.java

@@ -15,7 +15,7 @@ import java.math.BigDecimal;
  */
 @Getter
 @Setter
-@SearchBean(tables = "crop_user cu left join order_don o and cu.user_id = o.user_id and cu.user_id != 0 and o.status not in ('close','noPayment') :acId: :time:" +
+@SearchBean(tables = "corp_user cu inner join order_don o on cu.user_id = o.user_id and cu.user_id != 0 and o.status not in ('close','noPayment') :acId: :time:" +
 		" left join goods_don g on g.id = o.goods_id" +
 		" left join goods_don_sku sku on sku.id = o.sku_id" +
 		" left join user u on u.id = o.user_id",
@@ -42,7 +42,7 @@ public class CorpActiveCodeGoodsOrderView {
 	/**
 	 * 订单金额
 	 */
-	@DbField("IFNULL(sum(o1.money),0)")
+	@DbField("IFNULL(sum(o.money),0)")
 	private BigDecimal orderMoney;
 
 	/**

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/CorpActiveCodeOrderView.java

@@ -16,7 +16,7 @@ import java.util.Date;
  */
 @Getter
 @Setter
-@SearchBean(tables = "crop_user cu left join order_don o and cu.user_id = o.user_id and cu.user_id != 0 and o.status not in ('close','noPayment','refund') :acId:" +
+@SearchBean(tables = "corp_user cu inner join order_don o on cu.user_id = o.user_id and cu.user_id != 0 and o.status not in ('close','noPayment','refund') :acId:" +
 		" left join goods_don g on g.id = o.goods_id" +
 		" left join goods_don_sku sku on sku.id = o.sku_id" +
 		" left join user u on u.id = o.user_id")

+ 18 - 3
netflix-dao/src/main/java/com/cyksj/model/views/CorpFollowActiveCodeView.java

@@ -1,5 +1,7 @@
 package com.cyksj.model.views;
 
+import com.cyksj.model.entity.CorpFollow;
+import com.cyksj.model.request.corp.Attachments;
 import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
@@ -7,6 +9,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 项目名: yhlxj
@@ -29,11 +32,23 @@ public class CorpFollowActiveCodeView {
 	@DbField("cfa.follow_str")
 	private String followStr;
 
+	@DbIgnore
+	private List<CorpFollow> followList;
+
+	/**
+	 * 欢迎语内容 文本、附件
+	 */
+	@DbField("cfa.text")
+	private String text;
+
+	@DbIgnore
+	private List<Attachments> attachments;
+
 	/**
-	 * 欢迎语
+	 * 附件字符串
 	 */
-	@DbField("cfa.welcome")
-	private String welcome;
+	@DbField("cfa.attachments_str")
+	private String attachmentsStr;
 
 	/**
 	 * 活码

+ 1 - 1
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -652,7 +652,7 @@ public class RedisService {
         PLUS_GOODS_ADDRESS_KEY("plus_goods_address_key:", "优惠加购实物地址key", 10 * 60l),
         GROUPS_TRIPS_OUTSIDE_RELATION("groups_trips_outside_relation:key", "额外车位", 30l),
         DISTRIBUTE_RULE_TIME_KEY("DISTRIBUTE_RULE_TIME_KEY", "渠道规格记录时间key", 5 * 60L),
-        CORP_FOLLOW_ACTIVE_CODE_KEY("corp_follow_active_code_key:%s:%s", "活动客服活码key", 60 * 60 * 12L),
+        CORP_FOLLOW_ACTIVE_CODE_KEY("corp_follow_active_code_key:%s:%s", "活动客服活码key", 60 * 61),
         ;
 
         private String name;

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

@@ -15,5 +15,5 @@ public interface CorpFollowDynamicConfigService {
 
 	String createCorpFollowActiveCode(List<String> followIds, String state, Boolean isOne) throws Exception;
 
-	void updateCorpFollowActiveCode(String codeStr, String markTag) throws Exception;
+	void updateCorpFollowActiveCode(String oldMarkTag, String markTag) throws Exception;
 }

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

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

+ 58 - 9
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java

@@ -26,6 +26,7 @@ import com.cyksj.model.response.FollowedUser;
 import com.cyksj.model.response.corp.CorpExternalContactInfo;
 import com.cyksj.model.response.corp.CorpUserExternalTagGroupInfo;
 import com.cyksj.model.response.corp.CorpUserExternalTagGroupList;
+import com.cyksj.service.corp.CorpService;
 import com.cyksj.service.corp.WxCorpOps;
 import com.cyksj.service.corp.msg.CorpEventActionService;
 import com.cyksj.service.mange.coupon.CouponCommonService;
@@ -86,6 +87,8 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 
 	private final CorpFollowActiveCodeMapper corpFollowActiveCodeMapper;
 
+	private final CorpService corpService;
+
 	private static final String DEFAULT_MSG = "您好,欢迎加入银河录像局";
 
 	/**
@@ -113,7 +116,7 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 			List<FollowedUser> followedUsers = externalContact.getFollowedUsers();
 			//保存企微用户
 			CorpUser corpUser = saveOrUpdateCorpUser(message, corpUserInfo, followedUsers);
-			if (StrUtil.equals(message.getState(), Constant.DY_CS_CODE_KEY)) {
+			if (StrUtil.isNotBlank(state)) {
 				try {
 					followedUsers = wxCorpOps.getExternalContact(message.getToUserName(), message.getExternalUserId()).getFollowedUsers();
 				} catch (Exception e) {
@@ -436,11 +439,12 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 				corpFollowActiveCode = corpFollowActiveCodeMapper.selectById(acId);
 				if (corpFollowActiveCode != null) {
 					corpUser.setAcId(acId);
-					String welcomeStr = corpFollowActiveCode.getWelcomeStr();
+					String welcomeContent = corpFollowActiveCode.getText();
+					String attachmentsStr = corpFollowActiveCode.getAttachmentsStr();
 					//发送对应欢迎语
-					if (StrUtil.isNotBlank(corpFollowActiveCode.getWelcomeStr())) {
+					if (StrUtil.isNotBlank(welcomeContent) || StrUtil.isNotBlank(attachmentsStr)) {
 						THREAD_POOL.execute(() -> {
-							sendCorpFollowActiveCode(message, welcomeStr);
+							sendCorpFollowActiveCode(message, welcomeContent, attachmentsStr);
 						});
 					}
 				}
@@ -458,9 +462,33 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 		if (corpUser.getId() == null) {
 			corpUser.setState(state);
 		}
-		//打标签 抖音渠道活码 已有
-		if (StrUtil.equals(message.getState(), Constant.DY_CS_CODE_KEY) && CollUtil.isNotEmpty(followedUsers)) {
-			markAddUserTag(Constant.DY_CS_CODE_KEY, message.getToUserName(), corpUserInfo.getExternalUserId(), Constant.DY_CUS, followedUsers);
+
+		//打标签 抖音渠道活码 已有 兼容之前的临时
+		if (StrUtil.isNotBlank(message.getState())) {
+			//打标签
+			SysConfig one = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+					.eq(SysConfig::getSysKey, Constant.ACTIVE_CODE_TEMP_KEY).last("limit 1"));
+			if (one != null && StrUtil.isNotBlank(one.getSysValue()) && CollUtil.isNotEmpty(followedUsers)) {
+				try {
+					List<String> activeCodeList = Jsons.parseList(one.getSysValue(), String.class);
+					if (activeCodeList.contains(message.getState())) {
+						//查询对应标签是否存在
+						CorpTag corpTag = corpTagMapper.selectOne(Wrappers.lambdaQuery(CorpTag.class)
+								.eq(CorpTag::getName, message.getState()).last("limit 1"));
+						if (corpTag == null) {
+							try {
+								corpTag = addCorpTag(message.getState(), message.getState(), message.getToUserName());
+							} catch (Exception e) {
+							}
+						}
+						if (corpTag != null) {
+							List<String> tagId = List.of(corpTag.getTagId());
+							wxCorpOps.markTag(corpUserInfo.getExternalUserId(), message.getUserId(), tagId.toArray(new String[tagId.size()]), null);
+						}
+					}
+				} catch (Exception e) {
+				}
+			}
 		}
 
 		//新增修改客户信息
@@ -510,6 +538,11 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 				corpTag.setGroupName(tagGroup.getGroupName());
 				corpTag.setType(1);
 
+				CorpTagGroup corpTagGroup = new CorpTagGroup();
+				corpTagGroup.setGroupId(tagGroup.getGroupId());
+				corpTagGroup.setGroupName(tagGroup.getGroupName());
+				corpTagGroupMapper.insert(corpTagGroup);
+
 				corpTag.setTagId(save_tag.getId());
 				corpTag.setName(save_tag.getName());
 				corpTagMapper.insert(corpTag);
@@ -522,12 +555,28 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 	/**
 	 * 发送添加活动活码客服 发送欢迎语
 	 */
-	public void sendCorpFollowActiveCode(CorpXmlMessage message, String welcomeStr) {
+	public void sendCorpFollowActiveCode(CorpXmlMessage message, String content, String attachmentsStr) {
 		try {
 			String welcomeCode = message.getWelcomeCode();
 			String followId = message.getUserId();
+			JSONObject params = new JSONObject();
 			//新用户欢迎语
-			JSONObject params = Jsons.parseObject(welcomeStr, JSONObject.class);
+			if (StrUtil.isNotBlank(content)) {
+				JSONObject text = new JSONObject();
+				text.putOpt("content", content);
+				params.putOpt("text", text);
+			}
+			//附件
+			LinkedList<Attachments> attachments;
+			if (StrUtil.isNotBlank(attachmentsStr)) {
+				List<Attachments> dbAttachments = Jsons.parseList(attachmentsStr, Attachments.class);
+				attachments = new LinkedList<>();
+				for (Attachments dbAttachment : dbAttachments) {
+					attachments.add(corpService.updateMaterial(dbAttachment, message.getToUserName(), 1));
+				}
+				params.putOpt("attachments", attachments);
+			}
+
 			params.putOpt("welcome_code", welcomeCode);
 			HttpResponse<byte[]> res = null;
 			res = J11HttpC.custom()

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

@@ -91,15 +91,15 @@ public class CorpFollowActiveCodeFrontServiceImpl implements CorpFollowActiveCod
 				return qrCode;
 			}
 			List<CorpFollowDutyRelate> corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-					.eq(CorpFollowDutyRelate::getSt, hour)
-					.eq(CorpFollowDutyRelate::getEt, hour)
+					.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 = 1;
+			Integer index;
 			//未在时间期间
 			//若在当天之前
 			//若在当天之后 寻找下日值班客服
@@ -124,36 +124,36 @@ public class CorpFollowActiveCodeFrontServiceImpl implements CorpFollowActiveCod
 				if (week == Week.FRIDAY) {
 					index = 3;
 					corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-							.eq(CorpFollowDutyRelate::getIndex, index)
+							.eq(CorpFollowDutyRelate::getIndexTag, index)
 							.in(CorpFollowDutyRelate::getFollowId, followIds));
 					if (CollUtil.isEmpty(corpFollowDutyRelates)) {
 						index = 4;
 						corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-								.eq(CorpFollowDutyRelate::getIndex, index)
+								.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::getIndex, index)
+							.eq(CorpFollowDutyRelate::getIndexTag, index)
 							.in(CorpFollowDutyRelate::getFollowId, followIds));
 					if (CollUtil.isEmpty(corpFollowDutyRelates)) {
 						index = 6;
 						corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-								.eq(CorpFollowDutyRelate::getIndex, index)
+								.eq(CorpFollowDutyRelate::getIndexTag, index)
 								.in(CorpFollowDutyRelate::getFollowId, followIds));
 					}
 					qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);
 				}else {
 					index = 1;
 					corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-							.eq(CorpFollowDutyRelate::getIndex, index)
+							.eq(CorpFollowDutyRelate::getIndexTag, index)
 							.in(CorpFollowDutyRelate::getFollowId, followIds));
 					if (CollUtil.isEmpty(corpFollowDutyRelates)) {
 						index = 2;
 						corpFollowDutyRelates = corpFollowDutyRelateMapper.selectList(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-								.eq(CorpFollowDutyRelate::getIndex, index)
+								.eq(CorpFollowDutyRelate::getIndexTag, index)
 								.in(CorpFollowDutyRelate::getFollowId, followIds));
 					}
 					qrCode = getActiveQrCode(corpFollowDutyRelates, activeCodeDtos);

+ 15 - 8
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowDynamicConfigServiceImpl.java

@@ -7,9 +7,11 @@ import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
 import com.cyksj.mapper.corp.CorpFollowConfigMapper;
 import com.cyksj.mapper.corp.CorpFollowDutyRelateMapper;
+import com.cyksj.mapper.corp.CorpTagMapper;
 import com.cyksj.model.dto.CorpFollowActiveCodeDto;
 import com.cyksj.model.entity.CorpFollowConfig;
 import com.cyksj.model.entity.CorpFollowDutyRelate;
+import com.cyksj.model.entity.CorpTag;
 import com.cyksj.model.request.corp.CorpFollowContact;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
 import com.cyksj.service.corp.WxCorpOps;
@@ -38,6 +40,8 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 
 	private final CorpFollowDutyRelateMapper corpFollowDutyRelateMapper;
 
+	private final CorpTagMapper corpTagMapper;
+
 	@Override
 	public String corpFollowContactConfig(CorpFollowContact corpFollowContact) throws Exception {
 		String body = wxCorpOps.corpFollowContactConfig(corpFollowContact);
@@ -85,14 +89,17 @@ public class CorpFollowDynamicConfigServiceImpl implements CorpFollowDynamicConf
 	}
 
 	@Override
-	public void updateCorpFollowActiveCode(String codeStr, String markTag) throws Exception {
-		List<CorpFollowActiveCodeDto> activeCodeDtos = Jsons.parseList(codeStr, CorpFollowActiveCodeDto.class);
-		for (CorpFollowActiveCodeDto activeCode : activeCodeDtos) {
-			String configId = activeCode.getConfigId();
-			CorpFollowContact c = new CorpFollowContact();
-			c.setConfigId(configId);
-			c.setState(markTag);
-			wxCorpOps.updateCorpFollowContactConfig(c);
+	public void updateCorpFollowActiveCode(String oldMarkTag, String markTag) throws Exception {
+		CorpTag corpTag = corpTagMapper.selectOne(Wrappers.lambdaQuery(CorpTag.class)
+				.eq(CorpTag::getName, oldMarkTag).last("limit 1"));
+		if (corpTag != null) {
+			//更新该标签名
+			JSONObject params = new JSONObject();
+			params.putOpt("id", corpTag.getTagId());
+			params.putOpt("name", markTag);
+			wxCorpOps.editCorpTag(params);
+			corpTag.setName(markTag);
+			corpTagMapper.updateById(corpTag);
 		}
 	}
 

+ 71 - 33
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowServiceImpl.java

@@ -8,17 +8,21 @@ 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.config.corp.YHLXWxCorpConfig;
 import com.cyksj.mapper.corp.CorpFollowActiveCodeMapper;
 import com.cyksj.mapper.corp.CorpFollowDutyRelateMapper;
+import com.cyksj.mapper.corp.CorpFollowServiceRelateMapper;
+import com.cyksj.mapper.corp.CorpTagMapper;
 import com.cyksj.model.dto.YhServiceDto;
-import com.cyksj.model.entity.CmsUser;
-import com.cyksj.model.entity.CorpFollow;
-import com.cyksj.model.entity.CorpFollowActiveCode;
-import com.cyksj.model.entity.CorpFollowDutyRelate;
+import com.cyksj.model.entity.*;
+import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
 import com.cyksj.service.corp.CorpFollowService;
+import com.cyksj.service.corp.CorpService;
+import com.cyksj.service.corp.WxCorpOps;
 import com.cyksj.service.mange.cms.CmsUserManager;
 import lombok.RequiredArgsConstructor;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -44,6 +48,16 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 
 	private final CorpFollowDutyRelateMapper corpFollowDutyRelateMapper;
 
+	private final CorpFollowServiceRelateMapper corpFollowServiceRelateMapper;
+
+	private final WxCorpOps wxCorpOps;
+
+	private final CorpTagMapper corpTagMapper;
+
+	private final CorpService corpService;
+
+	private final YHLXWxCorpConfig yhlxWxCorpConfig;
+
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
 	public void postActiveCode(Long adminId, CorpFollowActiveCode activeCode) throws Exception {
@@ -52,16 +66,29 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 			activeCode.setOperator(cmsUser.getNickname());
 		}
 		Boolean isDuty = Optional.ofNullable(activeCode.getIsDuty()).orElse(false);
-		String followStr = activeCode.getFollowStr();
-		if (StrUtil.isEmpty(followStr)) {
+		List<CorpFollow> followList = activeCode.getFollowList();
+		if (CollUtil.isEmpty(followList)) {
 			throw BusinessRuntimeException.getInstance("请选择对应客服");
 		}
-		List<CorpFollow> corpFollows = Jsons.parseList(followStr, CorpFollow.class);
-		List<String> followIds = corpFollows.stream().map(CorpFollow::getUserid).collect(Collectors.toList());
+		activeCode.setFollowStr(Jsons.toJson(followList));
+		List<String> followIds = followList.stream().map(CorpFollow::getUserid).collect(Collectors.toList());
 		activeCode.setMarkTag(activeCode.getMarkTag().trim());
+		String text = activeCode.getText();
+		if (StrUtil.isNotBlank(text) && text.length() > 4000) {
+			throw BusinessRuntimeException.getInstance("欢迎语内容过长");
+		}
+		//附件
+		List<Attachments> attachments = activeCode.getAttachments();
+		if (CollUtil.isNotEmpty(attachments)) {
+			activeCode.setAttachmentsStr(Jsons.toJson(attachments));
+		}
 		//是否值班
 		String codeStr;
-		corpFollowActiveCodeMapper.insert(activeCode);
+		try {
+			corpFollowActiveCodeMapper.insert(activeCode);
+		} catch (DuplicateKeyException e) {
+			throw BusinessRuntimeException.getInstance("存在相同的标记标签");
+		}
 		if (!isDuty) {
 			//生成一个活码 一个客服或多个客服
 			codeStr = corpFollowDynamicConfigService.createCorpFollowActiveCode(followIds, Constant.AC_CODE_KEY + activeCode.getId(), true);
@@ -83,14 +110,11 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 			throw BusinessRuntimeException.getInstance("对应的数据已不存在");
 		}
 		String db_followStr = dbActiveCode.getFollowStr();
-		String up_followStr = activeCode.getFollowStr();
-		if (StrUtil.isEmpty(up_followStr)) {
-			throw BusinessRuntimeException.getInstance("请选择对应客服");
-		}
-		List<CorpFollow> up_corpFollows = Jsons.parseList(up_followStr, CorpFollow.class);
+		List<CorpFollow> up_corpFollows = activeCode.getFollowList();
 		if (CollUtil.isEmpty(up_corpFollows)) {
 			throw BusinessRuntimeException.getInstance("请选择对应客服");
 		}
+		activeCode.setFollowStr(Jsons.toJson(up_corpFollows));
 		if (StrUtil.isEmpty(activeCode.getMarkTag())) {
 			throw BusinessRuntimeException.getInstance("请输入标签");
 		}
@@ -121,13 +145,17 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 		if (!dbActiveCode.getMarkTag().equals(activeCode.getMarkTag())) {
 			isUpdateAcCode = true;
 		}
+		activeCode.setAttachmentsStr(dbActiveCode.getAttachmentsStr());
+		if (CollUtil.isEmpty(activeCode.getAttachments())) {
+			activeCode.setAttachmentsStr(null);
+		}
 
 		//重新构建活码配置
 		if (isReCreateAcCode) {
 			String code_str = corpFollowDynamicConfigService.createCorpFollowActiveCode(followIds, Constant.AC_CODE_KEY + activeCode.getId(), up_isDuty);
 			activeCode.setCodeStr(code_str);
 		} else if (isUpdateAcCode) {
-			corpFollowDynamicConfigService.updateCorpFollowActiveCode(activeCode.getCodeStr(), Constant.AC_CODE_KEY + activeCode.getId());
+			corpFollowDynamicConfigService.updateCorpFollowActiveCode(dbActiveCode.getMarkTag(), activeCode.getMarkTag());
 		}
 		if (activeCode.getCouponId() == null) {
 			activeCode.setCouponId(0l);
@@ -136,11 +164,19 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 	}
 
 	@Override
-	public void deleteActiveCodeById(Long id) {
-		corpFollowActiveCodeMapper.update(null, Wrappers.lambdaUpdate(CorpFollowActiveCode.class)
-				.eq(CorpFollowActiveCode::getId, id)
-				.set(CorpFollowActiveCode::getDeleted, false)
-				.eq(CorpFollowActiveCode::getDeleted, true));
+	public void deleteActiveCodeById(Long id) throws Exception {
+		CorpFollowActiveCode corpFollowActiveCode = corpFollowActiveCodeMapper.selectById(id);
+		if (corpFollowActiveCode == null) {
+			return;
+		}
+		corpFollowActiveCode.setDeleted(false);
+		corpFollowActiveCodeMapper.updateById(corpFollowActiveCode);
+
+		CorpTag corpTag = corpTagMapper.selectOne(Wrappers.lambdaQuery(CorpTag.class)
+				.eq(CorpTag::getName, corpFollowActiveCode.getMarkTag()).last("limit 1"));
+		if (corpTag != null) {
+			wxCorpOps.delCorpTag(new String[]{corpTag.getTagId()}, null);
+		}
 	}
 
 	@Override
@@ -148,6 +184,7 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 		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");
@@ -157,20 +194,21 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 			List<YhServiceDto.CustomerServiceDto> select = data.getSelect();
 			select.forEach(cs -> {
 				String name = cs.getName();
-				CorpFollowDutyRelate relate = Optional.ofNullable(corpFollowDutyRelateMapper.selectOne(Wrappers.lambdaQuery(CorpFollowDutyRelate.class)
-						.eq(CorpFollowDutyRelate::getServiceName, name).last("limit 1"))).orElse(new CorpFollowDutyRelate());
-				relate.setServiceName(name);
-				relate.setSt(st);
-				relate.setEt(et);
-				Integer index = cs.getIndex();
-				relate.setIndex(index);
-				//1工作日,2.周六,3周末
-				Integer type = index <= 2 ? 1 : index <= 4 ? 2 : 3;
-				relate.setType(type);
-				if (relate.getId() == null) {
+				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);
-				} else {
-					corpFollowDutyRelateMapper.updateById(relate);
 				}
 			});
 		});

+ 28 - 7
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpFollowController.java → netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CmsCorpFollowActiveCodeController.java

@@ -3,13 +3,17 @@ 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.util.Jsons;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.OrderDonMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.mapper.manage.coupon.CouponMapper;
+import com.cyksj.model.entity.CorpFollow;
 import com.cyksj.model.entity.CorpFollowActiveCode;
+import com.cyksj.model.entity.CorpFollowServiceRelate;
 import com.cyksj.model.entity.CorpUser;
+import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.model.request.corp.CorpFollowContact;
 import com.cyksj.model.views.CorpActiveCodeGoodsOrderView;
 import com.cyksj.model.views.CorpActiveCodeOrderView;
@@ -25,18 +29,19 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 import java.util.Optional;
 
 /*
  *项目名: netflix
- *文件名: CorpFollowController
+ *文件名: CmsCorpFollowActiveCodeController
  *创建者: JavaZou
  *创建时间:2023/7/6 18:36
  */
 @RestController
 @RequestMapping("/manage/corp")
 @RequiredArgsConstructor
-public class CorpFollowController {
+public class CmsCorpFollowActiveCodeController {
 
 	private final CorpFollowDynamicConfigService corpFollowDynamicConfigService;
 
@@ -81,10 +86,10 @@ public class CorpFollowController {
 	}
 
 	/**
-	 * 活动活码列表
+	 * 删除活码
 	 */
 	@DeleteMapping("/del/active/code/{id}")
-	public Result<String> getActiveCode(@PathVariable Long id) {
+	public Result<String> deleteByAcCodeById(@PathVariable Long id) throws Exception {
 		corpFollowService.deleteActiveCodeById(id);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -93,9 +98,9 @@ public class CorpFollowController {
 	 * 活动活码列表
 	 */
 	@GetMapping("/get/active/code")
-	public Result<SearchResult<CorpFollowActiveCodeView>> getActiveCode() {
+	public Result<SearchResult<CorpFollowActiveCodeView>> getActiveCodeList() {
 		SearchResult<CorpFollowActiveCodeView> search = beanSearcher.search(CorpFollowActiveCodeView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
-		search.getDataList().forEach(data->{
+		search.getDataList().forEach(data -> {
 			if (data.getCouponId() > 0) {
 				Optional.ofNullable(couponMapper.selectById(data.getCouponId())).ifPresent(c -> data.setCouponName(c.getName()));
 			}
@@ -104,6 +109,13 @@ public class CorpFollowController {
 			data.setNumOfUser(numOfUser);
 			Integer orderNum = orderDonMapper.selectCountActiveCodeOrderByAcId(data.getId());
 			data.setOrderNum(orderNum);
+			try {
+				data.setFollowList(Jsons.parseList(data.getFollowStr(), CorpFollow.class));
+				if (StrUtil.isNotBlank(data.getAttachmentsStr())) {
+					data.setAttachments(Jsons.parseList(data.getAttachmentsStr(), Attachments.class));
+				}
+			} catch (Exception e) {
+			}
 		});
 		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
 	}
@@ -124,7 +136,7 @@ public class CorpFollowController {
 	/**
 	 * 查看活码订单 详情
 	 */
-	@GetMapping("/get/active/code/userList")
+	@GetMapping("/get/active/code/orderDetail")
 	public Result<SearchResult<CorpActiveCodeOrderView>> getCorpActiveCodeOrderView(Long id) {
 		MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
 		if (id != null) {
@@ -156,4 +168,13 @@ public class CorpFollowController {
 		SearchResult<CorpActiveCodeGoodsOrderView> search = beanSearcher.search(CorpActiveCodeGoodsOrderView.class, mapBuilder.build());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
 	}
+
+	/**
+	 * 可选客服配置
+	 */
+	@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);
+	}
 }

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

@@ -67,6 +67,9 @@ public class SysConfigController {
 	@PutMapping("/update")
 	@Log(module = "系统设置/编辑配置", businessType = BusinessType.PUT, isSaveRequestData = true)
 	public Result<SysConfig> update(@RequestBody SysConfig sysConfig) throws Exception {
+		Long id = sysConfig.getId();
+		SysConfig byId = sysConfigService.getById(id);
+		sysConfig.setSysKey(byId.getSysKey());
 		if (Constant.EQUIPMENT_DISTRIBUTE_KEY.equals(sysConfig.getSysKey())) {
 			String sysValue = sysConfig.getSysValue();
 			if (StrUtil.isNotBlank(sysValue)) {