Browse Source

fix bug

release_toaliyun_real
winter 3 years ago
parent
commit
9cc394fe93
1 changed files with 29 additions and 20 deletions
  1. +29
    -20
      mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java

+ 29
- 20
mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java View File

@@ -10,6 +10,7 @@ import com.iformall.common.ResultData;
import com.iformall.common.SysConfigConstant;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.WxMerchantBuInfoVo;
import com.iformall.enums.EnumAppPlat;
import com.iformall.enums.EnumCreditLockedStatus;
import com.iformall.enums.EnumEnableType;
import com.iformall.enums.EnumMerchantBUserStatus;
@@ -17,6 +18,7 @@ import com.iformall.enums.EnumMerchantStatus;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.service.cuser.CUserServiceFactory;
import com.iformall.utils.Constant;
import com.iformall.utils.HashUtil;
import com.iformall.utils.IPUtil;
@@ -68,6 +70,9 @@ public class WxMerchantBUserController extends BaseController {
@Autowired
private SysConfigService sysConfigService;
@Autowired
private CUserServiceFactory cuserFactory;

@RedisCache
@ApiOperation("查寻当bUser详情接口")
@@ -135,7 +140,6 @@ public class WxMerchantBUserController extends BaseController {
@ApiOperation(value = "用户登录", notes = "{" +
"\"appId\":\"string\"," +
"\"phone\":\"string\",\"password\":\"string\"," +
"\"up\":\"string\","+
"\"latitude\":\"string\",\"longitude\":\"string\"}")
public ResultData userLogin(@RequestBody Map<String, String> map) {
logger.debug(map.toString());
@@ -145,8 +149,6 @@ public class WxMerchantBUserController extends BaseController {
String password = map.get("password");
String latitude = map.get("latitude");
String longitude = map.get("longitude");
//当前登陆人的授权手机号
String userPhone = map.get("up");
//登录凭证不能为空
if (StringUtils.isBlank(phone)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "手机号不能为空");
@@ -167,6 +169,11 @@ public class WxMerchantBUserController extends BaseController {
if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){
return new ResultData(ErrorCode.APP_ID_NOT_ENABLE);
}
EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat());
if(appPlat == null){
return new ResultData(ErrorCode.APP_PLAT_ERROR);
}

WxMerchantBUser userQ = new WxMerchantBUser();
userQ.updateTenantInfo(wxAppinfo);
@@ -184,16 +191,14 @@ public class WxMerchantBUserController extends BaseController {
// check merchant 状态
ResultData merchantStatus = checkMerchantStatus(orgUser);
if (merchantStatus != null) return merchantStatus;

Map<String, Object> resultMap = new HashMap<>();
resultMap.put("bUserId", orgUser.getId());
resultMap.put("logined", true);
try {
checkLoginUserPhone(orgUser, userPhone);
checkLoginUserPhone(orgUser, orgUser.getId(),appPlat);
}catch(Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("bUserId", orgUser.getId());
resultMap.put("logined", true);
// request.setAttribute(Constant.LOGIN_B_USER_KEY, orgUser.getId());
return new ResultData(resultMap);
} else {
@@ -231,10 +236,17 @@ public class WxMerchantBUserController extends BaseController {
}
}
private void checkLoginUserPhone(WxMerchantBUser orgUser,String userPhone) throws Exception {
if (StringUtils.isBlank(userPhone) || "undefined".equals(userPhone.toLowerCase())) {
private void checkLoginUserPhone(WxMerchantBUser orgUser,Long bUserId,EnumAppPlat appPlat) throws Exception {
if (null == bUserId) {
return;
}
CUser user = cuserFactory.getBUserService(appPlat).getById(bUserId, orgUser.getTenantId());
if (null == user) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前用户授权信息未查询到,请重新登录");
}
if (StringUtils.isBlank(user.getPhone())) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前用户未授权手机号,请重新登录并授权");
}
SysConfig config = sysConfigService.getByKey(SysConfigConstant.merchant_Login_CheckPhone, orgUser);
if (null != config ) {
String v = config.getConfigItemValue();
@@ -242,7 +254,7 @@ public class WxMerchantBUserController extends BaseController {
Integer iv = Integer.parseInt(v);
if (iv.intValue() == EnumYesOrNo.YES.getCode().intValue()) {
//校验当前登陆人的授权手机号和账号手机号是否一致
if (!userPhone.equals(orgUser.getPhone())) {
if (!user.getPhone().equals(orgUser.getPhone())) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前用户授权手机号非登录账号,不允许登录");
}
}
@@ -255,20 +267,17 @@ public class WxMerchantBUserController extends BaseController {
@PostMapping("/selectMerchant")
@ApiOperation(value = "选择商户", notes = "{" +
"\"buUserId\":\"string\"," +
"\"up\":\"string\","+
"\"merchantId\":\"string\"}")
public ResultData selectMerchant(@RequestBody Map<String, String> map) {
String buUserIdStr = map.get("buUserId");
String merchantIdStr = map.get("merchantId");
//当前登陆人的授权手机号
String userPhone = map.get("up");
if (StringUtils.isBlank(buUserIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "buUserId不能为空");
}
if (StringUtils.isBlank(merchantIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId不能为空");
}
WxMerchantBUser userQ = new WxMerchantBUser();
userQ.setId(Long.valueOf(buUserIdStr));
userQ.setMerchantId(Long.valueOf(merchantIdStr));
@@ -278,14 +287,14 @@ public class WxMerchantBUserController extends BaseController {
if (orgUser != null) {
ResultData merchantStatus = checkMerchantStatus(orgUser);
if (merchantStatus != null) return merchantStatus;
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("bUserId", orgUser.getId());
resultMap.put("logined", true);
try {
checkLoginUserPhone(orgUser, userPhone);
checkLoginUserPhone(orgUser, orgUser.getId(),this.getCUser().getAppPlat());
}catch(Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("bUserId", orgUser.getId());
resultMap.put("logined", true);
return new ResultData(resultMap);
} else {
logger.error("B端用户不存在");


Loading…
Cancel
Save