获取手机号
This commit is contained in:
parent
b4049079e0
commit
3e4ebd2039
|
|
@ -48,11 +48,11 @@
|
||||||
<artifactId>cash-common-tools</artifactId>
|
<artifactId>cash-common-tools</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.github.binarywang</groupId>
|
<!-- <groupId>com.github.binarywang</groupId>-->
|
||||||
<artifactId>weixin-java-miniapp</artifactId>
|
<!-- <artifactId>weixin-java-miniapp</artifactId>-->
|
||||||
<version>${weixin.java.miniapp.version}</version>
|
<!-- <version>${weixin.java.miniapp.version}</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.zxing</groupId>
|
<groupId>com.google.zxing</groupId>
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,16 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.github.binarywang</groupId>
|
<!-- <groupId>com.github.binarywang</groupId>-->
|
||||||
<artifactId>weixin-java-miniapp</artifactId>
|
<!-- <artifactId>weixin-java-miniapp</artifactId>-->
|
||||||
<exclusions>
|
<!-- <exclusions>-->
|
||||||
<exclusion>
|
<!-- <exclusion>-->
|
||||||
<groupId>org.projectlombok</groupId>
|
<!-- <groupId>org.projectlombok</groupId>-->
|
||||||
<artifactId>lombok</artifactId>
|
<!-- <artifactId>lombok</artifactId>-->
|
||||||
</exclusion>
|
<!-- </exclusion>-->
|
||||||
</exclusions>
|
<!-- </exclusions>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.whvcse</groupId>
|
<groupId>com.github.whvcse</groupId>
|
||||||
<artifactId>easy-captcha</artifactId>
|
<artifactId>easy-captcha</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.czg.service.account.service.impl;
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
//import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
|
@ -51,36 +51,37 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPhone(GetPhoneDTO phoneDTO) {
|
public String getPhone(GetPhoneDTO phoneDTO) {
|
||||||
String mobile;
|
// String mobile;
|
||||||
String openId;
|
// String openId;
|
||||||
UserInfo userInfo = null;
|
// UserInfo userInfo = null;
|
||||||
if (UserAuthSourceEnum.ALIPAY.getValue().equals(phoneDTO.getSource())) {
|
// if (UserAuthSourceEnum.ALIPAY.getValue().equals(phoneDTO.getSource())) {
|
||||||
openId = alipayUtil.getOpenId(phoneDTO.getCode(), true);
|
// openId = alipayUtil.getOpenId(phoneDTO.getCode(), true);
|
||||||
mobile = alipayUtil.getMobile(phoneDTO.getEncryptedData());
|
// mobile = alipayUtil.getMobile(phoneDTO.getEncryptedData());
|
||||||
if (StrUtil.isNotBlank(openId)) {
|
// if (StrUtil.isNotBlank(openId)) {
|
||||||
userInfo = userInfoService.queryChain().eq(UserInfo::getWechatOpenId, openId).one();
|
// userInfo = userInfoService.queryChain().eq(UserInfo::getWechatOpenId, openId).one();
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
JSONObject session = wechatAuthUtil.getSession(phoneDTO.getCode());
|
// JSONObject session = wechatAuthUtil.getSession(phoneDTO.getCode());
|
||||||
String sessionKey = session.getString("session_key");
|
// String sessionKey = session.getString("session_key");
|
||||||
openId = session.getString("openid");
|
// openId = session.getString("openid");
|
||||||
if (StrUtil.isNotBlank(openId)) {
|
// if (StrUtil.isNotBlank(openId)) {
|
||||||
userInfo = userInfoService.queryChain().eq(UserInfo::getAlipayOpenId, openId).one();
|
// userInfo = userInfoService.queryChain().eq(UserInfo::getAlipayOpenId, openId).one();
|
||||||
}
|
// }
|
||||||
String data = WxMaCryptUtils.decrypt(sessionKey, phoneDTO.getEncryptedData(), phoneDTO.getIv());
|
// String data = WxMaCryptUtils.decrypt(sessionKey, phoneDTO.getEncryptedData(), phoneDTO.getIv());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
// JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
if (jsonObject.containsKey("phoneNumber")) {
|
// if (jsonObject.containsKey("phoneNumber")) {
|
||||||
mobile = jsonObject.getString("phoneNumber");
|
// mobile = jsonObject.getString("phoneNumber");
|
||||||
}else {
|
// }else {
|
||||||
throw new ApiNotPrintException("手机号获取失败");
|
// throw new ApiNotPrintException("手机号获取失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (userInfo != null) {
|
// if (userInfo != null) {
|
||||||
userInfo.setPhone(mobile);
|
// userInfo.setPhone(mobile);
|
||||||
userInfoService.updateById(userInfo);
|
// userInfoService.updateById(userInfo);
|
||||||
}
|
// }
|
||||||
return mobile;
|
// return mobile;
|
||||||
|
return "123";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue