小程序和基础saas功能

This commit is contained in:
wangxiaopeng
2024-03-08 13:48:10 +08:00
parent 32942b5da9
commit 14e66f7d33
52 changed files with 4351 additions and 207 deletions

View File

@@ -12,7 +12,7 @@ public class PartnerUserHolder {
private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
public static PartnerUserInfoVO getUser() {
String userStr = contextHolder.get();
String userStr = contextHolder.get();
if (StringUtils.isNotBlank(userStr)) {
return JSON.parseObject(userStr, PartnerUserInfoVO.class);
}

View File

@@ -0,0 +1,123 @@
package com.cool.store.http;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.wx.CodeSessionDTO;
import com.cool.store.dto.wx.MiniAppUrlLinkDTO;
import com.cool.store.dto.wx.MiniAppUrlLinkReqDTO;
import com.cool.store.dto.wx.PhoneInfoDTO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mq.util.HttpRestTemplateService;
import com.cool.store.utils.RedisUtilPool;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
/**
* @author zhangchenbiao
* @FileName: WechatRest
* @Description:微信api
* @date 2023-05-29 14:49
*/
@Slf4j
@Service
public class WechatRest {
@Resource
private RedisUtilPool redisUtilPool;
@Resource
private HttpRestTemplateService httpRestTemplateService;
/**
* 小程序Token 地址
*/
String ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
/**
* 获取手机号码 地址
*/
String GET_USERPHONENUMBER = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s";
String GET_MINIAPP_URL_LINK = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=%s";
public CodeSessionDTO miniProgramJsCodeSession(String appId, String secret, String jsCode){
log.info("WechatRest#miniProgramJsCodeSession, jsCode:{}", jsCode);
String url = "https://api.weixin.qq.com/sns/jscode2session";
HashMap requestMap = new HashMap();
requestMap.put("appid", appId);
requestMap.put("secret", secret);
requestMap.put("js_code", jsCode);
requestMap.put("grant_type","authorization_code");
try {
String responseStr = httpRestTemplateService.getForObject(url, String.class ,requestMap);
log.info("WechatRest#miniProgramJsCodeSession, url:{}, response:{}", url, responseStr);
if(StringUtils.isNotBlank(responseStr)){
return JSONObject.parseObject(responseStr, CodeSessionDTO.class);
}
} catch (Exception e) {
log.info("调用微信服务异常{}", e);
throw new ServiceException(ErrorCodeEnum.WX_SERVICE_ERROR);
}
return null;
}
public String getAccessToken(String appId, String secret) {
String cacheAccessToken = "wechat_mini_" + appId;
String accessToken = redisUtilPool.getString(cacheAccessToken);
if (StringUtils.isNotBlank(accessToken)) {
return accessToken;
}
String reqUrl = String.format(ACCESS_TOKEN, appId, secret);
try {
JSONObject jsonObject = httpRestTemplateService.getForObject(reqUrl, JSONObject.class, new HashMap());
log.info("WechatRest#getAccessToken, reqUrl:{}, response:{}", reqUrl, JSONObject.toJSONString(jsonObject));
String token = jsonObject.getString("access_token");
if (StringUtils.isBlank(token)) {
throw new ServiceException(ErrorCodeEnum.GET_ACCESSTOKEN_ERROR);
}
redisUtilPool.setString(cacheAccessToken, token, 7000);
return token;
} catch (Exception e) {
log.error("获取微信小程序token异常", e);
}
return null;
}
public PhoneInfoDTO getUserPhoneNumber(String code, String accessToken){
String reqUrl = String.format(GET_USERPHONENUMBER, accessToken);
HashMap requestMap = new HashMap();
requestMap.put("code", code);
String responseStr = null;
try {
responseStr = httpRestTemplateService.postForObject(reqUrl, requestMap, String.class);
log.info("WechatRest#getUserPhoneNumber, reqUrl:{}, response:{}", reqUrl, responseStr);
if(StringUtils.isNotBlank(responseStr)){
return JSONObject.parseObject(responseStr, PhoneInfoDTO.class);
}
} catch (Exception e) {
log.error("获取手机号异常", e);
}
return null;
}
public MiniAppUrlLinkDTO getMiniAppUrlLink(String accessToken, MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO){
String reqUrl = String.format(GET_MINIAPP_URL_LINK, accessToken);
String responseStr = null;
try {
responseStr = httpRestTemplateService.postForObject(reqUrl, miniAppUrlLinkReqDTO, String.class);
log.info("WechatRest#getUserPhoneNumber, reqUrl:{}, response:{}", reqUrl, responseStr);
if(StringUtils.isNotBlank(responseStr)){
return JSONObject.parseObject(responseStr, MiniAppUrlLinkDTO.class);
}
} catch (Exception e) {
log.error("获取手机号异常", e);
}
return null;
}
}

View File

@@ -1,5 +1,8 @@
package com.cool.store.service;
import com.cool.store.dto.wx.MiniAppUrlLinkReqDTO;
import com.cool.store.dto.wx.MiniProgramLoginDTO;
import com.cool.store.request.MobileUpdateRequest;
import com.cool.store.vo.PartnerUserInfoVO;
/**
@@ -10,15 +13,15 @@ import com.cool.store.vo.PartnerUserInfoVO;
*/
public interface WechatMiniAppService {
// PartnerUserInfoVO miniProgramLogin(MiniProgramLoginDTO param);
//
// String getUserPhoneNumber(String mobileCode);
//
// String updateUserPhoneNumber(MobileUpdateRequest request, PartnerUserInfoVO userInfoVO);
//
PartnerUserInfoVO miniProgramLogin(MiniProgramLoginDTO param);
String getUserPhoneNumber(String mobileCode);
String updateUserPhoneNumber(MobileUpdateRequest request, PartnerUserInfoVO userInfoVO);
PartnerUserInfoVO getUserInfo(String mobile, String openId);
//
// String getMiniAppUrl();
//
// String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO);
String getMiniAppUrl();
String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO);
}

View File

@@ -4,26 +4,24 @@ import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.dao.*;
import com.cool.store.dto.wx.*;
import com.cool.store.entity.*;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.UserChannelEnum;
import com.cool.store.enums.UserPlatformTypeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.http.WechatRest;
import com.cool.store.request.MobileUpdateRequest;
import com.cool.store.service.WechatMiniAppService;
import com.cool.store.utils.AesUtil;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.UUIDUtils;
import com.cool.store.vo.PartnerUserInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.MessageFormat;
import java.util.Date;
import java.util.Objects;
/**
* @author zhangchenbiao
@@ -35,26 +33,14 @@ import java.util.Objects;
@Service
public class WechatMiniAppServiceImpl implements WechatMiniAppService {
// @Resource
// private RedisUtilPool redisUtilPool;
// @Resource
// private WechatRest wechatRest;
// @Resource
// private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
// @Resource
// private HyPartnerUserPlatformBindDAO hyPartnerUserPlatformBindDAO;
// @Resource
// private HyPartnerLineInfoDAO hyPartnerLineInfoDAO;
// @Resource
// HyOpenAreaInfoDAO hyOpenAreaInfoDAO;
// @Resource
// HyPartnerBaseInfoDAO hyPartnerBaseInfoDAO;
// @Resource
// HyPhoneLocationService hyPhoneLocationService;
//
// @Autowired
// private HyPartnerUserChannelMapper hyPartnerUserChannelMapper;
//
@Resource
private RedisUtilPool redisUtilPool;
@Resource
private WechatRest wechatRest;
@Resource
private HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
@Resource
HyOpenAreaInfoDAO hyOpenAreaInfoDAO;
@Value("${weixin.appId}")
private String wxAppId;
@Value("${weixin.appSecret}")
@@ -65,143 +51,119 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
private Integer exhibition;
@Value("${recommended.channel.id}")
private Integer recommended;
//
// @Override
// public PartnerUserInfoVO miniProgramLogin(MiniProgramLoginDTO param) {
// log.info("miniProgramLogin #param {}", JSONObject.toJSONString(param));
// PartnerUserInfoVO userInfoVO = new PartnerUserInfoVO();
// String jsCode = param.getJsCode();
// String lockKey = "codeSession:" + wxAppId + CommonConstants.MOSAICS + jsCode;
// boolean lock = redisUtilPool.lock(lockKey);
// if (!lock) {
// throw new ServiceException(ErrorCodeEnum.OPERATION_OVER_TIME);
// }
// CodeSessionDTO codeSession = wechatRest.miniProgramJsCodeSession(wxAppId, wxAppSecret, jsCode);
// String openid = codeSession.getOpenid();
// String sessionCacheKey = MessageFormat.format(CommonConstants.MINI_PROGRAM_SESSION_KEY, wxAppId, openid);
// redisUtilPool.setString(sessionCacheKey, codeSession.getSessionKey(), CommonConstants.THREE_DAY_SECONDS);
// String unionId = codeSession.getUnionId();
// log.info("小程序登录:{}", unionId);
// log.info("sessionKey {}", codeSession.getSessionKey());
// /* String decryptUser = AesUtil.decryptWechat(codeSession.getSessionKey(), param.getEncryptedData(), param.getIvStr());
// log.info("解密用户信息:{}", decryptUser);
// MiniProgramUserVO miniProgramUser = JSON.parseObject(decryptUser, MiniProgramUserVO.class);
// if (Objects.isNull(miniProgramUser)) {
// throw new ServiceException(ErrorCodeEnum.GET_WECHAT_USER_INFO_FAIL);
// }*/
// // 获取小程序token
// String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// // 获取手机号码
// PhoneInfoDTO phoneInfoDTO = wechatRest.getUserPhoneNumber(param.getMobileCode(), accessToken);
// if(phoneInfoDTO != null && phoneInfoDTO.getPhoneInfo() != null && StringUtils.isNotBlank(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
//
// HyPartnerUserPlatformBindDO hyPartnerUserPlatformBindDO = hyPartnerUserPlatformBindDAO.getByPlatformTypeAndUserId(UserPlatformTypeEnum.WECHAT.getCode(), openid);
// HyPartnerUserInfoDO hyPartnerUserInfoDO = null;
// // 微信未授权过
// if(hyPartnerUserPlatformBindDO == null){
// hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(phoneInfoDTO.getPhoneInfo().getPhoneNumber());
// if(hyPartnerUserInfoDO != null){
// HyPartnerUserPlatformBindDO hy = hyPartnerUserPlatformBindDAO.getByPartnerId(hyPartnerUserInfoDO.getPartnerId());
// if (hy!=null){
// throw new ServiceException(ErrorCodeEnum.MOBILE_WECHAT_EXIST);
// }
// }
// if(hyPartnerUserInfoDO == null){
// hyPartnerUserInfoDO = new HyPartnerUserInfoDO();
// hyPartnerUserInfoDO.setMobile(phoneInfoDTO.getPhoneInfo().getPhoneNumber());
// // hyPartnerUserInfoDO.setUsername(phoneInfoDTO.getPhoneInfo().getPhoneNumber());
// hyPartnerUserInfoDO.setPartnerId(UUIDUtils.get32UUID());
// hyPartnerUserInfoDO.setIsWritePartnerKnow(0);
// Integer channelId = null;
// String userChannel = param.getUserChannelEnum();
// if(StringUtils.isNotEmpty(userChannel)){
// if(UserChannelEnum.EXHIBITION.getCode().equals(userChannel)){
// channelId = exhibition;
// }else if(UserChannelEnum.RECOMMENDED.getCode().equals(userChannel)){
// channelId = recommended;
// }else {
// if (StringUtils.isNumeric(userChannel)) {
// channelId = Integer.valueOf(userChannel);
// HyPartnerUserChannelDO hyPartnerUserChannelDO = hyPartnerUserChannelMapper.selectByChannelId(Long.valueOf(channelId));
// if (Objects.isNull(hyPartnerUserChannelDO)|| hyPartnerUserChannelDO.getChannelId() == null ) {
// //用户渠道不存在
// throw new ServiceException(ErrorCodeEnum.USER_CHANNEL_NOT_EXISTS);
// }
//
// }
// }
// }
// hyPartnerUserInfoDO.setUserChannelId(channelId);
// hyPartnerUserInfoDAO.insertSelective(hyPartnerUserInfoDO);
// }
// hyPartnerUserPlatformBindDO = new HyPartnerUserPlatformBindDO();
// hyPartnerUserPlatformBindDO.setPlatformType(UserPlatformTypeEnum.WECHAT.getCode());
// hyPartnerUserPlatformBindDO.setPlatformUserId(openid);
// hyPartnerUserPlatformBindDO.setBindTime(new Date());
// hyPartnerUserPlatformBindDO.setPartnerId(hyPartnerUserInfoDO.getPartnerId());
// hyPartnerUserPlatformBindDAO.insertSelective(hyPartnerUserPlatformBindDO);
// }else {
// hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByPartnerId(hyPartnerUserPlatformBindDO.getPartnerId());
// }
// if(!hyPartnerUserInfoDO.getMobile().equals(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
// throw new ServiceException(ErrorCodeEnum.WECHAT_BIND_OTHER_MOBILE);
// }
// BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO);
// HyPartnerLineInfoDO lineInfoDO = hyPartnerLineInfoDAO.getByPartnerId(hyPartnerUserInfoDO.getPartnerId());
// if (lineInfoDO != null){
// userInfoVO.setPartnerLineId(lineInfoDO.getId());
// userInfoVO.setLineStatus(lineInfoDO.getLineStatus());
// }
// }
// userInfoVO.setOpenid(openid);
// userInfoVO.setUnionId(unionId);
// return userInfoVO;
// }
//
// public static void main(String[] args) {
//
// }
//
// @Override
// public String getUserPhoneNumber(String mobileCode) {
// // 获取小程序token
// String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// // 获取手机号码
// PhoneInfoDTO phoneInfoDTO = wechatRest.getUserPhoneNumber(mobileCode, accessToken);
// if(phoneInfoDTO != null && phoneInfoDTO.getPhoneInfo() != null && StringUtils.isNotBlank(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
// return phoneInfoDTO.getPhoneInfo().getPhoneNumber();
// }
// return null;
// }
//
// @Override
// public String updateUserPhoneNumber(MobileUpdateRequest request, PartnerUserInfoVO userInfoVO) {
// String newMobile = "";
// HyPartnerUserInfoDO oldUserInfo = hyPartnerUserInfoDAO.selectByMobile(userInfoVO.getMobile());
// if (oldUserInfo == null) {
// throw new ServiceException(ErrorCodeEnum.PARTNER_USER_NOT_EXIST);
// }
// // 获取小程序token
// String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// // 获取手机号码
// PhoneInfoDTO phoneInfoDTO = wechatRest.getUserPhoneNumber(request.getMobileCode(), accessToken);
// if(phoneInfoDTO != null && phoneInfoDTO.getPhoneInfo() != null && StringUtils.isNotBlank(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
// newMobile = phoneInfoDTO.getPhoneInfo().getPhoneNumber();
// if(newMobile.equals(oldUserInfo.getMobile())){
// return newMobile;
// }
// HyPartnerUserInfoDO newUserInfo = hyPartnerUserInfoDAO.selectByMobile(newMobile);
// if (newUserInfo != null) {
// throw new ServiceException(ErrorCodeEnum.NEW_MOBILE_HAS_EXIST);
// }
// oldUserInfo.setMobile(newMobile);
// hyPartnerUserInfoDAO.updateByPrimaryKeySelective(oldUserInfo);
// //修改意向申请信息中的手机号
// hyPartnerBaseInfoDAO.updateByPartnerId(null, newMobile, oldUserInfo.getPartnerId());
// }
// return newMobile;
// }
//
@Override
public PartnerUserInfoVO miniProgramLogin(MiniProgramLoginDTO param) {
log.info("miniProgramLogin #param {}", JSONObject.toJSONString(param));
PartnerUserInfoVO userInfoVO = new PartnerUserInfoVO();
String jsCode = param.getJsCode();
String lockKey = "codeSession:" + wxAppId + CommonConstants.MOSAICS + jsCode;
boolean lock = redisUtilPool.lock(lockKey);
if (!lock) {
throw new ServiceException(ErrorCodeEnum.OPERATION_OVER_TIME);
}
CodeSessionDTO codeSession = wechatRest.miniProgramJsCodeSession(wxAppId, wxAppSecret, jsCode);
String openid = codeSession.getOpenid();
String sessionCacheKey = MessageFormat.format(CommonConstants.MINI_PROGRAM_SESSION_KEY, wxAppId, openid);
redisUtilPool.setString(sessionCacheKey, codeSession.getSessionKey(), CommonConstants.THREE_DAY_SECONDS);
String unionId = codeSession.getUnionId();
log.info("小程序登录:{}", unionId);
log.info("sessionKey {}", codeSession.getSessionKey());
/* String decryptUser = AesUtil.decryptWechat(codeSession.getSessionKey(), param.getEncryptedData(), param.getIvStr());
log.info("解密用户信息:{}", decryptUser);
MiniProgramUserVO miniProgramUser = JSON.parseObject(decryptUser, MiniProgramUserVO.class);
if (Objects.isNull(miniProgramUser)) {
throw new ServiceException(ErrorCodeEnum.GET_WECHAT_USER_INFO_FAIL);
}*/
// 获取小程序token
String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// 获取手机号码
PhoneInfoDTO phoneInfoDTO = wechatRest.getUserPhoneNumber(param.getMobileCode(), accessToken);
if(phoneInfoDTO != null && phoneInfoDTO.getPhoneInfo() != null && StringUtils.isNotBlank(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByOpenid(openid);
if( hyPartnerUserInfoDO != null && !hyPartnerUserInfoDO.getMobile().equals(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
throw new ServiceException(ErrorCodeEnum.WECHAT_BIND_OTHER_MOBILE);
}
// 微信未授权过
if(hyPartnerUserInfoDO == null){
hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(phoneInfoDTO.getPhoneInfo().getPhoneNumber());
if(hyPartnerUserInfoDO != null && StringUtils.isNotBlank(hyPartnerUserInfoDO.getOpenid()) && !openid.equals(hyPartnerUserInfoDO.getOpenid())){
throw new ServiceException(ErrorCodeEnum.MOBILE_WECHAT_EXIST);
}
if(hyPartnerUserInfoDO == null){
hyPartnerUserInfoDO = new HyPartnerUserInfoDO();
hyPartnerUserInfoDO.setMobile(phoneInfoDTO.getPhoneInfo().getPhoneNumber());
hyPartnerUserInfoDO.setOpenid(openid);
hyPartnerUserInfoDO.setPartnerId(UUIDUtils.get32UUID());
hyPartnerUserInfoDO.setIsWritePartnerKnow(0);
Integer channelId = null;
String userChannel = param.getUserChannelEnum();
if(StringUtils.isNotEmpty(userChannel)){
if(UserChannelEnum.EXHIBITION.getCode().equals(userChannel)){
channelId = exhibition;
}else if(UserChannelEnum.RECOMMENDED.getCode().equals(userChannel)){
channelId = recommended;
}else {
if (StringUtils.isNumeric(userChannel)) {
channelId = Integer.valueOf(userChannel);
}
}
}
hyPartnerUserInfoDO.setUserChannelId(channelId);
hyPartnerUserInfoDAO.insertSelective(hyPartnerUserInfoDO);
}else {
hyPartnerUserInfoDO.setOpenid(openid);
hyPartnerUserInfoDAO.updateByPrimaryKeySelective(hyPartnerUserInfoDO);
}
}
BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO);
}
userInfoVO.setOpenid(openid);
userInfoVO.setUnionId(unionId);
return userInfoVO;
}
@Override
public String getUserPhoneNumber(String mobileCode) {
// 获取小程序token
String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// 获取手机号码
PhoneInfoDTO phoneInfoDTO = wechatRest.getUserPhoneNumber(mobileCode, accessToken);
if(phoneInfoDTO != null && phoneInfoDTO.getPhoneInfo() != null && StringUtils.isNotBlank(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
return phoneInfoDTO.getPhoneInfo().getPhoneNumber();
}
return null;
}
@Override
public String updateUserPhoneNumber(MobileUpdateRequest request, PartnerUserInfoVO userInfoVO) {
String newMobile = "";
HyPartnerUserInfoDO oldUserInfo = hyPartnerUserInfoDAO.selectByMobile(userInfoVO.getMobile());
if (oldUserInfo == null) {
throw new ServiceException(ErrorCodeEnum.PARTNER_USER_NOT_EXIST);
}
// 获取小程序token
String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// 获取手机号码
PhoneInfoDTO phoneInfoDTO = wechatRest.getUserPhoneNumber(request.getMobileCode(), accessToken);
if(phoneInfoDTO != null && phoneInfoDTO.getPhoneInfo() != null && StringUtils.isNotBlank(phoneInfoDTO.getPhoneInfo().getPhoneNumber())){
newMobile = phoneInfoDTO.getPhoneInfo().getPhoneNumber();
if(newMobile.equals(oldUserInfo.getMobile())){
return newMobile;
}
HyPartnerUserInfoDO newUserInfo = hyPartnerUserInfoDAO.selectByMobile(newMobile);
if (newUserInfo != null) {
throw new ServiceException(ErrorCodeEnum.NEW_MOBILE_HAS_EXIST);
}
oldUserInfo.setMobile(newMobile);
hyPartnerUserInfoDAO.updateByPrimaryKeySelective(oldUserInfo);
//修改意向申请信息中的手机号
// hyPartnerBaseInfoDAO.updateByPartnerId(null, newMobile, oldUserInfo.getPartnerId());
}
return newMobile;
}
@Override
public PartnerUserInfoVO getUserInfo(String mobile, String openId) {
PartnerUserInfoVO userInfoVO = new PartnerUserInfoVO();
@@ -211,37 +173,35 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
userInfoVO.setPartnerId("");
return userInfoVO;
}
// HyPartnerUserPlatformBindDO hyPartnerUserPlatformBindDO = hyPartnerUserPlatformBindDAO.getByPlatformTypeAndUserId(UserPlatformTypeEnum.WECHAT.getCode(), openId);
// if(hyPartnerUserPlatformBindDO != null){
// HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByPartnerId(hyPartnerUserPlatformBindDO.getPartnerId());
// BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO);
// userInfoVO.setOpenid(hyPartnerUserPlatformBindDO.getPlatformUserId());
// if(StringUtils.isNotBlank(hyPartnerUserInfoDO.getWantShopArea())){
// HyOpenAreaInfoDO hyOpenAreaInfoDO = hyOpenAreaInfoDAO.selectById(Long.valueOf(hyPartnerUserInfoDO.getWantShopArea()));
// userInfoVO.setWantShopAreaName(hyOpenAreaInfoDO.getAreaPath().replace("/", " ").trim());
// }
// HyPartnerLineInfoDO lineInfoDO = hyPartnerLineInfoDAO.getByPartnerId(hyPartnerUserInfoDO.getPartnerId());
// if (lineInfoDO != null){
// userInfoVO.setPartnerLineId(lineInfoDO.getId());
// }
// }
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByOpenid(openId);
if(hyPartnerUserInfoDO != null){
BeanUtil.copyProperties(hyPartnerUserInfoDO, userInfoVO);
if(StringUtils.isNotBlank(hyPartnerUserInfoDO.getWantShopArea())){
HyOpenAreaInfoDO hyOpenAreaInfoDO = hyOpenAreaInfoDAO.selectById(Long.valueOf(hyPartnerUserInfoDO.getWantShopArea()));
userInfoVO.setWantShopAreaName(hyOpenAreaInfoDO.getAreaPath().replace("/", " ").trim());
}
/*HyPartnerLineInfoDO lineInfoDO = hyPartnerLineInfoDAO.getByPartnerId(hyPartnerUserInfoDO.getPartnerId());
if (lineInfoDO != null){
userInfoVO.setPartnerLineId(lineInfoDO.getId());
}*/
}
return userInfoVO;
}
//
// @Override
// public String getMiniAppUrl() {
// MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO = new MiniAppUrlLinkReqDTO();
// return getMiniAppUrlLink(miniAppUrlLinkReqDTO);
// }
//
// @Override
// public String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO) {
// String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
// MiniAppUrlLinkDTO miniAppUrlLink = wechatRest.getMiniAppUrlLink(accessToken, miniAppUrlLinkReqDTO);
// if (miniAppUrlLink != null){
// return miniAppUrlLink.getUrlLink();
// }
// return null;
// }
@Override
public String getMiniAppUrl() {
MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO = new MiniAppUrlLinkReqDTO();
return getMiniAppUrlLink(miniAppUrlLinkReqDTO);
}
@Override
public String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO) {
String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
MiniAppUrlLinkDTO miniAppUrlLink = wechatRest.getMiniAppUrlLink(accessToken, miniAppUrlLinkReqDTO);
if (miniAppUrlLink != null){
return miniAppUrlLink.getUrlLink();
}
return null;
}
}