修复微信登录授权bug
This commit is contained in:
parent
795a62bf1d
commit
23e8bc4c91
|
|
@ -51,7 +51,7 @@ public class WxPayDriver {
|
|||
}
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
* 微信统一下单
|
||||
*
|
||||
* @param requestV3 请求参数
|
||||
* @return WxPayUnifiedOrderV3Result.JsapiResult
|
||||
|
|
@ -107,7 +107,9 @@ public class WxPayDriver {
|
|||
}
|
||||
|
||||
/**
|
||||
* 发起退款
|
||||
* 微信支付-申请退款
|
||||
* 文档地址: https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
|
||||
* 接口链接: https://api.mch.weixin.qq.com/secapi/pay/refund
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return WxPayRefundV3Result 退款结果
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import com.mdd.front.validate.PaymentValidate;
|
|||
import com.mdd.front.vo.PayWayListedVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
|
|||
|
|
@ -295,13 +295,14 @@ public class LoginServiceImpl implements ILoginService {
|
|||
* @return LoginTokenVo
|
||||
*/
|
||||
private LoginTokenVo __wxLoginHandle(String openId, String unionId, Integer terminal) {
|
||||
// 查询授权
|
||||
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
||||
.nested(wq->wq
|
||||
.eq("unionid", unionId).or()
|
||||
.eq("openid", openId)
|
||||
).last("limit 1"));
|
||||
|
||||
Integer userId;
|
||||
// 查询用户
|
||||
User user = null;
|
||||
if (StringUtils.isNotNull(userAuth)) {
|
||||
user = userMapper.selectOne(new QueryWrapper<User>()
|
||||
|
|
@ -310,6 +311,7 @@ public class LoginServiceImpl implements ILoginService {
|
|||
.last("limit 1"));
|
||||
}
|
||||
|
||||
// 创建用户
|
||||
if (StringUtils.isNull(user)) {
|
||||
Integer sn = this.__generateSn();
|
||||
User model = new User();
|
||||
|
|
@ -317,7 +319,7 @@ public class LoginServiceImpl implements ILoginService {
|
|||
model.setAvatar("/api/static/default_avatar.png");
|
||||
model.setNickname("用户" + sn);
|
||||
model.setUsername("u" + sn);
|
||||
model.setChannel(ClientEnum.PC.getCode());
|
||||
model.setChannel(terminal);
|
||||
model.setSex(0);
|
||||
model.setLastLoginIp(IpUtils.getHostIp());
|
||||
model.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||
|
|
@ -325,29 +327,17 @@ public class LoginServiceImpl implements ILoginService {
|
|||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setIsNew(1);
|
||||
userMapper.insert(model);
|
||||
userId = model.getId();
|
||||
user = model;
|
||||
|
||||
if (StringUtils.isNull(userAuth)) {
|
||||
UserAuth auth = new UserAuth();
|
||||
auth.setUserId(model.getId());
|
||||
auth.setUnionid(unionId);
|
||||
auth.setOpenid(openId);
|
||||
auth.setTerminal(terminal);
|
||||
auth.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
auth.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userAuthMapper.insert(auth);
|
||||
}
|
||||
} else {
|
||||
// 授权不存在则创建
|
||||
userId = user.getId();
|
||||
UserAuth auth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
||||
.nested(wq->wq
|
||||
.eq("unionid", unionId).or()
|
||||
|
||||
// 终端授权
|
||||
UserAuth auth = userAuthMapper.selectOne(
|
||||
new QueryWrapper<UserAuth>()
|
||||
.eq("openid", openId)
|
||||
).eq("terminal", terminal)
|
||||
.eq("terminal", terminal)
|
||||
.last("limit 1"));
|
||||
|
||||
// 创建授权
|
||||
if (StringUtils.isNull(auth)) {
|
||||
UserAuth authModel = new UserAuth();
|
||||
authModel.setUserId(user.getId());
|
||||
|
|
@ -357,13 +347,13 @@ public class LoginServiceImpl implements ILoginService {
|
|||
authModel.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
authModel.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userAuthMapper.insert(authModel);
|
||||
} else if(StringUtils.isEmpty(auth.getUnionid()) && StringUtils.isNotEmpty(unionId)) {
|
||||
} else if (StringUtils.isEmpty(auth.getUnionid())) {
|
||||
auth.setUnionid(unionId);
|
||||
userAuthMapper.updateById(userAuth);
|
||||
}
|
||||
auth.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userAuthMapper.updateById(auth);
|
||||
}
|
||||
|
||||
return this.__loginToken(userId, user.getMobile(), terminal);
|
||||
return this.__loginToken(user.getId(), user.getMobile(), terminal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue