| @@ -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", | |||
| @@ -91,17 +91,8 @@ public class BaseController { | |||
| //该方法兼容微信登陆和非微信登陆 | |||
| 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() { | |||
| @@ -109,12 +100,6 @@ public class BaseController { | |||
| Long id = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); | |||
| return id; | |||
| } | |||
| public WxAppinfo getCurrentApp() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| WxAppinfo appInfo = (WxAppinfo) request.getAttribute(Constant.APP_INFO); | |||
| return appInfo; | |||
| } | |||
| public CUser getCUser() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| @@ -137,22 +122,22 @@ public class BaseController { | |||
| if(user == null){ | |||
| 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; | |||
| } | |||
| @@ -168,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()); | |||
| @@ -378,7 +378,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(getLoginBUser().getId()); | |||
| WxMerchantBUser wxMerchantBUser = getLoginBUser(); | |||
| if (wxMerchantBUser == null) { | |||
| logger.error("核销员ID不存在:" + getLoginBUser().getId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "核销员ID不存在或者无权限"); | |||
| @@ -2,6 +2,7 @@ package com.iformall.controller; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| @@ -156,11 +157,11 @@ public class WxInfoController extends BaseController { | |||
| cUser = cuserFactory.getBUserService(appPlat).handleLoginUser(cUser,null); | |||
| resultMap.put("token", cUser.getToken()); | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||
| request.setAttribute(Constant.TENANT_ID, buUser.getTenantId()); | |||
| if (StringUtils.isNotBlank(buUser.getParentTenantId())) { | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, buUser.getParentTenantId()); | |||
| } | |||
| // request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||
| // request.setAttribute(Constant.TENANT_ID, buUser.getTenantId()); | |||
| // if (StringUtils.isNotBlank(buUser.getParentTenantId())) { | |||
| // request.setAttribute(Constant.PARENT_TENANT_ID, buUser.getParentTenantId()); | |||
| // } | |||
| return new ResultData(resultMap); | |||
| } | |||
| @@ -427,6 +428,7 @@ public class WxInfoController extends BaseController { | |||
| * @param map | |||
| * @return | |||
| */ | |||
| @TenantIgnore | |||
| @PostMapping("/getUserInfo") | |||
| @ApiOperation(value = "授权后获取用户的昵称,unionId等信息", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||
| public ResultData getUserInfo(@RequestBody Map<String, String> map) { | |||
| @@ -446,7 +448,7 @@ public class WxInfoController extends BaseController { | |||
| CUser user = getCUser(); | |||
| if (user != null) { | |||
| WxAppinfo wxAppinfo = getAppInfo(user.getAppId()); | |||
| WxAppinfo wxAppinfo = getAppInfo(user.getAppId(),user.getTenantId()); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| @@ -468,6 +470,7 @@ public class WxInfoController extends BaseController { | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @PostMapping("/updateExtInfo") | |||
| @ApiOperation(value = "用户更新扩展信息(手机)", notes = "{\"systemInfo\":\"string\"}") | |||
| public ResultData updateExtInfo(@RequestBody Map<String, String> map) { | |||
| @@ -485,6 +488,7 @@ public class WxInfoController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @TenantIgnore | |||
| @PostMapping("/updateLBS") | |||
| @ApiOperation(value = "用户更新位置信息", notes = "{\"latitude\":\"string\",\"longitude\":\"string\"}") | |||
| public ResultData updateLBS(@RequestBody Map<String, String> map) { | |||
| @@ -504,6 +508,7 @@ public class WxInfoController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @TenantIgnore | |||
| @PostMapping("/updateScene") | |||
| @ApiOperation(value = "用户更新scene", notes = "{\"scene\":\"string\"}") | |||
| public ResultData updateScene(@RequestBody Map<String, String> map) { | |||
| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.annotation.RedisCache; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| @@ -122,6 +123,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| * @param map | |||
| * @return | |||
| */ | |||
| @TenantIgnore | |||
| @AuthIgnore | |||
| @PostMapping("/login") | |||
| @ApiOperation(value = "用户登录", notes = "{" + | |||
| @@ -162,7 +164,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| // 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) { | |||
| // 集团内只发现一个用户 | |||
| @@ -174,16 +176,16 @@ public class WxMerchantBUserController extends BaseController { | |||
| ResultData merchantStatus = checkMerchantStatus(orgUser); | |||
| if (merchantStatus != null) return merchantStatus; | |||
| try { | |||
| wxMerchantBUserService.saveOrUpdate(orgUser); | |||
| } catch (Exception e) { | |||
| logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + e.getMessage()); | |||
| } | |||
| // try { | |||
| // wxMerchantBUserService.saveOrUpdate(orgUser); | |||
| // } catch (Exception e) { | |||
| // logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); | |||
| // return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + 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()); | |||
| // request.setAttribute(Constant.LOGIN_B_USER_KEY, orgUser.getId()); | |||
| return new ResultData(resultMap); | |||
| } else { | |||
| return new ResultData(ErrorCode.PASSWORD_ERROR); | |||
| @@ -199,12 +201,12 @@ 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", true); | |||
| resultMap.put("bUserId", orgUser.getId()); | |||
| request.setAttribute(Constant.LOGIN_B_USER_KEY, orgUser.getId()); | |||
| resultMap.put("logined", false); | |||
| // resultMap.put("bUserId", orgUser.getId()); | |||
| // request.setAttribute(Constant.LOGIN_B_USER_KEY, orgUser.getId()); | |||
| return new ResultData(resultMap); | |||
| } else { | |||
| logger.error(ErrorCode.PASSWORD_ERROR.getMessage()); | |||
| @@ -220,6 +222,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @AuthIgnore | |||
| @PostMapping("/selectMerchant") | |||
| @ApiOperation(value = "选择商户", notes = "{" + | |||
| @@ -239,18 +242,18 @@ 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) { | |||
| ResultData merchantStatus = checkMerchantStatus(orgUser); | |||
| if (merchantStatus != null) return merchantStatus; | |||
| try { | |||
| wxMerchantBUserService.saveOrUpdate(orgUser); | |||
| } catch (Exception e) { | |||
| logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + e.getMessage()); | |||
| } | |||
| // try { | |||
| // wxMerchantBUserService.saveOrUpdate(orgUser); | |||
| // } catch (Exception e) { | |||
| // logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); | |||
| // return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + e.getMessage()); | |||
| // } | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| resultMap.put("bUserId", orgUser.getId()); | |||
| resultMap.put("logined", true); | |||
| @@ -285,6 +288,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| } | |||
| @TenantIgnore | |||
| @AuthIgnore | |||
| @ApiOperation(value = "修改密码,集团版会修改集团下同一手机号的密码", notes = "{\"appId\",\"string\", \"phone\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") | |||
| @PostMapping("/updatepwd") | |||
| @@ -297,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(), "手机号不能为空"); | |||
| } | |||
| @@ -306,7 +318,7 @@ public class WxMerchantBUserController extends BaseController { | |||
| if (StringUtils.isBlank(pwd)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | |||
| } | |||
| return wxMerchantBUserService.updatePwd(getTenantInfo(), phone, code, pwd); | |||
| return wxMerchantBUserService.updatePwd(wxAppinfo.getTenantId(), phone, code, pwd); | |||
| } | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.annotation.RedisCache; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| @@ -131,6 +132,7 @@ public class WxMerchantController extends BaseController { | |||
| return new ResultData(has); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("获取微信OpenId") | |||
| @GetMapping("/getOpenIdByPhone") | |||
| @ApiImplicitParam(name = "phone", value = "商户C端注册手机号", dataType = "String", paramType = "query", required = true) | |||
| @@ -145,7 +147,7 @@ public class WxMerchantController extends BaseController { | |||
| phone = wxMerchant.getLinkPhone(); | |||
| } | |||
| WxCUser cuUser = new WxCUser(); | |||
| cuUser.updateTenantInfo(getTenantInfo()); | |||
| cuUser.updateTenantInfo(buser); | |||
| cuUser.setPhone(phone); | |||
| try { | |||
| WxCUser mUser = cUserService.getByObject(cuUser); | |||
| @@ -1,7 +1,9 @@ | |||
| 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; | |||
| @@ -37,8 +39,7 @@ public class WxMsgValidationcodeController extends BaseController { | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @TenantIgnore | |||
| @GetMapping("sendvalidationcode") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), | |||
| @@ -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); | |||
| @@ -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; | |||
| @@ -75,55 +80,51 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| if(StringUtils.isBlank(mallTenantId)){ | |||
| mallTenantId = request.getParameter("mallTenantId"); | |||
| } | |||
| // 查询token信息 | |||
| WxMerchantBUser buser = null; | |||
| String tenantId = null; | |||
| String parenTenantId = null; | |||
| boolean isChildMall = false; | |||
| if (!StringUtils.isBlank(token)) { | |||
| if (StringUtils.isNotBlank(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.isNotBlank(mallTenantId) && (!mallTenantId.equals(user.getTenantId()))) { | |||
| tenantId = mallTenantId; | |||
| parenTenantId = user.getTenantId(); | |||
| isChildMall = true; | |||
| }else { | |||
| tenantId = user.getTenantId(); | |||
| parenTenantId = user.getParentTenantId(); | |||
| } | |||
| 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); | |||
| 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失效,请重新登录"); | |||
| } | |||
| 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(); | |||
| } | |||
| } | |||
| if(!tenantId.equals(buser.getTenantId()) | |||
| && !buser.getTenantId().equals(parenTenantId) | |||
| && !tenantId.equals(buser.getParentTenantId())){ | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_ERROR); | |||
| } | |||
| request.setAttribute(Constant.LOGIN_B_USER_KEY, buser.getId()); | |||
| request.setAttribute(Constant.TENANT_ID, tenantId); | |||
| if (StringUtils.isNotBlank(parenTenantId)) { | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, parenTenantId); | |||
| } | |||
| //如果是要不需要自动设置tenantI信息 | |||
| TenantIgnore tenantIgnoreAnnotation = null; | |||
| @@ -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; | |||
| } | |||
| @@ -61,6 +61,9 @@ import java.util.*; | |||
| public class WxOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallService mallService; | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| @@ -207,9 +210,10 @@ public class WxOrderController extends BaseController { | |||
| map.put("err_tips","透传字段格式不正确"); | |||
| return map; | |||
| } | |||
| WxMall mall = mallService.getByTenantId(tenantId); | |||
| //验证app | |||
| WxAppinfo appinfo = wxAppinfoService.getByAppIdFromRedis(app_id,tenantId); | |||
| //验证app todo 想想集团版多小程序和单小程序怎么处理 | |||
| WxAppinfo appinfo = wxAppinfoService.getByAppIdFromRedis(app_id,mall.getFinalTenantId()); | |||
| if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||
| map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | |||
| @@ -223,10 +227,10 @@ public class WxOrderController extends BaseController { | |||
| return map; | |||
| } | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.updateTenantInfo(appinfo); | |||
| tenantEntity.updateTenantInfo(mall); | |||
| //验证用户 | |||
| Long memberId = null; | |||
| TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, tenantEntity.getTenantId()); | |||
| TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, appinfo.getTenantId()); | |||
| if(cuser != null && cuser.getUserId() != null){ | |||
| memberId = cuser.getUserId(); | |||
| } | |||
| @@ -253,7 +257,7 @@ public class WxOrderController extends BaseController { | |||
| Map<String, Object> data = new HashMap<>(); | |||
| data.put("out_order_no",order.getMainOrderId().toString()); | |||
| data.put("pay_expire_seconds",14*60); | |||
| data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(order.getMainOrderId())); | |||
| data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(mall.getTenantId(),order.getMainOrderId())); | |||
| if(order.getExtParam() != null && !order.getExtParam().isEmpty()){ | |||
| data.put("order_goods_info",order.getExtParam()); | |||
| } | |||
| @@ -756,9 +760,10 @@ public class WxOrderController extends BaseController { | |||
| String app_id = msgObject.getString("app_id"); | |||
| String open_id = msgObject.getString("open_id"); | |||
| String cp_extra = msgObject.getString("cp_extra"); | |||
| String tenantId = getTenantId(cp_extra); | |||
| WxMall mall = mallService.getByTenantId(tenantId); | |||
| //验证app | |||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id,getTenantId(cp_extra)); | |||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); | |||
| if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||
| map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | |||
| @@ -772,10 +777,10 @@ public class WxOrderController extends BaseController { | |||
| return map; | |||
| } | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.updateTenantInfo(appinfo); | |||
| tenantEntity.updateTenantInfo(mall); | |||
| //验证用户 | |||
| Long memberId = null; | |||
| TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, tenantEntity.getTenantId()); | |||
| TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, appinfo.getTenantId()); | |||
| if(cuser != null && cuser.getUserId() != null){ | |||
| memberId = cuser.getUserId(); | |||
| } | |||
| @@ -794,7 +799,7 @@ public class WxOrderController extends BaseController { | |||
| WxRefundOrder refundOrder = (WxRefundOrder) resultData.data; | |||
| Map<String, Object> data = new HashMap<>(); | |||
| data.put("out_refund_no",refundOrder.getId().toString()); | |||
| data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(Long.parseLong(refundOrder.getPayOrderNo()))); | |||
| data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(mall.getTenantId(),Long.parseLong(refundOrder.getPayOrderNo()))); | |||
| map.put("data",data); | |||
| map.put("err_no",0); | |||
| map.put("err_tips",resultData.message); | |||
| @@ -244,8 +244,8 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); | |||
| // request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); | |||
| // request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| CUser cUser = new CUser(); | |||
| @@ -270,7 +270,7 @@ public class WxUserGrantController extends BaseController { | |||
| cUser = cuserFactory.getCUserService(appPlat).handleLoginUser(cUser,wxCUserFrom); | |||
| resultMap.put("token", cUser.getToken()); | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||
| // request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||
| return new ResultData(resultMap); | |||
| } | |||
| @@ -1,13 +1,16 @@ | |||
| package com.iformall.interceptor; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| 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 +29,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 +76,60 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| if(StringUtils.isBlank(mallTenantId)){ | |||
| mallTenantId = request.getParameter("mallTenantId"); | |||
| } | |||
| if(StringUtils.isBlank(mallTenantId)){ | |||
| try{ | |||
| String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | |||
| mallTenantId = JSONObject.parseObject(body).getString("mallTenantId"); | |||
| }catch(Exception e){} | |||
| } | |||
| String tenantId = null; | |||
| String parenTenantId = null; | |||
| //设置userId到request里,后续根据userId,获取用户信息 | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||
| if (StringUtils.isNotBlank(mallTenantId) && (!mallTenantId.equals(cUser.getTenantId()))) { | |||
| 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(!tenantId.equals(cUser.getTenantId()) | |||
| && !cUser.getTenantId().equals(parenTenantId) | |||
| && !tenantId.equals(cUser.getParentTenantId())){ | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_ERROR); | |||
| } | |||
| // 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); | |||
| 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()); | |||
| }else{ | |||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY, null); | |||
| } | |||
| 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", | |||
| @@ -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(TenantEntity tenantEntity, 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); | |||
| } | |||
| @@ -265,7 +265,7 @@ public interface WxOrderService { | |||
| WxBatchOrder getWxBatchOrder(TenantEntity tenantInfo, Long orderId); | |||
| Map<String,String> getOrderEntrySchema(Long mainOrderId); | |||
| Map<String,String> getOrderEntrySchema(String tenantId,Long mainOrderId); | |||
| int updateCpsStatus(WxOrder order); | |||
| @@ -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,9 +18,11 @@ 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; | |||
| import org.springframework.beans.BeanUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -43,6 +42,9 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @@ -99,7 +101,7 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| } | |||
| @Override | |||
| public List<WxMerchantBUser> getBUserByAppId(WxMerchantBUser record) { | |||
| public List<WxMerchantBUser> findList(WxMerchantBUser record) { | |||
| return wxMerchantBUserMapper.findList(record); | |||
| } | |||
| @@ -148,10 +150,10 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| } | |||
| @Override | |||
| public ResultData updatePwd(TenantEntity tenantEntity, String phone, String code, String pwd) { | |||
| public ResultData updatePwd(String tenantId, String phone, String code, String pwd) { | |||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||
| wxMsgValidationcode.setTenantId(tenantEntity.getTenantId()); | |||
| wxMsgValidationcode.setTenantId(tenantId); | |||
| wxMsgValidationcode.setPhone(phone); | |||
| wxMsgValidationcode.setCode(code); | |||
| List<WxMsgValidationcode> msgValidationCodeList = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | |||
| @@ -161,18 +163,10 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||
| if (msgValidationCodeList.size() > 0) { | |||
| //更新 | |||
| WxMerchantBUser bUser = new WxMerchantBUser(); | |||
| bUser.setTenantId(tenantEntity.getTenantId()); | |||
| bUser.setTenantId(tenantId); | |||
| bUser.setPhone(phone); | |||
| bUser.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | |||
| List<WxMerchantBUser> list = wxMerchantBUserMapper.findList(bUser); | |||
| if(wxMallService.isgroupSupport(tenantEntity)){ | |||
| bUser.setTenantId(null); | |||
| bUser.setParentTenantId(tenantEntity.getTenantId()); | |||
| List<WxMerchantBUser> list1 = wxMerchantBUserMapper.findList(bUser); | |||
| if(list1.size() > 0){ | |||
| list.addAll(list1); | |||
| } | |||
| } | |||
| List<WxMerchantBUser> list = this.findAllList(bUser); | |||
| if (list.size() > 0) { | |||
| for (WxMerchantBUser merchantBUser:list) { | |||
| merchantBUser.setUserPwd(pwd); | |||
| @@ -191,5 +185,51 @@ 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)){ | |||
| WxMerchantBUser userQ2 = new WxMerchantBUser(); | |||
| BeanUtils.copyProperties(userQ,userQ2); | |||
| userQ2.setTenantId(null); | |||
| userQ2.setParentTenantId(userQ.getTenantId()); | |||
| List<WxMerchantBUser> list1 = wxMerchantBUserMapper.findList(userQ2); | |||
| 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(bUser.getTenantId()); | |||
| mbvo.updateTenantInfo(wxMall); | |||
| mbvo.setTenantName(wxMall.getName()); | |||
| mbvo.setMerchantId(mbvo.getMerchantId()); | |||
| WxMerchant merchant = merchantMap.get(bUser.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; | |||
| } | |||
| } | |||
| @@ -3589,11 +3589,12 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| @Override | |||
| public Map<String,String> getOrderEntrySchema(Long mainOrderId) { | |||
| public Map<String,String> getOrderEntrySchema(String tenantId,Long mainOrderId) { | |||
| Map<String,String> map = new HashMap<>(); | |||
| map.put("path", Constant.mainPageUrl); | |||
| Map<String,Object> paramMap = new HashMap<>(); | |||
| paramMap.put("type","dt"); | |||
| paramMap.put("tenantId",tenantId); | |||
| paramMap.put("orderId",mainOrderId); | |||
| map.put("params", JSON.toJSONString(paramMap)); | |||
| return map; | |||
| @@ -155,7 +155,7 @@ | |||
| mbu.tenant_id, mbu.parent_tenant_id, m.name tenant_name, | |||
| mc.name merchant_name, mbu.id bu_user_id, mbu.merchant_id, mc.img_url | |||
| from wx_merchant_b_user mbu, wx_merchant mc, wx_mall m | |||
| <where> m.tenant_id = mbu.parent_tenant_id | |||
| <where> m.tenant_id = mbu.tenant_id | |||
| and mbu.merchant_id = mc.id and mc.status = 1 | |||
| <if test=" null != appId "> | |||
| and mbu.`app_id` = #{appId} | |||