From 3e4ebd2039d653edbfdd1b5ffd295e96d488ec50 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 11 Mar 2025 10:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cash-dependencies/pom.xml | 10 +-- cash-service/account-service/pom.xml | 20 +++--- .../impl/UserAuthorizationServiceImpl.java | 63 ++++++++++--------- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/cash-dependencies/pom.xml b/cash-dependencies/pom.xml index 4e5e936a..fcf77de3 100644 --- a/cash-dependencies/pom.xml +++ b/cash-dependencies/pom.xml @@ -48,11 +48,11 @@ cash-common-tools ${project.version} - - com.github.binarywang - weixin-java-miniapp - ${weixin.java.miniapp.version} - + + + + + com.google.zxing diff --git a/cash-service/account-service/pom.xml b/cash-service/account-service/pom.xml index 2c77e981..3b673379 100644 --- a/cash-service/account-service/pom.xml +++ b/cash-service/account-service/pom.xml @@ -18,16 +18,16 @@ - - com.github.binarywang - weixin-java-miniapp - - - org.projectlombok - lombok - - - + + + + + + + + + + com.github.whvcse easy-captcha diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java index 470afc65..170affa1 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/UserAuthorizationServiceImpl.java @@ -1,6 +1,6 @@ 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.util.StrUtil; import com.alibaba.fastjson2.JSONObject; @@ -51,36 +51,37 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService { @Override public String getPhone(GetPhoneDTO phoneDTO) { - String mobile; - String openId; - UserInfo userInfo = null; - if (UserAuthSourceEnum.ALIPAY.getValue().equals(phoneDTO.getSource())) { - openId = alipayUtil.getOpenId(phoneDTO.getCode(), true); - mobile = alipayUtil.getMobile(phoneDTO.getEncryptedData()); - if (StrUtil.isNotBlank(openId)) { - userInfo = userInfoService.queryChain().eq(UserInfo::getWechatOpenId, openId).one(); - } - } else { - JSONObject session = wechatAuthUtil.getSession(phoneDTO.getCode()); - String sessionKey = session.getString("session_key"); - openId = session.getString("openid"); - if (StrUtil.isNotBlank(openId)) { - userInfo = userInfoService.queryChain().eq(UserInfo::getAlipayOpenId, openId).one(); - } - String data = WxMaCryptUtils.decrypt(sessionKey, phoneDTO.getEncryptedData(), phoneDTO.getIv()); - JSONObject jsonObject = JSONObject.parseObject(data); - if (jsonObject.containsKey("phoneNumber")) { - mobile = jsonObject.getString("phoneNumber"); - }else { - throw new ApiNotPrintException("手机号获取失败"); - } - } - - if (userInfo != null) { - userInfo.setPhone(mobile); - userInfoService.updateById(userInfo); - } - return mobile; +// String mobile; +// String openId; +// UserInfo userInfo = null; +// if (UserAuthSourceEnum.ALIPAY.getValue().equals(phoneDTO.getSource())) { +// openId = alipayUtil.getOpenId(phoneDTO.getCode(), true); +// mobile = alipayUtil.getMobile(phoneDTO.getEncryptedData()); +// if (StrUtil.isNotBlank(openId)) { +// userInfo = userInfoService.queryChain().eq(UserInfo::getWechatOpenId, openId).one(); +// } +// } else { +// JSONObject session = wechatAuthUtil.getSession(phoneDTO.getCode()); +// String sessionKey = session.getString("session_key"); +// openId = session.getString("openid"); +// if (StrUtil.isNotBlank(openId)) { +// userInfo = userInfoService.queryChain().eq(UserInfo::getAlipayOpenId, openId).one(); +// } +// String data = WxMaCryptUtils.decrypt(sessionKey, phoneDTO.getEncryptedData(), phoneDTO.getIv()); +// JSONObject jsonObject = JSONObject.parseObject(data); +// if (jsonObject.containsKey("phoneNumber")) { +// mobile = jsonObject.getString("phoneNumber"); +// }else { +// throw new ApiNotPrintException("手机号获取失败"); +// } +// } +// +// if (userInfo != null) { +// userInfo.setPhone(mobile); +// userInfoService.updateById(userInfo); +// } +// return mobile; + return "123"; } @Override