| @@ -66,6 +66,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "fengniao_map_config", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| @@ -78,6 +81,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_brand", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "wx_c_user_car", | |||
| "wx_c_user_from_b", | |||
| @@ -153,11 +153,9 @@ public class BaseController { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||
| String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); | |||
| boolean isChildMall = (boolean)request.getAttribute(Constant.IS_CHILD_MALL); | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.setTenantId(tenantId); | |||
| tenantEntity.setParentTenantId(parentTenantId); | |||
| tenantEntity.setChildMall(isChildMall); | |||
| return tenantEntity; | |||
| } | |||
| @@ -36,6 +36,8 @@ public class PosOrderController extends BaseController { | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute PosOrder posOrder, Integer pageNum, Integer pageSize) { | |||
| if (null == posOrder) posOrder = new PosOrder(); | |||
| WxMerchantBUser user = getLoginBUser(); | |||
| posOrder.updateTenantInfo(user); | |||
| final PageInfo<PosOrder> page = posOrderService.listAsPage(posOrder, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -72,7 +74,8 @@ public class PosOrderController extends BaseController { | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody PosOrder posOrder) { | |||
| posOrder.updateTenantInfo(getTenantInfo()); | |||
| WxMerchantBUser user = getLoginBUser(); | |||
| posOrder.updateTenantInfo(user); | |||
| posOrderService.saveOrUpdate(posOrder); | |||
| return new ResultData(); | |||
| } | |||
| @@ -89,7 +92,8 @@ public class PosOrderController extends BaseController { | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS, "查询成功", posOrderService.getById(id,getTenantInfo().getTenantId())); | |||
| WxMerchantBUser user = getLoginBUser(); | |||
| return new ResultData(Result.SUCCESS, "查询成功", posOrderService.getById(id,user.getTenantId())); | |||
| } | |||
| @@ -117,8 +117,7 @@ public class WxBillController extends BaseController { | |||
| if(!billFinishHasWorkFlow(wxBillAll)) { | |||
| return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"商户账单完结审批不存在工作流,不能提交审批。"); | |||
| } | |||
| WxMerchantBUser buser = this.getLoginBUser(); | |||
| WxMerchantBUser buser = getLoginBUser(); | |||
| Map<String,Object> billObject = wxBillAllService.detail(wxBillAll.getId(), wxBillAll.getBillTypeValue()); | |||
| @@ -6,11 +6,13 @@ import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.TenantThreadLocal; | |||
| import com.iformall.domain.po.WxBuser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.CUserTokenService; | |||
| import com.iformall.service.WxBuserTokenService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import com.iformall.utils.Constant; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -38,6 +40,9 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| @Autowired | |||
| private WxMerchantBUserService wxMerchantBUserService; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| AuthIgnore annotation; | |||
| @@ -71,10 +76,10 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| } | |||
| //集团版中针对某一商场的业务需要传递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; | |||
| @@ -144,11 +149,22 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| if (buser == null) { | |||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " bid失效,请重新登录"); | |||
| } | |||
| tenantId = buser.getTenantId(); | |||
| if(StringUtils.isNotBlank(mallTenantId)){ | |||
| tenantId = mallTenantId; | |||
| WxMall mall = wxMallService.getByTenantId(tenantId); | |||
| if(StringUtils.isNotBlank(mall.getParentTenantId())){ | |||
| parenTenantId = mall.getParentTenantId(); | |||
| } | |||
| }else{ | |||
| tenantId = buser.getTenantId(); | |||
| if (StringUtils.isNotBlank(buser.getParentTenantId())) { | |||
| parenTenantId = buser.getParentTenantId(); | |||
| } | |||
| } | |||
| 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.TENANT_ID, tenantId); | |||
| if (StringUtils.isNotBlank(parenTenantId)) { | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||
| } | |||
| @@ -55,6 +55,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "fengniao_map_config", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| }; | |||
| @@ -66,6 +69,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_brand", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| @@ -76,8 +82,6 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_c_user_from_b", | |||
| "wx_c_user_tags", | |||
| "wx_cuser_floating_layer", | |||
| "wx_buser", | |||
| "tt_buser", | |||
| "wx_floating_layer", | |||
| "wx_user_visit", | |||
| "wx_level_config", | |||
| @@ -113,11 +113,11 @@ public class BaseController { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||
| String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); | |||
| boolean isChildMall = (boolean)request.getAttribute(Constant.IS_CHILD_MALL); | |||
| // boolean isChildMall = (boolean)request.getAttribute(Constant.IS_CHILD_MALL); | |||
| TenantEntity tenantEntity = new TenantEntity() ; | |||
| tenantEntity.setTenantId(tenantId); | |||
| tenantEntity.setParentTenantId(parentTenantId); | |||
| tenantEntity.setChildMall(isChildMall); | |||
| // tenantEntity.setChildMall(isChildMall); | |||
| return tenantEntity; | |||
| } | |||
| @@ -188,13 +188,13 @@ public class BaseController { | |||
| if(user == null){ | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if (user.getTenantId() == null) { | |||
| user.setTenantId(tenantEntity.getTenantId()); | |||
| } | |||
| if (user.getParentTenantId() == null) { | |||
| user.setParentTenantId(tenantEntity.getParentTenantId()); | |||
| } | |||
| // TenantEntity tenantEntity = getTenantInfo(); | |||
| // if (user.getTenantId() == null) { | |||
| // user.setTenantId(tenantEntity.getTenantId()); | |||
| // } | |||
| // if (user.getParentTenantId() == null) { | |||
| // user.setParentTenantId(tenantEntity.getParentTenantId()); | |||
| // } | |||
| return user; | |||
| } | |||
| @@ -5,9 +5,11 @@ import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.TenantThreadLocal; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.CUserTokenService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.utils.Constant; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -26,9 +28,13 @@ import javax.servlet.http.HttpServletResponse; | |||
| */ | |||
| @Component | |||
| public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| @Autowired | |||
| private CUserTokenService cUserTokenService; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| @@ -69,25 +75,48 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| if(StringUtils.isBlank(mallTenantId)){ | |||
| mallTenantId = request.getParameter("mallTenantId"); | |||
| } | |||
| String tenantId = null; | |||
| String parenTenantId = null; | |||
| //设置userId到request里,后续根据userId,获取用户信息 | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||
| if (StringUtils.isNotBlank(mallTenantId)) { | |||
| request.setAttribute(Constant.TENANT_ID, mallTenantId); | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getTenantId()); | |||
| request.setAttribute(Constant.IS_CHILD_MALL,true); | |||
| }else { | |||
| request.setAttribute(Constant.TENANT_ID, cUser.getTenantId()); | |||
| if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getParentTenantId()); | |||
| if(StringUtils.isNotBlank(mallTenantId)){ | |||
| tenantId = mallTenantId; | |||
| WxMall mall = wxMallService.getByTenantId(tenantId); | |||
| if(StringUtils.isNotBlank(mall.getParentTenantId())){ | |||
| parenTenantId = mall.getParentTenantId(); | |||
| } | |||
| }else{ | |||
| tenantId = cUser.getTenantId(); | |||
| if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||
| parenTenantId = cUser.getParentTenantId(); | |||
| } | |||
| request.setAttribute(Constant.IS_CHILD_MALL,false); | |||
| } | |||
| // if (StringUtils.isNotBlank(mallTenantId)) { | |||
| // request.setAttribute(Constant.TENANT_ID, mallTenantId); | |||
| // request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getTenantId()); | |||
| // request.setAttribute(Constant.IS_CHILD_MALL,true); | |||
| // }else { | |||
| // request.setAttribute(Constant.TENANT_ID, cUser.getTenantId()); | |||
| // if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||
| // request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getParentTenantId()); | |||
| // } | |||
| // request.setAttribute(Constant.IS_CHILD_MALL,false); | |||
| // } | |||
| request.setAttribute(Constant.TENANT_ID, tenantId); | |||
| if(StringUtils.isNotBlank(parenTenantId)){ | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||
| } | |||
| request.setAttribute(Constant.REQUEST_C_USER_KEY, cUser); | |||
| request.setAttribute(Constant.APP_INFO,cUser.getAppinfo()); | |||
| if(cUser.basicInfoIs()){ | |||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId()); | |||
| } | |||
| request.setAttribute(Constant.APP_INFO,cUser.getAppinfo()); | |||
| //如果是要不需要自动设置tenantI信息 | |||
| TenantIgnore tenantIgnoreAnnotation = null; | |||
| @@ -60,6 +60,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "fengniao_map_config", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| }; | |||
| @@ -71,6 +74,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_brand", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||
| @@ -60,6 +60,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "fengniao_map_config", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| }; | |||
| @@ -71,6 +74,9 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_brand", | |||
| "wx_c_user", | |||
| "tt_c_user", | |||
| "tt_buser", | |||
| "wx_buser", | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "wx_c_user_basic_info", | |||
| "user_basic_info_address", | |||