From 1b031892c46535ddb2bf56ab8fb813ffed8614b0 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 03 Jun 2024 17:54:51 +0800
Subject: [PATCH] 新增商品在输入栏中,给出提示信息
---
src/main/java/cc/mrbird/febs/pay/service/impl/XcxPayServiceImpl.java | 67 +++++++++++++++++++++------------
1 files changed, 42 insertions(+), 25 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/pay/service/impl/XcxPayServiceImpl.java b/src/main/java/cc/mrbird/febs/pay/service/impl/XcxPayServiceImpl.java
index 69527a8..52cc8fa 100644
--- a/src/main/java/cc/mrbird/febs/pay/service/impl/XcxPayServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/pay/service/impl/XcxPayServiceImpl.java
@@ -33,6 +33,7 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@@ -51,21 +52,17 @@
@RequiredArgsConstructor
public class XcxPayServiceImpl implements IXcxPayService {
- @Autowired
- private MallOrderInfoMapper mallOrderInfoMapper;
- @Autowired
- private MallMemberMapper mallMemberMapper;
- @Autowired
- WeixinServiceUtil weixinServiceUtil;
- @Autowired
- private DataDictionaryCustomMapper dataDictionaryCustomMapper;
- @Autowired
- private MallMoneyFlowMapper mallMoneyFlowMapper;
- @Autowired
- private MallMemberWithdrawMapper mallMemberWithdrawMapper;
+ private final MallOrderInfoMapper mallOrderInfoMapper;
+ private final MallMemberMapper mallMemberMapper;
+ private final WeixinServiceUtil weixinServiceUtil;
+ private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
+ private final MallMoneyFlowMapper mallMoneyFlowMapper;
+ private final MallMemberWithdrawMapper mallMemberWithdrawMapper;
private final IMallMoneyFlowService mallMoneyFlowService;
- @Autowired
- RedisUtils redisUtils;
+
+ private final MallGoodsMapper mallGoodsMapper;
+ private final MallTeamLeaderMapper mallTeamLeaderMapper;
+ private final RedisUtils redisUtils;
private final SpringContextHolder springContextHolder;
@@ -290,11 +287,6 @@
return wxTemplates;
}
- @Autowired
- private MallGoodsMapper mallGoodsMapper;
- @Autowired
- private MallTeamLeaderMapper mallTeamLeaderMapper;
-
@Override
public FebsResponse generateQrCode(WxGenerateQrCodeDto wxGenerateQrCodeDto) {
Integer type = wxGenerateQrCodeDto.getType();
@@ -319,6 +311,17 @@
}
}
+ if (type == 3) {
+ String inviteId = wxGenerateQrCodeDto.getTypeParam();
+ MallMember member = mallMemberMapper.selectInfoByInviteId(inviteId);
+ if(ObjectUtil.isNotNull(member)){
+ String wxCodeImg = member.getInviteImg();
+ if(StrUtil.isNotBlank(wxCodeImg)){
+ return new FebsResponse().success().data(wxCodeImg);
+ }
+ }
+ }
+
String randomNum = MallUtils.getRandomNum(5);
String imgName="/user_" + randomNum + "_acode_1.jpg";
String codeImgPath = generateAcode(wxGenerateQrCodeDto.getScene(), wxGenerateQrCodeDto.getPage(), imgName, "400px", null);
@@ -333,6 +336,15 @@
MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(uniqueCode);
mallTeamLeader.setWxCodeImg(codeImgPath);
mallTeamLeaderMapper.updateById(mallTeamLeader);
+ }
+
+ if (type == 3) {
+ String inviteId = wxGenerateQrCodeDto.getTypeParam();
+ MallMember member = mallMemberMapper.selectInfoByInviteId(inviteId);
+ if(ObjectUtil.isNotNull(member)){
+ member.setInviteImg(codeImgPath);
+ mallMemberMapper.updateById(member);
+ }
}
return new FebsResponse().success().data(codeImgPath);
}
@@ -391,11 +403,15 @@
* @param imgName 图片唯一名称
* @return
*/
- //图片上传路径
- public static final String IMG_UPLOAD_PATH="/mnt/sdc/webresource/qianayi/wxcode";
+ // 文件保存目录路径
+ @Value("${static.resource.url}")
+ private String resourceUrl;
+ // 文件保存目录URL
+ @Value("${static.resource.path}")
+ private String resourcePath;
public String generateAcode(String scene,String path,String imgName,String width, Integer type){
- String urlPrefix="https://hwfile.csxuncong.com/qianayi/wxcode";
- String imgPath=IMG_UPLOAD_PATH+imgName;
+ String urlPrefix = resourceUrl + "/wxcode";
+ String imgPath=resourcePath +"/wxcode"+imgName;
if(!FileUtil.exist(imgPath)){
cn.hutool.json.JSONObject obj = JSONUtil.createObj();
@@ -403,12 +419,12 @@
String url = null;
if (type == null) {
// 该接口无数量限制,但是 scene 传参最大字符长度为32个字符
- url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}",redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY).toString());
+ url = StrUtil.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}",redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY).toString());
obj.set("scene", scene);
obj.set("page", path);
} else {
// 该接口存在数量限制, 总共可生成10w个, 但参数是接在path后面
- url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacode?access_token={}", redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY).toString());
+ url = StrUtil.format("https://api.weixin.qq.com/wxa/getwxacode?access_token={}", redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY).toString());
obj.set("page", path + "?" + scene );
}
@@ -424,6 +440,7 @@
obj.set("is_hyaline", false);
try {
HttpResponse execute = HttpRequest.post(url).body(obj.toString(), "application/json").execute();
+ log.error("微信返回值:{}", execute.body());
InputStream inputStream = execute.bodyStream();
File file = new File(imgPath);
FileUtil.writeFromStream(inputStream, file);
--
Gitblit v1.9.1