|
@@ -129,29 +129,28 @@ public class WxUserServiceImpl extends ServiceImpl<IWxUserMapper, WxUser> implem
|
|
|
|
|
|
@Override
|
|
|
public Object getPhone(String code,Integer reCount) {
|
|
|
- String token = wxService.getToken();
|
|
|
- if(StringUtils.isBlank(token)){
|
|
|
- throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
- }
|
|
|
- JSONObject jsonObject = wxClient.getPhone(token, new WxGetPhoneParam(code));
|
|
|
- if(jsonObject.getInteger("errcode") != null && jsonObject.getInteger("errcode") == 40001 && reCount < 2){
|
|
|
- log.info("wx-getPhone-error:{},当前重试次数:{}",code,reCount);
|
|
|
- reCount ++;
|
|
|
- wxService.delToken();
|
|
|
- return getPhone(code,reCount);
|
|
|
- }
|
|
|
- JSONObject phoneObj = (JSONObject) jsonObject.get("phone_info");
|
|
|
- if(phoneObj==null){
|
|
|
- throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- List<WxUser> wxUsers = this.getByPhone(phoneObj.getString("phoneNumber"));
|
|
|
- if(wxUsers.size() >0){
|
|
|
- log.info("getPhone-用户手机号码已存在:{}",phoneObj.toJSONString());
|
|
|
- throw new BusinessException(ResultCode.WX_PHONE_EXIST);
|
|
|
+ try {
|
|
|
+ String token = wxService.getToken();
|
|
|
+ if(StringUtils.isBlank(token)){
|
|
|
+ throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = wxClient.getPhone(token, new WxGetPhoneParam(code));
|
|
|
+ if(jsonObject.getInteger("errcode") != null && jsonObject.getInteger("errcode") == 40001 && reCount < 2){
|
|
|
+ log.info("wx-getPhone-error:{},当前重试次数:{}",code,reCount);
|
|
|
+ reCount ++;
|
|
|
+ wxService.delToken();
|
|
|
+ return getPhone(code,reCount);
|
|
|
+ }
|
|
|
+ JSONObject phoneObj = (JSONObject) jsonObject.get("phone_info");
|
|
|
+ if(phoneObj==null){
|
|
|
+ throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
+ }
|
|
|
+ //return phoneObj.getString("phoneNumber");
|
|
|
+ return phoneObj;
|
|
|
+ } catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- //return phoneObj.getString("phoneNumber");
|
|
|
- return phoneObj;
|
|
|
+ throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
}
|
|
|
|
|
|
@Override
|