diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 680fa69..55dc30d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -179,17 +179,12 @@ public class LoginContoller { // } @RequestMapping("getPhoneNumber") public Result getPhoneNumber(@RequestHeader String openId, @RequestBody Map map) { - - if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) { - Result.fail("code不能为空"); - } - + String encryptedData = map.get("encryptedData"); // 三方登录来源 wechat、alipay String source = map.getOrDefault("source",AuthSource.WECHAT.getValue()); - String code = map.get("code"); if (AuthSource.ALIPAY.getValue().equals(source)) { try { - String mobile = alipayUtil.getMobile(code); + String mobile = alipayUtil.getMobile(encryptedData); return Result.success(CodeEnum.SUCCESS, mobile); }catch (AlipayApiException e){ log.error("获取手机号失败:",e); @@ -200,7 +195,11 @@ public class LoginContoller { return Result.fail("获取手机号失败:未知错误"); } } - String encryptedData = map.get("encryptedData"); + if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) { + Result.fail("code不能为空"); + } + String code = map.get("code"); + String ivStr = map.get("iv"); if (StringUtils.isBlank(encryptedData) || StringUtils.isBlank(ivStr)) {