|
|
@@ -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);
|
|
|
}
|
|
|
}
|