zoujiajian преди 1 година
родител
ревизия
eb7fb78262

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

@@ -854,6 +854,7 @@ public class RedisService {
         USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY("user_mirror_shop_advertise_cache_key:", "用户镜像店铺广告缓存key", 60 * 60 * 12),
         NETFLIX_CHANGE_TICKET_KEY("netflix_change_ticket_key:", "奈飞更换车票key", 60l),
         CORP_KF_ACCOUNT_URL("corp_kf_account_url:", "微信客服url:", 60 * 60 * 6),
+        CORP_WX_YL_KEY("corp_wx_yl_key:", "企业微信引流", 60 * 60 * 24),
         ;
 
         private String name;

+ 16 - 3
netflix-web/src/main/java/com/cyksj/web/controller/user/CorpUserFrontController.java

@@ -1,9 +1,11 @@
 package com.cyksj.web.controller.user;
 
+import cn.hutool.core.util.StrUtil;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.request.TempCorpFollowCodeReq;
 import com.cyksj.model.response.UserInfoResp;
+import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpUserFrontService;
 import com.cyksj.web.util.StpUserUtil;
 import lombok.RequiredArgsConstructor;
@@ -21,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
 public class CorpUserFrontController {
 	private final CorpUserFrontService corpUserFrontService;
 
+	private final RedisService redisService;
+
 	/**
 	 * 获取用户添加企业微信和下单 情况
 	 */
@@ -36,11 +40,20 @@ public class CorpUserFrontController {
 	 */
 	@PostMapping("/post")
 	public Result<String> generateTempCorpFollowCode(@RequestBody TempCorpFollowCodeReq tempCorpFollowCodeReq) throws Exception {
+		String keyName = RedisService.key.CORP_WX_YL_KEY.getName();
 		String tokenValue = StpUserUtil.getTokenValue();
 		long userId = StpUserUtil.getLoginIdAsLong();
-		tempCorpFollowCodeReq.setUserId(userId);
-		tempCorpFollowCodeReq.setT(tokenValue);
-		String codeUrl = corpUserFrontService.generateTempCorpFollowCode(tempCorpFollowCodeReq);
+		keyName += userId;
+		if (tempCorpFollowCodeReq.getGoodsId() != null) {
+			keyName += ":" + tempCorpFollowCodeReq.getGoodsId();
+		}
+		String codeUrl = redisService.getStr(keyName);
+		if (StrUtil.isEmpty(codeUrl)) {
+			tempCorpFollowCodeReq.setUserId(userId);
+			tempCorpFollowCodeReq.setT(tokenValue);
+			codeUrl = corpUserFrontService.generateTempCorpFollowCode(tempCorpFollowCodeReq);
+			redisService.setNx(keyName, codeUrl, RedisService.key.CORP_WX_YL_KEY.getTimeout());
+		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult(codeUrl);
 	}
 }