winter 3 лет назад
Родитель
Сommit
b585b5c3b2
3 измененных файлов: 61 добавлений и 38 удалений
  1. +38
    -0
      mallinkBApi/src/main/java/com/iformall/controller/BaseController.java
  2. +5
    -0
      mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java
  3. +18
    -38
      mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java

+ 38
- 0
mallinkBApi/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -5,20 +5,26 @@ import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseCUserEntity;
import com.iformall.enums.EnumAppPlat;
import com.iformall.enums.EnumPayVersion;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.CUserTokenService;
import com.iformall.service.SysConfigService;
import com.iformall.utils.RedisCacheUtils;
import lombok.extern.slf4j.Slf4j;

import com.iformall.common.ErrorCode;
import com.iformall.common.SysConfigConstant;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxMerchantBUserService;
import com.iformall.service.WxPayAccountService;
import com.iformall.service.cuser.CUserServiceFactory;
import com.iformall.service.wechat.FmOpenService;
import com.iformall.utils.Constant;
import com.iformall.utils.IPUtil;
import com.iformall.utils.MaUtil;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
@@ -45,6 +51,12 @@ public class BaseController {
@Autowired
private WxPayAccountService wxPayAccountService;
@Autowired
private SysConfigService sysConfigService;
@Autowired
private CUserServiceFactory cuserFactory;
@Autowired
MaUtil maUtil;

@@ -172,4 +184,30 @@ public class BaseController {
String ipaddress = IPUtil.getIpAddr(request);
return ipaddress;
}
public 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) {
return;
}
if (StringUtils.isBlank(user.getPhone())) {
return;
}
SysConfig config = sysConfigService.getByKey(SysConfigConstant.merchant_Login_CheckPhone, orgUser);
if (null != config ) {
String v = config.getConfigItemValue();
if (!StringUtils.isBlank(v)) {
Integer iv = Integer.parseInt(v);
if (iv.intValue() == EnumYesOrNo.YES.getCode().intValue()) {
//校验当前登陆人的授权手机号和账号手机号是否一致
if (!user.getPhone().equals(orgUser.getPhone())) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前用户授权手机号非登录账号,不允许登录");
}
}
}
}
}
}

+ 5
- 0
mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java Просмотреть файл

@@ -162,6 +162,11 @@ public class WxInfoController extends BaseController {
// if (StringUtils.isNotBlank(buUser.getParentTenantId())) {
// request.setAttribute(Constant.PARENT_TENANT_ID, buUser.getParentTenantId());
// }
try {
checkLoginUserPhone(buUser, buUser.getId(),appPlat);
}catch(Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
return new ResultData(resultMap);

}


+ 18
- 38
mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java Просмотреть файл

@@ -67,12 +67,6 @@ public class WxMerchantBUserController extends BaseController {
@Autowired
private WxAppinfoService wxAppinfoService;
@Autowired
private SysConfigService sysConfigService;
@Autowired
private CUserServiceFactory cuserFactory;

@RedisCache
@ApiOperation("查寻当bUser详情接口")
@@ -194,11 +188,6 @@ public class WxMerchantBUserController extends BaseController {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("bUserId", orgUser.getId());
resultMap.put("logined", true);
try {
checkLoginUserPhone(orgUser, orgUser.getId(),appPlat);
}catch(Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
// request.setAttribute(Constant.LOGIN_B_USER_KEY, orgUser.getId());
return new ResultData(resultMap);
} else {
@@ -236,47 +225,26 @@ public class WxMerchantBUserController extends BaseController {
}
}
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) {
return;
}
if (StringUtils.isBlank(user.getPhone())) {
return;
}
SysConfig config = sysConfigService.getByKey(SysConfigConstant.merchant_Login_CheckPhone, orgUser);
if (null != config ) {
String v = config.getConfigItemValue();
if (!StringUtils.isBlank(v)) {
Integer iv = Integer.parseInt(v);
if (iv.intValue() == EnumYesOrNo.YES.getCode().intValue()) {
//校验当前登陆人的授权手机号和账号手机号是否一致
if (!user.getPhone().equals(orgUser.getPhone())) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前用户授权手机号非登录账号,不允许登录");
}
}
}
}
}

@TenantIgnore
@AuthIgnore
@PostMapping("/selectMerchant")
@ApiOperation(value = "选择商户", notes = "{" +
"\"appId\":\"string\"," +
"\"buUserId\":\"string\"," +
"\"merchantId\":\"string\"}")
public ResultData selectMerchant(@RequestBody Map<String, String> map) {
String buUserIdStr = map.get("buUserId");
String merchantIdStr = map.get("merchantId");
String appId = map.get("appId");
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不能为空");
}
if (StringUtils.isBlank(appId)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空");
}
WxMerchantBUser userQ = new WxMerchantBUser();
userQ.setId(Long.valueOf(buUserIdStr));
@@ -291,7 +259,19 @@ public class WxMerchantBUserController extends BaseController {
resultMap.put("bUserId", orgUser.getId());
resultMap.put("logined", true);
try {
checkLoginUserPhone(orgUser, orgUser.getId(),this.getCUser().getAppPlat());
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);
}
EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat());
if(appPlat == null){
return new ResultData(ErrorCode.APP_PLAT_ERROR);
}
checkLoginUserPhone(orgUser, orgUser.getId(),appPlat);
}catch(Exception e) {
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}


Загрузка…
Отмена
Сохранить