| @@ -91,17 +91,8 @@ public class BaseController { | |||||
| //该方法兼容微信登陆和非微信登陆 | //该方法兼容微信登陆和非微信登陆 | ||||
| public WxMerchantBUser getLoginBUser() { | public WxMerchantBUser getLoginBUser() { | ||||
| Long wxBuserId = getWxBuserId(); | |||||
| if (null != wxBuserId) { | |||||
| CUser buser = getCUser(); | |||||
| Long userId = buser.getUserId(); | |||||
| WxMerchantBUser user = getWxMerchantBUser(userId); | |||||
| user.setBuserId(buser.getId()); | |||||
| return user; | |||||
| }else { | |||||
| Long userId = getMerchantBUserId(); | |||||
| return getWxMerchantBUser(userId); | |||||
| } | |||||
| Long userId = getMerchantBUserId(); | |||||
| return getWxMerchantBUser(userId); | |||||
| } | } | ||||
| public Long getWxBuserId() { | public Long getWxBuserId() { | ||||
| @@ -109,12 +100,6 @@ public class BaseController { | |||||
| Long id = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); | Long id = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); | ||||
| return id; | return id; | ||||
| } | } | ||||
| public WxAppinfo getCurrentApp() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| WxAppinfo appInfo = (WxAppinfo) request.getAttribute(Constant.APP_INFO); | |||||
| return appInfo; | |||||
| } | |||||
| public CUser getCUser() { | public CUser getCUser() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| @@ -137,22 +122,22 @@ public class BaseController { | |||||
| if(user == null){ | if(user == null){ | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if (tenantEntity.isChildMall()) { | |||||
| if (user.getTenantId() == null) { | |||||
| user.setTenantId(tenantEntity.getParentTenantId()); | |||||
| } | |||||
| if (user.getParentTenantId() == null) { | |||||
| user.setParentTenantId(null); | |||||
| } | |||||
| }else { | |||||
| if (user.getTenantId() == null) { | |||||
| user.setTenantId(tenantEntity.getTenantId()); | |||||
| } | |||||
| if (user.getParentTenantId() == null) { | |||||
| user.setParentTenantId(tenantEntity.getParentTenantId()); | |||||
| } | |||||
| } | |||||
| // TenantEntity tenantEntity = getTenantInfo(); | |||||
| // if (tenantEntity.isChildMall()) { | |||||
| // if (user.getTenantId() == null) { | |||||
| // user.setTenantId(tenantEntity.getParentTenantId()); | |||||
| // } | |||||
| // if (user.getParentTenantId() == null) { | |||||
| // user.setParentTenantId(null); | |||||
| // } | |||||
| // }else { | |||||
| // if (user.getTenantId() == null) { | |||||
| // user.setTenantId(tenantEntity.getTenantId()); | |||||
| // } | |||||
| // if (user.getParentTenantId() == null) { | |||||
| // user.setParentTenantId(tenantEntity.getParentTenantId()); | |||||
| // } | |||||
| // } | |||||
| return user; | return user; | ||||
| } | } | ||||
| @@ -378,7 +378,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | ||||
| } | } | ||||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(getLoginBUser().getId()); | |||||
| WxMerchantBUser wxMerchantBUser = getLoginBUser(); | |||||
| if (wxMerchantBUser == null) { | if (wxMerchantBUser == null) { | ||||
| logger.error("核销员ID不存在:" + getLoginBUser().getId()); | logger.error("核销员ID不存在:" + getLoginBUser().getId()); | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "核销员ID不存在或者无权限"); | throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "核销员ID不存在或者无权限"); | ||||
| @@ -428,6 +428,7 @@ public class WxInfoController extends BaseController { | |||||
| * @param map | * @param map | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| @TenantIgnore | |||||
| @PostMapping("/getUserInfo") | @PostMapping("/getUserInfo") | ||||
| @ApiOperation(value = "授权后获取用户的昵称,unionId等信息", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | @ApiOperation(value = "授权后获取用户的昵称,unionId等信息", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | ||||
| public ResultData getUserInfo(@RequestBody Map<String, String> map) { | public ResultData getUserInfo(@RequestBody Map<String, String> map) { | ||||
| @@ -447,7 +448,7 @@ public class WxInfoController extends BaseController { | |||||
| CUser user = getCUser(); | CUser user = getCUser(); | ||||
| if (user != null) { | if (user != null) { | ||||
| WxAppinfo wxAppinfo = getAppInfo(user.getAppId()); | |||||
| WxAppinfo wxAppinfo = getAppInfo(user.getAppId(),user.getTenantId()); | |||||
| if(wxAppinfo == null){ | if(wxAppinfo == null){ | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -469,6 +470,7 @@ public class WxInfoController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @PostMapping("/updateExtInfo") | @PostMapping("/updateExtInfo") | ||||
| @ApiOperation(value = "用户更新扩展信息(手机)", notes = "{\"systemInfo\":\"string\"}") | @ApiOperation(value = "用户更新扩展信息(手机)", notes = "{\"systemInfo\":\"string\"}") | ||||
| public ResultData updateExtInfo(@RequestBody Map<String, String> map) { | public ResultData updateExtInfo(@RequestBody Map<String, String> map) { | ||||
| @@ -486,6 +488,7 @@ public class WxInfoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @PostMapping("/updateLBS") | @PostMapping("/updateLBS") | ||||
| @ApiOperation(value = "用户更新位置信息", notes = "{\"latitude\":\"string\",\"longitude\":\"string\"}") | @ApiOperation(value = "用户更新位置信息", notes = "{\"latitude\":\"string\",\"longitude\":\"string\"}") | ||||
| public ResultData updateLBS(@RequestBody Map<String, String> map) { | public ResultData updateLBS(@RequestBody Map<String, String> map) { | ||||
| @@ -505,6 +508,7 @@ public class WxInfoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @PostMapping("/updateScene") | @PostMapping("/updateScene") | ||||
| @ApiOperation(value = "用户更新scene", notes = "{\"scene\":\"string\"}") | @ApiOperation(value = "用户更新scene", notes = "{\"scene\":\"string\"}") | ||||
| public ResultData updateScene(@RequestBody Map<String, String> map) { | public ResultData updateScene(@RequestBody Map<String, String> map) { | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.annotation.RedisCache; | import com.iformall.annotation.RedisCache; | ||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| @@ -131,6 +132,7 @@ public class WxMerchantController extends BaseController { | |||||
| return new ResultData(has); | return new ResultData(has); | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @ApiOperation("获取微信OpenId") | @ApiOperation("获取微信OpenId") | ||||
| @GetMapping("/getOpenIdByPhone") | @GetMapping("/getOpenIdByPhone") | ||||
| @ApiImplicitParam(name = "phone", value = "商户C端注册手机号", dataType = "String", paramType = "query", required = true) | @ApiImplicitParam(name = "phone", value = "商户C端注册手机号", dataType = "String", paramType = "query", required = true) | ||||
| @@ -145,7 +147,7 @@ public class WxMerchantController extends BaseController { | |||||
| phone = wxMerchant.getLinkPhone(); | phone = wxMerchant.getLinkPhone(); | ||||
| } | } | ||||
| WxCUser cuUser = new WxCUser(); | WxCUser cuUser = new WxCUser(); | ||||
| cuUser.updateTenantInfo(getTenantInfo()); | |||||
| cuUser.updateTenantInfo(buser); | |||||
| cuUser.setPhone(phone); | cuUser.setPhone(phone); | ||||
| try { | try { | ||||
| WxCUser mUser = cUserService.getByObject(cuUser); | WxCUser mUser = cUserService.getByObject(cuUser); | ||||
| @@ -71,59 +71,86 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| } | } | ||||
| //集团版中针对某一商场的业务需要传递mallTenantId | //集团版中针对某一商场的业务需要传递mallTenantId | ||||
| String mallTenantId = request.getHeader("mallTenantId"); | |||||
| if(StringUtils.isBlank(mallTenantId)){ | |||||
| mallTenantId = request.getParameter("mallTenantId"); | |||||
| } | |||||
| // String mallTenantId = request.getHeader("mallTenantId"); | |||||
| // if(StringUtils.isBlank(mallTenantId)){ | |||||
| // mallTenantId = request.getParameter("mallTenantId"); | |||||
| // } | |||||
| // | |||||
| // String tenantId = null; | |||||
| // String parenTenantId = null; | |||||
| // boolean isChildMall = false; | |||||
| // if (!StringUtils.isBlank(token)) { | |||||
| // BaseCUserEntity user = cUserTokenService.getBByToken(token); | |||||
| // if (user == null || user.getExpireTime().getTime() < System.currentTimeMillis()) { | |||||
| // throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | |||||
| // } | |||||
| // if (StringUtils.isBlank(mallTenantId)) { | |||||
| // tenantId = user.getTenantId(); | |||||
| // parenTenantId = user.getParentTenantId(); | |||||
| // }else { | |||||
| // tenantId = mallTenantId; | |||||
| // parenTenantId = user.getTenantId(); | |||||
| // isChildMall = true; | |||||
| // } | |||||
| // request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); | |||||
| // request.setAttribute(Constant.TENANT_ID, tenantId); | |||||
| // request.setAttribute(Constant.REQUEST_C_USER_KEY, user); | |||||
| // request.setAttribute(Constant.APP_INFO, user.getAppinfo()); | |||||
| // request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); | |||||
| // if (StringUtils.isNotBlank(parenTenantId)) { | |||||
| // request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||||
| // } | |||||
| // | |||||
| // }else if (!StringUtils.isBlank(bid)) { | |||||
| // WxMerchantBUser buser = wxMerchantBUserService.getById(Long.parseLong(bid)); | |||||
| // if (buser == null) { | |||||
| // throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); | |||||
| // } | |||||
| // | |||||
| // if (StringUtils.isBlank(mallTenantId)) { | |||||
| // tenantId = buser.getTenantId(); | |||||
| // parenTenantId = buser.getParentTenantId(); | |||||
| // }else { | |||||
| // tenantId = mallTenantId; | |||||
| // parenTenantId = buser.getTenantId(); | |||||
| // isChildMall = true; | |||||
| // } | |||||
| // request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); | |||||
| // request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); | |||||
| // request.setAttribute(Constant.TENANT_ID, tenantId); | |||||
| // if (StringUtils.isNotBlank(parenTenantId)) { | |||||
| // request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||||
| // } | |||||
| // } | |||||
| // 查询token信息 | // 查询token信息 | ||||
| WxMerchantBUser buser = null; | |||||
| String tenantId = null; | String tenantId = null; | ||||
| String parenTenantId = null; | String parenTenantId = null; | ||||
| boolean isChildMall = false; | |||||
| if (!StringUtils.isBlank(token)) { | |||||
| if (StringUtils.isNotBlank(token)) { | |||||
| BaseCUserEntity user = cUserTokenService.getBByToken(token); | BaseCUserEntity user = cUserTokenService.getBByToken(token); | ||||
| if (user == null || user.getExpireTime().getTime() < System.currentTimeMillis()) { | if (user == null || user.getExpireTime().getTime() < System.currentTimeMillis()) { | ||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | ||||
| } | } | ||||
| if (StringUtils.isBlank(mallTenantId)) { | |||||
| tenantId = user.getTenantId(); | |||||
| parenTenantId = user.getParentTenantId(); | |||||
| }else { | |||||
| tenantId = mallTenantId; | |||||
| parenTenantId = user.getTenantId(); | |||||
| isChildMall = true; | |||||
| } | |||||
| request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); | request.setAttribute(Constant.LOGIN_USER_KEY, user.getId()); | ||||
| request.setAttribute(Constant.TENANT_ID, tenantId); | |||||
| request.setAttribute(Constant.REQUEST_C_USER_KEY, user); | request.setAttribute(Constant.REQUEST_C_USER_KEY, user); | ||||
| request.setAttribute(Constant.APP_INFO, user.getAppinfo()); | |||||
| request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); | |||||
| if (StringUtils.isNotBlank(parenTenantId)) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||||
| if(user.getUserId() != null){ | |||||
| buser = wxMerchantBUserService.getById(user.getUserId()); | |||||
| } | } | ||||
| }else if (!StringUtils.isBlank(bid)) { | |||||
| WxMerchantBUser buser = wxMerchantBUserService.getById(Long.parseLong(bid)); | |||||
| if (buser == null) { | |||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); | |||||
| } | |||||
| if (StringUtils.isBlank(mallTenantId)) { | |||||
| tenantId = buser.getTenantId(); | |||||
| parenTenantId = buser.getParentTenantId(); | |||||
| }else { | |||||
| tenantId = mallTenantId; | |||||
| parenTenantId = buser.getTenantId(); | |||||
| isChildMall = true; | |||||
| } | |||||
| request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); | |||||
| request.setAttribute(Constant.IS_CHILD_MALL,isChildMall); | |||||
| request.setAttribute(Constant.TENANT_ID, tenantId); | |||||
| if (StringUtils.isNotBlank(parenTenantId)) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||||
| } | |||||
| }else if (StringUtils.isNotBlank(bid)) { | |||||
| buser = wxMerchantBUserService.getById(Long.parseLong(bid)); | |||||
| } | } | ||||
| if (buser == null) { | |||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); | |||||
| } | |||||
| tenantId = buser.getTenantId(); | |||||
| request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); | |||||
| request.setAttribute(Constant.TENANT_ID, buser.getTenantId()); | |||||
| if (StringUtils.isNotBlank(buser.getParentTenantId())) { | |||||
| parenTenantId = buser.getParentTenantId(); | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||||
| } | |||||
| //如果是要不需要自动设置tenantI信息 | //如果是要不需要自动设置tenantI信息 | ||||
| TenantIgnore tenantIgnoreAnnotation = null; | TenantIgnore tenantIgnoreAnnotation = null; | ||||