Commit d3a47c6f authored by 刘帅's avatar 刘帅

1.推广码生成错误问题修复

parent e9479801
...@@ -52,7 +52,7 @@ public class ImgUpload { ...@@ -52,7 +52,7 @@ public class ImgUpload {
if (StringUtils.isBlank(path)) { if (StringUtils.isBlank(path)) {
path = "IMG"; path = "IMG";
} }
return auth.uploadToken(bucketname, null, 3600, new StringMap().put("saveKey", path + "$(etag)$(ext)")); return auth.uploadToken(bucketname, null, 3600, new StringMap().put("saveKey", "$(etag)$(ext)" + path));
} }
public String upload(byte[] data, String fileType) throws IOException { public String upload(byte[] data, String fileType) throws IOException {
......
package com.ruoyi.common.weixin.utils; package com.ruoyi.common.weixin.utils;
import cn.hutool.core.util.IdUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
...@@ -13,7 +14,6 @@ import org.slf4j.LoggerFactory; ...@@ -13,7 +14,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
...@@ -140,13 +140,13 @@ public class WeiXinUtils { ...@@ -140,13 +140,13 @@ public class WeiXinUtils {
* @return 图片链接 * @return 图片链接
*/ */
public String getQRCode(Long memberUserId, String key){ public String getQRCode(Long memberUserId, String key){
String qrCodeUrl = ""; String resultUrl = "";
try { try {
//获取token //获取token
String accessToken = this.getAccessToken(); String accessToken = this.getAccessToken();
String codeUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token="+ accessToken; String codeUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token="+ accessToken;
String path = weiXinConfig.getWxPath()+memberUserId;
//post参数 //post参数
String path = weiXinConfig.getWxPath()+memberUserId;
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("path", path); jsonObject.put("path", path);
Map<String, Object> lineColor = new HashMap<>(); Map<String, Object> lineColor = new HashMap<>();
...@@ -172,14 +172,54 @@ public class WeiXinUtils { ...@@ -172,14 +172,54 @@ public class WeiXinUtils {
//获取数据 //获取数据
BufferedInputStream bis = new BufferedInputStream(httpUrlConnection.getInputStream()); BufferedInputStream bis = new BufferedInputStream(httpUrlConnection.getInputStream());
//文件上传,返回小程序码url //文件上传,返回小程序码url
qrCodeUrl = new ImgUpload().streamUpload(bis, key); resultUrl = new ImgUpload().streamUpload(bis, IdUtil.getSnowflakeNextIdStr()+"_"+key);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return qrCodeUrl; return resultUrl;
} }
// public String getQRCode(Long memberUserId, String key){
// String qrCodeUrl = "";
// try {
// //获取token
// String accessToken = this.getAccessToken();
// String codeUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+ accessToken;
// String path = weiXinConfig.getWxPath()+memberUserId;
// //post参数
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("path", path);
// Map<String, Object> lineColor = new HashMap<>();
// lineColor.put("r", 4);
// lineColor.put("g", 157);
// lineColor.put("b", 150);
// jsonObject.put("line_color", lineColor);
// String env_version = "release";// 正式版为 "release",体验版为 "trial",开发版为 "develop"
// jsonObject.put("env_version", env_version);
// String params = jsonObject.toString();
//
// URL url = new URL(codeUrl);
// HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
// // 提交模式
// httpUrlConnection.setRequestMethod("POST");
// // 发送POST请求必须设置如下两行
// httpUrlConnection.setDoOutput(true);
// httpUrlConnection.setDoInput(true);
// // 获取URLConnection对象对应的输出流
// PrintWriter printWriter = new PrintWriter(httpUrlConnection.getOutputStream());
// printWriter.write(params);
// printWriter.flush();
// //获取数据
// BufferedInputStream bis = new BufferedInputStream(httpUrlConnection.getInputStream());
// //文件上传,返回小程序码url
// qrCodeUrl = new ImgUpload().streamUpload(bis, key);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// return qrCodeUrl;
// }
/** /**
* 获取不限制的小程序码 * 获取不限制的小程序码
* *
......
...@@ -1046,15 +1046,15 @@ public class MallMemberUserServiceImpl implements IMallMemberUserService ...@@ -1046,15 +1046,15 @@ public class MallMemberUserServiceImpl implements IMallMemberUserService
sysUser.setPassword(SecurityUtils.encryptPassword(password)); sysUser.setPassword(SecurityUtils.encryptPassword(password));
sysUserMapper.updateUser(sysUser); sysUserMapper.updateUser(sysUser);
} }
/**
if (StringUtils.isBlank(memberUser.getIndexCode())) { * 重新生成二维码
String qrCode = ""; */
// 小程序码 String qrCode = "";
Long schoolId = memberUser.getId(); // 小程序码
String key = schoolId + ".png"; Long userId = memberUser.getId();
qrCode = weiXinUtils.getSchoolQRCode(schoolId, key); String key = userId + ".png";
updateMemberUser.setIndexCode(qrCode); qrCode = weiXinUtils.getQRCode(userId, key);
} updateMemberUser.setIndexCode(qrCode);
mallMemberUserMapper.updateMallMemberUserInfo(updateMemberUser); mallMemberUserMapper.updateMallMemberUserInfo(updateMemberUser);
return AjaxResult.success(); return AjaxResult.success();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment