From ba8ac8e2c2aa0465cf1e24246c374a4a854ad008 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 23 Aug 2018 09:45:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81=E7=A0=81]?= =?UTF-8?q?[=E4=BF=AE=E6=94=B9]:=E5=8F=91=E9=80=81=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=8A=8AB=E7=AB=AF?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=94=BE=E5=88=B0controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WxMsgValidationcodeController.java | 36 +++++++++++++++++++ .../impl/WxMsgValidationcodeServiceImpl.java | 23 ------------ 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/mallinkBApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java b/mallinkBApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java index 4fde2135e..91372708c 100644 --- a/mallinkBApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java +++ b/mallinkBApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java @@ -1,7 +1,12 @@ package com.simple.controller; +import com.simple.common.ErrorCode; import com.simple.common.ResultData; +import com.simple.domain.po.WxMerchant; +import com.simple.domain.po.WxMerchantBUser; import com.simple.domain.po.WxMsgValidationcode; +import com.simple.service.WxMerchantBUserService; +import com.simple.service.WxMerchantService; import com.simple.service.WxMsgValidationcodeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -21,6 +26,14 @@ public class WxMsgValidationcodeController extends BaseController { @Autowired private WxMsgValidationcodeService wxMsgValidationcodeService; + @Autowired + private WxMerchantBUserService wxMerchantBUserService; + + @Autowired + private WxMerchantService wxMerchantService; + + + @GetMapping("sendvalidationcode") @ApiImplicitParams({ @ApiImplicitParam(name = "tenantId", value = "租户ID", dataType = "String", paramType = "query"), @@ -28,6 +41,29 @@ public class WxMsgValidationcodeController extends BaseController { @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) public ResultData sendvalidationcode(String tenantId, String phone, Integer type, String appid) { + + WxMerchantBUser user = new WxMerchantBUser(); + user.setAppId(appid); + user.setPhone(phone); + + WxMerchantBUser buser=wxMerchantBUserService.getBUserByAppId(user); + if (buser==null) { + logger.error("B端用户不存在, phone: " + phone); + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + + + WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); + if (merchant==null) { + logger.error("B端所在商户不存在, id: " + user.getMerchantId()); + return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); + } + + if(merchant.getStatus()==0){ + logger.error("B端所在商户已停用, id: " + merchant.getId()); + return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID); + } + WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); wxMsgValidationcode.setTenantId(tenantId); wxMsgValidationcode.setPhone(phone); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java index 03666c8d5..4993446e2 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java @@ -78,29 +78,6 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic @Override public ResultData sendvalidationcode(WxMsgValidationcode wxMsgValidationcode) { - WxMerchantBUser user = new WxMerchantBUser(); - user.setAppId(wxMsgValidationcode.getAppid()); - user.setPhone(wxMsgValidationcode.getPhone()); - - List userList = wxMerchantBUserMapper.findList(user); - if (userList.size()==0) { - logger.error("B端用户不存在, phone: " + wxMsgValidationcode.getPhone()); - return new ResultData(ErrorCode.USER_IS_EMPTY); - } - - WxMerchant wxMerchant = new WxMerchant(); - wxMerchant.setId(userList.get(0).getMerchantId()); - List merchantList = wxMerchantMapper.findList(wxMerchant); - if (merchantList.size()==0) { - logger.error("B端所在商户不存在, id: " + userList.get(0).getId()); - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); - } - - wxMerchant = merchantList.get(0); - if(wxMerchant.getStatus()==0){ - logger.error("B端所在商户已停用, id: " + userList.get(0).getId()); - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID); - } //1、查看是否存在未过期的短信,有返回成功 没有继续 List wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode);