yshop2.0.3新增公众号获取微信地址权限,优化一些代码
This commit is contained in:
@ -130,28 +130,19 @@ public class StoreOrderController extends BaseController {
|
|||||||
other.setIntegralFull(systemConfigService.getData("integral_full"));
|
other.setIntegralFull(systemConfigService.getData("integral_full"));
|
||||||
other.setIntegralMax(systemConfigService.getData("integral_max"));
|
other.setIntegralMax(systemConfigService.getData("integral_max"));
|
||||||
|
|
||||||
//todo 拼团 砍价 秒杀
|
//拼团 砍价 秒杀
|
||||||
int combinationId = 0;
|
int combinationId = 0;
|
||||||
if(cartId.split(",").length == 1){
|
|
||||||
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
|
|
||||||
.valueOf(cartId));
|
|
||||||
combinationId = cartQueryVo.getCombinationId();
|
|
||||||
}
|
|
||||||
|
|
||||||
int secKillId = 0;
|
int secKillId = 0;
|
||||||
if(cartId.split(",").length == 1){
|
|
||||||
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
|
|
||||||
.valueOf(cartId));
|
|
||||||
secKillId = cartQueryVo.getSeckillId();
|
|
||||||
}
|
|
||||||
|
|
||||||
int bargainId = 0;
|
int bargainId = 0;
|
||||||
if(cartId.split(",").length == 1){
|
if(cartId.split(",").length == 1){
|
||||||
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
|
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
|
||||||
.valueOf(cartId));
|
.valueOf(cartId));
|
||||||
|
combinationId = cartQueryVo.getCombinationId();
|
||||||
|
secKillId = cartQueryVo.getSeckillId();
|
||||||
bargainId = cartQueryVo.getBargainId();
|
bargainId = cartQueryVo.getBargainId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//拼团砍价秒杀类产品不参与抵扣
|
//拼团砍价秒杀类产品不参与抵扣
|
||||||
if(combinationId > 0 || secKillId > 0 || bargainId > 0) confirmOrderDTO.setDeduction(true);
|
if(combinationId > 0 || secKillId > 0 || bargainId > 0) confirmOrderDTO.setDeduction(true);
|
||||||
|
|
||||||
|
@ -156,26 +156,19 @@ public class AuthController {
|
|||||||
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = wxService.oauth2getAccessToken(code);
|
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = wxService.oauth2getAccessToken(code);
|
||||||
WxMpUser wxMpUser = wxService.oauth2getUserInfo(wxMpOAuth2AccessToken, null);
|
WxMpUser wxMpUser = wxService.oauth2getUserInfo(wxMpOAuth2AccessToken, null);
|
||||||
String openid = wxMpUser.getOpenId();
|
String openid = wxMpUser.getOpenId();
|
||||||
YxWechatUser wechatUser = wechatUserService.getUserInfo(openid);
|
|
||||||
|
|
||||||
|
YxUser yxUser = userService.findByName(openid);
|
||||||
|
|
||||||
JwtUser jwtUser = null;
|
JwtUser jwtUser = null;
|
||||||
if (ObjectUtil.isNotNull(wechatUser)) {
|
if (ObjectUtil.isNotNull(yxUser)) {
|
||||||
YxUserQueryVo yxUserQueryVo = userService.getYxUserById(wechatUser.getUid());
|
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(openid);
|
||||||
if (ObjectUtil.isNotNull(yxUserQueryVo)) {
|
|
||||||
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wechatUser.getOpenid());
|
|
||||||
} else {
|
} else {
|
||||||
if (ObjectUtil.isNotNull(wechatUser)) {
|
|
||||||
|
//如果后台删除了用户
|
||||||
|
YxWechatUser wechatUser = wechatUserService.getUserInfo(openid);
|
||||||
|
if(wechatUser != null){
|
||||||
wechatUserService.removeById(wechatUser.getUid());
|
wechatUserService.removeById(wechatUser.getUid());
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotNull(yxUserQueryVo)) {
|
|
||||||
userService.removeById(yxUserQueryVo.getUid());
|
|
||||||
}
|
|
||||||
return ApiResult.fail(ApiCode.FAIL_AUTH, "授权失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
//过滤掉表情
|
//过滤掉表情
|
||||||
String nickname = EmojiParser.removeAllEmojis(wxMpUser.getNickname());
|
String nickname = EmojiParser.removeAllEmojis(wxMpUser.getNickname());
|
||||||
@ -293,27 +286,22 @@ public class AuthController {
|
|||||||
wxMaConfig.setAppid(appId);
|
wxMaConfig.setAppid(appId);
|
||||||
wxMaConfig.setSecret(secret);
|
wxMaConfig.setSecret(secret);
|
||||||
|
|
||||||
|
|
||||||
wxMaService.setWxMaConfig(wxMaConfig);
|
wxMaService.setWxMaConfig(wxMaConfig);
|
||||||
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
||||||
YxWechatUser wechatUser = wechatUserService.getUserAppInfo(session.getOpenid());
|
String openid = session.getOpenid();
|
||||||
;
|
|
||||||
|
YxUser yxUser = userService.findByName(openid);
|
||||||
JwtUser jwtUser = null;
|
JwtUser jwtUser = null;
|
||||||
if (ObjectUtil.isNotNull(wechatUser)) {
|
if (ObjectUtil.isNotNull(yxUser)) {
|
||||||
YxUserQueryVo yxUserQueryVo = userService.getYxUserById(wechatUser.getUid());
|
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(openid);
|
||||||
if (ObjectUtil.isNotNull(yxUserQueryVo)) {
|
|
||||||
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wechatUser.getRoutineOpenid());
|
|
||||||
} else {
|
} else {
|
||||||
if (ObjectUtil.isNotNull(wechatUser)) {
|
|
||||||
|
//如果后台删除了用户
|
||||||
|
YxWechatUser wechatUser = wechatUserService.getUserAppInfo(openid);
|
||||||
|
if(wechatUser != null){
|
||||||
wechatUserService.removeById(wechatUser.getUid());
|
wechatUserService.removeById(wechatUser.getUid());
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotNull(yxUserQueryVo)) {
|
|
||||||
userService.removeById(yxUserQueryVo.getUid());
|
|
||||||
}
|
|
||||||
return ApiResult.fail(ApiCode.FAIL_AUTH, "授权失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
WxMaUserInfo wxMpUser = wxMaService.getUserService()
|
WxMaUserInfo wxMpUser = wxMaService.getUserService()
|
||||||
.getUserInfo(session.getSessionKey(), encryptedData, iv);
|
.getUserInfo(session.getSessionKey(), encryptedData, iv);
|
||||||
//过滤掉表情
|
//过滤掉表情
|
||||||
|
@ -13,6 +13,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||||
import co.yixiang.common.web.vo.Paging;
|
import co.yixiang.common.web.vo.Paging;
|
||||||
|
import co.yixiang.exception.ErrorRequestException;
|
||||||
import co.yixiang.modules.order.service.YxStoreOrderService;
|
import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||||
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
||||||
@ -423,13 +424,15 @@ public class YxUserServiceImpl extends BaseServiceImpl<YxUserMapper, YxUser> imp
|
|||||||
@Override
|
@Override
|
||||||
public YxUserQueryVo getYxUserById(Serializable id){
|
public YxUserQueryVo getYxUserById(Serializable id){
|
||||||
YxUserQueryVo userQueryVo = yxUserMapper.getYxUserById(id);
|
YxUserQueryVo userQueryVo = yxUserMapper.getYxUserById(id);
|
||||||
userQueryVo.setOrderStatusNum(orderService.orderData((int)id));
|
|
||||||
return userQueryVo;
|
return userQueryVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YxUserQueryVo getNewYxUserById(Serializable id) {
|
public YxUserQueryVo getNewYxUserById(Serializable id) {
|
||||||
YxUserQueryVo userQueryVo = yxUserMapper.getYxUserById(id);
|
YxUserQueryVo userQueryVo = yxUserMapper.getYxUserById(id);
|
||||||
|
if(userQueryVo == null){
|
||||||
|
throw new ErrorRequestException("用户不存在");
|
||||||
|
}
|
||||||
userQueryVo.setOrderStatusNum(orderService.orderData((int)id));
|
userQueryVo.setOrderStatusNum(orderService.orderData((int)id));
|
||||||
userQueryVo.setCouponCount(storeCouponUserService.getUserValidCouponCount((int)id));
|
userQueryVo.setCouponCount(storeCouponUserService.getUserValidCouponCount((int)id));
|
||||||
//判断分销类型
|
//判断分销类型
|
||||||
|
@ -46,14 +46,14 @@ public class YxWechatUserServiceImpl extends BaseServiceImpl<YxWechatUserMapper,
|
|||||||
@Override
|
@Override
|
||||||
public YxWechatUser getUserAppInfo(String openid) {
|
public YxWechatUser getUserAppInfo(String openid) {
|
||||||
QueryWrapper<YxWechatUser> wrapper = new QueryWrapper<>();
|
QueryWrapper<YxWechatUser> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("routine_openid",openid);
|
wrapper.eq("routine_openid",openid).last("limit 1");
|
||||||
return yxWechatUserMapper.selectOne(wrapper);
|
return yxWechatUserMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YxWechatUser getUserInfo(String openid) {
|
public YxWechatUser getUserInfo(String openid) {
|
||||||
QueryWrapper<YxWechatUser> wrapper = new QueryWrapper<>();
|
QueryWrapper<YxWechatUser> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("openid",openid);
|
wrapper.eq("openid",openid).last("limit 1");
|
||||||
return yxWechatUserMapper.selectOne(wrapper);
|
return yxWechatUserMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,8 @@ public class WechatController extends BaseController {
|
|||||||
|
|
||||||
map.put("appId",jsapiSignature.getAppId());
|
map.put("appId",jsapiSignature.getAppId());
|
||||||
map.put("jsApiList",new String[]{"updateAppMessageShareData","openLocation","scanQRCode",
|
map.put("jsApiList",new String[]{"updateAppMessageShareData","openLocation","scanQRCode",
|
||||||
"chooseWXPay","updateAppMessageShareData","updateTimelineShareData"});
|
"chooseWXPay","updateAppMessageShareData","updateTimelineShareData",
|
||||||
|
"openAddress","editAddress"});
|
||||||
map.put("nonceStr",jsapiSignature.getNonceStr());
|
map.put("nonceStr",jsapiSignature.getNonceStr());
|
||||||
map.put("signature",jsapiSignature.getSignature());
|
map.put("signature",jsapiSignature.getSignature());
|
||||||
map.put("timestamp",jsapiSignature.getTimestamp());
|
map.put("timestamp",jsapiSignature.getTimestamp());
|
||||||
|
Reference in New Issue
Block a user