| @@ -160,11 +160,11 @@ public class WxMerchantBUserController extends BaseController { | |||
| } | |||
| WxMerchantBUser userQ = new WxMerchantBUser(); | |||
| // userQ.updateTenantInfo(wxAppinfo); | |||
| userQ.setAppId(appId); | |||
| userQ.updateTenantInfo(wxAppinfo); | |||
| // userQ.setAppId(appId); | |||
| userQ.setPhone(phone); | |||
| userQ.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | |||
| List<WxMerchantBUser> orgList = wxMerchantBUserService.getBUserByAppId(userQ); | |||
| List<WxMerchantBUser> orgList = wxMerchantBUserService.findAllList(userQ); | |||
| if (orgList.size() == 1) { | |||
| // 集团内只发现一个用户 | |||
| @@ -201,7 +201,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| // check password | |||
| if (orgUser.getUserPwd().equalsIgnoreCase(password)) { | |||
| // 返回多个(商场+商户) | |||
| List<WxMerchantBuInfoVo> merchantListInfo = wxMerchantBUserService.getMerchantInfoByBUser(userQ); | |||
| List<WxMerchantBuInfoVo> merchantListInfo = wxMerchantBUserService.handMerchantBUser(orgList); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| resultMap.put("merchantList", merchantListInfo); | |||
| resultMap.put("logined", false); | |||
| @@ -242,7 +242,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| WxMerchantBUser userQ = new WxMerchantBUser(); | |||
| userQ.setId(Long.valueOf(buUserIdStr)); | |||
| userQ.setMerchantId(Long.valueOf(merchantIdStr)); | |||
| List<WxMerchantBUser> orgList = wxMerchantBUserService.getBUserByAppId(userQ); | |||
| List<WxMerchantBUser> orgList = wxMerchantBUserService.findList(userQ); | |||
| if (orgList.size() == 1) { | |||
| WxMerchantBUser orgUser = orgList.get(0); | |||
| if (orgUser != null) { | |||
| @@ -301,6 +301,14 @@ public class WxMerchantBUserController extends BaseController { | |||
| if (StringUtils.isBlank(appId)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = getAppInfo(appId); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||
| } | |||
| if (StringUtils.isBlank(phone)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "手机号不能为空"); | |||
| } | |||
| @@ -310,7 +318,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| if (StringUtils.isBlank(pwd)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | |||
| } | |||
| return wxMerchantBUserService.updatePwd(appId, phone, code, pwd); | |||
| return wxMerchantBUserService.updatePwd(wxAppinfo.getTenantId(), phone, code, pwd); | |||
| } | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxMsgValidationcode; | |||
| @@ -46,12 +47,20 @@ public class WxMsgValidationcodeController extends BaseController { | |||
| @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData sendvalidationcode(String phone, String type, String appid) { | |||
| WxAppinfo wxAppinfo = getAppInfo(appid); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||
| } | |||
| WxMerchantBUser userQ = new WxMerchantBUser(); | |||
| userQ.setAppId(appid); | |||
| userQ.updateTenantInfo(wxAppinfo); | |||
| userQ.setPhone(phone); | |||
| userQ.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | |||
| List<WxMerchantBUser> orgUserList = wxMerchantBUserService.getBUserByAppId(userQ); | |||
| List<WxMerchantBUser> orgUserList = wxMerchantBUserService.findList(userQ); | |||
| if (orgUserList.size() <= 0) { | |||
| logger.error("B端用户不存在, phone: " + phone); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| @@ -109,7 +109,7 @@ public class PosServiceImpl implements PosService { | |||
| List<WxMerchantBUser> orgUserList = null; | |||
| try { | |||
| orgUserList = merchantBUserService.getBUserByAppId(userQ); | |||
| orgUserList = merchantBUserService.findList(userQ); | |||
| } catch (Exception e) { | |||
| String errMessage = ErrorCode.MERCHANT_BUSER_NOT_VALID.getMessage() + "phone: " + phone + ", " +e.getMessage(); | |||
| throw new MallinkException(ErrorCode.MERCHANT_BUSER_NOT_VALID.getCode(), errMessage); | |||
| @@ -7,6 +7,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxMall; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxMallService { | |||
| @@ -93,4 +94,6 @@ public interface WxMallService { | |||
| boolean mallValid(Long loginUserId,WxMall mall); | |||
| boolean isgroupSupport(TenantEntity tenantEntity); | |||
| Map<String, WxMall> getMallMap(WxMall mallQ); | |||
| } | |||
| @@ -43,7 +43,7 @@ public interface WxMerchantBUserService { | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxMerchantBUser> getBUserByAppId(WxMerchantBUser record); | |||
| List<WxMerchantBUser> findList(WxMerchantBUser record); | |||
| List<WxMerchantBuInfoVo> getMerchantInfoByBUser(WxMerchantBUser record); | |||
| @@ -64,6 +64,9 @@ public interface WxMerchantBUserService { | |||
| boolean hasPhone(TenantEntity tenantEntity, String phone); | |||
| ResultData updatePwd(String appId, String phone, String code, String pwd); | |||
| ResultData updatePwd(String tenantId, String phone, String code, String pwd); | |||
| List<WxMerchantBUser> findAllList(WxMerchantBUser userQ); | |||
| List<WxMerchantBuInfoVo> handMerchantBUser(List<WxMerchantBUser> orgList); | |||
| } | |||
| @@ -205,4 +205,6 @@ public interface WxMerchantService { | |||
| WxMerchant findAdmin(TenantEntity tenantEntity); | |||
| WxMerchant findBrandAdmin(TenantEntity tenantEntity, Long brandId); | |||
| Map<Long, WxMerchant> findMerchantMap(WxMerchant merchantQ); | |||
| } | |||
| @@ -34,6 +34,7 @@ import org.springframework.util.Assert; | |||
| import java.util.*; | |||
| import java.util.concurrent.TimeUnit; | |||
| import java.util.function.Function; | |||
| import java.util.stream.Collectors; | |||
| @Service | |||
| @@ -397,4 +398,14 @@ public class WxMallServiceImpl implements WxMallService { | |||
| return false; | |||
| } | |||
| @Override | |||
| public Map<String, WxMall> getMallMap(WxMall mallQ) { | |||
| Map<String,WxMall> mallMap = new HashMap<>(); | |||
| List<WxMall> list = this.findList(mallQ); | |||
| if(!list.isEmpty()){ | |||
| mallMap = list.stream().collect(Collectors.toMap(WxMall::getTenantId, Function.identity())); | |||
| } | |||
| return mallMap; | |||
| } | |||
| } | |||
| @@ -6,10 +6,7 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxMsgValidationcode; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxMerchantBuInfoVo; | |||
| import com.iformall.enums.EnumMerchantBUserStatus; | |||
| @@ -21,6 +18,7 @@ import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.mapper.WxMsgValidationcodeMapper; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -43,6 +41,9 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @@ -99,7 +100,7 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| } | |||
| @Override | |||
| public List<WxMerchantBUser> getBUserByAppId(WxMerchantBUser record) { | |||
| public List<WxMerchantBUser> findList(WxMerchantBUser record) { | |||
| return wxMerchantBUserMapper.findList(record); | |||
| } | |||
| @@ -148,9 +149,10 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| } | |||
| @Override | |||
| public ResultData updatePwd(String appId, String phone, String code, String pwd) { | |||
| public ResultData updatePwd(String tenantId, String phone, String code, String pwd) { | |||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||
| wxMsgValidationcode.setTenantId(tenantId); | |||
| wxMsgValidationcode.setPhone(phone); | |||
| wxMsgValidationcode.setCode(code); | |||
| List<WxMsgValidationcode> msgValidationCodeList = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | |||
| @@ -160,10 +162,10 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| if (msgValidationCodeList.size() > 0) { | |||
| //更新 | |||
| WxMerchantBUser bUser = new WxMerchantBUser(); | |||
| bUser.setAppId(appId); | |||
| bUser.setTenantId(tenantId); | |||
| bUser.setPhone(phone); | |||
| bUser.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | |||
| List<WxMerchantBUser> list = wxMerchantBUserMapper.findList(bUser); | |||
| List<WxMerchantBUser> list = this.findAllList(bUser); | |||
| if (list.size() > 0) { | |||
| for (WxMerchantBUser merchantBUser:list) { | |||
| merchantBUser.setUserPwd(pwd); | |||
| @@ -182,5 +184,49 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public List<WxMerchantBUser> findAllList(WxMerchantBUser userQ) { | |||
| if(StringUtils.isBlank(userQ.getTenantId())){ | |||
| return new ArrayList<>(); | |||
| } | |||
| List<WxMerchantBUser> list = this.findList(userQ); | |||
| if(wxMallService.isgroupSupport(userQ)){ | |||
| userQ.setTenantId(null); | |||
| userQ.setParentTenantId(userQ.getTenantId()); | |||
| List<WxMerchantBUser> list1 = wxMerchantBUserMapper.findList(userQ); | |||
| if(list1.size() > 0){ | |||
| list.addAll(list1); | |||
| } | |||
| } | |||
| return list; | |||
| } | |||
| @Override | |||
| public List<WxMerchantBuInfoVo> handMerchantBUser(List<WxMerchantBUser> orgList) { | |||
| List<String> tenantIds = orgList.stream().map(mb -> mb.getTenantId()).collect(Collectors.toList()); | |||
| WxMall mallQ = new WxMall(); | |||
| mallQ.setTenantIdList(tenantIds); | |||
| Map<String,WxMall> mallMap = wxMallService.getMallMap(mallQ); | |||
| List<Long> merchantIds = orgList.stream().map(mb -> mb.getMerchantId()).collect(Collectors.toList()); | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.setIds(merchantIds); | |||
| Map<Long,WxMerchant> merchantMap = wxMerchantService.findMerchantMap(merchantQ); | |||
| List<WxMerchantBuInfoVo> listvo = new ArrayList<>(); | |||
| for (WxMerchantBUser bUser:orgList) { | |||
| WxMerchantBuInfoVo mbvo = new WxMerchantBuInfoVo(); | |||
| WxMall wxMall = mallMap.get(mbvo.getTenantId()); | |||
| mbvo.updateTenantInfo(wxMall); | |||
| mbvo.setTenantName(wxMall.getName()); | |||
| mbvo.setMerchantId(mbvo.getMerchantId()); | |||
| WxMerchant merchant = merchantMap.get(mbvo.getMerchantId()); | |||
| mbvo.setMerchantName(merchant.getName()); | |||
| mbvo.setImgUrl(merchant.getImgUrl()); | |||
| mbvo.setBuUserId(bUser.getId()); | |||
| listvo.add(mbvo); | |||
| } | |||
| return listvo; | |||
| } | |||
| } | |||
| @@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.math.BigDecimal; | |||
| import java.util.*; | |||
| import java.util.function.Function; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| @@ -1911,4 +1912,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public Map<Long, WxMerchant> findMerchantMap(WxMerchant merchantQ) { | |||
| Map<Long,WxMerchant> merchantMap = new HashMap<>(); | |||
| List<WxMerchant> list = this.findList(merchantQ); | |||
| if(!list.isEmpty()){ | |||
| merchantMap = list.stream().collect(Collectors.toMap(WxMerchant::getId, Function.identity())); | |||
| } | |||
| return merchantMap; | |||
| } | |||
| } | |||