diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java index d6e658972..59f0c4b65 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantController.java @@ -100,20 +100,24 @@ public class WxMerchantController extends BaseController { @ApiOperation("获取微信OpenId") @GetMapping("/getOpenIdByPhone") - @ApiImplicitParam(name = "phone", value = "商户C端注册手机号", dataType = "String", paramType = "query", required = true) - public ResultData getOpenIdByPhone(@ModelAttribute String phone) { + public ResultData getOpenIdByPhone() { log.debug("[" + getIpAddr() + "] WxMerchantController::getOpenIdByPhone"); - if (!hasPermission()) { - return new ResultData(ErrorCode.USER_NO_PERMISSION); - } - if (StringUtils.isBlank(phone)) { - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户C端注册手机号不能为空"); + // hasPermission + WxMerchantBUser user = getUser(); + WxBuser buser = getBuser(); + WxMerchant merchant = new WxMerchant(); + merchant.setId(user.getMerchantId()); + WxMerchant wxMerchant = wxMerchantService.findOne(merchant); + if ( wxMerchant != null && buser.getPhone().equals(wxMerchant.getLinkPhone()) ) { + WxCUser cuUser = new WxCUser(); + cuUser.updateTenantInfo(getTenantInfo()); + cuUser.setPhone(wxMerchant.getLinkPhone()); + WxCUser mUser = cUserService.getByObject(cuUser); + if (mUser != null) { + return new ResultData(mUser.getOpenId()); + } } - WxCUser cuUser = new WxCUser(); - cuUser.updateTenantInfo(getTenantInfo()); - cuUser.setPhone(phone); - WxCUser mUser = cUserService.getByObject(cuUser); - return new ResultData(mUser.getOpenId()); + return new ResultData(ErrorCode.USER_NO_PERMISSION); } public boolean hasPermission() {