Commit cb70febf authored by shangtx's avatar shangtx

feat: 微信依赖更新

parent e39619c8
...@@ -26,7 +26,7 @@ public class AdminWeixinService { ...@@ -26,7 +26,7 @@ public class AdminWeixinService {
try { try {
// 获取base64数据 // 获取base64数据
byte[] qrCode = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(miniQrCodeDTO.getScene(), byte[] qrCode = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(miniQrCodeDTO.getScene(),
miniQrCodeDTO.getPath(), miniQrCodeDTO.getWidth(), false, new WxMaCodeLineColor("0", "0", "0"), false); miniQrCodeDTO.getPath(),false, "release", miniQrCodeDTO.getWidth(), false, new WxMaCodeLineColor("0", "0", "0"), false);
return success(qrCode, "获取微信小程序码成功"); return success(qrCode, "获取微信小程序码成功");
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("获取微信小程序码失败"); throw new ServiceException("获取微信小程序码失败");
......
...@@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; ...@@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.onsiteservice.common.service.dto.MiniQrCodeDTO; import com.onsiteservice.common.service.dto.MiniQrCodeDTO;
import com.onsiteservice.constant.enums.EnvironmentEnum;
import com.onsiteservice.constant.enums.ServiceUserTypeEnum; import com.onsiteservice.constant.enums.ServiceUserTypeEnum;
import com.onsiteservice.core.exception.ServiceException; import com.onsiteservice.core.exception.ServiceException;
import com.onsiteservice.core.result.Result; import com.onsiteservice.core.result.Result;
...@@ -21,6 +22,7 @@ import io.micrometer.core.instrument.util.StringUtils; ...@@ -21,6 +22,7 @@ import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -49,6 +51,8 @@ public class WeiXinService { ...@@ -49,6 +51,8 @@ public class WeiXinService {
private UserService userService; private UserService userService;
@Resource @Resource
private ServicePromoteService promoteService; private ServicePromoteService promoteService;
@Value("${spring.profiles.active:dev}")
private String env;
/** /**
...@@ -61,6 +65,7 @@ public class WeiXinService { ...@@ -61,6 +65,7 @@ public class WeiXinService {
// 获取openid、unionid、session_key等 // 获取openid、unionid、session_key等
sessionResult = wxMaService.getUserService().getSessionInfo(loginDTO.getCode()); sessionResult = wxMaService.getUserService().getSessionInfo(loginDTO.getCode());
} catch (WxErrorException e) { } catch (WxErrorException e) {
e.printStackTrace();
throw new ServiceException("微信小程序登录失败:" + e.getMessage()); throw new ServiceException("微信小程序登录失败:" + e.getMessage());
} }
String unionId = sessionResult.getUnionid(); // unionId需要先在微信开放平台绑定平台 String unionId = sessionResult.getUnionid(); // unionId需要先在微信开放平台绑定平台
...@@ -157,10 +162,16 @@ public class WeiXinService { ...@@ -157,10 +162,16 @@ public class WeiXinService {
public Result getQrCode(MiniQrCodeDTO miniQrCodeDTO) { public Result getQrCode(MiniQrCodeDTO miniQrCodeDTO) {
try { try {
// 获取base64数据 // 获取base64数据
byte[] qrCode = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(miniQrCodeDTO.getScene(), byte[] qrCode = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(
miniQrCodeDTO.getPath(), miniQrCodeDTO.getWidth(), false, new WxMaCodeLineColor("0", "0", "0"), false); miniQrCodeDTO.getScene(),
miniQrCodeDTO.getPath(),
false,
"release",
miniQrCodeDTO.getWidth(),
false, new WxMaCodeLineColor("0", "0", "0"), false);
return success(qrCode, "获取微信小程序码成功"); return success(qrCode, "获取微信小程序码成功");
} catch (Exception e) { } catch (Exception e) {
log.error("{}", e);
throw new ServiceException("获取微信小程序码失败"); throw new ServiceException("获取微信小程序码失败");
} }
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<mapstruct.version>1.3.1.Final</mapstruct.version> <mapstruct.version>1.3.1.Final</mapstruct.version>
<lombok.version>1.18.12</lombok.version> <lombok.version>1.18.12</lombok.version>
<weixin.version>4.2.0</weixin.version> <weixin.version>4.3.0</weixin.version>
</properties> </properties>
<!-- 项目子模块 --> <!-- 项目子模块 -->
......
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