瀏覽代碼

获取链接链接;欢迎语模板发送

zoujiajian 2 年之前
父節點
當前提交
14385ac99d

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

@@ -64,4 +64,9 @@ public class CorpCustomerAcquisitionLink extends BaseEntity {
     @DbIgnore
     private List<String> tagStrList;
 
+    /**
+     * 模板id
+     */
+    private Long msgId;
+
 }

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

@@ -34,6 +34,11 @@ public class CorpFollowActiveCode extends BaseEntity{
 	 */
 	private String followStr;
 
+	/**
+	 * 欢迎语模板id
+	 */
+	private Long msgId;
+
 	/**
 	 * 欢迎语内容 文本、附件
 	 */

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

@@ -46,8 +46,12 @@ public class CorpWelcomeTemplate extends BaseEntity {
 	/**
 	 * 优惠券id
 	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private Long couponId;
 
+	@DbIgnore
+	private String couponName;
+
 	private Boolean deleted;
 
 	@Getter

+ 37 - 16
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpEventActionServiceImpl.java

@@ -131,6 +131,8 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 
 	private final OrderDonPostService orderDonPostService;
 
+	private final CorpWelcomeTemplateMapper corpWelcomeTemplateMapper;
+
 	private static final String DEFAULT_MSG = "您好,欢迎加入银河录像局";
 
 	/**
@@ -684,22 +686,16 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 					if (corpUser.getId() == null) {
 						corpUser.setAcId(acId);
 					}
-					String welcomeContent = corpFollowActiveCode.getText();
-					String attachmentsStr = corpFollowActiveCode.getAttachmentsStr();
-					//发送对应欢迎语
-					if (StrUtil.isNotBlank(welcomeContent) && StrUtil.isNotBlank(attachmentsStr)) {
-						THREAD_POOL.execute(() -> {
-							sendCorpFollowActiveCode(message, welcomeContent, attachmentsStr);
-						});
+					//欢迎语模板id
+					Long msgId = corpFollowActiveCode.getMsgId();
+					sendWelcomeMsg(msgId, message);
+					try {
+						//对客户进行标记
+						markAddUserTag(corpFollowActiveCode.getMarkTag(), message);
+						state = corpFollowActiveCode.getMarkTag();
+					} catch (Exception e) {
 					}
 				}
-				try {
-					//对客户进行标记
-					markAddUserTag(corpFollowActiveCode.getMarkTag(), message);
-					state = corpFollowActiveCode.getMarkTag();
-				} catch (Exception e) {
-				}
-
 			}
 		}
 
@@ -707,7 +703,7 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 		if(StrUtil.isNotBlank(message.getState()) && message.getState().contains(Constant.ACQUISTION_LINK_STATE_KEY)){
 			String customer = message.getState().replaceAll("customer_", "");
 			THREAD_POOL.execute(()->{
-				saveAcqusitionCallback(customer, corpUser, message.getExternalUserId(), message.getUserId());
+				saveAcqusitionCallback(customer, corpUser, message);
 			});
 		}
 
@@ -980,7 +976,9 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 	}
 
 
-	private void saveAcqusitionCallback(String customer, CorpUser corpUser,String externalUserid ,String userId) {
+	private void saveAcqusitionCallback(String customer, CorpUser corpUser,CorpXmlMessage message) {
+		String externalUserid = message.getExternalUserId() ;
+		String userId = message.getUserId();
 		//获客链接
 		Long linkId = customerAcquisitionSaveClickId(customer, corpUser.getUnionid());
 		CorpCustomerAcquisitionLink customerAcquisitionLink = corpCustomerAcquisitionLinkMapper.getByLinkPopularizeId(linkId);
@@ -998,6 +996,9 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 						wxCorpOps.markTag(externalUserid, userId, tagList.stream().map(CorpTag::getTagId).toArray(String[]::new), null);
 					}
 				}
+				//发送欢迎语
+				Long msgId = customerAcquisitionLink.getMsgId();
+				sendWelcomeMsg(msgId, message);
 			} catch (Exception e) {
 				log.error("处理获客链接解析标签id出错了,内容{},获客链接id: {}", customerAcquisitionLink.getTags(), customerAcquisitionLink.getId());
 			}
@@ -1049,4 +1050,24 @@ public class CorpEventActionServiceImpl implements CorpEventActionService {
 			throw BusinessRuntimeException.getInstance("加粉回传出错. error:" + StringUtil.getErrorText(e));
 		}
 	}
+
+
+	/**
+	 * 发送欢迎语
+	 * @param msgId 模板id
+	 * @param message
+	 */
+	public void sendWelcomeMsg(Long msgId,CorpXmlMessage message) {
+		CorpWelcomeTemplate corpWelcomeTemplate = corpWelcomeTemplateMapper.selectById(msgId);
+		if (corpWelcomeTemplate != null) {
+			String welcomeContent = corpWelcomeTemplate.getText();
+			String attachmentsStr = corpWelcomeTemplate.getAttachmentsStr();
+			//发送对应欢迎语
+			if (StrUtil.isNotBlank(welcomeContent) && StrUtil.isNotBlank(attachmentsStr)) {
+				THREAD_POOL.execute(() -> {
+					sendCorpFollowActiveCode(message, welcomeContent, attachmentsStr);
+				});
+			}
+		}
+	}
 }

+ 39 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpCustomerAcquistionLinkController.java

@@ -1,12 +1,24 @@
 package com.cyksj.web.controller.manage.corp;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.corp.CorpFollowMapper;
+import com.cyksj.mapper.corp.CorpTagMapper;
 import com.cyksj.model.entity.CorpCustomerAcquisitionLink;
+import com.cyksj.model.entity.CorpFollow;
+import com.cyksj.model.entity.CorpTag;
 import com.cyksj.service.corp.CorpCustomerAcquisitionLinkService;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  *  获客助手
  * @author chan
@@ -19,6 +31,14 @@ public class CorpCustomerAcquistionLinkController {
 
     private final CorpCustomerAcquisitionLinkService corpCustomerAcquisitionLinkService;
 
+    private final CorpFollowMapper corpFollowMapper;
+
+    private final CorpTagMapper corpTagMapper;
+
+    private final BeanSearcher beanSearcher;
+
+    private final HttpServletRequest request;
+
     /**
      * 新增获客助手链接
      */
@@ -47,4 +67,23 @@ public class CorpCustomerAcquistionLinkController {
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
 
+    /**
+     * 获取获客助手链接
+     */
+    @GetMapping("/get")
+    public Result<SearchResult<CorpCustomerAcquisitionLink>> get() throws Exception {
+        SearchResult<CorpCustomerAcquisitionLink> search = beanSearcher.search(CorpCustomerAcquisitionLink.class, MapUtils.flatBuilder(request.getParameterMap()).build());
+
+        search.getDataList().forEach(e->{
+            List<String> userStrList = corpFollowMapper.selectList(Wrappers.lambdaQuery(CorpFollow.class)
+                    .in(CorpFollow::getUserid, e.getUserList())).stream().map(CorpFollow::getName).collect(Collectors.toList());
+            e.setUserStrList(userStrList);
+
+            List<String> tagStrList = corpTagMapper.selectList(Wrappers.lambdaQuery(CorpTag.class)
+                    .in(CorpTag::getId, e.getTags())).stream().map(CorpTag::getName).collect(Collectors.toList());
+            e.setTagStrList(tagStrList);
+        });
+        return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+    }
+
 }

+ 7 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CorpWelcomeTemplateController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
 import com.cyksj.common.util.Jsons;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.manage.coupon.CouponMapper;
 import com.cyksj.model.entity.CorpWelcomeTemplate;
 import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.service.corp.CorpWelcomeTemplateService;
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * admin/企业微信/欢迎语模板
@@ -31,6 +33,8 @@ public class CorpWelcomeTemplateController {
 
 	private final CorpWelcomeTemplateService corpWelcomeTemplateService;
 
+	private final CouponMapper couponMapper;
+
 	private final BeanSearcher beanSearcher;
 
 	private final HttpServletRequest request;
@@ -82,6 +86,9 @@ public class CorpWelcomeTemplateController {
 				} catch (Exception ex) {
 				}
 			}
+			if (e.getCouponId() != null) {
+				Optional.ofNullable(couponMapper.selectById(e.getCouponId())).ifPresent(c -> e.setCouponName(c.getName()));
+			}
 		});
 		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
 	}