diff --git a/mallinkAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java b/mallinkAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java index c3e9acb90..2eccb410b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java +++ b/mallinkAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java @@ -19,6 +19,7 @@ public class MyBatisConfiguration { MultiTenancy multiTenancy = new MultiTenancy(); Properties properties = new Properties(); properties.setProperty("tenantIdColumn", "tenant_id"); + properties.setProperty("subTenantIdColumn", "sub_tenant_id"); properties.setProperty("dialect", "mysql"); properties.setProperty("tenantInfo", "com.iformall.tenant.TenantInfoImpl"); multiTenancy.setProperties(properties); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java index 032d699dd..8b9c8065e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java @@ -66,9 +66,11 @@ public class BaseController { public TenantEntity getTenantInfo(){ Session session = SecurityUtils.getSubject().getSession(); String tenantId = (String)session.getAttribute(UserSession.tenantId); + String subTenantId = (String)session.getAttribute(UserSession.subTenantId); TenantEntity tenantEntity = new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; return tenantEntity; } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMallController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMallController.java index fad44da89..51d4ae920 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMallController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMallController.java @@ -33,7 +33,7 @@ public class WxMallController extends BaseController { @SystemControllerLog(description = "商城-查询") public ResultData mallinfoExt() { logger.debug("[" + getIpAddr() + "] WxMallController::mallinfoExt"); - return new ResultData(wxMallService.getByTenantIdExt(getTenantId())); + return new ResultData(wxMallService.getByTenantInfoExt(getTenantInfo())); } @ApiOperation("查询当前mall的信息") @@ -41,7 +41,7 @@ public class WxMallController extends BaseController { @SystemControllerLog(description = "商城-当前查询") public ResultData mallinfo() { logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); - return new ResultData(wxMallService.getByTenantId(getTenantId())); + return new ResultData(wxMallService.getByTenantInfo(getTenantInfo())); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantBUserController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantBUserController.java index 4424a8eeb..bf6af813f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantBUserController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantBUserController.java @@ -22,7 +22,7 @@ public class WxMerchantBUserController extends BaseController { @ApiOperation("手机号是否存在") @GetMapping("/hasphone") @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) - public ResultData hasphone(String phone) { + public ResultData hasPhone(String phone) { logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::hasphone"); boolean has = wxMerchantBUserService.hasPhone(getTenantInfo(), phone); return new ResultData(Result.SUCCESS, "查询成功", has); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java index 0b66d7daf..d46553f77 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java @@ -14,7 +14,7 @@ import com.iformall.domain.vo.WxMerchantTradeVo; import com.iformall.domain.vo.WxMerchantVo; import com.iformall.service.QrCodeService; import com.iformall.service.WxMerchantService; -import com.iformall.service.WxScoreRulesService; +import com.iformall.utils.Constant; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -40,8 +40,6 @@ public class WxMerchantController extends BaseController { private WxMerchantService wxMerchantService; @Autowired private QrCodeService qrCodeService; - @Autowired - private WxScoreRulesService wxScoreRulesService; @UserDataRuleAnnotation("merchant_list") @ApiOperation("分页列表接口") @@ -124,12 +122,11 @@ public class WxMerchantController extends BaseController { public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) { logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant"); wxMerchant.updateTenantInfo(getTenantInfo()); - ResultData resultData = wxMerchantService.addMerchant(wxMerchant, getUserId()); if(resultData.code == 200){ //加载二维码图片 - String pageUrl = "pages/index/index"; + String pageUrl = Constant.mainPageUrl; String param = "t:md:"+resultData.data; ResultData resultQrCode = qrCodeService.uploadQrcode(wxMerchant,1,pageUrl,param,0,"","","店铺详情"); Map map = (Map)resultQrCode.data; diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantShopController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantShopController.java index 115701683..49a23b3f6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantShopController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantShopController.java @@ -32,6 +32,7 @@ public class WxMerchantShopController extends BaseController { public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxMerchantShopController::queryShopList"); if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); + wxMerchantShop.updateTenantInfo(getTenantInfo()); final PageInfo page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); return new ResultData(page); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java b/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java index a65d2ea41..b0809670d 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/car/WxCarController.java @@ -226,7 +226,7 @@ public class WxCarController extends BaseController { } } // check End - coupon.updateTenantInfo(getTenantInfo()); + coupon.updateTenantInfo(tenantEntity); ResultData resultData = wxCouponService.saveOrUpdate(coupon); if (resultData.code != ResultData.SUCCESS){ diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index 3f65a59c9..e7fdd8c24 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -35,6 +35,8 @@ import java.util.Map; @RestController @RequestMapping("wxPropertyContract") public class WxPropertyContractController extends BaseController { + private Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired private WxPropertyContractService wxPropertyContractService; @Autowired @@ -44,8 +46,6 @@ public class WxPropertyContractController extends BaseController { @Autowired private WxRentPropertyContractService wxRentPropertyContractService; - private Logger logger = LoggerFactory.getLogger(WxPropertyContractController.class); - @UserDataRuleAnnotation("property_contract_list") @GetMapping("/list") @ApiImplicitParams({ @@ -186,6 +186,7 @@ public class WxPropertyContractController extends BaseController { @SystemControllerLog(description = "物业合同-终止合同") public ResultData endContract(@RequestBody WxPropertyContract wxPropertyContract) { logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); + wxPropertyContract.updateTenantInfo(getTenantInfo()); wxPropertyContractService.endContract(wxPropertyContract); return new ResultData(); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index b892b92f5..901b10e9e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -173,23 +173,23 @@ public class WxRentContractController extends BaseController { @PostMapping("update") @SystemControllerLog(description = "租赁合同-更新") - public ResultData update(@RequestBody WxRentContract wxRentContract) { + public ResultData update(@RequestBody WxRentContract rentContract) { logger.debug("[" + getIpAddr() + "] WxRentContractController::update"); - if(StringUtils.isBlank(wxRentContract.getBusDiscountRatio())){ - wxRentContract.setBusDiscountTime(new Integer(0)); + if(StringUtils.isBlank(rentContract.getBusDiscountRatio())){ + rentContract.setBusDiscountTime(new Integer(0)); } MallUserInfo user = getUser(); - wxRentContract.updateTenantInfo(user); - wxRentContract.setAdjustPeriodHandle(); - wxRentContract.setRentPriceHandle(); - Date oldDate = wxRentContract.getRentalStartDate(); - if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ - wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); + rentContract.updateTenantInfo(user); + rentContract.setAdjustPeriodHandle(); + rentContract.setRentPriceHandle(); + Date oldDate = rentContract.getRentalStartDate(); + if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ + rentContract.setRentalStartDate(rentContract.getStartDate()); } ResultData update = null; try { - update = wxRentContractService.update(wxRentContract, user.getId(), user.getName(), EnumFromType.OTHER.getCode(), oldDate); + update = wxRentContractService.update(rentContract, user.getId(), user.getName(), EnumFromType.OTHER.getCode(), oldDate); } catch (MallinkException e) { return new ResultData(ErrorCode.SYS_SERVER_ERROR); } @@ -387,6 +387,7 @@ public class WxRentContractController extends BaseController { @SystemControllerLog(description = "租赁合同-终止合同") public ResultData endContract(@RequestBody WxRentContract wxRentContract) { logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); + wxRentContract.updateTenantInfo(getTenantInfo()); wxRentContractService.endContract(wxRentContract); return new ResultData(); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxChartDataController.java b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxChartDataController.java index 3af40399f..b378737be 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxChartDataController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxChartDataController.java @@ -3,6 +3,7 @@ package com.iformall.controller.datatower; import com.iformall.annotation.SystemControllerLog; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.service.WxChartDataService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -11,10 +12,7 @@ import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.Map; @@ -72,7 +70,9 @@ public class WxChartDataController extends BaseController { public ResultData queryData(@RequestParam Map params) { String chart = params.get("chart"); logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart); - params.put("tenantId",super.getTenantId()); + TenantEntity tenantEntity = getTenantInfo(); + params.put("tenantId",tenantEntity.getTenantId()); + params.put("subTenantId", tenantEntity.getSubTenantId()); ResultData data = wxChartDataService.queryData(params); logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart + " end"); return data; diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java index 68e2ac5d4..cea346286 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxMerchantTradeDailyController.java @@ -57,6 +57,7 @@ public class WxMerchantTradeDailyController extends BaseController { @SystemControllerLog(description = "商户解单-数据汇总") public ResultData summary(@ModelAttribute WxMerchantTradeDaily wxMerchantTradeDaily) { logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::summary"); + wxMerchantTradeDaily.updateTenantInfo(getTenantInfo()); return wxMerchantTradeDailyService.summary(wxMerchantTradeDaily); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxUserStructureController.java b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxUserStructureController.java index 7eadb5302..92d280a6e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxUserStructureController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/datatower/WxUserStructureController.java @@ -294,12 +294,12 @@ public class WxUserStructureController extends BaseController { public ResultData findUserCount(Date startTime, Date endTime, Integer reportType) { logger.debug("[" + getIpAddr() + "] WxUserStructureController::findUserCount"); - + TenantEntity tenantEntity = getTenantInfo(); //昨日同比 Map map = new HashMap<>(); WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); - dto.updateTenantInfo(getTenantInfo()); + dto.updateTenantInfo(tenantEntity); dto.setEndTime(new Date()); //微信用户数据 long wxTotalCount = wxCUserService.findCount(dto);//总量 @@ -352,7 +352,7 @@ public class WxUserStructureController extends BaseController { reportType = EnumUserCountReportType.DAY.getCode(); } - dto.updateTenantInfo(getTenantInfo()); + dto.updateTenantInfo(tenantEntity); dto.setStartTime(startTime); dto.setEndTime(endTime); dto.setReportType(reportType); @@ -424,7 +424,7 @@ public class WxUserStructureController extends BaseController { && wxCountList.get(0).getTotalCount() != null && wxCountList.get(0).getTotalCount() == 0) { WxCUserBasicInfoDto pdto = new WxCUserBasicInfoDto(); - pdto.updateTenantInfo(getTenantInfo()); + pdto.updateTenantInfo(tenantEntity); pdto.setEndTime(startTime); wxCountList.get(0).setTotalCount(wxCUserService.findCount(pdto)); } @@ -440,7 +440,7 @@ public class WxUserStructureController extends BaseController { && memCountList.get(0).getTotalCount() != null && memCountList.get(0).getTotalCount() == 0) { WxCUserBasicInfoDto pdto = new WxCUserBasicInfoDto(); - pdto.updateTenantInfo(getTenantInfo()); + pdto.updateTenantInfo(tenantEntity); pdto.setEndTime(startTime); memCountList.get(0).setTotalCount(wxCUserBasicInfoService.findCount(pdto)); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/device/KwMeterController.java b/mallinkAdmin/src/main/java/com/iformall/controller/device/KwMeterController.java index 0f6d2dd9a..4515788ba 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/device/KwMeterController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/device/KwMeterController.java @@ -149,14 +149,14 @@ public class KwMeterController extends BaseController { } - private KwBox addOrBind(KwBox kwBox) { + private KwBox addOrBind(KwBox kwBox, TenantEntity tenantEntity) { KwBox record = new KwBox(); record.setImei(kwBox.getImei()); record.setStatus(EnumBoxStatus.VALID.getCode()); List list = kwBoxService.findList(record); if (list.size() > 0) return list.get(0); - kwBox.updateTenantInfo(getTenantInfo()); + kwBox.updateTenantInfo(tenantEntity); kwBox.setStatus(EnumBoxStatus.VALID.getCode()); kwBoxService.saveOrUpdate(kwBox); return kwBox; @@ -177,9 +177,9 @@ public class KwMeterController extends BaseController { kwMerchantMeterService.saveOrUpdate(kwMerchantMeter); } - private void addOrUpdate(KwMeter kwMeter) { + private void addOrUpdate(KwMeter kwMeter, TenantEntity tenantEntity) { KwMeter record = new KwMeter(); - record.updateTenantInfo(getTenantInfo()); + record.updateTenantInfo(tenantEntity); record.setAddress(kwMeter.getAddress()); record.setStatus(EnumMeterStatus.VALID.getCode()); List kwMeters = kwMeterService.findList(record); @@ -196,6 +196,8 @@ public class KwMeterController extends BaseController { return new ResultData(ErrorCode.EXCEL_IMPORT_ERROR); } + TenantEntity tenantEntity = getTenantInfo(); + try { XSSFWorkbook workbook = new XSSFWorkbook(mFile.getInputStream()); XSSFSheet sheet = workbook.getSheetAt(0); @@ -234,7 +236,7 @@ public class KwMeterController extends BaseController { String imei = c.getStringCellValue(); KwBox kwBox = new KwBox(); kwBox.setImei(imei); - kwBox = addOrBind(kwBox); + kwBox = addOrBind(kwBox, tenantEntity); kwMeter.setBindStatus(EnumMeterBindStatus.BIND.getCode()); kwMeter.setBoxId(kwBox.getId()); } else { @@ -243,7 +245,7 @@ public class KwMeterController extends BaseController { } kwMeter.setStatus(EnumMeterStatus.VALID.getCode()); kwMeter.setOnlineStatus(EnumMeterOnlineStatus.OFFLINE.getCode()); - addOrUpdate(kwMeter); + addOrUpdate(kwMeter, tenantEntity); c = row.getCell(7,Row.MissingCellPolicy.RETURN_BLANK_AS_NULL); if (c != null && c.getCellType() == CellType.STRING ) { diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/device/WxScreenAdController.java b/mallinkAdmin/src/main/java/com/iformall/controller/device/WxScreenAdController.java index a7ed5ce27..7d5f5bad9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/device/WxScreenAdController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/device/WxScreenAdController.java @@ -44,8 +44,8 @@ public class WxScreenAdController extends BaseController { @SystemControllerLog(description = "广告屏-广告列表") public Result list(@ModelAttribute WxScreenAd wxScreenAd, Integer pageNum, Integer pageSize) { if (wxScreenAd == null) wxScreenAd = new WxScreenAd(); - wxScreenAd.updateTenantInfo(getTenantInfo()); wxScreenAd.setStatus(EnumScreenAdStatus.VALID.getCode()); + wxScreenAd.updateTenantInfo(getTenantInfo()); return new ResultData(wxScreenAdService.listAsPage(wxScreenAd,pageNum,pageSize)); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java index 95f409ad0..6e4ff467b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java @@ -17,6 +17,7 @@ import com.iformall.service.QrCodeService; import com.iformall.service.WxCouponChannelService; import com.iformall.service.WxCouponService; import com.iformall.service.WxFlowService; +import com.iformall.utils.Constant; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -80,7 +81,7 @@ public class WxCouponChannelController extends BaseController { WxCouponChannel couponChannel = (WxCouponChannel)resultData.data; //生成二维码 if(couponChannel!=null){ - String pageUrl = "pages/index/index"; + String pageUrl = Constant.mainPageUrl; String param = couponChannel.getWeappScene(); ResultData resultDataQ = qrCodeService.uploadQrcode(couponChannel,1,pageUrl,param,0,"","","券"); Map map = (Map)resultDataQ.data; diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java index e43687707..3a59ba99b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java @@ -52,8 +52,8 @@ public class WxFloatingLayerController extends BaseController { @SystemControllerLog(description = "新增") public ResultData add(@RequestBody WxFloatingLayer wxFloatingLayer) { logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::add"); - wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_THROW_IN.getCode()); wxFloatingLayer.updateTenantInfo(getTenantInfo()); + wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_THROW_IN.getCode()); try { return wxFloatingLayerService.saveOrUpdate(wxFloatingLayer); } catch (MallinkException e) { diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxQuestionController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxQuestionController.java index c3847e5bc..b8d94ddd0 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxQuestionController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxQuestionController.java @@ -36,9 +36,9 @@ public class WxQuestionController extends BaseController { public Result getQuestionConfig() { logger.debug("[" + getIpAddr() + "] WxQuestionController::getQuestionConfig"); WxQuestionConfig wxQuestionConfig = new WxQuestionConfig(); - WxQuestion wxQuestion = new WxQuestion(); wxQuestionConfig.updateTenantInfo(getTenantInfo()); - wxQuestion.updateTenantInfo(getTenantInfo()); + WxQuestion wxQuestion = new WxQuestion(); + wxQuestion.updateTenantInfo(wxQuestionConfig); List list = wxQuestionService.findConfigList(wxQuestionConfig); if (list.size() > 0) { diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java index fafbcf6d6..b47c44fa4 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java @@ -175,17 +175,18 @@ public class WxCUserBasicInfoController extends BaseController { @SystemControllerLog(description = "会员管理-更新") public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::update"); + TenantEntity tenantEntity = getTenantInfo(); WxCUserBasicInfo oldInfo = wxCUserBasicInfoService.getById(wxCUserBasicInfo.getId()); if (!oldInfo.getPhone().equals(wxCUserBasicInfo.getPhone())) { - if (checkUniquePhone(wxCUserBasicInfo.getPhone(), getTenantInfo()) > 0) { + if (checkUniquePhone(wxCUserBasicInfo.getPhone(), tenantEntity) > 0) { return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(), "手机号已存在"); } } - wxCUserBasicInfo.updateTenantInfo(getTenantInfo()); + wxCUserBasicInfo.updateTenantInfo(tenantEntity); if (StringUtils.isNotBlank(wxCUserBasicInfo.getTagIds())) { WxCUserTags record = new WxCUserTags(); record.setUserId(oldInfo.getId()); - record.updateTenantInfo(getTenantInfo()); + record.updateTenantInfo(tenantEntity); PageInfo page = wxCUserTagsService.listAsPage(record, 1, 1); if (page.getSize() > 0) { WxCUserTags t = page.getList().get(0); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java index 6bfecb2a6..204f578d1 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java @@ -19,6 +19,7 @@ import com.iformall.mapper.WxCUserBasicInfoMapper; import com.iformall.service.WxCUserBasicInfoService; import com.iformall.utils.DataUtil; import com.iformall.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -58,8 +59,9 @@ public class WxCUserDataController extends BaseController { @SystemControllerLog(description = "会员首页-报表数据-查询用户数量接口") public ResultData findUserCountData() { logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserCountData"); + TenantEntity tenantEntity = getTenantInfo(); WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); - dto.updateTenantInfo(getTenantInfo()); + dto.updateTenantInfo(tenantEntity); long allCount = wxCUserService.findCount(dto);//总数 Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); @@ -139,7 +141,7 @@ public class WxCUserDataController extends BaseController { //Date startDate = DateUtils.getDateFromString(startdate + " 00:00:00","yyyy-MM-dd HH:mm:ss").getTime(); //Date endDate = DateUtils.getDateFromString(systemTime + " 23:59:59","yyyy-MM-dd HH:mm:ss").getTime(); WxCUserBasicInfoDto wxCUserBasicInfoDto = new WxCUserBasicInfoDto(); - wxCUserBasicInfoDto.updateTenantInfo(getTenantInfo()); + wxCUserBasicInfoDto.updateTenantInfo(tenantEntity); wxCUserBasicInfoDto.setStartTime(null); wxCUserBasicInfoDto.setEndTime(null); map.put("growCount", wxCUserBasicInfoService.findGrowUserCount(wxCUserBasicInfoDto)); @@ -155,6 +157,7 @@ public class WxCUserDataController extends BaseController { @SystemControllerLog(description = "会员首页-报表数据-查询用户活跃量") public ResultData findUserVisitData() { logger.debug("[" + getIpAddr() + "] WxCUserDataController::findUserVisitData"); + TenantEntity tenantEntity = getTenantInfo(); HashMap params = new HashMap<>(); Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -1); @@ -166,9 +169,12 @@ public class WxCUserDataController extends BaseController { Date startTime = c.getTime(); params.put("startTime", startTime); params.put("endTime", endTime); - params.put("tenantId", getTenantId()); + params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } MarkingCouponDataReportDto markingCouponDataReportDto = new MarkingCouponDataReportDto(); - markingCouponDataReportDto.updateTenantInfo(getTenantInfo()); + markingCouponDataReportDto.updateTenantInfo(tenantEntity); markingCouponDataReportDto.setStartTime(startTime); markingCouponDataReportDto.setEndTime(endTime); List list = wxUserVisitService.touchUsersReportList(markingCouponDataReportDto); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java index e7ff6b36b..fa9276ee6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java @@ -28,11 +28,11 @@ import java.util.Objects; @RestController @RequestMapping("wxCreditHistory") public class WxCreditHistoryController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired private WxCreditHistoryService wxCreditHistoryService; - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - @ApiOperation("分页列表接口") @GetMapping("list") @ApiImplicitParams({ @@ -42,6 +42,7 @@ public class WxCreditHistoryController extends BaseController { public ResultData list(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::list"); if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory(); + wxCreditHistory.updateTenantInfo(getTenantInfo()); final PageInfo page = wxCreditHistoryService.listAsPageMore(wxCreditHistory, pageNum, pageSize); return new ResultData(page); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java index 80c98bb6c..a39c40bad 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java @@ -57,7 +57,7 @@ public class WxScoreRulesController extends BaseController { @ApiOperation("更新积分开关状态") @PostMapping("updateCreditLocked") @SystemControllerLog(description = "更新积分开关状态") - public ResultData 更新积分开关状态(@RequestBody WxScoreRules wxScoreRules) { + public ResultData updateCreditLocked(@RequestBody WxScoreRules wxScoreRules) { logger.debug("[" + getIpAddr() + "] WxScoreRulesController::updateCreditLocked"); if (null == wxScoreRules.getId()) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgController.java b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgController.java index 953983694..82eac5e0f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgController.java @@ -6,6 +6,7 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.msg.WxMsg; import com.iformall.service.WxMsgService; import io.swagger.annotations.ApiImplicitParam; diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java index 9ebc89d08..8a9ee6640 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java @@ -81,7 +81,7 @@ public class WxMsgModelController extends BaseController { @ApiOperation("获取所有数据") @GetMapping("getmodellist") @SystemControllerLog(description = "短信模板-获取所有数据") - public ResultData getmodellist() { + public ResultData getModelList() { logger.debug("[" + getIpAddr() + "] WxMsgModelController::getmodellist"); return wxMsgModelService.getModelList(getTenantInfo()); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java index a63a75db7..07c812f20 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java @@ -82,8 +82,8 @@ public class WxMsgSignatureController extends BaseController { @ApiOperation("获取所有数据") @GetMapping("getsignaturelist") @SystemControllerLog(description = "消息签名-获取所有") - public ResultData getmodellist() { - logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::getmodellist"); + public ResultData getsignaturelist() { + logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::getsignaturelist"); return wxMsgSignatureService.getSignatureList(getTenantInfo()); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeController.java b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeController.java index 3fbb7571c..ab0f4b92b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeController.java @@ -74,14 +74,16 @@ public class WxMsgValidationcodeController extends BaseController { @GetMapping("sendvalidationcode") @ApiImplicitParams({ @ApiImplicitParam(name = "tenantId", value = "租户ID", dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "subTenantId", value = "子租户ID", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) - public ResultData sendvalidationcode(String tenantId, String phone, Integer type, String appid) { + public ResultData sendvalidationcode(String tenantId, String subTenantId, String phone, Integer type, String appid) { logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::sendvalidationcode"); WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); wxMsgValidationcode.updateTenantInfo(new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}); wxMsgValidationcode.setPhone(phone); wxMsgValidationcode.setType(type); @@ -92,15 +94,17 @@ public class WxMsgValidationcodeController extends BaseController { @GetMapping("hasvalidationcode") @ApiImplicitParams({ @ApiImplicitParam(name = "tenantId", value = "租户ID", dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "subTenantId", value = "子租户ID", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "code", value = "验证码", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) - public ResultData hasvalidationcode(String tenantId, String phone, Integer type, String code, String appid) { + public ResultData hasvalidationcode(String tenantId, String subTenantId, String phone, Integer type, String code, String appid) { logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeController::hasvalidationcode"); WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); wxMsgValidationcode.updateTenantInfo(new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}); wxMsgValidationcode.setPhone(phone); wxMsgValidationcode.setType(type); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillAllController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillAllController.java index 224987237..098a3d205 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillAllController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillAllController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.iformall.annotation.SystemControllerLog; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; +import com.iformall.domain.po.WxPayAccountBill; import com.iformall.domain.vo.WxBillAll; import com.iformall.domain.vo.WxBillExcelTemplate; import com.iformall.service.WxBillAllService; @@ -53,6 +54,8 @@ public class WxBillAllController extends BaseController { @SystemControllerLog(description = "账单总览-列表") public ResultData list(@ModelAttribute WxBillAll wxBillAll, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxBillAllController::list"); + wxBillAll.updateTenantInfo(getTenantInfo()); + WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxBillAll); if (null == wxBillAll) { wxBillAll = new WxBillAll(); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDailyController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDailyController.java index a177d36df..92ba22cad 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDailyController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillDailyController.java @@ -85,6 +85,7 @@ public class WxBillDailyController extends BaseController { public ResultData update(@RequestBody WxBillDaily wxBillDaily) { logger.debug("[" + getIpAddr() + "] WxBillDailyController::update"); MallUserInfo user = getUser(); + wxBillDaily.updateTenantInfo(user); wxBillDaily.setUserId(user.getId()); return wxBillDailyService.saveOrUpdate(wxBillDaily, user); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherController.java index 6b78b4066..5b5626559 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherController.java @@ -60,6 +60,7 @@ public class WxBillOtherController extends BaseController { public ResultData update(@RequestBody WxBillOther wxBillOther) { logger.debug("[" + getIpAddr() + "] WxBillOtherController::update"); MallUserInfo user = getUser(); + wxBillOther.updateTenantInfo(user); wxBillOther.setUserId(user.getId()); return wxBillOtherService.saveOrUpdate(wxBillOther, user); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherDepositController.java b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherDepositController.java index 3ef056a00..827b880ea 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherDepositController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillOtherDepositController.java @@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.Map; /** * @author gongbiao @@ -60,6 +59,7 @@ public class WxBillOtherDepositController extends BaseController { public ResultData update(@RequestBody WxBillOtherDeposit wxBillOtherDeposit) { logger.debug("[" + getIpAddr() + "] WxBillOtherDepositController::update"); MallUserInfo user = getUser(); + wxBillOtherDeposit.updateTenantInfo(user); wxBillOtherDeposit.setUserId(user.getId()); return wxBillOtherDepositService.saveOrUpdate(wxBillOtherDeposit, user); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/sys/HomeController.java b/mallinkAdmin/src/main/java/com/iformall/controller/sys/HomeController.java index 45a38d8cc..3b50a6e08 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/sys/HomeController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/sys/HomeController.java @@ -158,6 +158,14 @@ public class HomeController extends BaseController { logger.error("mall未启用"); return new ResultData(Result.ERROR, "mall未启用"); } + Map map = new HashMap(); + if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && + StringUtils.isBlank(info.getSubTenantId())) { + // 集团用户获取子商场 + List mallList = mallService.getSubByParentTenantId(info.getTenantId()); + map.put("subMalls", JSON.toJSONString(mallList)); + map.put("group", EnumGroupSupport.SUPPORT.getCode()); + } try { String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); @@ -166,7 +174,6 @@ public class HomeController extends BaseController { unameCookie.setMaxAge(3600); response.addCookie(unameCookie); - Map map = new HashMap(); map.put("username", info.getUsername()); map.put("withWechat", info.getWithWechat()); data.data = map; @@ -185,6 +192,31 @@ public class HomeController extends BaseController { return isInMobile; } + @PostMapping("/selectMall") + @ApiOperation(value = "用户选中子广场及父广场", notes = "{\"tenantId\":\"string\",\"subTenantId\":\"string\"}") + public ResultData selectMall(@RequestBody Map map) { + logger.debug(map.toString()); + + String tenantId = map.get("tenantId"); + String subTenantId = map.get("subTenantId"); + + if (StringUtils.isBlank(tenantId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "tenantId不能为空"); + } + + MallUserInfo userInfo = getUser(); + if (userInfo.getTenantId().equalsIgnoreCase(tenantId)) { + Session session = SecurityUtils.getSubject().getSession(); + session.setAttribute(UserSession.tenantId, tenantId); + if (StringUtils.isNotBlank(subTenantId)) { + session.setAttribute(UserSession.subTenantId, subTenantId); + } else { + session.setAttribute(UserSession.subTenantId, null); + } + } + return new ResultData(); + } + @ApiOperation("B端登录") @PostMapping("/bHidLogin") public ResultData bLogin(@RequestBody MallUserInfo user, HttpServletResponse response) { @@ -255,6 +287,12 @@ public class HomeController extends BaseController { logger.error("mall未启用"); return new ResultData(Result.ERROR, "mall未启用"); } + Map map = new HashMap(); + if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { + List mallList = mallService.getSubByParentTenantId(mall.getTenantId()); + map.put("subMalls", JSON.toJSONString(mallList)); + map.put("group", EnumGroupSupport.SUPPORT.getCode()); + } try { String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); Cookie unameCookie = new Cookie("uname", cookieName); @@ -262,7 +300,6 @@ public class HomeController extends BaseController { unameCookie.setMaxAge(3600); response.addCookie(unameCookie); - Map map = new HashMap(); map.put("username", info.getUsername()); map.put("withWechat", info.getWithWechat()); data.data = map; @@ -355,6 +392,12 @@ public class HomeController extends BaseController { logger.error("mall未启用"); return new ResultData(Result.ERROR, "mall未启用"); } + Map map = new HashMap(); + if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { + List mallList = mallService.getSubByParentTenantId(mall.getTenantId()); + map.put("subMalls", JSON.toJSONString(mallList)); + map.put("group", EnumGroupSupport.SUPPORT.getCode()); + } String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); Cookie unameCookie = new Cookie("uname", cookieName); @@ -362,7 +405,6 @@ public class HomeController extends BaseController { unameCookie.setMaxAge(3600); response.addCookie(unameCookie); - Map map = new HashMap(); map.put("username", info.getUsername()); map.put("withWechat", info.getWithWechat()); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java b/mallinkAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java index 78e355a54..070389634 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java @@ -58,7 +58,7 @@ public class SysMenuController extends BaseController { logger.debug("[" + getIpAddr() + "] MallPermissionController::nav"); MallUserInfo user = getUser(); List menuList = mallPermissionService.getUserMenuList(user, 0L, true); - Set permissions = mallUserInfoService.getUserPermissions(user); + Set permissions = mallUserInfoService.getUserPermissions(user, true); Map map = new HashMap<>(); map.put("menuList", menuList); map.put("permissions", permissions); @@ -72,8 +72,14 @@ public class SysMenuController extends BaseController { public ResultData getList() { logger.debug("[" + getIpAddr() + "] MallPermissionController::list"); MallUserInfo user = getUser(); + if (user.checkGroupAdmin()) { + TenantEntity tenantEntity = getTenantInfo(); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + user.setSubTenantId(tenantEntity.getSubTenantId()); + } + } List menuList = mallPermissionService.getUserMenuList(user, 0L, false); - Set permissions = mallUserInfoService.getUserPermissions(user); + Set permissions = mallUserInfoService.getUserPermissions(user, false); Map map = new HashMap<>(); map.put("menuList", menuList); map.put("permissions", permissions); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/sys/UploadController.java b/mallinkAdmin/src/main/java/com/iformall/controller/sys/UploadController.java index 99470f4fc..d61a455e6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/sys/UploadController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/sys/UploadController.java @@ -38,7 +38,11 @@ public class UploadController extends BaseController { private QrCodeService qrCodeService; private String getFileName(TenantEntity tenantEntity, String fileName) { - fileName = tenantEntity.getTenantId() + "/" + fileName; + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + fileName = tenantEntity.getTenantId() + "/" + fileName; + } else { + fileName = tenantEntity.getTenantId() + "/" + tenantEntity.getSubTenantId() + "/" +fileName; + } return fileName; } @@ -71,7 +75,7 @@ public class UploadController extends BaseController { } System.out.println(fileName); - ResultData data = qrCodeService.awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantInfo()); + ResultData data = qrCodeService.awsUpload(multiReq.getInputStream(), metadata, fileName, tenantEntity); return data; } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/sys/WechatLoginController.java b/mallinkAdmin/src/main/java/com/iformall/controller/sys/WechatLoginController.java index 6d67cd177..7415f67d7 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/sys/WechatLoginController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/sys/WechatLoginController.java @@ -8,12 +8,15 @@ import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.MallUserAction; import com.iformall.domain.po.MallUserInfo; +import com.iformall.domain.po.WxMall; import com.iformall.domain.vo.MallUserInfoVo; +import com.iformall.enums.EnumGroupSupport; import com.iformall.enums.EnumMallUserAction; import com.iformall.enums.EnumUserAdmin; import com.iformall.service.MallUserActionService; import com.iformall.service.MallUserInfoService; import com.iformall.service.MallUserRoleService; +import com.iformall.service.WxMallService; import com.iformall.shiro.UserSession; import com.iformall.shiro.UseriFormallToken; import com.iformall.utils.TOTP; @@ -69,6 +72,9 @@ public class WechatLoginController extends BaseController { @Autowired private MallUserActionService mallUserActionService; + @Autowired + private WxMallService mallService; + @Autowired @Qualifier("openRedisTemplate") RedisTemplate openRedisTemplate; @@ -149,6 +155,35 @@ public class WechatLoginController extends BaseController { if(menus != null) { info.setMenus(menus); } + WxMall mall = mallService.getByTenantInfo(info); + if (mall == null) { + ret.put("code", Result.ERROR); + ret.put("message", "未配置相应的mall"); + log.info("用户登录失败-4,返回登录"); + try { + String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); + response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); + } catch (Exception e) { + log.error(e.getMessage()); + } + } + if (!mall.isValid()) { + ret.put("code", Result.ERROR); + ret.put("message", "mall未启用"); + log.info("用户登录失败-5,返回登录"); + try { + String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); + response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); + } catch (Exception e) { + log.error(e.getMessage()); + } + } + Map map = new HashMap(); + if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { + List mallList = mallService.getSubByParentTenantId(mall.getTenantId()); + map.put("subMalls", JSON.toJSONString(mallList)); + map.put("group", EnumGroupSupport.SUPPORT.getCode()); + } try { String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); Cookie unameCookie = new Cookie("uname", cookieName); @@ -284,6 +319,36 @@ public class WechatLoginController extends BaseController { if(menus != null) { info.setMenus(menus); } + Map ret = new HashMap<>(); + WxMall mall = mallService.getByTenantInfo(info); + if (mall == null) { + ret.put("code", Result.ERROR); + ret.put("message", "未配置相应的mall"); + log.info("用户登录失败-4,返回登录"); + try { + String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); + response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); + } catch (Exception e) { + log.error(e.getMessage()); + } + } + if (!mall.isValid()) { + ret.put("code", Result.ERROR); + ret.put("message", "mall未启用"); + log.info("用户登录失败-5,返回登录"); + try { + String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); + response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); + } catch (Exception e) { + log.error(e.getMessage()); + } + } + Map map = new HashMap(); + if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { + List mallList = mallService.getSubByParentTenantId(mall.getTenantId()); + map.put("subMalls", JSON.toJSONString(mallList)); + map.put("group", EnumGroupSupport.SUPPORT.getCode()); + } // 登录cookie String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); Cookie unameCookie = new Cookie("uname", cookieName); @@ -380,6 +445,9 @@ public class WechatLoginController extends BaseController { if(StringUtils.isBlank(userInfo.getTenantId())) { userInfo.setTenantId(user.getTenantId()); } + if(StringUtils.isBlank(userInfo.getSubTenantId())) { + userInfo.setSubTenantId(user.getSubTenantId()); + } if(userInfo.getId() == null && userInfo.getUsername() == null) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } diff --git a/mallinkAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java b/mallinkAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java index 862f472ca..960205ead 100644 --- a/mallinkAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java +++ b/mallinkAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java @@ -5,6 +5,7 @@ import javax.annotation.Resource; import com.iformall.common.ErrorCode; import com.iformall.enums.EnumMallUserStatus; import com.iformall.service.MallUserInfoService; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.*; import org.apache.shiro.authz.AuthorizationInfo; @@ -30,7 +31,7 @@ public class MyShiroRealm extends AuthorizingRealm { @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal(); - Set permissionSet = userService.getUserPermissions(user); + Set permissionSet = userService.getUserPermissions(user, true); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setStringPermissions(permissionSet); return info; @@ -65,6 +66,9 @@ public class MyShiroRealm extends AuthorizingRealm { session.setAttribute(UserSession.userInfo, user); session.setAttribute(UserSession.userId, user.getId()); session.setAttribute(UserSession.tenantId, user.getTenantId()); + if (StringUtils.isNotBlank(user.getSubTenantId())) { + session.setAttribute(UserSession.subTenantId, user.getSubTenantId()); + } return authenticationInfo; } diff --git a/mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java b/mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java index 02a7aca87..aba5865b0 100644 --- a/mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java +++ b/mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java @@ -8,4 +8,6 @@ public class UserSession { public static String tenantId ="TENANT_ID"; + public static String subTenantId ="SUB_TENANT_ID"; + } diff --git a/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java b/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java index 0df1360ac..dd89b2128 100644 --- a/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java +++ b/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java @@ -22,8 +22,22 @@ public class TenantInfoImpl implements TenantInfo { return tenantId; } + @Override + public String getSubTenantId() { + String subTenantId = null; + try { + subTenantId = (String) SecurityUtils.getSubject().getSession().getAttribute(UserSession.subTenantId); + } catch (InvalidSessionException e) { + logger.error("InvalidSession: " + e.getMessage()); + } + return subTenantId; + } + @Override public boolean doTableFilter(String tableName) { + if ("wx_mall".equals(tableName)) { + return true; + } if ("mall_permission".equals(tableName)) { return true; } @@ -78,8 +92,69 @@ public class TenantInfoImpl implements TenantInfo { if ("wx_data_rule_target".equals(tableName)) { return true; } + if ("wx_logic_permission".equals(tableName)) { + return true; + } + return false; + } - if ("wx_logic_permission".equals(tableName)) { + @Override + public boolean doTableFilterSub(String tableName) { + if ("wx_mall".equals(tableName)) { + return true; + } + if ("wx_appinfo".equals(tableName)) { + return true; + } + if ("wx_authorizer_info".equals(tableName)) { + return true; + } + if ("wx_c_user".equals(tableName)) { + return true; + } + if ("wx_c_user_basic_info".equals(tableName)) { + return true; + } + if ("wx_c_user_car".equals(tableName)) { + return true; + } + if ("wx_c_user_from_b".equals(tableName)) { + return true; + } + if ("wx_c_user_tags".equals(tableName)) { + return true; + } + if ("wx_question".equals(tableName)) { + return true; + } + if ("wx_question_config".equals(tableName)) { + return true; + } + if ("wx_question_log".equals(tableName)) { + return true; + } + if ("wx_user_visit".equals(tableName)) { + return true; + } + if ("wx_level_config".equals(tableName)) { + return true; + } + if ("wx_score_rules".equals(tableName)) { + return true; + } + if ("view_coupon_data".equals(tableName)) { + return true; + } + if ("view_touch_user".equals(tableName)) { + return true; + } + if ("wx_weapp_audit_status".equals(tableName)) { + return true; + } + if ("wx_weapp_code_status".equals(tableName)) { + return true; + } + if ("wx_weapp_release_status".equals(tableName)) { return true; } return false; diff --git a/mallinkAdmin/src/main/java/com/iformall/ueditor/upload/Uploader.java b/mallinkAdmin/src/main/java/com/iformall/ueditor/upload/Uploader.java index dcb6d548d..29f20cc32 100644 --- a/mallinkAdmin/src/main/java/com/iformall/ueditor/upload/Uploader.java +++ b/mallinkAdmin/src/main/java/com/iformall/ueditor/upload/Uploader.java @@ -42,7 +42,11 @@ public class Uploader { private AmazonS3 s3 = null; private String getFileName(TenantEntity tenantEntity, String fileName) { - fileName = tenantEntity.getTenantId() + "/" + fileName; + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + fileName = tenantEntity.getTenantId() + "/" + fileName; + } else { + fileName = tenantEntity.getTenantId() + "/" + tenantEntity.getSubTenantId() + "/" + fileName; + } return fileName; } @@ -77,9 +81,11 @@ public class Uploader { MultipartFile multiReq= ((MultipartHttpServletRequest) this.request).getFile("upfile"); Session session = SecurityUtils.getSubject().getSession(); String tenantId = (String)session.getAttribute(UserSession.tenantId); + String subTenantId = (String)session.getAttribute(UserSession.subTenantId); TenantEntity tenantEntity = new TenantEntity(){{ - setTenantId(tenantId); - }}; + setTenantId(tenantId); + setSubTenantId(subTenantId); + }}; if (StringUtils.isBlank(tenantId)) { logger.error("TENANT is null"); } diff --git a/mallinkBApi/src/main/java/com/iformall/config/MyBatisConfiguration.java b/mallinkBApi/src/main/java/com/iformall/config/MyBatisConfiguration.java index 66ec7d418..512e838e5 100644 --- a/mallinkBApi/src/main/java/com/iformall/config/MyBatisConfiguration.java +++ b/mallinkBApi/src/main/java/com/iformall/config/MyBatisConfiguration.java @@ -14,6 +14,7 @@ public class MyBatisConfiguration { MultiTenancy multiTenancy = new MultiTenancy(); Properties properties = new Properties(); properties.setProperty("tenantIdColumn", "tenant_id"); + properties.setProperty("subTenantIdColumn", "sub_tenant_id"); properties.setProperty("dialect", "mysql"); properties.setProperty("tenantInfo", "com.iformall.tenant.TenantInfoImpl"); multiTenancy.setProperties(properties); diff --git a/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java b/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java index 97f813619..a6088c059 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/BaseController.java @@ -99,8 +99,10 @@ public class BaseController { public TenantEntity getTenantInfo() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String tenantId = (String) request.getAttribute(Constant.TENANT_ID); + String subTenantId = (String) request.getAttribute(Constant.SUB_TENANT_ID); TenantEntity tenantEntity = new TenantEntity() {{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; return tenantEntity; } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/PosController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosController.java index f80db4518..d33c55d5b 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/PosController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosController.java @@ -3,6 +3,7 @@ package com.iformall.controller; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.po.WxMerchantBUser; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.exception.MallinkException; import com.iformall.pay.WxPayConstant; import com.iformall.service.PosBrunService; @@ -47,18 +48,6 @@ public class PosController extends BaseController { return posService.checkUserPassword(user, phone, password); } - @ApiOperation(value = "获取会员折扣/优惠券/消费卡是否启用") - @PostMapping("getPosMemConfig") - public ResultData getPosMemConfig() { - return posService.getPosMemConfig(getTenantId()); - } - - @ApiOperation(value = "获取注册二维码及小票二维码规则") - @PostMapping("getQrCode") - public ResultData getQrCode() { - return posService.getQrCode(getTenantId()); - } - @ApiOperation(value = "券独立核销-1-检查", notes = "{\"couponOrderId\":\"string\"}") @PostMapping("checkCouponOrderForIndepentVerify") public ResultData checkCouponOrderForIndepentVerify(@RequestBody Map params) { diff --git a/mallinkBApi/src/main/java/com/iformall/controller/UploadController.java b/mallinkBApi/src/main/java/com/iformall/controller/UploadController.java index 80cea64f7..a4e377533 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/UploadController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/UploadController.java @@ -53,7 +53,11 @@ public class UploadController extends BaseController { private AmazonS3 s3 = null; private String getFileName(TenantEntity tenantEntity, String fileName) { - fileName = tenantEntity.getTenantId() + "/" + fileName; + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + fileName = tenantEntity.getTenantId() + "/" + fileName; + } else { + fileName = tenantEntity.getTenantId() + "/" + tenantEntity.getSubTenantId() + "/" + fileName; + } return fileName; } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java index 51de154a3..abd38bb44 100755 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java @@ -118,7 +118,7 @@ public class WxCUserController extends BaseController { wxCUserBasicInfoService.update(wxCUserBasicInfo); wxScoreRulesService.addScore(EnumScoreType.COMPLETE_INFO, wxCUserBasicInfo); //增加积分 - addCredit(wxCUserBasicInfo, EnumScoreType.COMPLETE_INFO, wxCUserFromBDto.getUserId()); + addCredit(wxCUserBasicInfo, EnumScoreType.COMPLETE_INFO, wxCUserFromBDto.getUserId(), wxCUserFromB); wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, wxCUserBasicInfo); //新增来自B端的会员关联数据 wxCUserFromB = new WxCUserFromB(); @@ -179,7 +179,7 @@ public class WxCUserController extends BaseController { wxCUserBasicInfoService.update(wxCUserBasicInfo); wxScoreRulesService.addScore(EnumScoreType.COMPLETE_INFO, wxCUserBasicInfo); //增加积分 - addCredit(wxCUserBasicInfo, EnumScoreType.COMPLETE_INFO, wxCUserFromBDto.getUserId()); + addCredit(wxCUserBasicInfo, EnumScoreType.COMPLETE_INFO, wxCUserFromBDto.getUserId(), wxCUserFromB); wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, wxCUserBasicInfo); //更新B端来源会员 wxCUserFromB.setInfo(JSONObject.toJSONString(wxCUserBasicInfo)); @@ -188,10 +188,10 @@ public class WxCUserController extends BaseController { return new ResultData(); } - private void addCredit(WxCUserBasicInfo wxCUserBasicInfo, EnumScoreType enumScoreType, Long userId) { + private void addCredit(WxCUserBasicInfo wxCUserBasicInfo, EnumScoreType enumScoreType, Long userId, TenantEntity tenantEntity) { WxCreditHistory wxCreditHistory = new WxCreditHistory(); wxCreditHistory.setCUserId(wxCUserBasicInfo.getId()); - wxCreditHistory.updateTenantInfo(getTenantInfo()); + wxCreditHistory.updateTenantInfo(tenantEntity); wxCreditHistory.setCreateDate(new Date()); wxCreditHistory.setCreditType(enumScoreType.getCode()); wxCreditHistory.setOperatorType(EnumUserType.BUSER.getCode()); diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java index b2f39fc5a..8ed6b53bc 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java @@ -5,6 +5,7 @@ import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponActionLogVo; import com.iformall.domain.vo.WxCouponSendVo; import com.iformall.enums.EnumCouponSendSendType; @@ -18,6 +19,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -65,7 +67,7 @@ public class WxCouponSendController extends BaseController { final PageInfo page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); for (WxCouponSendVo cs : page.getList()) { - cs.setSendCount(wxCouponActionLogService.getCountByChannelId(getTenantInfo(), cs.getSendType(), cs.getId())); + cs.setSendCount(wxCouponActionLogService.getCountByChannelId(wxCouponSend, cs.getSendType(), cs.getId())); } return new ResultData(page); } @@ -134,7 +136,11 @@ public class WxCouponSendController extends BaseController { cal.add(Calendar.DATE, 1); params.put("endDate", cal.getTime()); } - params.put("tenantId", getTenantId()); + TenantEntity tenantEntity = getTenantInfo(); + params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("channelType", channelType); params.put("merchantId", getUser().getMerchantId()); PageInfo data = wxCouponActionLogService.getActionLog(params, pageNum, pageSize); diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java index 40175abdb..53a84226b 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java @@ -8,6 +8,7 @@ import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCreditHistory; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchantBUser; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCreditHistoryVo; import com.iformall.enums.EnumMerchantStatus; import com.iformall.enums.EnumScoreType; diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java index 0c2edf9d5..45315ecc8 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java @@ -12,6 +12,7 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.enums.EnumEnableType; import com.iformall.enums.EnumMallUserStatus; import com.iformall.exception.MallinkException; import com.iformall.service.*; @@ -70,6 +71,9 @@ public class WxInfoController extends BaseController { @Autowired WxBuserTokenService wxBuserTokenService; + @Autowired + WxMerchantBUserService merchantBUserService; + @AuthIgnore @ApiOperation("获取OPENID") @PostMapping("getOpenId") @@ -87,6 +91,10 @@ public class WxInfoController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "bUserId不能为空"); } String scene = param.get("scene"); + WxMerchantBUser buUser = merchantBUserService.getById(Long.valueOf(userId)); + if (buUser == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "登录用户未找到"); + } WxAppinfo wxAppinfo = getAppInfo(appId); // 通过authorizerInfo得到tenant_id WxAuthorizerInfo wxAuthorizerInfo = null; @@ -96,6 +104,9 @@ public class WxInfoController extends BaseController { if (wxAuthorizerInfo == null) { return new ResultData(ErrorCode.APP_ID_NOT_FOUND); } + if (!wxAuthorizerInfo.getEnable().equals(EnumEnableType.Enable.getCode())) { + return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); + } if (isFmOpen) { wxMaService = getWeappService(appId); } else { @@ -164,7 +175,10 @@ public class WxInfoController extends BaseController { token = oldUser.createToken(new Date()); resultMap.put("token", token); request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); - request.setAttribute(Constant.TENANT_ID, oldUser.getTenantId()); + request.setAttribute(Constant.TENANT_ID, buUser.getTenantId()); + if (StringUtils.isNotBlank(buUser.getSubTenantId())) { + request.setAttribute(Constant.SUB_TENANT_ID, buUser.getSubTenantId()); + } oldUser.setRegisterIp(ipaddress); oldUser.setSessionKey(session_key); @@ -177,7 +191,7 @@ public class WxInfoController extends BaseController { oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); } if (StringUtils.isBlank(oldUser.getScene()) || - oldUser.getScene().equals("undefined")) { // from pages/index/index onLoad.options.scene + oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene oldUser.setScene(scene); } oldUser.setLoginCount(oldUser.getLoginCount() + 1); @@ -191,7 +205,7 @@ public class WxInfoController extends BaseController { newUser.setSessionKey(session_key); if (StringUtils.isBlank(newUser.getScene()) || - newUser.getScene().equals("undefined")) { // from pages/index/index onLoad.options.scene + newUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene newUser.setScene(scene); } newUser.setLoginCount(0); @@ -199,7 +213,10 @@ public class WxInfoController extends BaseController { wxBuserTokenService.saveOrUpdate(newUser); resultMap.put("token", token); request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); - request.setAttribute(Constant.TENANT_ID, newUser.getTenantId()); + request.setAttribute(Constant.TENANT_ID, buUser.getTenantId()); + if (StringUtils.isNotBlank(buUser.getSubTenantId())) { + request.setAttribute(Constant.SUB_TENANT_ID, buUser.getSubTenantId()); + } } return new ResultData(resultMap); @@ -249,6 +266,12 @@ public class WxInfoController extends BaseController { private Map getOpenIdInfo(String appId, String code) { WxAppinfo wxAppinfo = getAppInfo(appId); + if (wxAppinfo == null) { + throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); + } + if (!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())) { + throw new MallinkException(ErrorCode.APP_ID_NOT_ENABLE); + } WxMaService wxMaService = null; if(isFmOpen) { wxMaService = getWeappService(appId); diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMallController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMallController.java index 944784f44..d04c6509c 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMallController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMallController.java @@ -1,11 +1,14 @@ package com.iformall.controller; +import com.alibaba.fastjson.JSON; import com.iformall.annotation.AuthIgnore; import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxMall; +import com.iformall.domain.po.WxMerchantBUser; +import com.iformall.enums.EnumGroupSupport; import com.iformall.service.WxAppinfoService; import com.iformall.service.WxMallService; import io.swagger.annotations.Api; @@ -25,6 +28,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; +import java.util.List; import java.util.Map; @RestController @@ -66,14 +70,19 @@ public class WxMallController extends BaseController { @GetMapping("/mallInfo") @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) public ResultData getMallInfo(String appId) { - WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); - if (appInfo == null) { - return new ResultData(ErrorCode.APP_ID_NOT_FOUND); - } - WxMall mall = wxMallService.getByTenantId(appInfo.getTenantId()); + WxMerchantBUser buUser = getUser(); + WxMall mall = wxMallService.getByTenantInfo(buUser); if (mall == null) { return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); } + if(!mall.isValid()) { + logger.error("mall未启用"); + return new ResultData(Result.ERROR, "mall未启用"); + } + if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { + List mallList = wxMallService.getSubByParentTenantId(mall.getTenantId()); + mall.setSubMalls(mallList); + } return new ResultData(Result.SUCCESS, "查询成功", mall); } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java index 47a356477..40ab3634b 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMerchantBUserController.java @@ -8,6 +8,7 @@ import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchantBUser; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxMerchantBuInfoVo; import com.iformall.enums.EnumCreditLockedStatus; import com.iformall.enums.EnumMerchantBUserStatus; import com.iformall.enums.EnumMerchantStatus; @@ -26,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; +import java.util.List; import java.util.Map; @RestController @@ -71,7 +73,7 @@ public class WxMerchantBUserController extends BaseController { return new ResultData(ErrorCode.MCH_INFO_NOT_FOUND); } - WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); + WxMall mall = wxMallService.getByTenantInfo(merchant); if (mall == null){ return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); } @@ -81,13 +83,14 @@ public class WxMerchantBUserController extends BaseController { if (scoreRules.getCreditLocked().equals(EnumCreditLockedStatus.CLOSE.getCode())) { resultMap.put("creditLocked", EnumCreditLockedStatus.CLOSE.getCode()); } + resultMap.put("tenant_id",merchant.getTenantId()); + resultMap.put("sub_tenant_id",merchant.getSubTenantId()); resultMap.put("phone", user.getPhone()); resultMap.put("name", user.getName()); resultMap.put("merchant_name", merchant.getName()); resultMap.put("merchant_img_url", merchant.getImgUrl()); resultMap.put("mall_name", mall.getName()); resultMap.put("service_phone", mall.getServicePhone()); - resultMap.put("tenant_id",merchant.getTenantId()); resultMap.put("merchant_id",merchant.getId()); resultMap.put("is_admin",merchant.getIsAdmin()); resultMap.put("businessId", merchant.getBusinessId()); @@ -136,63 +139,135 @@ public class WxMerchantBUserController extends BaseController { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String ipaddress = IPUtil.getIpAddr(request); - if (!StringUtils.isBlank(latitude) && !StringUtils.isBlank(longitude)) { + if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) { logger.info("B端用户: " + phone + " 登录 IP" + ipaddress + ", 经纬度(" + longitude + "," + latitude + ")"); } - WxMerchantBUser user = new WxMerchantBUser(); - user.setAppId(appId); - user.setPhone(phone); - user.setStatus(EnumMerchantBUserStatus.VALID.getCode()); - WxMerchantBUser user1 = null; - try { - user1 = wxMerchantBUserService.getBUserByAppId(user); - } catch (Exception e) { - logger.error(e.getMessage()); + WxMerchantBUser userQ = new WxMerchantBUser(); + userQ.setAppId(appId); + userQ.setPhone(phone); + userQ.setStatus(EnumMerchantBUserStatus.VALID.getCode()); + List orgList = wxMerchantBUserService.getBUserByAppId(userQ); + + if (orgList.size() == 1) { + // 集团内只发现一个用户 + WxMerchantBUser orgUser = orgList.get(0); + if (orgUser != null) { + // check password + if (orgUser.getUserPwd().equalsIgnoreCase(password)) { + // check merchant 状态 + 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()); + } + Map resultMap = new HashMap<>(); + resultMap.put("bUserId", orgUser.getId()); + resultMap.put("logined", true); + return new ResultData(resultMap); + } else { + return new ResultData(ErrorCode.PASSWORD_ERROR); + } + } else { + logger.error("B端用户不存在, phone: " + phone); + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + } else if (orgList.size() > 1) { + // 集团内发现多个用户, 系统会保证密码一致 + WxMerchantBUser orgUser = orgList.get(0); + if (orgUser != null) { + // check password + if (orgUser.getUserPwd().equalsIgnoreCase(password)) { + // 返回多个(商场+商户) + List merchantListInfo = wxMerchantBUserService.getMerchantInfoByBUser(userQ); + Map resultMap = new HashMap<>(); + resultMap.put("merchantList", merchantListInfo); + resultMap.put("logined", true); + return new ResultData(resultMap); + } else { + logger.error(ErrorCode.PASSWORD_ERROR.getMessage()); + return new ResultData(ErrorCode.PASSWORD_ERROR); + } + } else { + logger.error("B端用户不存在, phone: " + phone); + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + } else { logger.error("B端用户不存在, phone: " + phone); return new ResultData(ErrorCode.USER_IS_EMPTY); } + } - if (user1 != null) { - // check merchant 状态 - WxMerchant merchant = null; - try { - merchant = wxMerchantService.getById(user1.getMerchantId()); - } catch (Exception e) { - logger.error(ErrorCode.DB_FAIL.getMessage() + ": " + user1.getMerchantId() + e.getMessage()); - return new ResultData(ErrorCode.DB_FAIL); - } - if (merchant == null) { - logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + user1.getMerchantId()); - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); - } - if (merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { - logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + user1.getMerchantId()); - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID); - } - // check password - if (user1.getUserPwd().equalsIgnoreCase(password)) { + @AuthIgnore + @PostMapping("/selectMerchant") + @ApiOperation(value = "选择商户", notes = "{" + + "\"buUserId\":\"string\"," + + "\"merchantId\":\"string\"}") + public ResultData selectMerchant(@RequestBody Map map) { + String buUserIdStr = map.get("buUserId"); + String merchantIdStr = map.get("merchantId"); + + 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)); + List orgList = wxMerchantBUserService.getBUserByAppId(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(user1); + wxMerchantBUserService.saveOrUpdate(orgUser); } catch (Exception e) { logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + e.getMessage()); } Map resultMap = new HashMap<>(); - resultMap.put("bUserId", user1.getId()); + resultMap.put("bUserId", orgUser.getId()); + resultMap.put("logined", true); return new ResultData(resultMap); } else { - return new ResultData(ErrorCode.PASSWORD_ERROR); + logger.error("B端用户不存在"); + return new ResultData(ErrorCode.USER_IS_EMPTY); } } else { - logger.error("B端用户不存在, phone: " + phone); - return new ResultData(ErrorCode.USER_IS_EMPTY); + return new ResultData(ErrorCode.USER_NO_PERMISSION); } } + private ResultData checkMerchantStatus(WxMerchantBUser orgUser) { + WxMerchant merchant = null; + try { + merchant = wxMerchantService.getById(orgUser.getMerchantId()); + } catch (Exception e) { + logger.error(ErrorCode.DB_FAIL.getMessage() + ": " + orgUser.getMerchantId() + e.getMessage()); + return new ResultData(ErrorCode.DB_FAIL); + } + if (merchant == null) { + logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + orgUser.getMerchantId()); + return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); + } + if (!merchant.checkStatus()) { + logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + orgUser.getMerchantId()); + return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID); + } + return null; + } + @AuthIgnore - @ApiOperation(value = "修改密码", notes = "{\"appId\",\"string\", \"phone\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") + @ApiOperation(value = "修改密码,集团版会修改集团下同一手机号的密码", notes = "{\"appId\",\"string\", \"phone\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") @PostMapping("/updatepwd") public ResultData updatepwd(@RequestBody Map params) { // String phone,String code,String pwd diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java index 599e2bad8..bf8e3b4e6 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxMsgValidationcodeController.java @@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @RestController @RequestMapping("wxMsgValidationcode") @Api(description="短信验证相关接口") @@ -49,11 +51,12 @@ public class WxMsgValidationcodeController extends BaseController { userQ.setPhone(phone); userQ.setStatus(EnumMerchantBUserStatus.VALID.getCode()); - WxMerchantBUser user=wxMerchantBUserService.getBUserByAppId(userQ); - if (user==null) { + List orgUserList = wxMerchantBUserService.getBUserByAppId(userQ); + if (orgUserList.size() <= 0) { logger.error("B端用户不存在, phone: " + phone); return new ResultData(ErrorCode.USER_IS_EMPTY); } + WxMerchantBUser user = orgUserList.get(0); WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); if (merchant==null) { @@ -77,14 +80,16 @@ public class WxMsgValidationcodeController extends BaseController { @GetMapping("hasvalidationcode") @ApiImplicitParams({ @ApiImplicitParam(name = "tenantId", value = "租户ID", dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "subTenantId", value = "子租户ID", dataType = "String", paramType = "query"), @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "code", value = "验证码", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "appid", value = "appid", dataType = "String", paramType = "query", required = true)}) - public ResultData hasvalidationcode(String tenantId, String phone, Integer type, String code, String appid) { + public ResultData hasvalidationcode(String tenantId, String subTenantId, String phone, Integer type, String code, String appid) { WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); wxMsgValidationcode.updateTenantInfo(new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}); wxMsgValidationcode.setPhone(phone); wxMsgValidationcode.setType(EnumMsgModel.VALIDATION_CODE.getCode()); diff --git a/mallinkBApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java b/mallinkBApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java index dbfd96ad0..0132960bb 100644 --- a/mallinkBApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java +++ b/mallinkBApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java @@ -26,8 +26,24 @@ public class TenantInfoImpl implements TenantInfo { return tenantId; } + @Override + public String getSubTenantId() { + String subTenantId = null; + try { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + subTenantId = (String) request.getAttribute(Constant.SUB_TENANT_ID); + return subTenantId; + } catch (Exception e) { + logger.error(e.getMessage()); + } + return subTenantId; + } + @Override public boolean doTableFilter(String tableName) { + if ("wx_mall".equals(tableName)) { + return true; + } if ("mall_permission".equals(tableName)) { return true; } @@ -72,6 +88,62 @@ public class TenantInfoImpl implements TenantInfo { return false; } + @Override + public boolean doTableFilterSub(String tableName) { + if ("wx_mall".equals(tableName)) { + return true; + } + if ("wx_appinfo".equals(tableName)) { + return true; + } + if ("wx_authorizer_info".equals(tableName)) { + return true; + } + if ("wx_c_user".equals(tableName)) { + return true; + } + if ("wx_c_user_basic_info".equals(tableName)) { + return true; + } + if ("wx_c_user_car".equals(tableName)) { + return true; + } + if ("wx_c_user_from_b".equals(tableName)) { + return true; + } + if ("wx_c_user_tags".equals(tableName)) { + return true; + } + if ("wx_buser".equals(tableName)) { + return true; + } + if ("wx_user_visit".equals(tableName)) { + return true; + } + if ("wx_level_config".equals(tableName)) { + return true; + } + if ("wx_score_rules".equals(tableName)) { + return true; + } + if ("view_coupon_data".equals(tableName)) { + return true; + } + if ("view_touch_user".equals(tableName)) { + return true; + } + if ("wx_weapp_audit_status".equals(tableName)) { + return true; + } + if ("wx_weapp_code_status".equals(tableName)) { + return true; + } + if ("wx_weapp_release_status".equals(tableName)) { + return true; + } + return false; + } + @Override public boolean doMappedStatementFIlter(MappedStatement ms) { if ("com.iformall.mapper.WxMerchantBUserMapper.getByToken".equals(ms.getId())) diff --git a/mallinkCApi/src/main/java/com/iformall/config/MyBatisConfiguration.java b/mallinkCApi/src/main/java/com/iformall/config/MyBatisConfiguration.java index 66ec7d418..512e838e5 100644 --- a/mallinkCApi/src/main/java/com/iformall/config/MyBatisConfiguration.java +++ b/mallinkCApi/src/main/java/com/iformall/config/MyBatisConfiguration.java @@ -14,6 +14,7 @@ public class MyBatisConfiguration { MultiTenancy multiTenancy = new MultiTenancy(); Properties properties = new Properties(); properties.setProperty("tenantIdColumn", "tenant_id"); + properties.setProperty("subTenantIdColumn", "sub_tenant_id"); properties.setProperty("dialect", "mysql"); properties.setProperty("tenantInfo", "com.iformall.tenant.TenantInfoImpl"); multiTenancy.setProperties(properties); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java b/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java index 9d03c2877..999daab0f 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java @@ -79,8 +79,10 @@ public class BaseController { public TenantEntity getTenantInfo() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String tenantId = (String) request.getAttribute(Constant.TENANT_ID); + String subTenantId = (String) request.getAttribute(Constant.SUB_TENANT_ID); TenantEntity tenantEntity = new TenantEntity() {{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; return tenantEntity; } @@ -100,7 +102,13 @@ public class BaseController { if (user == null) { throw new MallinkException(ErrorCode.USER_IS_EMPTY); } - user.updateTenantInfo(getTenantInfo()); + TenantEntity tenantEntity = getTenantInfo(); + if (user.getTenantId() == null) { + user.setTenantId(tenantEntity.getTenantId()); + } + if (user.getSubTenantId() == null) { + user.setSubTenantId(tenantEntity.getSubTenantId()); + } return user; } diff --git a/mallinkCApi/src/main/java/com/iformall/controller/UploadController.java b/mallinkCApi/src/main/java/com/iformall/controller/UploadController.java index cd944f7ad..291870825 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/UploadController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/UploadController.java @@ -13,8 +13,10 @@ import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; import com.iformall.common.ResultData; import com.iformall.config.AwsProperty; +import com.iformall.domain.po.base.TenantEntity; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -100,6 +102,15 @@ public class UploadController extends BaseController { return data; } + private String getFileName(TenantEntity tenantEntity, String fileName) { + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + fileName = tenantEntity.getTenantId() + "/" + fileName; + } else { + fileName = tenantEntity.getTenantId() + "/" + tenantEntity.getSubTenantId() + "/" + fileName; + } + return fileName; + } + /** * 上传文件 * @@ -112,6 +123,8 @@ public class UploadController extends BaseController { public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) { logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); + TenantEntity tenantEntity = getTenantInfo(); + ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentType(multiReq.getContentType()); metadata.setContentLength(multiReq.getSize()); @@ -122,9 +135,10 @@ public class UploadController extends BaseController { String fileName = UUID.randomUUID().toString(); int dot = multiReq.getOriginalFilename().lastIndexOf('.'); if (dot >= 0) { - fileName = getTenantId() + "/" + fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); + String fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); + fileName = getFileName(tenantEntity, fileName + fileFormat); } else { - fileName = getTenantId() + "/" + fileName; + fileName = getFileName(tenantEntity, fileName); } ResultData data = awsUpload(multiReq, metadata, fileName); @@ -143,6 +157,8 @@ public class UploadController extends BaseController { public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) { logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); + TenantEntity tenantEntity = getTenantInfo(); + if (files.length > 0) { ResultData data = new ResultData(); List> dataList = new ArrayList>(); @@ -161,9 +177,10 @@ public class UploadController extends BaseController { String fileName = UUID.randomUUID().toString(); int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); if (dot >= 0) { - fileName = getTenantId() + "/" + fileName + multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); + String fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); + fileName = getFileName(tenantEntity, fileName + fileFormat); } else { - fileName = getTenantId() + "/" + fileName; + fileName = getFileName(tenantEntity, fileName); } ResultData data1 = awsUpload(multipartFile, metadata, fileName); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxActivityJoinController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxActivityJoinController.java index bb8365ac1..55170ec30 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxActivityJoinController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxActivityJoinController.java @@ -42,8 +42,8 @@ public class WxActivityJoinController extends BaseController { @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) public ResultData list(@ModelAttribute WxActivityJoin wxActivityJoin, Integer pageNum, Integer pageSize) { if (null == wxActivityJoin) wxActivityJoin = new WxActivityJoin(); - wxActivityJoin.setUserId(getUserId()); wxActivityJoin.updateTenantInfo(getTenantInfo()); + wxActivityJoin.setUserId(getUserId()); wxActivityJoin.setSortColumns(BaseEntity.SortField.CreateTime_DESC); final PageInfo page = wxActivityJoinService.clistAsPage(wxActivityJoin, pageNum, pageSize); return new ResultData(page); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCampaignController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCampaignController.java index afc5dd872..493d17c51 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCampaignController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCampaignController.java @@ -6,6 +6,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.WxCampaign; import com.iformall.domain.po.WxCouponChannel; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.enums.EnumCampaignStatus; import com.iformall.enums.EnumCouponChannelType; @@ -45,9 +46,8 @@ public class WxCampaignController extends BaseController { @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) { if (null == wxCampaign) wxCampaign = new WxCampaign(); - - wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); wxCampaign.updateTenantInfo(getTenantInfo()); + wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); wxCampaign.setSortColumns(BaseEntity.SortField.SortNum_ASC, BaseEntity.SortField.CreateTime_ASC); final PageInfo page = wxCampaignService.clistAsPage(wxCampaign, pageNum, pageSize); return new ResultData(page); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java index e7f88e6bd..11cda0e64 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java @@ -269,7 +269,7 @@ public class WxCarController extends BaseController { } } - private ResultData etcpBindCar(Map paramMap, WxPark park) { + private ResultData etcpBindCar(Map paramMap, WxPark park, Long cuUserId) { String etcpToken = paramMap.get("etcpToken"); if (StringUtils.isBlank(etcpToken)) { logger.error("etcpToken为空"); @@ -296,7 +296,7 @@ public class WxCarController extends BaseController { } JSONObject retObj = JSON.parseObject(ret); if (retObj.getIntValue("code") == 0) { - addCarInfoToDB(carNumber, EnumCarVendor.CAR_ETCP); + addCarInfoToDB(carNumber, EnumCarVendor.CAR_ETCP, park, cuUserId); JSONObject dataObj = retObj.getJSONObject("data"); return new ResultData(dataObj); } else { @@ -306,14 +306,14 @@ public class WxCarController extends BaseController { } } - private ResultData bindCar(Map paramMap, WxPark park) { + private ResultData bindCar(Map paramMap, WxPark park, Long cuUserId) { String carNumber = paramMap.get("carNumber"); if (StringUtils.isBlank(carNumber)) { logger.error("carNumber为空"); return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); } try { - addCarInfoToDB(carNumber, EnumCarVendor.getEnum(park.getVendorType())); + addCarInfoToDB(carNumber, EnumCarVendor.getEnum(park.getVendorType()), park, cuUserId); } catch (MallinkException e) { return new ResultData(e.getErrorCode(), e.getMessage()); } catch (Exception e) { @@ -322,12 +322,12 @@ public class WxCarController extends BaseController { return new ResultData(); } - private void addCarInfoToDB(String carNumber, EnumCarVendor carVendor) { + private void addCarInfoToDB(String carNumber, EnumCarVendor carVendor, WxPark park, Long cuUserId) { // 插入车牌 Date curr = new Date(); WxCUserCar userCar = new WxCUserCar(); userCar.setCUserId(getUserId()); - userCar.updateTenantInfo(getTenantInfo()); + userCar.updateTenantInfo(park); userCar.setCarNumber(carNumber); userCar.setVendorType(carVendor.getCode()); userCar.setCreateDate(curr); @@ -337,11 +337,11 @@ public class WxCarController extends BaseController { // 成长值 wxScoreRulesService.addScore(EnumScoreType.BIND_CAR, userCar); //增加积分 - addCredit(); - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_CAR, getUserId()); + addCredit(park, cuUserId); + wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_CAR,getUserId()); } - private ResultData tjdBindCar(@RequestBody Map paramMap, WxPark park) { + private ResultData tjdBindCar(@RequestBody Map paramMap, WxPark park, Long cuUserId) { String carNumber = paramMap.get("carNumber"); if (StringUtils.isBlank(carNumber)) { logger.error("carNumber为空"); @@ -370,7 +370,7 @@ public class WxCarController extends BaseController { JSONObject retObj = JSON.parseObject(ret); retObj.put("vendor", park.getVendorType()); if (retObj.getString("returnCode").equalsIgnoreCase(EnumTJDCode.SUCCESS.getMessage())) { - ResultData e = tjdInsertToDB(carNumber, newCarId, retObj); + ResultData e = tjdInsertToDB(carNumber, newCarId, retObj, park, cuUserId); if (e != null) return e; return new ResultData(retObj); } else { @@ -378,14 +378,14 @@ public class WxCarController extends BaseController { } } - private ResultData tjdInsertToDB(String carNumber, Long newCarId, JSONObject retObj) { + private ResultData tjdInsertToDB(String carNumber, Long newCarId, JSONObject retObj, WxPark park, Long cuUserId) { String carId = retObj.getString("carId"); // 插入车牌 Date curr = new Date(); WxCUserCar userCar = new WxCUserCar(); userCar.setId(newCarId); - userCar.setCUserId(getUserId()); - userCar.updateTenantInfo(getTenantInfo()); + userCar.setCUserId(cuUserId); + userCar.updateTenantInfo(park); userCar.setCarNumber(carNumber); userCar.setVendorType(EnumCarVendor.CAR_TJD.getCode()); JSONObject jo = new JSONObject(); @@ -397,7 +397,7 @@ public class WxCarController extends BaseController { wxCUserCarService.save(userCar); wxScoreRulesService.addScore(EnumScoreType.BIND_CAR, userCar); //增加积分 - addCredit(); + addCredit(park, cuUserId); } catch (Exception e) { logger.error(e.getMessage()); return new ResultData(ErrorCode.DB_FAIL.getCode(), "TJD保存车牌失败, e:" + e.getMessage()); @@ -408,14 +408,14 @@ public class WxCarController extends BaseController { } //-----增加积分start----- - private void addCredit() { + private void addCredit(WxPark park, Long cuUserId){ WxCreditHistory wxCreditHistory = new WxCreditHistory(); - wxCreditHistory.setCUserId(getUserId()); - wxCreditHistory.updateTenantInfo(getTenantInfo()); + wxCreditHistory.setCUserId(cuUserId); + wxCreditHistory.updateTenantInfo(park); wxCreditHistory.setCreateDate(new Date()); wxCreditHistory.setCreditType(EnumScoreType.BIND_CAR.getCode()); wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); - wxCreditHistory.setOperatorId(getUserId()); + wxCreditHistory.setOperatorId(cuUserId); wxCreditHistoryService.saveOrUpdate(wxCreditHistory); } @@ -436,13 +436,13 @@ public class WxCarController extends BaseController { // 1, get mall's park WxPark park = getCurrentPark(getTenantInfo()); if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { - return etcpUnbindCar(paramMap, park); + return etcpUnbindCar(paramMap, park, getUserId()); } else { - return unbindCar(paramMap, park); + return unbindCar(paramMap, park, getUserId()); } } - private ResultData etcpUnbindCar(Map paramMap, WxPark park) { + private ResultData etcpUnbindCar(Map paramMap, WxPark park, Long cuUserId) { String etcpToken = paramMap.get("etcpToken"); if (StringUtils.isBlank(etcpToken)) { logger.error("etcpToken为空"); @@ -472,8 +472,8 @@ public class WxCarController extends BaseController { if (retObj.getIntValue("code") == 0) { try { WxCUserCar userCar = new WxCUserCar(); - userCar.setCUserId(getUserId()); - userCar.updateTenantInfo(getTenantInfo()); + userCar.setCUserId(cuUserId); + userCar.updateTenantInfo(park); userCar.setCarNumber(carNumber); wxCUserCarService.deleteByObj(userCar); } catch (Exception e) { @@ -489,7 +489,7 @@ public class WxCarController extends BaseController { } } - private ResultData unbindCar(Map paramMap, WxPark park) { + private ResultData unbindCar(Map paramMap, WxPark park, Long cuUserId) { String carNumber = paramMap.get("carNumber"); if (StringUtils.isBlank(carNumber)) { logger.error("carNumber为空"); @@ -497,8 +497,8 @@ public class WxCarController extends BaseController { } try { WxCUserCar userCar = new WxCUserCar(); - userCar.updateTenantInfo(getTenantInfo()); - userCar.setCUserId(getUserId()); + userCar.updateTenantInfo(park); + userCar.setCUserId(cuUserId); userCar.setCarNumber(carNumber); wxCUserCarService.deleteByObj(userCar); } catch (Exception e) { @@ -516,7 +516,7 @@ public class WxCarController extends BaseController { } WxCUserCar queryOne = new WxCUserCar(); queryOne.setCarNumber(carNumber); - queryOne.updateTenantInfo(getTenantInfo()); + queryOne.updateTenantInfo(park); queryOne.setCUserId(getUserId()); WxCUserCar userCar = wxCUserCarService.getOne(queryOne); if (userCar != null) { @@ -727,7 +727,7 @@ public class WxCarController extends BaseController { WxCouponOrderCarCVo userCar = null; WxCouponOrder userCarQ = new WxCouponOrder(); - userCarQ.updateTenantInfo(getTenantInfo()); + userCarQ.updateTenantInfo(park); userCarQ.setCUserId(getUserId()); userCarQ.setId(couponOrderId); userCarQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); @@ -775,7 +775,7 @@ public class WxCarController extends BaseController { // 券状态设为已使用 WxCouponOrder couponOrder = new WxCouponOrder(); couponOrder.setId(userCar.getId()); - couponOrder.updateTenantInfo(getTenantInfo()); + couponOrder.updateTenantInfo(park); couponOrder.setUpdateDate(new Date()); couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); try { diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxMallController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxMallController.java index 25b0f0eeb..75a4f812e 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxMallController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxMallController.java @@ -85,7 +85,7 @@ public class WxMallController extends BaseController { @ApiOperation("商场信息") @GetMapping("/mallInfo") public ResultData getMallInfo() { - WxMall mall = wxMallService.getByTenantId(getTenantId()); + WxMall mall = wxMallService.getByTenantInfo(getTenantInfo()); if (mall == null) { return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); } diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxMerchantController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxMerchantController.java index 93ae24e39..f13a0577e 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxMerchantController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxMerchantController.java @@ -4,7 +4,7 @@ import com.github.pagehelper.PageInfo; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.dto.WxMerchantDto; -import com.iformall.domain.po.WxMerchant; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxMerchantVo; import com.iformall.enums.EnumMerchantPublic; import com.iformall.enums.EnumMerchantStatus; @@ -40,6 +40,7 @@ public class WxMerchantController extends BaseController { public ResultData list(@ModelAttribute WxMerchantDto wxMerchantDto, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); if (null == wxMerchantDto) wxMerchantDto = new WxMerchantDto(); + wxMerchantDto.updateTenantInfo(getTenantInfo()); wxMerchantDto.setMerchantStatus(EnumMerchantStatus.VALID.getCode()); wxMerchantDto.setIsPublic(EnumMerchantPublic.PUBLIC.getCode()); return new ResultData(wxMerchantService.listAsPageCVo(wxMerchantDto, pageNum, pageSize)); @@ -58,7 +59,11 @@ public class WxMerchantController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } HashMap params = new HashMap(); - params.put("tenantId", getTenantId()); + TenantEntity tenantEntity = getTenantInfo(); + params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("merchantCode", codeMD5); WxMerchantVo wxMerchant = wxMerchantService.getMerchantInfo(params); return new ResultData(wxMerchant); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxParkController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxParkController.java index 058930304..6e02b8094 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxParkController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxParkController.java @@ -3,7 +3,6 @@ package com.iformall.controller; import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; -import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxPark; import com.iformall.service.WxParkService; import io.swagger.annotations.Api; diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxQuestionController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxQuestionController.java index 21e94cfb1..de574b881 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxQuestionController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxQuestionController.java @@ -13,7 +13,6 @@ import com.iformall.service.WxCUserTagsService; import com.iformall.service.WxQuestionService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import net.sf.saxon.trans.Err; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -59,7 +58,7 @@ public class WxQuestionController extends BaseController { if (wxQuestionConfig.getStatus().equals(EnumQuestionConfigStatus.ON.getCode()) && questionIds.size() > 0) { WxQuestion wxQuestion = new WxQuestion(); - wxQuestion.updateTenantInfo(getTenantInfo()); + wxQuestion.updateTenantInfo(wxQuestionConfig); wxQuestion.setIds(questionIds); List listQuestion = wxQuestionService.findList(wxQuestion); if (listQuestion.size() > 0) { @@ -69,7 +68,7 @@ public class WxQuestionController extends BaseController { WxQuestion x = q.next(); wxQuestionLog.setQuestionId(x.getId()); wxQuestionLog.setUserId(getUserId()); - wxQuestionLog.updateTenantInfo(getTenantInfo()); + wxQuestionLog.updateTenantInfo(wxQuestionConfig); if(wxQuestionService.findLogList(wxQuestionLog).size()>0){ q.remove(); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java index b2806096c..160b07bfb 100755 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java @@ -15,10 +15,7 @@ import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCUserVo; import com.iformall.domain.vo.WxLevelMerchantCVo; -import com.iformall.enums.EnumAssignTagsTrigger; -import com.iformall.enums.EnumLevelConfigDiscountStatus; -import com.iformall.enums.EnumScoreType; -import com.iformall.enums.EnumUserType; +import com.iformall.enums.*; import com.iformall.service.*; import com.iformall.service.wechat.FmOpenService; import com.iformall.utils.Constant; @@ -43,6 +40,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @RestController @RequestMapping("/api/user") @@ -92,6 +90,9 @@ public class WxUserGrantController extends BaseController { @Autowired WxCreditHistoryService wxCreditHistoryService; + @Autowired + WxMallService mallService; + /** * 微信消息服务验证 * @@ -160,6 +161,12 @@ public class WxUserGrantController extends BaseController { if (wxAuthorizerInfo == null) { return new ResultData(ErrorCode.APP_ID_NOT_FOUND); } + // 集团版,获取子集团list + List mallList = null; + if (wxAuthorizerInfo.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { + mallList = mallService.getSubByParentTenantId(wxAuthorizerInfo.getTenantId()); + resultMap.put("subMalls", JSON.toJSONString(mallList)); + } if (isFmOpen) { wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); @@ -241,7 +248,30 @@ public class WxUserGrantController extends BaseController { resultMap.put("token", token); request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); - request.setAttribute(Constant.TENANT_ID, oldUser.getTenantId()); + request.setAttribute(Constant.TENANT_ID, wxAuthorizerInfo.getTenantId()); + + // 老用户,给出来已选中的mall + if (mallList != null) { + WxMall selectedMall = null; + if (StringUtils.isNotBlank(oldUser.getSubTenantId())) { + final String lastSubTenant = oldUser.getSubTenantId(); + List selMallList = mallList.stream().filter(ml -> ml.getTenantId().equalsIgnoreCase(lastSubTenant)).collect(Collectors.toList()); + if (selMallList.size() > 0) { + selectedMall = selMallList.get(0); + } + } + if (selectedMall == null){ + WxMall firstMall = mallList.get(0); + if (firstMall != null) { + selectedMall = firstMall; + } + } + if (selectedMall != null) { + request.setAttribute(Constant.SUB_TENANT_ID, selectedMall.getTenantId()); + resultMap.put("selectedMall", selectedMall.getTenantId()); + oldUser.setSubTenantId(selectedMall.getTenantId()); + } + } oldUser.setRegisterIp(ipaddress); oldUser.setSessionKey(session_key); @@ -254,11 +284,11 @@ public class WxUserGrantController extends BaseController { oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); } if (StringUtils.isBlank(oldUser.getSceneAddress()) || - oldUser.getSceneAddress().equalsIgnoreCase("undefined")) { // from app.js onLaunch.options.scene + oldUser.getSceneAddress().equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene oldUser.setSceneAddress(sceneAddress); } if (StringUtils.isBlank(oldUser.getScene()) || - oldUser.getScene().equals("undefined")) { // from pages/index/index onLoad.options.scene + oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene oldUser.setScene(scene); } if (StringUtils.isNotBlank(longitude)) { @@ -286,12 +316,12 @@ public class WxUserGrantController extends BaseController { token = newUser.createToken(new Date()); newUser.setRegisterIp(ipaddress); - if (StringUtils.isBlank(newUser.getSceneAddress()) || - newUser.getSceneAddress().equalsIgnoreCase("undefined")) { // from app.js onLaunch.options.scene + if (StringUtils.isNotBlank(sceneAddress) && + !sceneAddress.equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene newUser.setSceneAddress(sceneAddress); } - if (StringUtils.isBlank(newUser.getScene()) || - newUser.getScene().equals("undefined")) { // from pages/index/index onLoad.options.scene + if (StringUtils.isNotBlank(scene) && + !scene.equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene newUser.setScene(scene); } newUser.setSessionKey(session_key); @@ -314,6 +344,15 @@ public class WxUserGrantController extends BaseController { resultMap.put("token", token); request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); request.setAttribute(Constant.TENANT_ID, newUser.getTenantId()); + if (mallList != null) { + WxMall firstMall = mallList.get(0); + if (firstMall != null) { + // 默认选中第一个mall, 或者经纬度最近的那个 + request.setAttribute(Constant.SUB_TENANT_ID, firstMall.getTenantId()); + resultMap.put("selectedMall", firstMall.getTenantId()); + newUser.setSubTenantId(firstMall.getTenantId()); + } + } // 登录后处理 int score = wxCUserService.actionAfterLogin(newUser, null); @@ -323,6 +362,33 @@ public class WxUserGrantController extends BaseController { return new ResultData(resultMap); } + @PostMapping("/selectMall") + @ApiOperation(value = "用户选中子广场", notes = "{\"tenantId\":\"string\",\"subTenantId\":\"string\"}") + public ResultData selectMall(@RequestBody Map map) { + logger.debug(map.toString()); + + String tenantId = map.get("tenantId"); + String subTenantId = map.get("subTenantId"); + + if (StringUtils.isBlank(tenantId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "tenantId不能为空"); + } + if (StringUtils.isBlank(subTenantId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "subTenantId不能为空"); + } + + WxCUser user = getUser(); + if (user.getTenantId().equalsIgnoreCase(tenantId)) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + request.setAttribute(Constant.TENANT_ID, tenantId); + request.setAttribute(Constant.SUB_TENANT_ID, subTenantId); + user.setSubTenantId(subTenantId); + userTokenService.saveOrUpdate(user); + } + + return new ResultData(); + } + @PostMapping("/updateScene") @ApiOperation(value = "用户更新scene", notes = "{\"scene\":\"string\"}") public ResultData updateScene(@RequestBody Map map) { @@ -331,8 +397,9 @@ public class WxUserGrantController extends BaseController { String scene = map.get("scene"); WxCUser user = getUser(); - if (StringUtils.isBlank(user.getScene())) { - if(StringUtils.isNotBlank(scene)) { + if (StringUtils.isBlank(user.getScene()) || + user.getScene().equalsIgnoreCase(Constant.UNDEFINED)) { + if(StringUtils.isNotBlank(scene) && scene.equalsIgnoreCase(Constant.UNDEFINED)) { user.setScene(scene); wxCUserService.updateScene(user); } @@ -383,10 +450,16 @@ public class WxUserGrantController extends BaseController { private void updateAppAccessToken(WxAppinfo wxAppinfo, WxMaService wxMaService) { try { String accessToken = wxMaService.getAccessToken(true); - wxAppinfo.setAccessToken(accessToken); - wxAppinfo.setLastTokenTime(new Date()); - wxAppinfo.setExpiresIn(7200); - wxAppinfoService.saveOrUpdate(wxAppinfo); + WxAppinfo updateApp = new WxAppinfo(); + updateApp.setId(wxAppinfo.getId()); + updateApp.setAccessToken(accessToken); + updateApp.setLastTokenTime(new Date()); + updateApp.setExpiresIn(7200); + wxAppinfo.setAccessToken(updateApp.getAccessToken()); + wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); + wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); + wxAppinfoService.saveOrUpdate(updateApp); + } catch (WxErrorException e) { logger.error(e.getMessage()); } catch (Exception e) { @@ -434,6 +507,15 @@ public class WxUserGrantController extends BaseController { WxMaUserInfo userInfo = wxMaService.getUserService().getUserInfo(session_key, encryptedData, iv); if (userInfo != null) { logger.debug(userInfo.toString()); + WxCUser updateUser = new WxCUser(); + updateUser.setId(user.getId()); + updateUser.setUnionId(userInfo.getUnionId()); + updateUser.setNickName(userInfo.getNickName()); + updateUser.setGender(Integer.parseInt(userInfo.getGender())); + updateUser.setAvatarUrl(userInfo.getAvatarUrl()); + updateUser.setProvince(userInfo.getProvince()); + updateUser.setCity(userInfo.getCity()); + updateUser.setLanguage(userInfo.getLanguage()); user.setUnionId(userInfo.getUnionId()); user.setNickName(userInfo.getNickName()); user.setGender(Integer.parseInt(userInfo.getGender())); @@ -441,7 +523,7 @@ public class WxUserGrantController extends BaseController { user.setProvince(userInfo.getProvince()); user.setCity(userInfo.getCity()); user.setLanguage(userInfo.getLanguage()); - wxCUserService.saveOrUpdate(user); + wxCUserService.saveOrUpdate(updateUser); if(bFirstNickName) { // 首次获取昵称 @@ -681,7 +763,7 @@ public class WxUserGrantController extends BaseController { public ResultData carCount() { WxCUser user = getUser(); WxCUserCar userCar = new WxCUserCar(); - userCar.updateTenantInfo(getTenantInfo()); + userCar.updateTenantInfo(user); userCar.setCUserId(user.getId()); Integer count = wxCUserCarService.countUserCar(userCar); if (count > 0) { @@ -761,11 +843,14 @@ public class WxUserGrantController extends BaseController { if (wxCUserBasicInfoService.getById(getUserId()) == null) return new ResultData(ErrorCode.USER_IS_NOT_MEMBER); + TenantEntity tenantEntity = getTenantInfo(); + if (wxCUserBasicInfo.getName() != null || wxCUserBasicInfo.getBirthdate() != null || wxCUserBasicInfo.getSex() != null || wxCUserBasicInfo.getAddress() != null) { WxCUserBasicInfo record = new WxCUserBasicInfo(); + record.updateTenantInfo(tenantEntity); record.setName(wxCUserBasicInfo.getName()); record.setBirthdate(wxCUserBasicInfo.getBirthdate()); record.setSex(wxCUserBasicInfo.getSex()); @@ -777,7 +862,7 @@ public class WxUserGrantController extends BaseController { //增加积分 WxCreditHistory wxCreditHistory = new WxCreditHistory(); wxCreditHistory.setCUserId(record.getId()); - wxCreditHistory.updateTenantInfo(getTenantInfo()); + wxCreditHistory.updateTenantInfo(tenantEntity); wxCreditHistory.setCreateDate(new Date()); wxCreditHistory.setCreditType(EnumScoreType.COMPLETE_INFO.getCode()); wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); @@ -796,7 +881,6 @@ public class WxUserGrantController extends BaseController { @RequestMapping("/getDiscountInfo") @ApiOperation(value = "获取用户折扣率", notes = "") public ResultData getDiscountInfo() { - WxCUser user = getUser(); List levelList = wxLevelConfigService.getByTenantId(user.getTenantId()); @@ -811,6 +895,7 @@ public class WxUserGrantController extends BaseController { } } WxLevelMerchant levelMerchant = new WxLevelMerchant(); + levelMerchant.updateTenantInfo(getTenantInfo()); levelMerchant.setLevelId(levelId); List levelMerchantList = wxLevelConfigService.findListCVo(levelMerchant); diff --git a/mallinkCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java b/mallinkCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java index c8c12f652..5ca1e6a96 100644 --- a/mallinkCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java +++ b/mallinkCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java @@ -62,6 +62,9 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { //设置userId到request里,后续根据userId,获取用户信息 request.setAttribute(Constant.LOGIN_USER_KEY, wxCUser.getId()); request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId()); + if (StringUtils.isNotBlank(wxCUser.getSubTenantId())) { + request.setAttribute(Constant.SUB_TENANT_ID, wxCUser.getSubTenantId()); + } return true; } diff --git a/mallinkCApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java b/mallinkCApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java index 5ddafb769..1f6a9f188 100644 --- a/mallinkCApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java +++ b/mallinkCApi/src/main/java/com/iformall/tenant/TenantInfoImpl.java @@ -26,8 +26,24 @@ public class TenantInfoImpl implements TenantInfo { return tenantId; } + @Override + public String getSubTenantId() { + String subTenantId = null; + try { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + subTenantId = (String) request.getAttribute(Constant.SUB_TENANT_ID); + return subTenantId; + } catch (Exception e) { + logger.error(e.getMessage()); + } + return subTenantId; + } + @Override public boolean doTableFilter(String tableName) { + if ("wx_mall".equals(tableName)) { + return true; + } if ("mall_permission".equals(tableName)) { return true; } @@ -72,6 +88,68 @@ public class TenantInfoImpl implements TenantInfo { return false; } + @Override + public boolean doTableFilterSub(String tableName) { + if ("wx_mall".equals(tableName)) { + return true; + } + if ("wx_appinfo".equals(tableName)) { + return true; + } + if ("wx_authorizer_info".equals(tableName)) { + return true; + } + if ("wx_c_user".equals(tableName)) { + return true; + } + if ("wx_c_user_basic_info".equals(tableName)) { + return true; + } + if ("wx_c_user_car".equals(tableName)) { + return true; + } + if ("wx_c_user_from_b".equals(tableName)) { + return true; + } + if ("wx_c_user_tags".equals(tableName)) { + return true; + } + if ("wx_question".equals(tableName)) { + return true; + } + if ("wx_question_config".equals(tableName)) { + return true; + } + if ("wx_question_log".equals(tableName)) { + return true; + } + if ("wx_user_visit".equals(tableName)) { + return true; + } + if ("wx_level_config".equals(tableName)) { + return true; + } + if ("wx_score_rules".equals(tableName)) { + return true; + } + if ("view_coupon_data".equals(tableName)) { + return true; + } + if ("view_touch_user".equals(tableName)) { + return true; + } + if ("wx_weapp_audit_status".equals(tableName)) { + return true; + } + if ("wx_weapp_code_status".equals(tableName)) { + return true; + } + if ("wx_weapp_release_status".equals(tableName)) { + return true; + } + return false; + } + @Override public boolean doMappedStatementFIlter(MappedStatement ms) { if ("com.iformall.mapper.WxCUserMapper.getByToken".equals(ms.getId())) diff --git a/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarETCPCallBackController.java b/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarETCPCallBackController.java index a71b7587d..cc53a4526 100644 --- a/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarETCPCallBackController.java +++ b/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarETCPCallBackController.java @@ -173,24 +173,29 @@ public class WxCarETCPCallBackController extends BaseController { // 根据orderId获取入场信息,确定租户ID String orderId = paramMap.get(ETCPUtil.ETCP_ORDER_ID); String etcpTime = paramMap.get(ETCPUtil.ETCP_TIME); - HashMap map = new HashMap(); - map.put("synId", orderId); - map.put("plateNumber", carNumber); - String tenantId = wxCarCmdLogService.getTenantIdBySynId(map); + WxCarCmdLog carCmdLogQ = new WxCarCmdLog(); + carCmdLogQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); + carCmdLogQ.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); + carCmdLogQ.setSynId(orderId); + carCmdLogQ.setPlateNumber(carNumber); + WxCarCmdLog tenantInfo = wxCarCmdLogService.getTenantInfoBySynId(carCmdLogQ); + String tenantId = null; /// if not found syn_id, maybe use user_car to get tenantId - if(StringUtils.isBlank(tenantId)) { + if(tenantInfo == null) { WxCUserCar queryOne = new WxCUserCar(); queryOne.setCarNumber(carNumber); WxCUserCar userCar = wxCUserCarService.getOnlyOne(queryOne); if(userCar != null) { tenantId = userCar.getTenantId(); } + if (StringUtils.isNotBlank(tenantId)) { + carCmdLogQ.setTenantId(tenantId); + } + } else { + carCmdLogQ.updateTenantInfo(tenantInfo); } - // 检查是否有重复数据 - if(StringUtils.isNotBlank(tenantId)) { - map.put("tenantId", tenantId); - } + String paidServiceFee = paramMap.get(ETCPUtil.ETCP_PAID_SERVICE_FEE); String fee = paramMap.get(ETCPUtil.ETCP_FEE); Date feeTime = null; @@ -202,19 +207,24 @@ public class WxCarETCPCallBackController extends BaseController { logger.error("解析fee time出错" + etcpTime); } } - map.put("plateNumber", carNumber); - map.put("orderId", orderId); - map.put("fee", fee); - map.put("feeTime", etcpTime); - WxCarCmdLog carCmdLog = wxCarCmdLogService.getByOrderId(map); + carCmdLogQ.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PAY_MANUAL.getCode()); + carCmdLogQ.setPlateNumber(carNumber); + carCmdLogQ.setOrderId(orderId); + carCmdLogQ.setFee(fee); + carCmdLogQ.setFeeTime(etcpTime); + WxCarCmdLog carCmdLog = wxCarCmdLogService.getByOrderId(carCmdLogQ); if(carCmdLog != null) { logger.error("ETCP order paid 已入库: " + orderId); } Date currentDate = new Date(); WxCarCmdLog wxCarCmdLog = new WxCarCmdLog(); - if(StringUtils.isNotBlank(tenantId)) { - wxCarCmdLog.setTenantId(tenantId); + if (tenantInfo != null) { + wxCarCmdLog.updateTenantInfo(tenantInfo); + } else { + if (StringUtils.isNotBlank(tenantId)) { + wxCarCmdLog.setTenantId(tenantId); + } } if(carCmdLog != null) { // 如果有15分钟的已支付的数据,自动覆盖 @@ -290,7 +300,6 @@ public class WxCarETCPCallBackController extends BaseController { wxCarCmdLog.setUpdateDate(currentDate); String etcpParkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); - String tenantId = null; WxPark parkQ = new WxPark(); parkQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); parkQ.setParkingId(etcpParkId); @@ -299,13 +308,11 @@ public class WxCarETCPCallBackController extends BaseController { logger.error("etcpParkInCallback: ETCP车场未找到" + etcpParkId); //return new Result(ErrorCode.CAR_PARK_NOT_FOUND.getCode(), "ETCP车场未找到"+ etcpParkId); } else { - tenantId = park.getTenantId(); wxCarCmdLog.updateTenantInfo(park); } String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); String synId = paramMap.get(ETCPUtil.ETCP_SYN_ID); - String parkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); @@ -316,8 +323,11 @@ public class WxCarETCPCallBackController extends BaseController { HashMap map = new HashMap(); map.put("synId", synId); map.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); - if(tenantId != null) { - map.put("tenantId", tenantId); + if (StringUtils.isNotBlank(wxCarCmdLog.getTenantId())) { + map.put("tenantId", wxCarCmdLog.getTenantId()); + } + if (StringUtils.isNotBlank(wxCarCmdLog.getSubTenantId())) { + map.put("subTenantId", wxCarCmdLog.getSubTenantId()); } WxCarCmdLog carCmdLog = wxCarCmdLogService.getBySynId(map); if(carCmdLog != null) { @@ -338,13 +348,16 @@ public class WxCarETCPCallBackController extends BaseController { if (!StringUtils.isBlank(carNumber)) { // 根据车牌查找用户 WxCUserCar userCarQ = new WxCUserCar(); - userCarQ.setTenantId(tenantId); + if (StringUtils.isNotBlank(wxCarCmdLog.getTenantId())) { + userCarQ.setTenantId(wxCarCmdLog.getTenantId()); + } userCarQ.setCarNumber(carNumber); userCarQ.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); // TODO 可能多用户关联同一张车牌 List userCarList = wxCUserCarService.getList(userCarQ); boolean bFirst = true; for (WxCUserCar userCar : userCarList) { + userCar.setSubTenantId(park.getSubTenantId()); wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar); WxCUser cUser = wxCUserService.getById(userCar.getCUserId()); if(cUser != null){ @@ -363,7 +376,7 @@ public class WxCarETCPCallBackController extends BaseController { WxCarPayRecord record = new WxCarPayRecord(); record.setVendorType(wxCarCmdLog.getVendorType()); record.setSynId(synId); - record.setParkId(parkId); + record.setParkId(etcpParkId); record.setParkName(parkName); record.setUserType(userType); record.setPlateNumber(carNumber); @@ -373,7 +386,7 @@ public class WxCarETCPCallBackController extends BaseController { record.setFixParkingId(fixParkingId); record.setRemainingDays(remainingDays); record.setPhone(phoneStrs); - record.setTenantId(tenantId); + record.updateTenantInfo(wxCarCmdLog); WxCarPayRecord query = new WxCarPayRecord(); query.setSynId(synId); @@ -426,7 +439,6 @@ public class WxCarETCPCallBackController extends BaseController { String exitTime = paramMap.get(ETCPUtil.ETCP_EXIT_TIME); String stayedTime = paramMap.get(ETCPUtil.ETCP_STAYED_TIME); String carNumber = paramMap.get(ETCPUtil.ETCP_CAR_NUMBER); - String parkId = paramMap.get(ETCPUtil.ETCP_PARK_ID); String parkName = paramMap.get(ETCPUtil.ETCP_PARK_NAME); String userType = paramMap.get(ETCPUtil.ETCP_USER_TYPE); String entranceTime = paramMap.get(ETCPUtil.ETCP_ENTRANCE_TIME); @@ -445,7 +457,7 @@ public class WxCarETCPCallBackController extends BaseController { } record.setVendorType(wxCarCmdLog.getVendorType()); record.setSynId(synId); - record.setParkId(parkId); + record.setParkId(etcpParkId); record.setParkName(parkName); record.setUserType(userType); record.setPlateNumber(carNumber); diff --git a/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarTJDCallBackController.java b/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarTJDCallBackController.java index 156b62c5a..91d357f11 100644 --- a/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarTJDCallBackController.java +++ b/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarTJDCallBackController.java @@ -164,6 +164,7 @@ public class WxCarTJDCallBackController extends BaseController { List userCarList = wxCUserCarService.getList(userCarQ); boolean bFirst = true; for (WxCUserCar userCar : userCarList) { + userCar.setSubTenantId(park.getSubTenantId()); wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.CAR_STOP, userCar); WxCUser cUser = wxCUserService.getById(userCar.getCUserId()); if(cUser != null){ diff --git a/mallinkCallback/src/main/java/com/iformall/controller/device/KwBoxV1Controller.java b/mallinkCallback/src/main/java/com/iformall/controller/device/KwBoxV1Controller.java index 122217524..497cb5623 100644 --- a/mallinkCallback/src/main/java/com/iformall/controller/device/KwBoxV1Controller.java +++ b/mallinkCallback/src/main/java/com/iformall/controller/device/KwBoxV1Controller.java @@ -13,9 +13,7 @@ import com.iformall.enums.EnumBoxRegisterStatus; import com.iformall.service.kw.KwBoxCmdHistoryService; import com.iformall.service.kw.KwBoxService; -import com.iformall.utils.HashUtil; import com.iformall.utils.Utility; -import com.sun.crypto.provider.HmacSHA1; import io.netty.util.internal.StringUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/mallinkCallback/src/main/java/com/iformall/controller/device/WxDeviceScreenAdController.java b/mallinkCallback/src/main/java/com/iformall/controller/device/WxDeviceScreenAdController.java index d0f26e692..615a469d3 100644 --- a/mallinkCallback/src/main/java/com/iformall/controller/device/WxDeviceScreenAdController.java +++ b/mallinkCallback/src/main/java/com/iformall/controller/device/WxDeviceScreenAdController.java @@ -119,9 +119,10 @@ public class WxDeviceScreenAdController extends BaseController { @SystemControllerLog(description = "广告屏-基础信息") public Result info(@RequestParam String deviceId) { WxDevice wxDevice = findDevice(deviceId); - if (wxDevice == null) + if (wxDevice == null) { return new ResultData(ErrorCode.DEVICE_NOT_FOUND); - return new ResultData(wxMallService.getByTenantId(wxDevice.getTenantId())); + } + return new ResultData(wxMallService.getByTenantInfo(wxDevice)); } } diff --git a/mallinkCallback/src/main/java/com/iformall/shiro/MyShiroRealm.java b/mallinkCallback/src/main/java/com/iformall/shiro/MyShiroRealm.java index e20788087..520d5dbe6 100644 --- a/mallinkCallback/src/main/java/com/iformall/shiro/MyShiroRealm.java +++ b/mallinkCallback/src/main/java/com/iformall/shiro/MyShiroRealm.java @@ -28,7 +28,7 @@ public class MyShiroRealm extends AuthorizingRealm { @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal(); - Set permissionSet = userService.getUserPermissions(user); + Set permissionSet = userService.getUserPermissions(user, true); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setStringPermissions(permissionSet); return info; diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index c50991c8d..bd29c119d 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; import com.iformall.domain.po.*; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.PromotionCalc; import com.iformall.domain.vo.WxCouponOrderCVo; import com.iformall.domain.vo.WxLevelMerchantCVo; @@ -87,35 +88,45 @@ public class PosServiceImpl implements PosService { throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); } - PosMallConfig config = posMallConfigService.getByTenantId(tenantId); + TenantEntity tenantEntity = mall.getTenantInfo(); + + PosMallConfig config = posMallConfigService.getByTenantInfo(tenantEntity); if (config == null) { logger.error(ErrorCode.MALL_INFO_NOT_FOUND.getMessage()); throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); } - WxMerchantBUser user = new WxMerchantBUser(); - user.setTenantId(tenantId); - user.setPhone(phone); - user.setStatus(EnumMerchantBUserStatus.VALID.getCode()); - WxMerchantBUser user1 = null; + WxMerchantBUser userQ = new WxMerchantBUser(); + userQ.updateTenantInfo(tenantEntity); + userQ.setPhone(phone); + userQ.setStatus(EnumMerchantBUserStatus.VALID.getCode()); + WxMerchantBUser orgUser = null; + List orgUserList = null; try { - user1 = merchantBUserService.getBUserByAppId(user); + orgUserList = merchantBUserService.getBUserByAppId(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); } - if (user1 != null) { + if (orgUserList.size() > 0) { + orgUser = orgUserList.get(0); + } + if (orgUser != null) { // check merchant 状态 - WxMerchant merchant = checkAndGetMerchant(user1.getMerchantId()); + WxMerchant merchant = checkAndGetMerchant(orgUser.getMerchantId()); // check password - if (user1.getUserPwd().equalsIgnoreCase(password)) { - retMap.put(WxPayConstant.TENANT_ID, user1.getTenantId()); + if (orgUser.getUserPwd().equalsIgnoreCase(password)) { + if (StringUtils.isBlank(orgUser.getSubTenantId())) { + retMap.put(WxPayConstant.TENANT_ID, orgUser.getTenantId()); + } else { + retMap.put(WxPayConstant.TENANT_ID, orgUser.getSubTenantId()); + } retMap.put(WxPayConstant.MALL_NAME, mall.getName()); - retMap.put(WxPayConstant.MERCHANT_ID, String.valueOf(user1.getMerchantId())); + retMap.put(WxPayConstant.MERCHANT_ID, String.valueOf(orgUser.getMerchantId())); retMap.put(WxPayConstant.MERCHANT_NAME, merchant.getName()); retMap.put(WxPayConstant.MERCHANT_IMG, merchant.getImgUrl()); - retMap.put(WxPayConstant.BUSER_ID, String.valueOf(user1.getId())); + retMap.put(WxPayConstant.BUSER_ID, String.valueOf(orgUser.getId())); JSONObject qrCodeInfo = new JSONObject(); qrCodeInfo.put(WxPayConstant.REG_QRCODE_URL, mall.getImgQrcodeWeapp()); @@ -188,8 +199,15 @@ public class PosServiceImpl implements PosService { throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); } + WxMall mall = mallService.getByTenantId(tenantId); + if (mall == null) { + logger.error(ErrorCode.MALL_INFO_NOT_FOUND.getMessage()); + throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); + } + TenantEntity tenantEntity = mall.getTenantInfo(); + // 1. POS 支持 配置 - PosMallConfig config = posMallConfigService.getByTenantId(tenantId); + PosMallConfig config = posMallConfigService.getByTenantInfo(tenantEntity); if (config == null) { logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); @@ -284,7 +302,7 @@ public class PosServiceImpl implements PosService { errParam2(WxPayConstant.MEM_ID, WxPayConstant.MEM_PHONE); } // 10. 获取会员信息 - user = getMemUser(tenantId, memIdStr, memPhoneStr); + user = getMemUser(merchant, memIdStr, memPhoneStr); } if (user == null) { @@ -309,12 +327,15 @@ public class PosServiceImpl implements PosService { promotionCalc.setPromotionAmount(0); promotionCalc.setAmountLeftAfterPay(orderAmountLeft); // 12. 会员折扣 - JSONObject discountObj = getMemLevelDiscount(promotionCalc, config.getDiscount(), tenantId, user, merchantId); + JSONObject discountObj = getMemLevelDiscount(promotionCalc, config.getDiscount(), tenantEntity, user, merchantId); promotionInfo.put(WxPayConstant.MEMBER_DISCOUNT, discountObj); // 14. 获取用户可用券列表 if (!config.getCoupon().equals(EnumPosCouponEnableType.Disable.getCode())) { Map coQ = new HashMap<>(); coQ.put("tenantId", tenantId); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + coQ.put("subTenantId", tenantEntity.getSubTenantId()); + } coQ.put("cUserId", user.getId()); coQ.put("merchantId", merchantId); List avaCoList = couponOrderMapper.findAvailCouponOrder(coQ); @@ -663,7 +684,7 @@ public class PosServiceImpl implements PosService { return couponOrderCVo; } - private WxCUser getMemUser(String tenantId, String memIdStr, String memPhoneStr) { + private WxCUser getMemUser(TenantEntity tenantEntity, String memIdStr, String memPhoneStr) { WxCUser user = null; if (StringUtils.isNotBlank(memIdStr)) { Long memId; @@ -678,7 +699,7 @@ public class PosServiceImpl implements PosService { } if (StringUtils.isNotBlank(memPhoneStr)) { WxCUser q = new WxCUser(); - q.setTenantId(tenantId); + q.updateTenantInfo(tenantEntity); q.setPhone(memPhoneStr); user = cUserService.getByObject(q); } @@ -689,18 +710,18 @@ public class PosServiceImpl implements PosService { * 会员折扣 * @param promotionCalc * @param discountConfig - * @param tenantId + * @param tenantEntity * @param user * @param merchantId * @return */ - private JSONObject getMemLevelDiscount(PromotionCalc promotionCalc, Integer discountConfig, String tenantId, WxCUser user, Long merchantId) { + private JSONObject getMemLevelDiscount(PromotionCalc promotionCalc, Integer discountConfig, TenantEntity tenantEntity, WxCUser user, Long merchantId) { JSONObject discountObj = new JSONObject(); Integer discount = 100; if (discountConfig.equals(EnumPosEnableType.Enable.getCode())) { String level = WxLevelConfigService.DEFAULT_LEVEL; // 1. 会员级别Level - List levelList = levelConfigService.getByTenantId(tenantId); + List levelList = levelConfigService.getByTenantId(tenantEntity.getTenantId()); Long levelId = 0L; for (WxLevelConfig levelConfig : levelList) { if (user.getScore() >= levelConfig.getPoints()) { @@ -712,7 +733,7 @@ public class PosServiceImpl implements PosService { // 2. 会员级别对应折扣discount WxLevelMerchant levelMerchant = new WxLevelMerchant(); - levelMerchant.setTenantId(tenantId); + levelMerchant.updateTenantInfo(tenantEntity); levelMerchant.setLevelId(levelId); levelMerchant.setMerchantId(merchantId); List levelMerchantList = levelConfigService.findListCVo(levelMerchant); @@ -798,8 +819,16 @@ public class PosServiceImpl implements PosService { throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR); } + WxMall mall = mallService.getByTenantId(tenantId); + if (mall == null) { + logger.error(ErrorCode.MALL_INFO_NOT_FOUND.getMessage()); + throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); + } + + TenantEntity tenantEntity = mall.getTenantInfo(); + // 1. POS 支持 配置 - PosMallConfig config = posMallConfigService.getByTenantId(tenantId); + PosMallConfig config = posMallConfigService.getByTenantInfo(tenantEntity); if (config == null) { logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); @@ -880,7 +909,7 @@ public class PosServiceImpl implements PosService { errParam2(WxPayConstant.MEM_ID, WxPayConstant.MEM_PHONE); } // 10. 获取会员信息 - WxCUser user = getMemUser(tenantId, memIdStr, memPhoneStr); + WxCUser user = getMemUser(merchant, memIdStr, memPhoneStr); if (user == null) { logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); throw new MallinkException(ErrorCode.USER_NOT_MEMBER); @@ -903,12 +932,15 @@ public class PosServiceImpl implements PosService { promotionCalc.setPromotionAmount(0); promotionCalc.setAmountLeftAfterPay(orderAmountLeft); // 12. 会员折扣 - JSONObject discountObj = getMemLevelDiscount(promotionCalc, config.getDiscount(), tenantId, user, merchantId); + JSONObject discountObj = getMemLevelDiscount(promotionCalc, config.getDiscount(), tenantEntity, user, merchantId); promotionInfo.put(WxPayConstant.MEMBER_DISCOUNT, discountObj); // 14. 获取用户可用券列表 if (!config.getCoupon().equals(EnumPosCouponEnableType.Disable.getCode())) { Map coQ = new HashMap<>(); coQ.put("tenantId", tenantId); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + coQ.put("subTenantId", tenantEntity.getSubTenantId()); + } coQ.put("cUserId", user.getId()); coQ.put("merchantId", merchantId); List avaCoList = couponOrderMapper.findAvailCouponOrder(coQ); @@ -1144,7 +1176,7 @@ public class PosServiceImpl implements PosService { throw new MallinkException(ErrorCode.POS_COUPON_REFUND_ERROR.getCode(), errMesg); } // 10. 获取会员信息 - WxCUser user = getMemUser(tenantId, memIdStr, memPhoneStr); + WxCUser user = getMemUser(merchant, memIdStr, memPhoneStr); if (user == null) { logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); throw new MallinkException(ErrorCode.USER_NOT_MEMBER); @@ -1186,7 +1218,7 @@ public class PosServiceImpl implements PosService { int num = 0; // 1. insert posOrderId PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); - posCouponOrderVerify.setTenantId(couponOrderCVo.getTenantId()); + posCouponOrderVerify.updateTenantInfo(couponOrderCVo); posCouponOrderVerify.setCouponOrderId(couponOrderCVo.getId()); posCouponOrderVerify.setPosOrderId(posOrderId); posCouponOrderVerify.setOrderFrom(EnumOrderFrom.POS.getCode()); @@ -1204,7 +1236,7 @@ public class PosServiceImpl implements PosService { try { WxCouponOrder couponOrder = new WxCouponOrder(); couponOrder.setId(couponOrderCVo.getId()); - couponOrder.setTenantId(couponOrderCVo.getTenantId()); + couponOrder.updateTenantInfo(couponOrderCVo); couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.POS_PRE_VERIFY.getCode()); couponOrder.setBUserId(buUserId); couponOrder.setVerifyType(EnumCouponVerifyType.VERIFY_POS_PAY.getCode()); @@ -1230,7 +1262,7 @@ public class PosServiceImpl implements PosService { int num = 0; // 1. update posOrderId PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); - posCouponOrderVerify.setTenantId(couponOrderCVo.getTenantId()); + posCouponOrderVerify.updateTenantInfo(couponOrderCVo); posCouponOrderVerify.setCouponOrderId(couponOrderCVo.getId()); posCouponOrderVerify.setPosOrderId(posOrderId); posCouponOrderVerify.setState(EnumEnableType.Enable.getCode()); @@ -1254,7 +1286,7 @@ public class PosServiceImpl implements PosService { try { WxCouponOrder couponOrder = new WxCouponOrder(); couponOrder.setId(couponOrderCVo.getId()); - couponOrder.setTenantId(couponOrderCVo.getTenantId()); + couponOrder.updateTenantInfo(couponOrderCVo); couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); couponOrder.setUpdateDate(new Date()); num = couponOrderMapper.cancelVerifyCouponOrder(couponOrder); @@ -1281,7 +1313,7 @@ public class PosServiceImpl implements PosService { int num = 0; // 1. insert posOrderId PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); - posCouponOrderVerify.setTenantId(couponOrderCVo.getTenantId()); + posCouponOrderVerify.updateTenantInfo(couponOrderCVo); posCouponOrderVerify.setCouponOrderId(couponOrderCVo.getId()); posCouponOrderVerify.setPosOrderId(posOrderId); posCouponOrderVerify.setOrderFrom(EnumOrderFrom.POS.getCode()); @@ -1297,7 +1329,7 @@ public class PosServiceImpl implements PosService { try { WxCouponOrder couponOrder = new WxCouponOrder(); couponOrder.setId(couponOrderCVo.getId()); - couponOrder.setTenantId(couponOrderCVo.getTenantId()); + couponOrder.updateTenantInfo(couponOrderCVo); if (actionType.equals(EnumPosActionType.VERIFY_INDEPENT)) { couponOrder.setVerifyType(EnumCouponVerifyType.VERIFY_POS_INDEPENDENT.getCode()); couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); @@ -1331,7 +1363,7 @@ public class PosServiceImpl implements PosService { creditHistory.setOperatorId(buUserId); creditHistory.setCUserId(couponOrderCVo.getcUserId()); creditHistory.setCreateDate(new Date()); - creditHistory.setTenantId(couponOrderCVo.getTenantId()); + creditHistory.updateTenantInfo(couponOrderCVo); creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); creditHistory.setCouponId(couponOrderCVo.getCouponId()); creditHistory.setBusinessId(coupon.getBusiness()); @@ -1358,7 +1390,7 @@ public class PosServiceImpl implements PosService { creditHistory.setOperatorId(buUserId); creditHistory.setCUserId(memId); creditHistory.setCreateDate(new Date()); - creditHistory.setTenantId(merchant.getTenantId()); + creditHistory.updateTenantInfo(merchant); creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); creditHistory.setBusinessId(merchant.getBusinessId()); creditHistory.setSpend(payment); @@ -1389,7 +1421,7 @@ public class PosServiceImpl implements PosService { creditHistory.setOperatorType(EnumUserType.BUSER.getCode()); creditHistory.setOperatorId(buUserId); creditHistory.setCUserId(couponOrderCVo.getcUserId()); - creditHistory.setTenantId(couponOrderCVo.getTenantId()); + creditHistory.updateTenantInfo(couponOrderCVo); creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); creditHistory.setCouponId(couponOrderCVo.getCouponId()); int num = creditHistoryService.cancelCredit(creditHistory); @@ -1404,7 +1436,7 @@ public class PosServiceImpl implements PosService { // 2. 成长值历史回退 try { WxScoreHistory scoreHistory = new WxScoreHistory(); - scoreHistory.setTenantId(couponOrderCVo.getTenantId()); + scoreHistory.updateTenantInfo(couponOrderCVo); scoreHistory.setScoreType(EnumScoreType.CONSUMPTION.getCode()); scoreHistory.setCUserId(couponOrderCVo.getcUserId()); scoreHistory.setOrderId(couponOrderCVo.getOrderId()); @@ -1420,7 +1452,7 @@ public class PosServiceImpl implements PosService { // 3. update posOrderId PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); - posCouponOrderVerify.setTenantId(couponOrderCVo.getTenantId()); + posCouponOrderVerify.updateTenantInfo(couponOrderCVo); posCouponOrderVerify.setCouponOrderId(couponOrderCVo.getId()); posCouponOrderVerify.setPosOrderId(posOrderId); posCouponOrderVerify.setState(EnumEnableType.Enable.getCode()); @@ -1444,7 +1476,7 @@ public class PosServiceImpl implements PosService { try { WxCouponOrder couponOrder = new WxCouponOrder(); couponOrder.setId(couponOrderCVo.getId()); - couponOrder.setTenantId(couponOrderCVo.getTenantId()); + couponOrder.updateTenantInfo(couponOrderCVo); couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); couponOrder.setUpdateDate(new Date()); num = couponOrderMapper.cancelVerifyCouponOrder(couponOrder); @@ -1481,7 +1513,14 @@ public class PosServiceImpl implements PosService { } else { retMap.put(WxPayConstant.TENANT_ID, tenantId); } - PosMallConfig config = posMallConfigService.getByTenantId(tenantId); + WxMall mall = mallService.getByTenantId(tenantId); + if (mall == null) { + logger.error(ErrorCode.MALL_INFO_NOT_FOUND.getMessage()); + throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); + } + + TenantEntity tenantEntity = mall.getTenantInfo(); + PosMallConfig config = posMallConfigService.getByTenantInfo(tenantEntity); if (config == null) { logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); @@ -1558,7 +1597,7 @@ public class PosServiceImpl implements PosService { throw new MallinkException(ErrorCode.CARD_IS_NOT_FOUND); } if (StringUtils.isNotBlank(memIdStr) || StringUtils.isNotBlank(memPhoneStr)) { - WxCUser cuUser = getMemUser(tenantId, memIdStr, memPhoneStr); + WxCUser cuUser = getMemUser(merchant, memIdStr, memPhoneStr); if (cuUser == null) { logger.error(ErrorCode.USER_NOT_MEMBER.getMessage()); throw new MallinkException(ErrorCode.USER_NOT_MEMBER); @@ -1578,7 +1617,7 @@ public class PosServiceImpl implements PosService { WxCardSpend record = new WxCardSpend(); record.setPayFrom(EnumCardSpendFrom.POS.getCode()); - record.setTenantId(merchant.getTenantId()); + record.updateTenantInfo(merchant); record.setCardId(cardId); record.setOwnerId(couponOrder.getOwnerId()); record.setMerchantId(merchantId); @@ -1626,7 +1665,15 @@ public class PosServiceImpl implements PosService { } else { retMap.put(WxPayConstant.TENANT_ID, tenantId); } - PosMallConfig config = posMallConfigService.getByTenantId(tenantId); + WxMall mall = mallService.getByTenantId(tenantId); + if (mall == null) { + logger.error(ErrorCode.MALL_INFO_NOT_FOUND.getMessage()); + throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); + } + + TenantEntity tenantEntity = mall.getTenantInfo(); + + PosMallConfig config = posMallConfigService.getByTenantInfo(tenantEntity); if (config == null) { logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); @@ -1795,7 +1842,15 @@ public class PosServiceImpl implements PosService { if (StringUtils.isBlank(tenantId)) { errParam(WxPayConstant.TENANT_ID); } - PosMallConfig config = posMallConfigService.getByTenantId(tenantId); + WxMall mall = mallService.getByTenantId(tenantId); + if (mall == null) { + logger.error(ErrorCode.MALL_INFO_NOT_FOUND.getMessage()); + throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND); + } + + TenantEntity tenantEntity = mall.getTenantInfo(); + + PosMallConfig config = posMallConfigService.getByTenantInfo(tenantEntity); if (config == null) { logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); @@ -2012,7 +2067,7 @@ public class PosServiceImpl implements PosService { final IdWorker idWorker = IdWorker.get(); Long id = idWorker.nextId(); setId(id); - setTenantId(merchantBUser.getTenantId()); + updateTenantInfo(merchantBUser); setCUserId(memId); setOrderId(order.getId()); setCreateTime(curDate); @@ -2058,7 +2113,7 @@ public class PosServiceImpl implements PosService { final IdWorker idWorker = IdWorker.get(); Long id = idWorker.nextId(); setId(id); - setTenantId(merchantBUser.getTenantId()); + updateTenantInfo(merchantBUser); setCUserId(memId); setBUserId(merchantBUser.getId()); setOrderId(order.getId()); @@ -2143,7 +2198,7 @@ public class PosServiceImpl implements PosService { final IdWorker idWorker = IdWorker.get(); Long id = idWorker.nextId(); setId(id); - setTenantId(buUser.getTenantId()); + updateTenantInfo(buUser); setCUserId(memId); setBUserId(buUser.getId()); setOrderId(order.getId()); @@ -2206,7 +2261,7 @@ public class PosServiceImpl implements PosService { final IdWorker idWorker = IdWorker.get(); Long id = idWorker.nextId(); setId(id); - setTenantId(buUser.getTenantId()); + updateTenantInfo(buUser); setCUserId(memId); setOrderId(order.getId()); setCreateTime(curDate); @@ -2269,7 +2324,7 @@ public class PosServiceImpl implements PosService { // 1. pay order // 查找支付订单 WxPayOrder payOrderQ = new WxPayOrder() {{ - setTenantId(refundOrder.getTenantId()); + updateTenantInfo(refundOrder); setCUserId(refundOrder.getCUserId()); setOrderId(refundOrder.getId()); setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); @@ -2292,7 +2347,7 @@ public class PosServiceImpl implements PosService { Long id = idWorker.nextId(); setId(id); setRefundId(String.valueOf(id)); - setTenantId(buUser.getTenantId()); + updateTenantInfo(buUser); setCUserId(memId); setOrderId(refundOrder.getId()); setCreateTime(curDate); @@ -2360,7 +2415,7 @@ public class PosServiceImpl implements PosService { final IdWorker idWorker = IdWorker.get(); Long orderId = idWorker.nextId(); setId(orderId); - setTenantId(merchantBUser.getTenantId()); + updateTenantInfo(merchantBUser); setOrderNumber(orderId); setType(EnumOrderType.POSPAY.getCode()); setProductId(merchantBUser.getId()); @@ -2439,7 +2494,7 @@ public class PosServiceImpl implements PosService { final IdWorker idWorker = IdWorker.get(); Long orderId = idWorker.nextId(); setId(orderId); - setTenantId(buUser.getTenantId()); + updateTenantInfo(buUser); setType(EnumOrderType.POSPAY.getCode()); setProductId(buUser.getId()); setCUserId(memId); diff --git a/mallinkPosApi/src/test/java/com/iformall/pos/test/PosAppTest.java b/mallinkPosApi/src/test/java/com/iformall/pos/test/PosAppTest.java index 070abd7dd..bf64c49a7 100644 --- a/mallinkPosApi/src/test/java/com/iformall/pos/test/PosAppTest.java +++ b/mallinkPosApi/src/test/java/com/iformall/pos/test/PosAppTest.java @@ -58,7 +58,7 @@ public class PosAppTest { private static final String phone = "13120223636"; private static final String password = "drpos345"; - private static final String posSN = "1"; + private static final String posSN = "WDPS0110GW175210001"; /* 可用的交易券, 支付可用(1, 2, 6), 核销可用(4, 6, 8, 9) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/BillNotificationSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/BillNotificationSchedule.java index f9385cab2..3264fc85d 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/BillNotificationSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/BillNotificationSchedule.java @@ -55,6 +55,7 @@ public class BillNotificationSchedule { List> oweBillList = wxBillAllMapper.getOweBill(); for (Map bill : oweBillList) { String tenantId = bill.get("tenantId").toString(); + String subTenantId = bill.get("subTenantId").toString(); logger.info("欠缴账单:" + JSONObject.toJSONString(bill)); BigDecimal owe = (BigDecimal) bill.get("owe"); BigDecimal price = owe.divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN); @@ -69,6 +70,7 @@ public class BillNotificationSchedule { wxMsgRecord.setReceiver(phone); wxMsgRecord.updateTenantInfo(new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}); Map map = new HashedMap(); map.put("price", price.toString()); @@ -84,6 +86,7 @@ public class BillNotificationSchedule { List> waitBillList = wxBillAllMapper.getWaitPayBill(); for (Map bill : waitBillList) { String tenantId = bill.get("tenantId").toString(); + String subTenantId = bill.get("subTenantId").toString(); logger.info("待缴账单账单:" + JSONObject.toJSONString(bill)); String receiveDate = bill.get("receiveDate").toString(); @@ -100,6 +103,7 @@ public class BillNotificationSchedule { wxMsgRecord.setReceiver(phone); wxMsgRecord.updateTenantInfo(new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}); Map map = new HashedMap(); map.put("price", price.toString()); diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java index ccf1949d4..94addee48 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java @@ -12,6 +12,7 @@ import com.iformall.enums.EnumCarCmd; import com.iformall.enums.EnumChartType; import com.iformall.mapper.*; import com.iformall.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -80,6 +81,9 @@ public class ChartDataSchedule { for (WxMall wxMall : wxMalls) { TenantEntity tenantEntity = wxMall.getTenantInfo(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", wxMall.getTenantId()); + } wxChartDataEntity.updateTenantInfo(tenantEntity); wxChartDataEntity.setType(EnumChartType.CAR_OUT.getCode()); int count = wxChartDataMapper.selectCount(new QueryWrapper(wxChartDataEntity)); @@ -139,6 +143,9 @@ public class ChartDataSchedule { for (WxMall wxMall : wxMalls) { TenantEntity tenantEntity = wxMall.getTenantInfo(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } wxChartDataEntity.updateTenantInfo(tenantEntity); wxChartDataEntity.setType(EnumChartType.SALE_COUPON_PRICE.getCode()); int count = wxChartDataMapper.selectCount(new QueryWrapper(wxChartDataEntity)); @@ -170,6 +177,9 @@ public class ChartDataSchedule { for (WxMall wxMall : wxMalls) { TenantEntity tenantEntity = wxMall.getTenantInfo(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } wxChartDataEntity.updateTenantInfo(tenantEntity); wxChartDataEntity.setType(EnumChartType.MERCHANT_TRADE.getCode()); diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java index 737849079..a0feb8e87 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java @@ -12,6 +12,7 @@ import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.utils.CreditUtil; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -96,12 +97,12 @@ public class CouponSendSchedule { //查找所有couponSendConfig Map mallConfigMap = getAllCouponSendConfig(EnumCouponSendSendType.TIMED.getCode()); mallList.stream().forEach(mall -> { + TenantEntity tenantEntity = mall.getTenantInfo(); //判断启用状态,状态为关闭时跳过不执行 if (isCouponSendDisable(mallConfigMap, mall)) { logger.info("定时发券: {}发券状态关闭, 任务跳过不执行", mall.getName()); return; } - TenantEntity tenantEntity = mall.getTenantInfo(); WxLevelConfig wxLevelConfig = new WxLevelConfig(); wxLevelConfig.updateTenantInfo(tenantEntity); List levelConfigList = WxLevelConfigMapper.findList(wxLevelConfig); @@ -160,6 +161,9 @@ public class CouponSendSchedule { int sentCount = couponSendList.stream().map(cs -> { Map params = new HashMap(); params.put("tenantId", cs.getTenantId()); + if (StringUtils.isNotBlank(cs.getSubTenantId())) { + params.put("subTenantId", cs.getSubTenantId()); + } params.put("cUserId", cu.getId()); params.put("couponId", cs.getCouponId()); params.put("startTime", startTime); diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index f484b9c48..2d5ef3854 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -293,6 +293,7 @@ public enum ErrorCode{ REFUND_ORDER_BUSER_IS_NULL(12015, "B端用户不存在"), REFUND_ORDER_BUSER_NOT_EQUAL(12016, "B端用户无操作权限"), + APP_ID_NOT_ENABLE(12019, "APP未启用"), APP_ID_NOT_FOUND(12020, "APPID没找到"), MCH_INFO_NOT_FOUND(12021, "微信商户平台信息没找到"), MCH_INFO_NOT_EQUAL(12022, "微信商户平台信息不对应"), diff --git a/mallinkService/src/main/java/com/iformall/domain/po/MallUserInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/MallUserInfo.java index 7a260ed83..f67263c46 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/MallUserInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/MallUserInfo.java @@ -133,6 +133,20 @@ public class MallUserInfo extends TenantEntity { } return false; } - + + /** + * 是否集团管理员 + * @return + */ + public boolean checkGroupAdmin() { + if(StringUtils.isBlank(getTenantId())) { + return false; + } + if(StringUtils.isBlank(getSubTenantId()) && + isAdmin.equals(EnumUserAdmin.ADMIN.getCode())) { + return true; + } + return false; + } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxAppinfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAppinfo.java index a395e7bd4..d35f5aa35 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAppinfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAppinfo.java @@ -40,5 +40,9 @@ public class WxAppinfo extends BaseTenantEntity { private Integer type; @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account_bill",name="payBillId") private Long payBillId; + @io.swagger.annotations.ApiModelProperty(value="集团支持(0:不支持,1支持)",name="groupSupport") + private Integer groupSupport; + @io.swagger.annotations.ApiModelProperty(value="是否启用(0:启用,1禁用)",name="enable") + private Integer enable; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java index a1c7e3ce4..44fa9e6b1 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java @@ -69,5 +69,9 @@ public class WxAuthorizerInfo extends BaseTenantEntity { private String accessToken; @io.swagger.annotations.ApiModelProperty(value="accessToken过期时间",name="accessTokenExpire") private Date accessTokenExpire; + @io.swagger.annotations.ApiModelProperty(value="集团支持(0:不支持,1支持)",name="groupSupport") + private Integer groupSupport; + @io.swagger.annotations.ApiModelProperty(value="是否启用(0:启用,1禁用)",name="enable") + private Integer enable; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCarCmdLog.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCarCmdLog.java index b05d90f27..a06c55e05 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCarCmdLog.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCarCmdLog.java @@ -1,5 +1,6 @@ package com.iformall.domain.po; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.domain.po.base.TenantEntity; import lombok.Data; @@ -24,5 +25,25 @@ public class WxCarCmdLog extends TenantEntity { private Date updateDate; @io.swagger.annotations.ApiModelProperty(value="命令请求或者结果及相应花费的时间",name="cmdJson") private String cmdJson; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="synId",name="synId") + private String synId; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="车牌",name="plateNumber") + private String plateNumber; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="停车费",name="fee") + private String fee; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="orderId",name="orderId") + private String orderId; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="feeTime",name="feeTime") + private String feeTime; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxChartDataEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/WxChartDataEntity.java index d3a309c65..02e9e8190 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxChartDataEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxChartDataEntity.java @@ -24,6 +24,9 @@ public class WxChartDataEntity extends TenantEntity { sb.append("WxChartDataEntity{") .append("id=").append(id) .append(", tenantId='").append(getTenantId()).append('\''); + if (getSubTenantId() != null) { + sb.append(", subTenantId='").append(getSubTenantId()).append('\''); + } sb.append(", type=").append(type) .append(", result='").append(result).append('\'') .append(", querytime=").append(querytime) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java index 1f05c0a25..2002ef203 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java @@ -1,5 +1,6 @@ package com.iformall.domain.po; +import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; @@ -7,6 +8,7 @@ import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.base.TenantEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; import java.util.Date; @@ -21,6 +23,8 @@ public class WxMall extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="父租户ID",name="parentTenantId") + private String parentTenantId; @io.swagger.annotations.ApiModelProperty(value="商场名",name="name") private String name; @TableField(value = "`group`") @@ -73,12 +77,22 @@ public class WxMall extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value = "启用结束时间", name = "validEnd") private Date validEnd; + @io.swagger.annotations.ApiModelProperty(value="集团支持(0:不支持,1支持)",name="groupSupport") + private Integer groupSupport; + @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") + private BigDecimal longitude; + @io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude") + private BigDecimal latitude; + @TableField(exist = false) protected List buildings; @TableField(exist = false) private boolean valid; + @TableField(exist = false) + protected List subMalls; + public boolean isValid() { if(saleType != null) { if(validStart != null && validEnd != null) { @@ -109,13 +123,25 @@ public class WxMall extends BaseEntity { private String tenantInfo; public TenantEntity getTenantInfo() { - TenantEntity mul = new TenantEntity(); - mul.setTenantId(getTenantId()); - return mul; + if (StringUtils.isBlank(getParentTenantId())) { + TenantEntity single = new TenantEntity(); + single.setTenantId(getTenantId()); + return single; + } else { + TenantEntity mul = new TenantEntity(); + mul.setTenantId(getParentTenantId()); + mul.setSubTenantId(getTenantId()); + return mul; + } } public void setTenantInfo(TenantEntity tenantInfo) { - setTenantId(tenantInfo.getTenantId()); + if (StringUtils.isBlank(tenantInfo.getSubTenantId())) { + setTenantId(tenantInfo.getTenantId()); + } else { + setTenantId(tenantInfo.getSubTenantId()); + setParentTenantId(tenantInfo.getTenantId()); + } } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java index cdc4e68f1..844b41131 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; /** * @author Stormeye @@ -15,16 +16,26 @@ public class BaseTenantEntity extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="子租户ID",name="subTenantId") + private String subTenantId; + @TableField(exist = false) @JsonProperty(access = JsonProperty.Access.READ_ONLY) private TenantEntity tenantInfo; public void updateTenantInfo(TenantEntity info) { setTenantId(info.getTenantId()); + if (StringUtils.isNotBlank(info.getSubTenantId())) { + setSubTenantId(info.getSubTenantId()); + } } public void updateTenantInfo(BaseTenantEntity info) { setTenantId(info.getTenantId()); + if (StringUtils.isNotBlank(info.getSubTenantId())) { + setSubTenantId(info.getSubTenantId()); + } } public TenantEntity getTenantInfo() { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java index f9c96156d..420583ca9 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java @@ -2,6 +2,7 @@ package com.iformall.domain.po.base; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; /** * @author Stormeye @@ -13,11 +14,20 @@ public class TenantEntity extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="子租户ID",name="subTenantId") + private String subTenantId; + public void updateTenantInfo(TenantEntity info) { setTenantId(info.getTenantId()); + if (StringUtils.isNotBlank(info.getSubTenantId())) { + setSubTenantId(info.getSubTenantId()); + } } public void updateTenantInfo(BaseTenantEntity info) { setTenantId(info.getTenantId()); + if (StringUtils.isNotBlank(info.getSubTenantId())) { + setSubTenantId(info.getSubTenantId()); + } } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java index b7c51e115..cb5bd4e1f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java @@ -33,6 +33,13 @@ public class InvestBaseEntity extends TenantEntity { @JsonProperty(access = JsonProperty.Access.READ_ONLY) private String tenantId; + /** + * 子租户ID + */ + @io.swagger.annotations.ApiModelProperty(value = "子租户ID", name = "subTenantId") + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private String subTenantId; + /** * 创建时间 */ diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/BaseMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/BaseMsg.java index b74a817da..4b3d86a31 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/BaseMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/BaseMsg.java @@ -27,6 +27,10 @@ public class BaseMsg extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") private String tenantId; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="子租户id",name="subTenantId") + private String subTenantId; + @io.swagger.annotations.ApiModelProperty(value="唯一标识",name="uuid") @TableField(exist = false) private String uuid; @@ -53,15 +57,18 @@ public class BaseMsg extends BaseEntity { public void updateTenantInfo(TenantEntity tenantEntity) { setTenantId(tenantEntity.getTenantId()); + setSubTenantId(tenantEntity.getSubTenantId()); } public void updateTenantInfo(BaseTenantEntity tenantEntity) { setTenantId(tenantEntity.getTenantId()); + setSubTenantId(tenantEntity.getSubTenantId()); } public TenantEntity getTenantInfo() { return new TenantEntity() {{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCLoginMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCLoginMsg.java index 8b4209abb..ec3975a68 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCLoginMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCLoginMsg.java @@ -12,6 +12,8 @@ public class FmInsideCLoginMsg extends BaseMsg{ @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="子租户id",name="subTenantId") + private String subTenantId; @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "cUserId") private Long cUserId; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java index 880fd5c81..9f4f62ffe 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java @@ -12,6 +12,8 @@ public class FmInsideCouponVerifyMsg extends BaseMsg{ @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="子租户id",name="subTenantId") + private String subTenantId; @io.swagger.annotations.ApiModelProperty(value = "券包ID", name = "couponOrderId") private Long couponOrderId; @io.swagger.annotations.ApiModelProperty(value = "B端用户ID", name = "bUserId") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideOrderSuccessMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideOrderSuccessMsg.java index 74d0845d0..96db784e8 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideOrderSuccessMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideOrderSuccessMsg.java @@ -11,6 +11,8 @@ public class FmInsideOrderSuccessMsg extends BaseMsg{ @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="子租户id",name="subTenantId") + private String subTenantId; @io.swagger.annotations.ApiModelProperty(value = "成功订单ID", name = "orderId") private Long orderId; @io.swagger.annotations.ApiModelProperty(value = "券ID", name = "couponId") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/WxMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/WxMsg.java index 264410a13..38069e19c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/WxMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/WxMsg.java @@ -22,6 +22,8 @@ public class WxMsg extends BaseMsg { @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="子租户ID",name="subTenantId") + private String subTenantId; @io.swagger.annotations.ApiModelProperty(value = "模板id", name = "modelId") private Long modelId; @io.swagger.annotations.ApiModelProperty(value = "内容", name = "msg") diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantBuInfoVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantBuInfoVo.java new file mode 100644 index 000000000..e5f881e31 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantBuInfoVo.java @@ -0,0 +1,26 @@ +package com.iformall.domain.vo; + +import com.iformall.domain.po.base.TenantEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WxMerchantBuInfoVo extends TenantEntity { + + @ApiModelProperty(value="广场名",name="tenantName") + private String tenantName; + + @ApiModelProperty(value="商户ID",name="merchantId") + private Long merchantId; + + @ApiModelProperty(value="商户名",name="merchantName") + private String merchantName; + + @ApiModelProperty(value="商户图片",name="imgUrl") + private String imgUrl; + + @ApiModelProperty(value="b端用户ID",name="buUserId") + private Long buUserId; +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumGroupSupport.java b/mallinkService/src/main/java/com/iformall/enums/EnumGroupSupport.java new file mode 100644 index 000000000..8aef78467 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumGroupSupport.java @@ -0,0 +1,36 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2019/09/21 + */ +public enum EnumGroupSupport { + + NOT_SUPPORT(0, "不支持"), + SUPPORT(1, "支持"), + ; + + public static EnumGroupSupport getEnum(Integer code) { + for (EnumGroupSupport value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumGroupSupport(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/KwMerchantMeterMapper.java b/mallinkService/src/main/java/com/iformall/mapper/KwMerchantMeterMapper.java index 018afde76..37ca31cd0 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/KwMerchantMeterMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/KwMerchantMeterMapper.java @@ -28,6 +28,6 @@ public interface KwMerchantMeterMapper extends CommonMapper getMerchantMeter(@Param("tenantId") String tenantId); + List getMerchantMeter(@Param("tenantId") String tenantId, @Param("subTenantId") String subTenantId); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/PosMallConfigMapper.java b/mallinkService/src/main/java/com/iformall/mapper/PosMallConfigMapper.java index 034f4985a..6371e06c3 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/PosMallConfigMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/PosMallConfigMapper.java @@ -8,9 +8,10 @@ public interface PosMallConfigMapper extends CommonMapper { List findList(PosMallConfig posMallConfig); + @Deprecated PosMallConfig getByTenantId(String tenantId); - PosMallConfig getByTenantInfo(String tenantId); + PosMallConfig getByTenantInfo(String tenantId, String subTenantId); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBusinessMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBusinessMapper.java index c258320a4..aad5748e8 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBusinessMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBusinessMapper.java @@ -11,8 +11,8 @@ public interface WxBusinessMapper extends CommonMapper { List findList(WxBusiness wxBusiness); List findListAll(); - List findListForMerchant(@Param("tenantId") String tenantId); - List findListForCoupon(@Param("tenantId") String tenantId); + List findListForMerchant(@Param("tenantId") String tenantId, @Param("subTenantId") String subTenantId); + List findListForCoupon(@Param("tenantId") String tenantId, @Param("subTenantId") String subTenantId); List> businessDataList(WxBusiness wxBusiness); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCampaignMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCampaignMapper.java index 531febd7d..03164987c 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCampaignMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCampaignMapper.java @@ -2,7 +2,6 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCampaign; -import com.iformall.domain.po.base.TenantEntity; import java.util.List; @@ -15,7 +14,7 @@ public interface WxCampaignMapper extends CommonMapper { List findCList(WxCampaign wxCampaign); - int getMaxSortNum(String tenantId); + int getMaxSortNum(String tenantId, String subTenantId); List queryNotify(WxCampaign wxCampaign); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCarCmdLogMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCarCmdLogMapper.java index e71d32bc4..abc96882f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCarCmdLogMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCarCmdLogMapper.java @@ -24,11 +24,11 @@ public interface WxCarCmdLogMapper extends CommonMapper { List> queryPlateNumberList(Map carParams); - List queryTenantIdBySynId(HashMap params); + List queryTenantInfoBySynId(WxCarCmdLog wxCarCmdLog); Long queryWeekCarPayCount(HashMap params); - WxCarCmdLog queryByOrderId(HashMap params); + WxCarCmdLog queryByOrderId(WxCarCmdLog carCmdLog); WxCarCmdLog queryBySynId(HashMap params); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java index b04f7a851..bd7b7ed44 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java @@ -33,10 +33,10 @@ public interface WxCouponActionLogMapper extends CommonMapper { * @param endTime * @return */ - List queryPriceTotalGroup(@Param("tenantId")String tenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); + List queryPriceTotalGroup(@Param("tenantId")String tenantId, @Param("subTenantId")String subTenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); List queryForSceneRepotyHistoryVerified(HashMap params); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java index 28d073dd7..68fdac77f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java @@ -11,6 +11,10 @@ public interface WxMallMapper extends CommonMapper { WxMall getByTenantId(String tenantId); + WxMall getByTenantInfo(WxMall wxMall); + String queryMenusByTenantId(String tenantId); + String queryMenusByTenantInfo(WxMall wxMall); + } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxMerchantBUserMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxMerchantBUserMapper.java index 627c9b894..a0c92529f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxMerchantBUserMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxMerchantBUserMapper.java @@ -3,11 +3,13 @@ package com.iformall.mapper; import java.util.*; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxMerchantBUser; +import com.iformall.domain.vo.WxMerchantBuInfoVo; public interface WxMerchantBUserMapper extends CommonMapper { List findList(WxMerchantBUser wxMerchantBUser); + List findSelMerchantList(WxMerchantBUser wxMerchantBUser); WxMerchantBUser findByToken(String token); diff --git a/mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java b/mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java index eee36bb43..d24bf11fa 100644 --- a/mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java @@ -192,5 +192,5 @@ public interface MallUserInfoService { * @param record * @return */ - Set getUserPermissions(MallUserInfo record); + Set getUserPermissions(MallUserInfo record, boolean boolNav); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCarCmdLogService.java b/mallinkService/src/main/java/com/iformall/service/WxCarCmdLogService.java index 4d66bcdc3..7fdbe4a46 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCarCmdLogService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCarCmdLogService.java @@ -45,12 +45,12 @@ public interface WxCarCmdLogService { /** * 根据synId获取tenantId - * @param params + * @param carCmdLog * @return */ - String getTenantIdBySynId(HashMap params); + WxCarCmdLog getTenantInfoBySynId(WxCarCmdLog carCmdLog); - WxCarCmdLog getByOrderId(HashMap params); + WxCarCmdLog getByOrderId(WxCarCmdLog carCmdLog); WxCarCmdLog getBySynId(HashMap params); diff --git a/mallinkService/src/main/java/com/iformall/service/WxMallService.java b/mallinkService/src/main/java/com/iformall/service/WxMallService.java index 6c4c786f6..f70aebb20 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMallService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMallService.java @@ -62,5 +62,11 @@ public interface WxMallService { @Deprecated WxMall getByTenantIdExt(String id); + /** + * 集团查找子广场 + * @param parentTenantId + * @return + */ + List getSubByParentTenantId(String parentTenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxMerchantBUserService.java b/mallinkService/src/main/java/com/iformall/service/WxMerchantBUserService.java index c4dabafee..1f3d0f2b7 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMerchantBUserService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMerchantBUserService.java @@ -4,10 +4,14 @@ import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.WxMerchantBUser; +import com.iformall.domain.vo.WxMerchantBuInfoVo; + +import java.util.List; +import java.util.Map; public interface WxMerchantBUserService { - /** + /** * 根据实体查询分页列表 * * @param record @@ -15,9 +19,9 @@ public interface WxMerchantBUserService { * @param pageSize * @return */ - PageInfo listAsPage(WxMerchantBUser record, Integer pageIndex, Integer pageSize); - - /** + PageInfo listAsPage(WxMerchantBUser record, Integer pageIndex, Integer pageSize); + + /** * 根据Id获得实体 * * @param id @@ -39,14 +43,16 @@ public interface WxMerchantBUserService { * @param record * @return */ - WxMerchantBUser getBUserByAppId(WxMerchantBUser record); - - /** + List getBUserByAppId(WxMerchantBUser record); + + List getMerchantInfoByBUser(WxMerchantBUser record); + + /** * 保存或更新实体 * * @param record */ - Long saveOrUpdate(WxMerchantBUser record); + Long saveOrUpdate(WxMerchantBUser record); /** * 根据Id删除实体 diff --git a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java index a131855c5..97176f6fe 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java @@ -37,7 +37,7 @@ public interface WxPropertyContractService { * 保存或更新实体 * @param record * @param userId - * @param oldDate + * @param userName * @return */ ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName); @@ -49,7 +49,6 @@ public interface WxPropertyContractService { */ void deleteById(Long id); - void download(HttpServletRequest request, HttpServletResponse response); Object getRentContractStatusInfo(WxPropertyContract record); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java index 9e2e58090..99cf51087 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java @@ -110,6 +110,9 @@ public class DataTowerServiceImpl implements DataTowerService { HashMap rentMap = new HashMap<>(); Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } Calendar instance = Calendar.getInstance(); instance.set(Calendar.DAY_OF_YEAR, 1); @@ -180,6 +183,9 @@ public class DataTowerServiceImpl implements DataTowerService { HashMap carMap = new HashMap<>(); HashMap paramsCar = new HashMap<>(); paramsCar.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + paramsCar.put("subTenantId", tenantEntity.getSubTenantId()); + } paramsCar.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); String startdate = DateUtils.getTimeBefore(30, new Date()); String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); @@ -422,6 +428,9 @@ public class DataTowerServiceImpl implements DataTowerService { //租金 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } Calendar instance = Calendar.getInstance(); instance.set(Calendar.DAY_OF_YEAR, 1); instance.set(Calendar.HOUR_OF_DAY, 0); @@ -485,6 +494,9 @@ public class DataTowerServiceImpl implements DataTowerService { logger.info("停车-月统计-开始"); HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); String startdate = DateUtils.getTimeBefore(30, new Date()); String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); @@ -519,6 +531,9 @@ public class DataTowerServiceImpl implements DataTowerService { logger.info("停车-查询近一周的缴费车辆-开始"); HashMap weekParams = new HashMap<>(); weekParams.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + weekParams.put("subTenantId", tenantEntity.getSubTenantId()); + } String oneWeekStartdate = DateUtils.getTimeBefore(7, new Date()); String oneWeekEndDate = DateUtils.getTimeBefore(1, new Date()); weekParams.put("startdate", oneWeekStartdate + " 00:00:00"); @@ -689,6 +704,9 @@ public class DataTowerServiceImpl implements DataTowerService { logger.info("停车-绑定车牌-开始"); Map carParams=new HashMap<>(); carParams.put("tenantId",tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + carParams.put("subTenantId", tenantEntity.getSubTenantId()); + } carParams.put("startdate",DateUtils.getSystemTime("yyyy-MM-dd 00:00:00")); carParams.put("enddate",DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); long todaybindcar = wxCUserCarMapper.queryCarCount(carParams); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/MallPermissionServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/MallPermissionServiceImpl.java index 871e0840c..ccb19777a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/MallPermissionServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/MallPermissionServiceImpl.java @@ -11,6 +11,7 @@ import com.iformall.domain.po.WxLogicPermission; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.MallPermission; import com.iformall.domain.po.MallUserInfo; +import com.iformall.domain.po.WxMall; import com.iformall.enums.EnumMenuType; import com.iformall.enums.EnumPermissionType; import com.iformall.enums.EnumUserAdmin; @@ -19,6 +20,7 @@ import com.iformall.mapper.MallUserInfoMapper; import com.iformall.mapper.WxLogicPermissionMapper; import com.iformall.mapper.WxMallMapper; import com.iformall.service.MallPermissionService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -75,7 +77,15 @@ public class MallPermissionServiceImpl implements MallPermissionService { public List queryAdminMenuList(MallUserInfo userInfo) { if(userInfo.isFmSuperAdmin() || userInfo.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { - String menus = wxMallMapper.queryMenusByTenantId(userInfo.getTenantId()); + WxMall q = new WxMall() {{ + if (StringUtils.isBlank(userInfo.getSubTenantId())) { + setTenantId(userInfo.getTenantId()); + } else { + setTenantId(userInfo.getSubTenantId()); + setParentTenantId(userInfo.getTenantId()); + } + }}; + String menus = wxMallMapper.queryMenusByTenantInfo(q); JSONArray menuIdList = JSON.parseArray(menus); return menuIdList.toJavaList(Long.class); } else { @@ -109,10 +119,26 @@ public class MallPermissionServiceImpl implements MallPermissionService { if(userInfo.isFmSuperAdmin()) { // 富茂系统管理员,返回所有菜单 return getAllMenuListByParentId(parentId, null, boolNav); - } - else if(userInfo.checkAdmin()) { + } else if (userInfo.checkGroupAdmin()) { + // 集团超管 + if (boolNav) { + WxMall q = new WxMall() {{ + setTenantId(userInfo.getTenantId()); + }}; + String menus = wxMallMapper.queryMenusByTenantInfo(q); + JSONArray menuIdList = JSON.parseArray(menus); + return getAllMenuListByParentId(0L, menuIdList.toJavaList(Long.class), boolNav); + } else { + // 配置菜单时, 返回所有菜单 + return getAllMenuListByParentId(parentId, null, boolNav); + } + } else if (userInfo.checkAdmin()) { // 租户超管 - String menus = wxMallMapper.queryMenusByTenantId(userInfo.getTenantId()); + WxMall q = new WxMall() {{ + setTenantId(userInfo.getSubTenantId()); + setParentTenantId(userInfo.getTenantId()); + }}; + String menus = wxMallMapper.queryMenusByTenantInfo(q); JSONArray menuIdList = JSON.parseArray(menus); return getAllMenuListByParentId(0L, menuIdList.toJavaList(Long.class), boolNav); } else { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java index 06d8cf43a..f4e46b43e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java @@ -254,7 +254,7 @@ public class MallUserInfoServiceImpl implements MallUserInfoService { } @Override - public Set getUserPermissions(MallUserInfo record) { + public Set getUserPermissions(MallUserInfo record, boolean boolNav) { List permsList; if(record.isFmSuperAdmin()) { // 富茂超管 @@ -262,6 +262,16 @@ public class MallUserInfoServiceImpl implements MallUserInfoService { q.setAvailable("Y"); List menuList = mallPermissionMapper.selectList(new QueryWrapper(q)); + permsList = new ArrayList<>(menuList.size()); + for(MallPermission menu : menuList){ + permsList.add(menu.getPermission()); + } + } else if (record.checkGroupAdmin() && !boolNav) { + // 集团超管 + MallPermission q = new MallPermission(); + q.setAvailable("Y"); + List menuList = mallPermissionMapper.selectList(new QueryWrapper(q)); + permsList = new ArrayList<>(menuList.size()); for(MallPermission menu : menuList){ permsList.add(menu.getPermission()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/MarkingDataReportServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/MarkingDataReportServiceImpl.java index 5d68e6a66..c3173b3dd 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/MarkingDataReportServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/MarkingDataReportServiceImpl.java @@ -107,6 +107,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //couponData HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); List couponDatalist = wxCouponOrderMapper.couponDataMap(params); @@ -146,9 +149,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { @Override public Map getSceneData(TenantEntity tenantEntity) { //今日营销投放券数 - int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), addDay(0), addDay(1)); - int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), addDay(-1), addDay(0)); - int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), addDay(-7), addDay(-6)); + int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), addDay(0), addDay(1)); + int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), addDay(-1), addDay(0)); + int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), addDay(-7), addDay(-6)); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 @@ -163,6 +166,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); //停车发券数 停车发券被核销数 核销发券数 核销发券被核销数 @@ -172,6 +178,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //停车发券被核销数 HashMap params1 = new HashMap<>(); params1.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params1.put("subTenantId", tenantEntity.getSubTenantId()); + } params1.put("startTime", addDay(-30)); params1.put("endTime", addDay(1)); params1.put("channelType", EnumCouponSendSendType.CAR_STOP.getCode());//停车 @@ -181,6 +190,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //核销发券被核销数 HashMap params2 = new HashMap<>(); params2.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params2.put("subTenantId", tenantEntity.getSubTenantId()); + } params2.put("startTime", addDay(-30)); params2.put("endTime", addDay(1)); params2.put("channelType", EnumCouponSendSendType.COUPON_VERIFY.getCode());//核销 @@ -190,6 +202,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { // B端刷卡支付被核销数 HashMap params3 = new HashMap<>(); params3.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params3.put("subTenantId", tenantEntity.getSubTenantId()); + } params3.put("startTime", addDay(-30)); params3.put("endTime", addDay(1)); params3.put("channelType", EnumCouponSendSendType.B_MICROPAY.getCode());//B端刷卡支付 @@ -199,6 +214,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { // 购买发券被核销数 HashMap params4 = new HashMap<>(); params4.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params4.put("subTenantId", tenantEntity.getSubTenantId()); + } params4.put("startTime", addDay(-30)); params4.put("endTime", addDay(1)); params4.put("channelType", EnumCouponSendSendType.C_ORDER.getCode());//买券 @@ -266,6 +284,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { public PageInfo getCouponDataList(TenantEntity tenantEntity, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize) { HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } if (markingCouponDataReportDto.getStartTime() != null) params.put("startTime", convertDateAndAdd(markingCouponDataReportDto.getStartTime(), 0)); if (markingCouponDataReportDto.getEndTime() != null) @@ -307,6 +328,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + params.put("subTenantId", tenantEntity.getSubTenantId()); if (markingCouponDataReportDto.getStartTime() != null) { params.put("startTime", convertDateAndAdd(markingCouponDataReportDto.getStartTime(), 0)); @@ -349,6 +371,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { params.clear(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } if(markingCouponDataReportDto.getType().equals(EnumCouponSendSendType.CAR_STOP.getCode())){ //停车 //停车发券被核销数 if (markingCouponDataReportDto.getStartTime() != null) @@ -400,6 +425,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { params.clear(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } if(markingCouponDataReportDto.getType().equals(EnumCouponSendSendType.CAR_STOP.getCode())){ //停车 //获取车辆进场数 if (markingCouponDataReportDto.getStartTime() != null) @@ -724,6 +752,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //核销量 HashMap params2 = new HashMap<>(); params2.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params2.put("subTenantId", tenantEntity.getSubTenantId()); + } if (markingCouponDataReportDto.getStartTime() != null) params2.put("startTime", convertDateAndAdd(markingCouponDataReportDto.getStartTime(),0)); if (markingCouponDataReportDto.getEndTime() != null) @@ -737,6 +768,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //查询UV PV HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("tenantId", tenantEntity.getTenantId()); + } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); List wxUserVisitList = wxUserVisitMapper.touchUsersReportData(params); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PosMallConfigServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PosMallConfigServiceImpl.java index a5a1627fa..c0fab2a41 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PosMallConfigServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PosMallConfigServiceImpl.java @@ -35,7 +35,7 @@ public class PosMallConfigServiceImpl implements PosMallConfigService { @Override public PosMallConfig getByTenantInfo(TenantEntity tenantEntity) { - PosMallConfig config = posMallConfigMapper.getByTenantInfo(tenantEntity.getTenantId()); + PosMallConfig config = posMallConfigMapper.getByTenantInfo(tenantEntity.getTenantId(), tenantEntity.getSubTenantId()); return config; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java index c7d2b2145..1dfe46dfc 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java @@ -11,6 +11,7 @@ import com.iformall.mapper.WxCouponActionLogMapper; import com.iformall.service.PushLimitService; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -40,6 +41,9 @@ public class PushLimitServiceImpl implements PushLimitService { private String getKey(TenantEntity tenantEntity) { StringBuilder sb = new StringBuilder(); sb.append(Constant.PUSH_LIMIT_KEY_PREV).append(tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + sb.append("-").append(tenantEntity.getSubTenantId()); + } return sb.toString(); } @@ -164,6 +168,9 @@ public class PushLimitServiceImpl implements PushLimitService { // 3. check 每人每天多少张券 Map params = new HashMap(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("cUserId", cUserId); int countForUser = wxCouponActionLogMapper.getCountByUser(params); if (countForUser >= pushLimit.getCouponAmount()) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java index 855e321f4..1e60a5a96 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java @@ -303,7 +303,11 @@ public class QrCodeServiceImpl implements QrCodeService { } private String getFileName(TenantEntity tenantEntity, String fn) { - fn = tenantEntity.getTenantId() + "/" + fn; + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + fn = tenantEntity.getTenantId() + "/" + fn; + } else { + fn = tenantEntity.getTenantId() + "/" + tenantEntity.getSubTenantId() + "/" + fn; + } return fn; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java index 2551717db..ee5975f5c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java @@ -734,7 +734,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { @Override public void exportOweBill(WxBillAll wxBillAll, HttpServletRequest request, HttpServletResponse response) { //商场名称 - WxMall wxMall = wxMallMapper.getByTenantId(wxBillAll.getTenantId()); + WxMall q = new WxMall(); + q.setTenantInfo(wxBillAll); + WxMall wxMall = wxMallMapper.getByTenantInfo(q); //映射结果 Map result = new HashMap<>(); result.put("mall", wxMall.getName()); @@ -896,7 +898,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { //映射结果 Map result = new HashMap<>(); - WxMall wxMall = wxMallMapper.getByTenantId(wxBillSettle.getTenantId()); + WxMall q = new WxMall(); + q.setTenantInfo(wxBillSettle); + WxMall wxMall = wxMallMapper.getByTenantInfo(q); result.put("mall", wxMall.getName()); result.put("merchant", wxMerchantMapper.selectById(wxBillSettle.getMerchantId()).getName()); result.put("num", wxBillSettle.getSettleNumber()); @@ -1634,6 +1638,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { if (StringUtils.isBlank(email)) { continue; } + // TODO group String tenantId = (String) mapList.get(0).get("tenantId"); String receiveDate = (String) mapList.get(0).get("receiveDate"); String manager = (String) mapList.get(0).get("manager"); @@ -1692,6 +1697,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { if (StringUtils.isBlank(email)) { continue; } + // TODO group String tenantId = (String) mapList.get(0).get("tenantId"); String receiveDate = (String) mapList.get(0).get("receiveDate"); String manager = (String) mapList.get(0).get("manager"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java index 3479caa62..11de32dab 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java @@ -20,6 +20,7 @@ import com.iformall.service.WxBillActionService; import com.iformall.service.WxBillDailyService; import com.iformall.service.WxPayAccountBillService; import com.iformall.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -105,6 +106,9 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { public void updateWaidPayStatus(WxBillDaily record) { Map params = new HashMap<>(); params.put("tenantId", record.getTenantId()); + if (StringUtils.isNotBlank(record.getSubTenantId())) { + params.put("subTenantId", record.getSubTenantId()); + } params.put("waitPay", EnumBillDailyStatus.WAIT_PAY.getCode()); params.put("paid", EnumBillRentStatus.PAID.getCode()); try { @@ -120,6 +124,9 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { public void updateNotPaidStatus(WxBillDaily record) { Map params = new HashMap<>(); params.put("tenantId", record.getTenantId()); + if (StringUtils.isNotBlank(record.getSubTenantId())) { + params.put("subTenantId", record.getSubTenantId()); + } params.put("notPaid", EnumBillDailyStatus.NOT_PAID.getCode()); params.put("paid", EnumBillRentStatus.PAID.getCode()); try { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java index b42048a19..dfaec6caa 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBusinessServiceImpl.java @@ -54,9 +54,9 @@ public class WxBusinessServiceImpl implements WxBusinessService { if (filter == null) return wxBusinessMapper.findListAll(); else if (filter.equals(EnumBusinessFilter.FILTER_BY_COUPON.getCode())) - return wxBusinessMapper.findListForCoupon(tenantEntity.getTenantId()); + return wxBusinessMapper.findListForCoupon(tenantEntity.getTenantId(), tenantEntity.getSubTenantId()); else if (filter.equals(EnumBusinessFilter.FILTER_BY_MERCHANT.getCode())) - return wxBusinessMapper.findListForMerchant(tenantEntity.getTenantId()); + return wxBusinessMapper.findListForMerchant(tenantEntity.getTenantId(), tenantEntity.getSubTenantId()); else return wxBusinessMapper.findListAll(); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java index b3affd326..bb9df5c58 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java @@ -288,7 +288,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { @Override public int getMaxSortNum(TenantEntity tenantEntity) { - return wxCampaignMapper.getMaxSortNum(tenantEntity.getTenantId()); + return wxCampaignMapper.getMaxSortNum(tenantEntity.getTenantId(), tenantEntity.getSubTenantId()); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCarCmdLogServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCarCmdLogServiceImpl.java index 6043c6e9b..f47631263 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCarCmdLogServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCarCmdLogServiceImpl.java @@ -48,12 +48,11 @@ public class WxCarCmdLogServiceImpl implements WxCarCmdLogService { public void deleteById(Long id) { wxCarCmdLogMapper.deleteById(id); } - - + @Override - public String getTenantIdBySynId(HashMap params) { + public WxCarCmdLog getTenantInfoBySynId(WxCarCmdLog carCmdLog) { // 同一辆车,一天内可能多次入场 - List list = wxCarCmdLogMapper.queryTenantIdBySynId(params); + List list = wxCarCmdLogMapper.queryTenantInfoBySynId(carCmdLog); if(list.size() > 0) { return list.get(0); } @@ -61,8 +60,8 @@ public class WxCarCmdLogServiceImpl implements WxCarCmdLogService { } @Override - public WxCarCmdLog getByOrderId(HashMap params) { - return wxCarCmdLogMapper.queryByOrderId(params); + public WxCarCmdLog getByOrderId(WxCarCmdLog carCmdLog) { + return wxCarCmdLogMapper.queryByOrderId(carCmdLog); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java index fe715f19e..5b4c203f4 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java @@ -100,6 +100,7 @@ public class WxChartServiceImpl implements WxChartDataService { @Override public ResultData queryData(Map paramsMap) { String tenantId = paramsMap.get("tenantId"); + String subTenantId = paramsMap.get("subTenantId"); Integer chart = Integer.valueOf(paramsMap.get("chart")); String startdate = paramsMap.get("startdate"); String enddate = paramsMap.get("enddate"); @@ -121,6 +122,7 @@ public class WxChartServiceImpl implements WxChartDataService { TenantEntity tenantEntity = new TenantEntity() {{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; //出租率 @@ -623,6 +625,9 @@ public class WxChartServiceImpl implements WxChartDataService { } Map query = new HashedMap(); query.put("tenantId",tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + query.put("subTenantId",tenantEntity.getSubTenantId()); + } query.put("id",paramsMap.get("id")); query.put("buildingId",paramsMap.get("buildingId")); List> mapList = wxMerchantMapper.findBusByFloorId(query); @@ -642,6 +647,9 @@ public class WxChartServiceImpl implements WxChartDataService { Map queryMap = new HashMap<>(); queryMap.put("tenantId",tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + queryMap.put("subTenantId",tenantEntity.getSubTenantId()); + } queryMap.put("dateType",dateType); String building = paramsMap.get("building"); @@ -749,6 +757,9 @@ public class WxChartServiceImpl implements WxChartDataService { //绑定车牌 Map carParams = new HashMap<>(); carParams.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + carParams.put("subTenantId", tenantEntity.getSubTenantId()); + } carParams.put("startdate", DateUtils.getSystemTime("yyyy-MM-dd 00:00:00")); carParams.put("enddate", DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); long todaybindcar = wxCUserCarMapper.queryCarCount(carParams); @@ -788,6 +799,9 @@ public class WxChartServiceImpl implements WxChartDataService { String lastweek = DateUtils.getTimeBefore(7, new Date()); HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); params.put("startdate", systemTime + " 05:00:00"); params.put("enddate", DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); @@ -857,6 +871,9 @@ public class WxChartServiceImpl implements WxChartDataService { HashMap datamap = new HashMap<>(); HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("cmdType", EnumCarCmd.CAR_ETCP_CALLBACK_PARK_IN.getCode()); startdate = DateUtils.getTimeBefore(30, new Date()); String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); @@ -931,6 +948,9 @@ public class WxChartServiceImpl implements WxChartDataService { HashMap datamap = new HashMap<>(); HashMap weekParams = new HashMap<>(); weekParams.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + weekParams.put("subTenantId", tenantEntity.getSubTenantId()); + } String oneWeekStartdate = DateUtils.getTimeBefore(7, new Date()); String oneWeekEndDate = DateUtils.getTimeBefore(1, new Date()); weekParams.put("startdate", oneWeekStartdate + " 00:00:00"); @@ -949,6 +969,9 @@ public class WxChartServiceImpl implements WxChartDataService { HashMap datamap = new HashMap<>(); HashMap weekParams = new HashMap<>(); weekParams.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + weekParams.put("subTenantId", tenantEntity.getSubTenantId()); + } String oneWeekStartdate = DateUtils.getTimeBefore(7, new Date()); String oneWeekEndDate = DateUtils.getTimeBefore(1, new Date()); weekParams.put("startdate", oneWeekStartdate + " 00:00:00"); @@ -1017,6 +1040,9 @@ public class WxChartServiceImpl implements WxChartDataService { HashMap datamap = new HashMap<>(); HashMap weekParams = new HashMap<>(); weekParams.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + weekParams.put("subTenantId", tenantEntity.getSubTenantId()); + } String oneWeekStartdate = DateUtils.getTimeBefore(7, new Date()); String oneWeekEndDate = DateUtils.getTimeBefore(1, new Date()); weekParams.put("startdate", oneWeekStartdate + " 00:00:00"); @@ -1059,6 +1085,9 @@ public class WxChartServiceImpl implements WxChartDataService { //查询UV PV HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("startTime", addDay(-1)); params.put("endTime", addDay(1)); List wxUserVisitList = wxUserVisitMapper.touchUsersReportData(params); @@ -1121,9 +1150,9 @@ public class WxChartServiceImpl implements WxChartDataService { */ private ResultData getSaleSceneCount(TenantEntity tenantEntity) { HashMap datamap = new HashMap<>(); - int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), addDay(0), addDay(1)); - int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), addDay(-1), addDay(0)); - int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), addDay(-7), addDay(-6)); + int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), addDay(0), addDay(1)); + int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), addDay(-1), addDay(0)); + int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), addDay(-7), addDay(-6)); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 String sceneDownDay = "--"; @@ -1150,6 +1179,9 @@ public class WxChartServiceImpl implements WxChartDataService { String enddate;//查询UV PV HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); List wxUserVisitList = wxUserVisitMapper.touchUsersReportData(params); @@ -1189,6 +1221,9 @@ public class WxChartServiceImpl implements WxChartDataService { HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); //停车发券数 停车发券被核销数 核销发券数 核销发券被核销数 @@ -1197,6 +1232,9 @@ public class WxChartServiceImpl implements WxChartDataService { //停车发券被核销数 HashMap params1 = new HashMap<>(); params1.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params1.put("subTenantId", tenantEntity.getSubTenantId()); + } params1.put("startTime", addDay(-30)); params1.put("endTime", addDay(1)); params1.put("channelType", EnumCouponSendSendType.CAR_STOP.getCode());//停车 @@ -1206,6 +1244,9 @@ public class WxChartServiceImpl implements WxChartDataService { //核销发券被核销数 HashMap params2 = new HashMap<>(); params2.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params2.put("subTenantId", tenantEntity.getSubTenantId()); + } params2.put("startTime", addDay(-30)); params2.put("endTime", addDay(1)); params2.put("channelType", EnumCouponSendSendType.COUPON_VERIFY.getCode());//核销 @@ -1215,6 +1256,9 @@ public class WxChartServiceImpl implements WxChartDataService { // B端刷卡支付被核销数 HashMap params3 = new HashMap<>(); params3.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params3.put("subTenantId", tenantEntity.getSubTenantId()); + } params3.put("startTime", addDay(-30)); params3.put("endTime", addDay(1)); params3.put("channelType", EnumCouponSendSendType.B_MICROPAY.getCode());//B端刷卡支付 @@ -1224,6 +1268,9 @@ public class WxChartServiceImpl implements WxChartDataService { // 购买发券被核销数 HashMap params4 = new HashMap<>(); params4.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params4.put("subTenantId", tenantEntity.getSubTenantId()); + } params4.put("startTime", addDay(-30)); params4.put("endTime", addDay(1)); params4.put("channelType", EnumCouponSendSendType.C_ORDER.getCode());//买券 @@ -1472,7 +1519,7 @@ public class WxChartServiceImpl implements WxChartDataService { Date eTime = c.getTime(); c.add(Calendar.DAY_OF_YEAR, -7); Date sTime = c.getTime(); - List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), sTime, eTime); + List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), sTime, eTime); Map dataMap = new HashMap<>(); for (CUserDateAmountVo v : datas) { dataMap.put(v.getXTime(), v.getPrice()); @@ -1513,7 +1560,7 @@ public class WxChartServiceImpl implements WxChartDataService { c.set(Calendar.SECOND, 0); Date eTime = c.getTime();//明天0点 c.add(Calendar.DAY_OF_YEAR, -30);//三十天前 - List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), sTime, eTime); + List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), sTime, eTime); List monthVos = new ArrayList<>();//周消费金额 Map dataMap = new HashMap<>(); for (CUserDateAmountVo v : datas) { @@ -1651,7 +1698,7 @@ public class WxChartServiceImpl implements WxChartDataService { Date eTime = c.getTime();//明天0点 c.add(Calendar.DAY_OF_YEAR, -30);//三十天前 Date sTime = c.getTime(); - List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), sTime, eTime); + List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), sTime, eTime); Map dataMap = new HashMap<>(); for (CUserDateAmountVo v : datas) { dataMap.put(v.getXTime(), v.getPrice()); @@ -1790,6 +1837,9 @@ public class WxChartServiceImpl implements WxChartDataService { //couponData HashMap params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("tenantId", tenantEntity.getSubTenantId()); + } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); List couponDatalist = wxCouponOrderMapper.couponDataMap(params); @@ -2396,6 +2446,9 @@ public class WxChartServiceImpl implements WxChartDataService { private ResultData getSaleGroupAnalysis(Map paramsMap, TenantEntity tenantEntity, String startdate) { Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } //默认时间本月第一天,截止到当天 Map result = new HashMap<>(); Date startTime = new Date(); @@ -2536,6 +2589,7 @@ public class WxChartServiceImpl implements WxChartDataService { //租金 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + params.put("subTenantId", tenantEntity.getSubTenantId()); params.put("startdate", startdate + " 00:00:00"); params.put("enddate", enddate + " 23:59:59"); Map payinfo = wxBillRentMapper.queryPayInfo(params); @@ -2622,6 +2676,7 @@ public class WxChartServiceImpl implements WxChartDataService { HashMap datamap = new HashMap<>(); WxShop query = new WxShop(); String tenantId = paramMap.get("tenantId"); + String subTenantId = paramMap.get("subTenantId"); String building = paramMap.get("building"); String floor = paramMap.get("floor"); String business = paramMap.get("businessId"); @@ -2629,6 +2684,9 @@ public class WxChartServiceImpl implements WxChartDataService { if (StringUtils.isNotEmpty(tenantId)) { query.setTenantId(tenantId); } + if (StringUtils.isNotEmpty(subTenantId)) { + query.setSubTenantId(subTenantId); + } if (StringUtils.isNotEmpty(building)) { query.setBuilding(Long.valueOf(building)); } @@ -2708,6 +2766,9 @@ public class WxChartServiceImpl implements WxChartDataService { //租金收缴率 ysje 应收金额 ssje 实收金额 zjsjl收缴率 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("startdate", DateUtils.date2String(startDate,"yyyy-MM-dd") + " 00:00:00"); params.put("enddate", DateUtils.date2String(endDate,"yyyy-MM-dd") + " 23:59:59"); Map payinfo = wxBillRentMapper.queryPayInfoTotal(params); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java index 53c3c5a5a..c30751adb 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java @@ -72,7 +72,7 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { @Override public int getCountByChannelId(TenantEntity tenantEntity, int channelType, Long channelId) { - return wxCouponActionLogMapper.getCountByChannelId(tenantEntity.getTenantId(), channelType, channelId); + return wxCouponActionLogMapper.getCountByChannelId(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), channelType, channelId); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 1e9e66a28..65f08b520 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -934,7 +934,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { @Override public List queryPriceTotalGroup(TenantEntity tenantEntity, Date startTime, Date endTime) { - return wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), startTime, endTime); + return wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), tenantEntity.getSubTenantId(), startTime, endTime); } @Override @@ -1083,6 +1083,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { public JSONArray queryMicroPayCouponOrder(WxMerchantBUser user, WxCUser cUser, Integer payPrice) { Map coQ = new HashMap<>(); coQ.put("tenantId", user.getTenantId()); + if (StringUtils.isNotBlank(user.getSubTenantId())) { + coQ.put("subTenantId", user.getSubTenantId()); + } coQ.put("cUserId", cUser.getId()); coQ.put("merchantId", user.getMerchantId()); List avaCoList = wxCouponOrderMapper.findAvailCouponOrder(coQ); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPresentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPresentServiceImpl.java index 4ffa891c3..d7b5b0ed0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPresentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPresentServiceImpl.java @@ -7,8 +7,8 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxCouponPassword; import com.iformall.domain.po.WxCouponPresent; -import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.msg.WxMsgRecord; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.*; import com.iformall.mapper.WxCouponPasswordMapper; import com.iformall.mapper.WxCouponPresentMapper; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index c1b984516..c18242ad7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -415,6 +415,9 @@ public class WxFlowServiceImpl implements WxFlowService { map.put("taskAssignee",flowModel.getFlow()); setSignAssignee(map,flowModel.getFlow()); map.put("tenantId",tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + map.put("subTenantId", tenantEntity.getSubTenantId()); + } ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(flowModel.getFlowId(), map); logger.debug("流程启动,流程id:{}",processInstance.getId()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index 0ecefd21e..2c0ae9ca5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -21,6 +21,7 @@ import com.iformall.mapper.WxCouponOrderMapper; import com.iformall.mapper.WxGameActionLogMapper; import com.iformall.mapper.WxGameMapper; import com.iformall.service.*; +import com.iformall.utils.Constant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -312,7 +313,7 @@ public class WxGameServiceImpl implements WxGameService { wxCouponChannel.setId(idWorker.nextId()); wxCouponChannelMapper.insert(wxCouponChannel); - String pageUrl = "pages/index/index"; + String pageUrl = Constant.mainPageUrl; WxCouponChannel couponChannel = new WxCouponChannel(); couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java index 876260ee9..901d54bbc 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java @@ -123,6 +123,9 @@ public class WxMallServiceImpl implements WxMallService { public WxMall getByTenantInfo(TenantEntity tenantEntity) { StringBuilder sb = new StringBuilder(); sb.append(Constant.TENANT_KEY_PREV).append(tenantEntity.getTenantId()); + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + sb.append("-").append(tenantEntity.getSubTenantId()); + } String key = sb.toString(); ValueOperations operations = mallRedisTemplate.opsForValue(); @@ -134,9 +137,17 @@ public class WxMallServiceImpl implements WxMallService { return mall; } // 不存在,从数据库中获取 + WxMall q = new WxMall() {{ + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + setTenantId(tenantEntity.getTenantId()); + } else { + setTenantId(tenantEntity.getSubTenantId()); + setParentTenantId(tenantEntity.getTenantId()); + } + }}; WxMall mall = null; try { - mall = wxMallMapper.getByTenantId(tenantEntity.getTenantId()); + mall = wxMallMapper.getByTenantInfo(q); } catch (Exception e) { logger.error(e.getMessage()); } @@ -236,5 +247,12 @@ public class WxMallServiceImpl implements WxMallService { return wxMall; } + @Override + public List getSubByParentTenantId(String parentTenantId) { + WxMall q = new WxMall(); + q.setParentTenantId(parentTenantId); + List mallList = wxMallMapper.selectList(new QueryWrapper<>(q)); + return mallList; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantBUserServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantBUserServiceImpl.java index ffeda3ad5..07d9735d8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantBUserServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantBUserServiceImpl.java @@ -10,6 +10,7 @@ import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxMerchantBUser; import com.iformall.domain.po.WxMsgValidationcode; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.WxMerchantBuInfoVo; import com.iformall.enums.EnumMerchantBUserStatus; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxAppinfoMapper; @@ -23,6 +24,7 @@ import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -52,12 +54,13 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { } @Override - public WxMerchantBUser getBUserByAppId(WxMerchantBUser record) { - List userList = wxMerchantBUserMapper.findList(record); - if (userList.size() > 0) { - return userList.get(0); - } - return null; + public List getBUserByAppId(WxMerchantBUser record) { + return wxMerchantBUserMapper.findList(record); + } + + @Override + public List getMerchantInfoByBUser(WxMerchantBUser record) { + return wxMerchantBUserMapper.findSelMerchantList(record); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantTradeDailyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantTradeDailyServiceImpl.java index 8d503363c..1a6ede0cc 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantTradeDailyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantTradeDailyServiceImpl.java @@ -84,19 +84,19 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ public ResultData saveDailyTradingVolume(Long userId, Integer volume) { WxMerchantBUser user = wxMerchantBUserService.getById(userId); - - if (user == null) + if (user==null) { return new ResultData(ErrorCode.USER_IS_EMPTY); + } WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); - - if (merchant == null) + if (merchant==null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); + } - WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); - if (mall == null) + WxMall mall = wxMallService.getByTenantInfo(merchant); + if (mall==null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); - + } WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); @@ -283,14 +283,17 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ @Override public ResultData getVolume(WxMerchantTradeDaily merchantTradeDaily, Long userId) { WxMerchantBUser user = wxMerchantBUserService.getById(userId); - if (user == null) + if (user==null) { return new ResultData(ErrorCode.USER_IS_EMPTY); + } WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); - if (merchant == null) + if (merchant==null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); - WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); - if (mall == null) + } + WxMall mall = wxMallService.getByTenantInfo(merchant); + if (mall==null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); + } WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); wxMerchantTradeDaily.setMerchantId(merchant.getId()); @@ -317,19 +320,19 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ public ResultData getVolumeOfWeek(Long userId) { WxMerchantBUser user = wxMerchantBUserService.getById(userId); - - if (user == null) + if (user==null) { return new ResultData(ErrorCode.USER_IS_EMPTY); + } WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); - - if (merchant == null) + if (merchant==null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); + } - WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); - if (mall == null) + WxMall mall = wxMallService.getByTenantInfo(merchant); + if (mall==null) { return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); - + } WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java index f3f9e33da..2b58114fd 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java @@ -180,6 +180,7 @@ public class WxMsgServiceImpl implements WxMsgService { public ResultData add(WxMsg wxMsg){ TenantEntity tenantEntity = new TenantEntity() {{ setTenantId(wxMsg.getTenantId()); + setSubTenantId(wxMsg.getSubTenantId()); }}; //不是草稿检验疲劳度 if (!wxMsg.getStatus().equals(EnumMsgStatus.MSG_STATUS_DRAFT.getCode())) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index af2a14a07..e1ab47ecf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -19,6 +19,7 @@ import com.iformall.mapper.*; import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.utils.*; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -1368,6 +1369,9 @@ public class WxOrderServiceImpl implements WxOrderService { //全部商户个数 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } String thirtyTime = DateUtils.getTimeBefore(29, new Date()); params.put("startdate", thirtyTime + " 00:00:00"); params.put("enddate", systemTime + " 23:59:59"); @@ -1413,6 +1417,9 @@ public class WxOrderServiceImpl implements WxOrderService { //总数 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } String thirtyTime = DateUtils.getTimeBefore(29, new Date()); params.put("startdate", thirtyTime + " 00:00:00"); params.put("enddate", systemTime + " 23:59:59"); @@ -1475,6 +1482,9 @@ public class WxOrderServiceImpl implements WxOrderService { //总数 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } String thirtyTime = DateUtils.getTimeBefore(29, new Date()); params.put("startdate", thirtyTime + " 00:00:00"); params.put("enddate", systemTime + " 23:59:59"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java index d4d6410e8..822c6ed18 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -683,6 +683,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ //全部商户个数 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } String thirtyTime = DateUtils.getTimeBefore(29, new Date()); params.put("startdate", thirtyTime + " 00:00:00"); params.put("enddate", systemTime + " 23:59:59"); @@ -728,6 +731,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ //全部分账总数 Map params = new HashMap<>(); params.put("tenantId", tenantEntity.getTenantId()); + if (StringUtils.isNotBlank(tenantEntity.getSubTenantId())) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } String thirtyTime = DateUtils.getTimeBefore(29, new Date()); params.put("startdate", thirtyTime + " 00:00:00"); params.put("enddate", systemTime + " 23:59:59"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java index 3bf2abeb1..0932ba01c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -169,6 +169,9 @@ public class WxShopServiceImpl implements WxShopService { public ResultData getShopList(TenantEntity tenantEntity, String shopNumber) { Map params=new HashMap<>(); params.put("tenantId",tenantEntity.getTenantId()); + if (tenantEntity.getSubTenantId() != null) { + params.put("subTenantId", tenantEntity.getSubTenantId()); + } params.put("shopNumber",shopNumber); List> list=wxShopMapper.getShopList(params); return new ResultData(ResultData.SUCCESS,"",list); @@ -178,6 +181,9 @@ public class WxShopServiceImpl implements WxShopService { public ResultData getMerchantShopByShopId(TenantEntity tenantEntity, String shopId) { Map params=new HashMap<>(); params.put("tenantId",tenantEntity.getTenantId()); + if (tenantEntity.getSubTenantId() != null) { + params.put("subTenantId",tenantEntity.getSubTenantId()); + } params.put("shopId",shopId); Map map=wxShopMapper.getMerchantShopByShopId(params); return new ResultData(ResultData.SUCCESS,"",map); diff --git a/mallinkService/src/main/java/com/iformall/service/kw/impl/KwMerchantMeterServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/kw/impl/KwMerchantMeterServiceImpl.java index 70d185bcc..6971578d6 100644 --- a/mallinkService/src/main/java/com/iformall/service/kw/impl/KwMerchantMeterServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/kw/impl/KwMerchantMeterServiceImpl.java @@ -90,7 +90,7 @@ public class KwMerchantMeterServiceImpl implements KwMerchantMeterService { @Override public List getMerchantMeter(TenantEntity tenantEntity) { - return kwMerchantMeterMapper.getMerchantMeter(tenantEntity.getTenantId()); + return kwMerchantMeterMapper.getMerchantMeter(tenantEntity.getTenantId(), tenantEntity.getSubTenantId()); } } diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index f9ab8c0a4..1e1421097 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -24,6 +24,7 @@ public class Constant { // C端token public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; public static final String TENANT_ID = "TENANT_ID"; + public static final String SUB_TENANT_ID = "SUB_TENANT_ID"; public static final String adminPage = "https://admin.malls.iformall.com"; diff --git a/mallinkService/src/main/resources/mapper/KwBoxCmdHistoryMapper.xml b/mallinkService/src/main/resources/mapper/KwBoxCmdHistoryMapper.xml index 457f9ea29..c632c129a 100644 --- a/mallinkService/src/main/resources/mapper/KwBoxCmdHistoryMapper.xml +++ b/mallinkService/src/main/resources/mapper/KwBoxCmdHistoryMapper.xml @@ -4,6 +4,7 @@ + @@ -13,7 +14,7 @@ - `id`,`tenant_id`,`imei`,`iccid`,`content`,`info`,`device_time`,`create_time` + `id`,`tenant_id`,`sub_tenant_id`,`imei`,`iccid`,`content`,`info`,`device_time`,`create_time` @@ -26,6 +27,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and id in diff --git a/mallinkService/src/main/resources/mapper/KwBoxMapper.xml b/mallinkService/src/main/resources/mapper/KwBoxMapper.xml index 5d9612423..4e9e4a48b 100644 --- a/mallinkService/src/main/resources/mapper/KwBoxMapper.xml +++ b/mallinkService/src/main/resources/mapper/KwBoxMapper.xml @@ -4,6 +4,7 @@ + @@ -23,7 +24,7 @@ - `id`,`tenant_id`,`imei`,`iccid`,`place`,`fw_version`,`hd_version`,`register_status`,`online_status`,`register_time`, + `id`,`tenant_id`,`sub_tenant_id`,`imei`,`iccid`,`place`,`fw_version`,`hd_version`,`register_status`,`online_status`,`register_time`, `last_online_time`,`config`,`create_time`,`update_time`,`com_key`,`status`,`max_tag_num` @@ -37,6 +38,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `imei` like concat('%', #{imei},'%') diff --git a/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml b/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml index 25f70632a..5b1585b8a 100644 --- a/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml +++ b/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml @@ -4,6 +4,7 @@ + @@ -13,7 +14,7 @@ - `id`,`tenant_id`,`meter_id`,`merchant_id`,`status`,`create_time`,`update_time` + `id`,`tenant_id`,`sub_tenant_id`,`meter_id`,`merchant_id`,`status`,`create_time`,`update_time` @@ -26,6 +27,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `merchant_id` = #{merchantId} @@ -55,7 +60,7 @@ - select m.`id`, m.`total_power` from kw_merchant_meter mm left join kw_meter m on mm.`meter_id` = m.id where mm.`status` = 0 @@ -67,6 +72,7 @@ + @@ -80,7 +86,7 @@ - `id`, `tenant_id`, `merchant_id`, `status`, `name`, `link_phone` + `id`, `tenant_id`, `sub_tenant_id`, `merchant_id`, `status`, `name`, `link_phone` select - temp.tenant_id, + temp.tenant_id, temp.sub_tenant_id, mm.merchant_id as merchantId, m.name as merchantName, @@ -222,7 +233,7 @@ from kw_merchant_meter mm, (SELECT - tenant_id,box_id,meter_id, + tenant_id,sub_tenant_id,box_id,meter_id, min(last_device_time) as recordStartTime, min(last_total_power) as lastTotalPower, max(device_time) as recordEndTime, @@ -230,7 +241,7 @@ sum(used_power) as usedPower FROM kw_meter_data - group by tenant_id,box_id,meter_id + group by tenant_id,sub_tenant_id,box_id,meter_id ) as temp, wx_merchant m where mm.status = 0 @@ -276,9 +287,15 @@ diff --git a/mallinkService/src/main/resources/mapper/KwMeterDataMapper.xml b/mallinkService/src/main/resources/mapper/KwMeterDataMapper.xml index 8c76f0691..667ef1ae2 100644 --- a/mallinkService/src/main/resources/mapper/KwMeterDataMapper.xml +++ b/mallinkService/src/main/resources/mapper/KwMeterDataMapper.xml @@ -4,6 +4,7 @@ + @@ -16,7 +17,7 @@ - `id`,`tenant_id`,`meter_id`,`box_id`,`address`,`total_power`,`device_time`,`create_time`,`used_power`,`last_device_time`,`last_total_power` + `id`,`tenant_id`,`sub_tenant_id`,`meter_id`,`box_id`,`address`,`total_power`,`device_time`,`create_time`,`used_power`,`last_device_time`,`last_total_power` @@ -93,6 +94,7 @@ + @@ -143,7 +145,7 @@ - select from mall_role + select + + from mall_role diff --git a/mallinkService/src/main/resources/mapper/MallRolePermissionMapper.xml b/mallinkService/src/main/resources/mapper/MallRolePermissionMapper.xml index 9aa81ea8e..2813c4fcd 100644 --- a/mallinkService/src/main/resources/mapper/MallRolePermissionMapper.xml +++ b/mallinkService/src/main/resources/mapper/MallRolePermissionMapper.xml @@ -4,12 +4,13 @@ + - `id`,`tenant_id`,`permission_id`,`role_id` + `id`,`tenant_id`,`sub_tenant_id`,`permission_id`,`role_id` @@ -23,6 +24,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `permission_id` = #{permissionId} @@ -47,10 +52,11 @@ - insert into mall_role_permission (id, tenant_id, permission_id, role_id) values + insert into mall_role_permission (id, tenant_id, sub_tenant_id,permission_id, role_id) values (#{item.id,jdbcType=BIGINT}, #{item.tenantId,jdbcType=VARCHAR}, + #{item.subTenantId,jdbcType=VARCHAR}, #{item.permissionId,jdbcType=BIGINT}, #{item.roleId,jdbcType=BIGINT}) diff --git a/mallinkService/src/main/resources/mapper/MallUserActionMapper.xml b/mallinkService/src/main/resources/mapper/MallUserActionMapper.xml index 0f7769fdd..cc8baaa5f 100644 --- a/mallinkService/src/main/resources/mapper/MallUserActionMapper.xml +++ b/mallinkService/src/main/resources/mapper/MallUserActionMapper.xml @@ -3,6 +3,8 @@ + + @@ -11,14 +13,20 @@ - `id`,`user_id`,`type`,`ip`,`action_desc`,`action_time` + `id`,`tenant_id`,`sub_tenant_id`,`user_id`,`type`,`ip`,`action_desc`,`action_time` where 1 = 1 and `id` = #{id} - + + + and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `user_id` = #{userId} @@ -51,6 +59,8 @@ + + @@ -60,7 +70,7 @@ - mua.`id`,mua.`user_id`,mua.`type`,mua.`ip`,mua.`action_desc`,mua.`action_time`,mui.`name` + mua.`id`,mua.`tenant_id`,mua.`sub_tenant_id`,mua.`user_id`,mua.`type`,mua.`ip`,mua.`action_desc`,mua.`action_time`,mui.`name` diff --git a/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml b/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml index b63ec6105..6235909d5 100644 --- a/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml @@ -4,6 +4,7 @@ + @@ -20,11 +21,11 @@ - `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,`web_open_id`,email + `id`,`tenant_id`,`sub_tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,`web_open_id`,email - `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`, + `id`,`tenant_id`,`sub_tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`, `bopen_id`,`web_open_id`,email @@ -37,8 +38,12 @@ and `tenant_id` = #{tenantId} - - + + + and `sub_tenant_id` = #{subTenantId} + + + and `username` like concat('%', #{username},'%') @@ -166,7 +171,7 @@ - + update mall_user_info set `web_open_id` = null where 1=1 @@ -181,7 +186,7 @@ - + update mall_user_info set `web_open_id` = null, `bopen_id` = null where 1=1 @@ -260,6 +265,7 @@ + @@ -281,12 +287,12 @@ - u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`, + u.`id`,u.`tenant_id`,u.`sub_tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`, m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email - u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`, + u.`id`,u.`tenant_id`,u.`sub_tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`, u.`bopen_id`,u.`web_open_id`, m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email diff --git a/mallinkService/src/main/resources/mapper/PosCouponOrderVerifyMapper.xml b/mallinkService/src/main/resources/mapper/PosCouponOrderVerifyMapper.xml index 7de6dec42..bdd7a6906 100644 --- a/mallinkService/src/main/resources/mapper/PosCouponOrderVerifyMapper.xml +++ b/mallinkService/src/main/resources/mapper/PosCouponOrderVerifyMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`coupon_order_id`,`pos_order_id`,`state` + `id`,`tenant_id`,`sub_tenant_id`,`coupon_order_id`,`pos_order_id`,`state` @@ -21,8 +22,11 @@ and `id` = #{id} - and `tenant_id` like concat('%', #{tenantId},'%') - + and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `coupon_order_id` = #{couponOrderId} diff --git a/mallinkService/src/main/resources/mapper/PosMallConfigMapper.xml b/mallinkService/src/main/resources/mapper/PosMallConfigMapper.xml index dd51e8230..d17c036fb 100644 --- a/mallinkService/src/main/resources/mapper/PosMallConfigMapper.xml +++ b/mallinkService/src/main/resources/mapper/PosMallConfigMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`discount`,`coupon`,`card`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,,`discount`,`coupon`,`card`,`create_date`,`update_date` @@ -23,6 +24,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `discount` = #{discount} @@ -64,6 +68,7 @@ from pos_mall_config where 1=1 and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} diff --git a/mallinkService/src/main/resources/mapper/PosOrderMapper.xml b/mallinkService/src/main/resources/mapper/PosOrderMapper.xml index 4e5491b48..64d1a17af 100644 --- a/mallinkService/src/main/resources/mapper/PosOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/PosOrderMapper.xml @@ -15,7 +15,7 @@ - `id`,`tenant_id`,`pos_order_no`,`type`,`order_status`,`bu_user_id`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,`pos_order_no`,`type`,`order_status`,`bu_user_id`,`create_date`,`update_date` @@ -25,7 +25,10 @@ and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} + and `pos_order_no` like concat('%', #{posOrderNo},'%') diff --git a/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml b/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml index 21e0e5b5b..bf109bba1 100644 --- a/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml @@ -4,6 +4,7 @@ + @@ -28,7 +29,7 @@ - `id`,`tenant_id`,`create_time`,`update_time`,`order_id`,`bu_user_id`,`type`,`pay_from`,`pay_amount`,`pay_time_start`,`pay_time_end`,`prepay_id`,`transaction_id`,`pay_vendor`,`pay_order_no`,`pay_order_status`,`share`,`share_amount`,`rate_amount`,`fail_reason`,`auth_code`,`open_id`,`pay_end_from` + `id`,`tenant_id`,`sub_tenant_id`,`create_time`,`update_time`,`order_id`,`bu_user_id`,`type`,`pay_from`,`pay_amount`,`pay_time_start`,`pay_time_end`,`prepay_id`,`transaction_id`,`pay_vendor`,`pay_order_no`,`pay_order_status`,`share`,`share_amount`,`rate_amount`,`fail_reason`,`auth_code`,`open_id`,`pay_end_from` @@ -38,7 +39,10 @@ and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} + and `create_time` = #{createTime} diff --git a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml index d4efafc06..e2b4e74dc 100644 --- a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml +++ b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml @@ -4,6 +4,7 @@ + @@ -16,7 +17,7 @@ - `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_enable`,`time_start`,`time_end`,`create_time`,`update_time`,`enable` + `id`,`tenant_id`,`sub_tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_enable`,`time_start`,`time_end`,`create_time`,`update_time`,`enable` @@ -30,6 +31,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `msg_amount` = #{msgAmount} diff --git a/mallinkService/src/main/resources/mapper/WxActivityJoinMapper.xml b/mallinkService/src/main/resources/mapper/WxActivityJoinMapper.xml index f0cbb1407..6a67a6fdf 100644 --- a/mallinkService/src/main/resources/mapper/WxActivityJoinMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxActivityJoinMapper.xml @@ -4,6 +4,7 @@ + @@ -23,7 +24,7 @@ - `id`,`tenant_id`,`user_id`,`activity_id`,`name`,`nick_name`,`birthday`,`sex`,`phone`, + `id`,`tenant_id`,`sub_tenant_id`,`user_id`,`activity_id`,`name`,`nick_name`,`birthday`,`sex`,`phone`, `address`,`answer`,`sign_in`,`status`,`create_time`,`update_time`,`img_url`,`send_msg` @@ -36,6 +37,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `name` like concat('%', #{name},'%') diff --git a/mallinkService/src/main/resources/mapper/WxActivityMapper.xml b/mallinkService/src/main/resources/mapper/WxActivityMapper.xml index 9cc0714c5..206d4de53 100644 --- a/mallinkService/src/main/resources/mapper/WxActivityMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxActivityMapper.xml @@ -4,6 +4,7 @@ + @@ -30,7 +31,7 @@ - `id`,`tenant_id`,`cover_img`,`title`,`sub_title`,`detail`,`html`,`person_limit`,`activity_start_time`,`activity_end_time`, + `id`,`tenant_id`,`sub_tenant_id`,`cover_img`,`title`,`sub_title`,`detail`,`html`,`person_limit`,`activity_start_time`,`activity_end_time`, `use_credit`,`credit`,`type`,`status`,`start_time`,`end_time`,`question`,`is_expired`,`create_time`,`update_time`,`use_img`, `img_detail`,`send_msg`,`selectques` @@ -45,6 +46,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `title` like concat('%', #{title},'%') diff --git a/mallinkService/src/main/resources/mapper/WxAdminLogMapper.xml b/mallinkService/src/main/resources/mapper/WxAdminLogMapper.xml index 58d33673e..9eca3e4ab 100644 --- a/mallinkService/src/main/resources/mapper/WxAdminLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAdminLogMapper.xml @@ -4,6 +4,7 @@ + @@ -11,7 +12,7 @@ - `id`,`tenant_id`,`url`,`action_date`,`type`,`count` + `id`,`tenant_id`,`sub_tenant_id`,`url`,`action_date`,`type`,`count` @@ -24,7 +25,9 @@ and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} @@ -56,7 +59,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml b/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml index 1f18cb79b..713032e6d 100644 --- a/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml @@ -17,13 +17,14 @@ + `id`,`tenant_id`,`app_id`,`parent_app_id`,`name`, `secret`,`token`,`aes_key`,`msg_data_format`,`access_token`,`last_token_time`,`expires_in`, - `pay_id`,`type`,`pay_bill_id` + `pay_id`,`type`,`pay_bill_id`,`group_support` @@ -85,6 +86,9 @@ and `pay_bill_id` = #{payBillId} + + and `group_support` = #{groupSupport} + and id in diff --git a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml index c5516133c..06a06703f 100644 --- a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml @@ -29,6 +29,8 @@ + + @@ -36,7 +38,7 @@ `base_status`, `base_time`, `domain_status`, `domain_time`, `webdomain_status`, `webdomain_time`, `template_status`, `template_time`, `current_version`,`current_desc`,`release_time`, `open_appid`,`bind_open_time`,`refresh_token`, - `access_token`,`access_token_expire` + `access_token`,`access_token_expire`,`group_support`,`enable` @@ -113,6 +115,12 @@ and `bind_open_time` = #{bindOpenTime} + + and `group_support` = #{groupSupport} + + + and `enable` = #{enable} + and id in diff --git a/mallinkService/src/main/resources/mapper/WxBillActionMapper.xml b/mallinkService/src/main/resources/mapper/WxBillActionMapper.xml index 51c8bcb69..c0e71eb44 100644 --- a/mallinkService/src/main/resources/mapper/WxBillActionMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillActionMapper.xml @@ -4,6 +4,7 @@ + @@ -16,7 +17,7 @@ - `id`,`tenant_id`,`bill_id`,`user_id`,`user_name`,`phone`,`action`,`details`,`createtime`,`updatetime`,`pay_date` + `id`,`tenant_id`,`sub_tenant_id`,`bill_id`,`user_id`,`user_name`,`phone`,`action`,`details`,`createtime`,`updatetime`,`pay_date` @@ -26,6 +27,14 @@ and `id` = #{id} + + + and `tenant_id` = #{tenantId} + + + + and `sub_tenant_id` = #{subTenantId} + and `action` = #{action} diff --git a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml index 754b1a6f6..80d80387c 100644 --- a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml @@ -6,6 +6,7 @@ + @@ -48,9 +49,8 @@ select count(bill.id) paycount,IFNULL(sum(bill.pay),0) pay from ( - select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,1 bill_type_value,'租金' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,2 bill_type_value,'租赁押金' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent_deposit union all - select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,3 bill_type_value,'物业费' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_property where is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,4 bill_type_value,'物业押金' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_property_deposit union all - select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,5 bill_type_value,'水费' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=1 union all - select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,6 bill_type_value,'电费' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=2 union all - select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,9 bill_type_value,'空调费' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where type=3 union all - select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,7 bill_type_value,'其他费用' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other union all - select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,8 bill_type_value,'其他押金' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit ) bill where bill.tenant_id=#{tenantId} + and bill.`sub_tenant_id` = #{subTenantId} and bill.status=#{status} and bill.receive_date between #{starttime} and #{endtime} @@ -258,161 +271,168 @@ - select bill.tenant_id tenantId,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate, + select bill.tenant_id tenantId,bill.sub_tenant_id sub_tenant_id,bill.merchant_id merchantId,m.name merchantName,bill.receive_date receiveDate, bill.need_pay needPay,m.link_phone linkPhone,app.appname,m.email,bill.bill_type billType from ( - select bill.bill_type,bill.tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from ( - select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' + select bill.bill_type,bill.tenant_id,bill.sub_tenant_id,bill.merchant_id,bill.receive_date,ifnull(sum(need_pay),0) need_pay from ( + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'租金' name,1 bill_type_value,'租金' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_rent where is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_rent_deposit union all - select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'物业费' name,3 bill_type_value,'物业费' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_property where is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'物业押金' name,4 bill_type_value,'物业押金' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_property_deposit union all - select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'水费' name,5 bill_type_value,'水费' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_daily where type=1 union all - select id,merchant_id,shop_id,tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'电费' name,6 bill_type_value,'电费' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_daily where type=2 union all - select id,merchant_id,shop_id,tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'空调费' name,9 bill_type_value,'空调费' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_daily where type=3 union all - select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,name,7 bill_type_value,'其他费用' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_other union all - select id,merchant_id,shop_id,tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type from wx_bill_other_deposit ) bill where bill.status not in(3,5,6) - group by bill.tenant_id,bill.merchant_id,bill.receive_date) bill + group by bill.tenant_id,bill.sub_tenant_id,bill.merchant_id,bill.receive_date) bill left join wx_merchant m on bill.merchant_id=m.id left join (select tenant_id,`name` appname from wx_appinfo app where type=1) app on bill.tenant_id=app.tenant_id where m.status=1 and DATEDIFF(bill.receive_date,now())=m.bill_setting @@ -517,93 +541,93 @@ - select bill.tenant_id tenantId,bill.merchant_id merchantId,m.name merchantName,bill.bill_type billType, + select bill.tenant_id tenantId,bill.sub_tenant_id sub_tenantId,bill.merchant_id merchantId,m.name merchantName,bill.bill_type billType, m.link_phone managerPhone,m.`link_person` manager,m.email, bill.receive_date receiveDate,DATEDIFF(now(),bill.receive_date) expiredDay, @@ -746,59 +770,70 @@ max(case oweList.bill_type when '其他费用' then oweList.serviceChargePay else 0 end) otherServiceChargePay from( - select bill.tenant_id,bill.merchant_id,bill.bill_type,sum(owe) - owe,bill.receive_date,bill.expired_day,sum(bill.receive_pay) receive_pay,sum(bill.pay) - pay,sum(ifnull(bill.late_pay_price,0)) latePayPrice,sum(bill.service_charge_pay) serviceChargePay from ( - - select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' - bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') - receive_date,pay_date,expired_day,status,'' starttime,'' - endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent where tenant_id = #{tenantId} and - is_preview = 0 + select bill.tenant_id,bill.sub_tenant_id,bill.merchant_id,bill.bill_type,sum(owe) owe, + bill.receive_date,bill.expired_day,sum(bill.receive_pay) receive_pay,sum(bill.pay) pay, + sum(ifnull(bill.late_pay_price,0)) latePayPrice,sum(bill.service_charge_pay) serviceChargePay from ( + + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'租金' name,1 bill_type_value,'租金' + bill_type,need_pay,receive_pay,pay,owe, + DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' + endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_rent + where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} + and is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'物业费' name,3 bill_type_value,'物业费' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' - endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_property where tenant_id = #{tenantId} and - is_preview = 0 + endtime,rent_shop_type,late_pay_price,service_charge_pay from wx_bill_property + where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} + and is_preview = 0 union all - select res.id,res.merchant_id,res.shop_id,res.tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay, - res.receive_pay,res.pay,res.owe - owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0 - late_pay_price,0 service_charge_pay from( - select id,merchant_id,shop_id,tenant_id,'欠缴押金' name,2 bill_type_value,'欠缴押金' + select res.id,res.merchant_id,res.shop_id,res.tenant_id,sub_tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay, + res.receive_pay,res.pay,res.owe owe, + res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type, + 0 late_pay_price,0 service_charge_pay from( + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'欠缴押金' name,2 bill_type_value,'欠缴押金' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' - endtime,rent_shop_type,service_charge_pay from wx_bill_rent_deposit where tenant_id = #{tenantId} + endtime,rent_shop_type,service_charge_pay from wx_bill_rent_deposit + where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} union all - select id,merchant_id,shop_id,tenant_id,'欠缴押金' name,4 bill_type_value,'欠缴押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'欠缴押金' name,4 bill_type_value,'欠缴押金' bill_type,need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,0 service_charge_pay from wx_bill_property_deposit where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} union all - select id,merchant_id,shop_id,tenant_id,'欠缴押金' name,8 bill_type_value,'欠缴押金' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'欠缴押金' name,8 bill_type_value,'欠缴押金' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date, pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay from wx_bill_other_deposit where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} ) res union all - select res.id,res.merchant_id,res.shop_id,res.tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay, - res.receive_pay,res.pay,res.owe - owe,res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type,0 - late_pay_price,service_charge_pay from( - select id,merchant_id,shop_id,tenant_id,'其他费用' name,5 bill_type_value,'其他费用' bill_type,0 as + select res.id,res.merchant_id,res.shop_id,res.tenant_id,sub_tenant_id,res.name,res.bill_type_value,res.bill_type,res.need_pay, + res.receive_pay,res.pay,res.owe owe, + res.receive_date,res.pay_date,res.expired_day,res.status,res.starttime,res.endtime,res.rent_shop_type0 + late_pay_price,service_charge_pay + from( + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'其他费用' name,5 bill_type_value,'其他费用' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date, expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay from wx_bill_daily where tenant_id = #{tenantId} - and type in(1,2,3) + and `sub_tenant_id` = #{subTenantId} + and type in(1,2,3) union all - select id,merchant_id,shop_id,tenant_id,'其他费用' name,7 bill_type_value,'其他费用' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'其他费用' name,7 bill_type_value,'其他费用' bill_type,0 as need_pay,receive_pay,pay,owe,DATE_FORMAT(receive_date,'%Y-%m-%d') receive_date,pay_date, expired_day,status,'' starttime,'' endtime,rent_shop_type,service_charge_pay from wx_bill_other where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} ) res @@ -811,15 +846,15 @@ ) bill left join wx_merchant m on bill.merchant_id=m.id where m.tenant_id = #{tenantId} + and m.`sub_tenant_id` = #{subTenantId} and m.name like concat('%', #{merchantName},'%') order by ${sortColumns} order by totalOwe desc select bill.* from ( - select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 billTypeValue,'租赁押金' - billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0 - late_pay_price,0 - service_charge_pay + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'租赁押金' name,2 billTypeValue,'租赁押金' + billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze, + 0 late_pay_price,0 service_charge_pay from wx_bill_rent_deposit where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} union all - select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 billTypeValue,'物业押金' - billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0 - late_pay_price,0 - service_charge_pay + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,'物业押金' name,4 billTypeValue,'物业押金' + billType,need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze, + 0 late_pay_price,0 service_charge_pay from wx_bill_property_deposit where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} union all - select id,merchant_id,shop_id,tenant_id,comments as name,8 billTypeValue,concat('其他押金-',comments) as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,comments as name,8 billTypeValue,concat('其他押金-',comments) as billType,0 as need_pay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date,expired_day,status,freeze,0 late_pay_price,service_charge_pay from wx_bill_other_deposit where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} ) bill where 1=1 and bill.freeze = #{freeze} diff --git a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml index 33efb3dcc..784661968 100644 --- a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml @@ -10,6 +10,7 @@ + @@ -33,7 +34,7 @@ `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`, - `tenant_id`,`owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`type`, + `tenant_id`,`sub_tenant_id`,`owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`type`, `rent_shop_type`,`pay_way`,`price_detail`,`starttime`,`endtime`,freeze,build_way,service_charge_pay @@ -46,7 +47,8 @@ and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `owe` = #{owe} and `status` = #{status} and `is_del` = #{isDel} diff --git a/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml index 633ba5730..976d79c8b 100644 --- a/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml @@ -3,6 +3,8 @@ + + @@ -10,7 +12,6 @@ - @@ -30,14 +31,16 @@ - `id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`, - `expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`, + `id`,`tenant_id`,`sub_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`, + `expired_day`,`owe`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`, `rent_shop_type`,`return_price`,`pay_way`,service_charge_pay where 1 = 1 and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `rent_contract_id` = #{rentContractId} and `receive_pay` = #{receivePay} and `pay` = #{pay} @@ -45,7 +48,6 @@ and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} and `owe` = #{owe} and `status` = #{status} and `is_del` = #{isDel} @@ -82,6 +84,7 @@ and br.`merchant_id` = #{merchantId} and m.`name` like concat('%',#{merchantName},'%') and br.`tenant_id` = #{tenantId} + and br.`sub_tenant_id` = #{subTenantId} and br.`status` = #{status} and br.`is_del` = #{isDel} and br.`rent_shop_type` = #{rentShopType} @@ -92,10 +95,11 @@ @@ -120,14 +127,17 @@ ( select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_rent_deposit where status = 1 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} union all select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_property_deposit where status = 1 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} union all select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_other_deposit where status = 1 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} ) res @@ -135,6 +145,7 @@ update wx_bill_rent_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and status!=#{paid} and status!=5 and DATEDIFF(now(),receive_date)>0 @@ -143,6 +154,7 @@ select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_deposit br left join wx_rent_contract rc on br.rent_contract_id=rc.id where br.tenant_id=#{tenantId} + and br.`sub_tenant_id` = #{subTenantId} and br.status!=#{paid} and br.status!=5 and now() < br.receive_date and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) diff --git a/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml index c935e17a0..6b3bd5c3a 100644 --- a/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml @@ -3,13 +3,14 @@ + + - @@ -32,21 +33,22 @@ - `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`, - `tenant_id`,`owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`name`,`comments`, + `id`,`tenant_id`,`sub_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`, + `owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`name`,`comments`, `rent_shop_type`,`return_price`,`pay_way`,`starttime`,`endtime`,freeze,service_charge_pay where 1 = 1 and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `receive_pay` = #{receivePay} and `pay` = #{pay} and `receive_date` = #{receiveDate} and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} and `owe` = #{owe} and `status` = #{status} and `is_del` = #{isDel} @@ -102,12 +104,14 @@ update wx_bill_other_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and status!=#{paid} and status!=5 and DATEDIFF(now(),receive_date)>0 update wx_bill_other_deposit set status=#{waitPay} where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and status!=5 and status!=#{paid} and DATEDIFF(now(),receive_date) <=0 diff --git a/mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml b/mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml index 4d4869f14..a16a7b595 100644 --- a/mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml @@ -3,13 +3,14 @@ + + - @@ -31,21 +32,22 @@ - `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`, - `tenant_id`,`owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`name`,`comments`, + `id`,`tenant_id`,`sub_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`, + `owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`name`,`comments`, `rent_shop_type`,`pay_way`,`starttime`,`endtime`,endtime,service_charge_pay where 1 = 1 and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `receive_pay` = #{receivePay} and `pay` = #{pay} and `receive_date` = #{receiveDate} and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} and `owe` = #{owe} and `status` = #{status} and `is_del` = #{isDel} @@ -101,11 +103,13 @@ update wx_bill_other set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0 update wx_bill_other set status=#{waitPay} where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and status!=#{paid} and DATEDIFF(now(),receive_date) <=0 @@ -115,10 +119,12 @@ ( select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} union select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_daily where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} ) t @@ -129,10 +135,12 @@ ( select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_daily where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} and status = 1 union all select IFNULL(sum(owe),0) owe,tenant_id from wx_bill_daily where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and receive_date between #{startdate} and #{enddate} and status = 1 ) res diff --git a/mallinkService/src/main/resources/mapper/WxBillPropertyDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxBillPropertyDepositMapper.xml index 61ba0831c..cf8016664 100644 --- a/mallinkService/src/main/resources/mapper/WxBillPropertyDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillPropertyDepositMapper.xml @@ -3,6 +3,8 @@ + + @@ -10,7 +12,6 @@ - @@ -30,22 +31,23 @@ - `id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`, - `pay_date`,`createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`, + `id`,`tenant_id`,`sub_tenant_id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`, + `pay_date`,`createtime`,`expired_day`,`owe`,`status`,`is_del`,`need_pay`, `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`return_price`,`shop_info`,`pay_way`,freeze,service_charge_pay where 1 = 1 - and `id` = #{id} + and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `property_contract_id` = #{propertyContractId} and `receive_pay` = #{receivePay} and `pay` = #{pay} and `receive_date` = #{receiveDate} and `pay_date` = #{payDate} and `createtime` = #{createtime} - and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} + and `expired_day` = #{expiredDay} and `owe` = #{owe} and `status` = #{status} and `is_del` = #{isDel} @@ -83,6 +85,7 @@ and br.`id` = #{id} and br.`tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and br.`merchant_id` = #{merchantId} and m.`name` like concat('%',#{merchantName},'%') and br.`status` = #{status} @@ -98,6 +101,7 @@ @@ -105,6 +109,7 @@ update wx_bill_property_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and status!=#{paid} and status!=5 and DATEDIFF(now(),receive_date)>0 @@ -113,6 +118,7 @@ select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property_deposit br left join wx_property_contract rc on br.property_contract_id=rc.id where br.tenant_id=#{tenantId} + and br.`sub_tenant_id` = #{subTenantId} and br.status!=#{paid} and br.status!=5 and now() < br.receive_date and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) diff --git a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml index 5c21b2c23..aff647824 100644 --- a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml @@ -1,241 +1,257 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - `id`,`tenant_id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`, + + + + + + + + `id`,`tenant_id`,`sub_tenant_id`,`property_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`, `createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`, `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`, `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`,`shop_info`, `pay_way`,`late_pay_status`,`comments`,starttime,endtime,freeze,service_charge_pay - - where 1=1 - and `id` = #{id} - and `property_contract_id` = #{propertyContractId} - and `receive_pay` = #{receivePay} - and `pay` = #{pay} - and `receive_date` = #{receiveDate} - and `pay_date` = #{payDate} - and `createtime` = #{createtime} - and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} - and `owe` = #{owe} - and `status` = #{status} - and `is_del` = #{isDel} - and `need_pay` = #{needPay} - and `merchant_id` = #{merchantId} - and `user_id` = #{userId} - and `shop_id` = #{shopId} - and `updatetime` = #{updatetime} - and `rent_shop_type` = #{rentShopType} - and is_preview = #{isPreview} - and `pay_way` = #{payWay} - and `late_pay_status` = #{latePayStatus} + + where 1=1 + and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} + and `property_contract_id` = #{propertyContractId} + and `receive_pay` = #{receivePay} + and `pay` = #{pay} + and `receive_date` = #{receiveDate} + and `pay_date` = #{payDate} + and `createtime` = #{createtime} + and `expired_day` = #{expiredDay} + and `owe` = #{owe} + and `status` = #{status} + and `is_del` = #{isDel} + and `need_pay` = #{needPay} + and `merchant_id` = #{merchantId} + and `user_id` = #{userId} + and `shop_id` = #{shopId} + and `updatetime` = #{updatetime} + and `rent_shop_type` = #{rentShopType} + and is_preview = #{isPreview} + and `pay_way` = #{payWay} + and `late_pay_status` = #{latePayStatus} - - and id in - - #{idItem} - - - order by ${sortColumns} - + + and id in + + #{idItem} + + + order by ${sortColumns} + - - - + - + + - + - - - update wx_bill_property b set b.status=#{notPaid},b.expired_day= - DATEDIFF(now(), b.receive_date) - where b.tenant_id=#{tenantId} - and b.status!=#{paid} and b.status!=6 and - DATEDIFF(now(), b.receive_date) >0 - + - - update wx_bill_property set status=#{waitPay} where id in( - select a.id from (select br.id,rc.receive_period,br.property_contract_id,br.receive_date from wx_bill_property br - left join wx_property_contract rc on br.property_contract_id=rc.id - where br.tenant_id=#{tenantId} - and br.status!=#{paid} and br.status != 6 and now() < br.receive_date - and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) - + + update wx_bill_property b set b.status=#{notPaid},b.expired_day= + DATEDIFF(now(), b.receive_date) + where b.tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + and b.status!=#{paid} and b.status!=6 + and DATEDIFF(now(), b.receive_date) >0 + + + + update wx_bill_property set status=#{waitPay} where id in( + select a.id from ( + select br.id,rc.receive_period,br.property_contract_id,br.receive_date + from wx_bill_property br + left join wx_property_contract rc on br.property_contract_id=rc.id + where br.tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + and br.status!=#{paid} and br.status != 6 and now() < br.receive_date + and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) + - + update wx_bill_property set status = 6 where property_contract_id = #{propertyContractId} and status in(4,2) - + update wx_bill_property set status = 6 where property_contract_id in (select id from wx_property_contract where rent_contract_id = #{id}) and status != 3 - + delete from wx_bill_property where property_contract_id = #{id} - - update wx_bill_property set updatetime = now() - ,receive_pay = #{receivePay},owe=#{receivePay} - ,comments = #{comments} - ,receive_date = #{receiveDate} - ,status = 3,pay_date=now() - where id = #{id} - + + update wx_bill_property set updatetime = now() + ,receive_pay = #{receivePay},owe=#{receivePay} + ,comments = #{comments} + ,receive_date = #{receiveDate} + ,status = 3,pay_date=now() + where id = #{id} + - + update wx_bill_property set is_preview = #{isPreview},merchant_id = #{merchantId},need_pay = receive_pay, owe=receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay where property_contract_id = #{propertyContractId} - select count(br.id) from wx_bill_property br,wx_property_contract c where c.id = br.property_contract_id and br.status = 1 and c.id = #{contractId} - - - INSERT INTO wx_bill_property (id,property_contract_id, receive_pay, pay, receive_date, pay_date, createtime, - expired_day, - tenant_id, owe, status, is_del, need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime, - rent_shop_type, revenue, late_pay_ratio, late_pay_time, late_pay_price, period, is_preview, shop_info, - pay_way, late_pay_status, comments,service_charge_pay) - VALUES - - ( - #{item.id},#{item.propertyContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime}, - #{item.expiredDay},#{item.tenantId},#{item.owe},#{item.status},#{item.isDel},#{item.needPay},#{item.merchantId}, - #{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime},#{item.endtime},#{item.rentShopType},#{item.revenue}, - #{item.latePayRatio},#{item.latePayTime},#{item.latePayPrice},#{item.period},#{item.isPreview},#{item.shopInfo}, - #{item.payWay},#{item.latePayStatus},#{item.comments},#{item.serviceChargePay} - ) - - - - - - update wx_bill_property - - updatetime = now(),receive_pay = #{item.receivePay}, - comments = #{item.comments}, - receive_date = #{item.receiveDate}, - status = 3,pay_date=now() - - where id = #{item.id} - - - - select * from wx_bill_property where merchant_id=#{merchantId} AND rent_shop_type = #{rentShopType} AND is_preview = #{isPreview} AND date_format(starttime,'%Y-%m-%d 00:00:00.0') = #{starttime} AND date_format(endtime,'%Y-%m-%d 00:00:00.0') = #{endtime} - + insert into wx_bill_action(id,user_name,`action`,bill_id,details,tenant_id) select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000) + CEILING(RAND()*90000+10000) + CEILING(RAND()*90000+10000)) id @@ -257,7 +273,7 @@ and b.status!=3 and b.status!=6 - + update wx_bill_property b set b.late_pay_price = if(b.late_pay_price is null, round( @@ -274,13 +290,19 @@ and (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) > 0 and DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) >0; - - - update wx_bill_property set service_charge_pay=round(receive_pay*#{serviceChargeRate}/10000),owe=receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay where tenant_id=#{tenantId} and service_charge_pay=0 and status in(1,2,4) + + + update wx_bill_property + set service_charge_pay=round(receive_pay*#{serviceChargeRate}/10000),owe=receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay + where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + and service_charge_pay=0 and status in(1,2,4) - - - update wx_bill_property set owe = receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay where status in (1,2,4) + + + update wx_bill_property + set owe = receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay + where status in (1,2,4) diff --git a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml index 08ca3bc3f..9f1381d45 100644 --- a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml @@ -4,6 +4,7 @@ + @@ -51,8 +52,8 @@ - `id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`, - `createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`, + `id`,`tenant_id`,`sub_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`, + `createtime`,`expired_day`,`owe`,`status`,`is_del`,`need_pay`, `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`, `revenue`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,`period`,`is_preview`,`shop_info`, `pay_way`,`late_pay_status`,`comments`,starttime,endtime,bus_discount_ratio,freeze,join_rent_price,service_charge_pay @@ -61,6 +62,8 @@ where 1=1 and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `rent_contract_id` = #{rentContractId} and `receive_pay` = #{receivePay} and `pay` = #{pay} @@ -68,7 +71,6 @@ and `pay_date` = #{payDate} and `createtime` = #{createtime} and `expired_day` = #{expiredDay} - and `tenant_id` = #{tenantId} and `owe` = #{owe} and `status` = #{status} and `is_del` = #{isDel} @@ -138,27 +140,33 @@ update wx_bill_rent b set b.status=#{notPaid},b.expired_day= DATEDIFF(now(), b.receive_date) where b.tenant_id=#{tenantId} + and b.`sub_tenant_id` = #{subTenantId} and b.status!=#{paid} and b.status!=6 and DATEDIFF(now(), b.receive_date) >0 @@ -168,6 +176,7 @@ select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent br left join wx_rent_contract rc on br.rent_contract_id=rc.id where br.tenant_id=#{tenantId} + and br.`sub_tenant_id` = #{subTenantId} and br.status!=#{paid} and br.status!=6 and now() < br.receive_date and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) @@ -204,15 +213,15 @@ - INSERT INTO wx_bill_rent (id,tenant_id, - rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime,expired_day, + INSERT INTO wx_bill_rent (id,tenant_id,sub_tenant_id, + rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime, expired_day, owe, status, is_del, need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime, rent_shop_type, revenue, late_pay_ratio, late_pay_time, late_pay_price, period, is_preview, shop_info, pay_way, late_pay_status, comments,service_charge_pay) VALUES ( - #{item.id},#{item.tenantId}, + #{item.id},#{item.tenantId},#{item.subTenantId}, #{item.rentContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime}, #{item.expiredDay},#{item.owe},#{item.status},#{item.isDel},#{item.needPay},#{item.merchantId}, #{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime},#{item.endtime},#{item.rentShopType},#{item.revenue}, diff --git a/mallinkService/src/main/resources/mapper/WxBillSettleBillMapper.xml b/mallinkService/src/main/resources/mapper/WxBillSettleBillMapper.xml index 1e4991fe8..4ba6686e3 100644 --- a/mallinkService/src/main/resources/mapper/WxBillSettleBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillSettleBillMapper.xml @@ -4,6 +4,7 @@ + @@ -20,7 +21,7 @@ - `id`,`tenant_id`,`settle_id`,`type`,`bill_id`,`bill_type` + `id`,`tenant_id`,`sub_tenant_id`,`settle_id`,`type`,`bill_id`,`bill_type` ,`createtime`,`updatetime` @@ -42,10 +43,10 @@ select bl.`type`,IFNULL(bill.starttime,NULL),IFNULL(bill.endtime,NULL),bl.bill_id,bl.bill_type,bill.bill_type billName,IFNULL(bill.owe,0) receivePay from wx_bill_settle_bill bl left join - (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金-租金' + (select id,merchant_id,shop_id,tenant_id,sub_tenant_id,1 bill_type_value,'租金-租金' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_rent where is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金-租赁押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,2 bill_type_value,'租赁押金-租赁押金' bill_type,need_pay,receive_pay,pay, @@ -58,11 +59,11 @@ ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_rent_deposit union all - select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费-物业费' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,3 bill_type_value,'物业费-物业费' bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_property where is_preview = 0 union all - select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金-物业押金' + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,4 bill_type_value,'物业押金-物业押金' bill_type,need_pay,receive_pay,pay, @@ -75,22 +76,22 @@ ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_property_deposit union all - select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费-水费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,5 bill_type_value,'水费-水费' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where type=1 union all - select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费-电费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,6 bill_type_value,'电费-电费' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where type=2 union all - select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费-空调费' bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,9 bill_type_value,'空调费-空调费' bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_daily where type=3 union all - select id,merchant_id,shop_id,tenant_id,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other union all - select id,merchant_id,shop_id,tenant_id,8 bill_type_value,concat('其他押金-',comments) as bill_type,0 as + select id,merchant_id,shop_id,tenant_id,sub_tenant_id,8 bill_type_value,concat('其他押金-',comments) as bill_type,0 as need_pay,receive_pay,pay, @@ -103,13 +104,14 @@ ,receive_date,pay_date,expired_day,status,rent_shop_type,starttime,endtime from wx_bill_other_deposit union all - select id, id merchant_id,'' shop_id,tenant_id,10 bill_type_value,'补贴-补贴' bill_type,0 as + select id, id merchant_id,'' shop_id,tenant_id,sub_tenant_id,10 bill_type_value,'补贴-补贴' bill_type,0 as need_pay,subsidy receive_pay,0 pay,subsidy owe,'' receive_date,'' pay_date,'' expired_day,status,'' rent_shop_type,'' starttime,'' endtime from wx_merchant_subsidy ) bill on(bl.bill_id = bill.id) where 1=1 and bill.`id` = #{billId} and bl.`tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and bl.`settle_id` = #{settleId} and bl.`type` = #{type} @@ -117,10 +119,10 @@ diff --git a/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml b/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml index b4b4aa577..5f7b741e2 100644 --- a/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml @@ -45,22 +45,28 @@ - select from wx_c_user_car + select + + from wx_c_user_car diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml index c9a5a5097..413e0693a 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -4,6 +4,7 @@ + @@ -48,7 +49,7 @@ - `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, + `id`,`tenant_id`,`sub_tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`, `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`, `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, diff --git a/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml b/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml index 982dff917..233b390d6 100644 --- a/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCampaignMapper.xml @@ -4,6 +4,7 @@ + @@ -30,17 +31,17 @@ - `id`,`tenant_id`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`, + `id`,`tenant_id`,`sub_tenant_id`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`, `mechant_id`,`sort_num`,`status`,`create_time`,`update_time`,`html`, `produce_type`,`produce_id`,`page_path`,`page_scene` - `id`,`tenant_id`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`type`,`sort_num`,`page_path` + `id`,`tenant_id`,`sub_tenant_id`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`type`,`sort_num`,`page_path` - `id`,`tenant_id`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`, + `id`,`tenant_id`,`sub_tenant_id`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`use_price`,`discount_price`,`detail`,`valid_start_date`,`valid_end_date`,`img_detail`,`type`,`coupon_ids`, `mechant_id`,`sort_num`,`status`,`create_time`,`update_time`,`page_path` @@ -55,6 +56,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `cover_img` like concat('%', #{coverImg},'%') diff --git a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml index fce682c40..2de1ffe0f 100644 --- a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`vendor_type`,`cmd_type`,`create_date`,`update_date`,`cmd_json` + `id`,`tenant_id`,`sub_tenant_id`,`vendor_type`,`cmd_type`,`create_date`,`update_date`,`cmd_json` @@ -25,6 +26,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `vendor_type` = #{vendorType} @@ -65,6 +70,7 @@ select count(c.id) carcount,c.create_date from ( select id,DATE_FORMAT(create_date,'%Y-%m-%d') create_date from wx_car_cmd_log where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and cmd_type=#{cmdType} and create_date BETWEEN #{startdate} and #{enddate} ) c @@ -75,6 +81,7 @@ select count(c.id) carcount,c.create_time from ( select id,DATE_FORMAT(DATE_ADD(create_date,INTERVAL 1 HOUR),'%H:00') create_time from wx_car_cmd_log where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and cmd_type=#{cmdType} and create_date BETWEEN #{startdate} and #{enddate} ) c group by c.create_time order by c.create_time @@ -83,6 +90,7 @@ @@ -91,6 +99,7 @@ select sum(fee) fee,c.create_time from ( select id,DATE_FORMAT(create_date,'%m/%d') create_time,CONVERT(JSON_EXTRACT(cmd_json,'$.fee'), Decimal(16,2)) fee from wx_car_cmd_log where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and cmd_type=#{cmdType} and REPLACE (JSON_EXTRACT(cmd_json,'$.time'),'"','') BETWEEN #{startdate} and #{enddate} ) c group by c.create_time order by c.create_time @@ -100,7 +109,9 @@ select DATE_FORMAT(ccl.create_date,'%Y-%m-%d') xTime, count(ccl.id) triggerCount from wx_c_user_car cuc, wx_car_cmd_log ccl where cuc.tenant_id = #{tenantId} + and cuc`sub_tenant_id` = #{subTenantId} and ccl.tenant_id = #{tenantId} + and ccl`sub_tenant_id` = #{subTenantId} and ccl.plateNumber = cuc.car_number and cmd_type=#{cmdType} @@ -119,26 +130,32 @@ group by plateNumber - + select `tenant_id`,`sub_tenant_id` from wx_car_cmd_log + where cmd_type = #{cmdType} and syn_id = #{synId} and plateNumber = #{plateNumber} - select * from wx_car_cmd_log - where cmd_type = 604 + where and tenant_id = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + + and `cmd_type` = #{cmdType} + - and plateNumber = #{plateNumber} + and `plateNumber` = #{plateNumber} - and order_id = #{orderId} + and `order_id` = #{orderId} and JSON_EXTRACT(cmd_json,'$.fee') = #{fee} @@ -155,6 +172,9 @@ and tenant_id = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and plateNumber = #{plateNumber} diff --git a/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml b/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml index 5f0510109..2a1a6e17d 100644 --- a/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml @@ -4,6 +4,7 @@ + @@ -27,7 +28,7 @@ - `id`,`tenant_id`,`vendor_type`,`create_date`,`update_date`,syn_id,park_id,park_name,user_type, + `id`,`tenant_id`,`sub_tenant_id`,`vendor_type`,`create_date`,`update_date`,syn_id,park_id,park_name,user_type, plate_number,entrance_time,exit_time,fee,fee_time,coupon,coupon_code,fix_parking_id,remaining_days,discount_amount,phone ,paid_service_fee,create_date,update_date,floor(stayed_time/60) stayed_time @@ -53,6 +54,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `vendor_type` = #{vendorType} diff --git a/mallinkService/src/main/resources/mapper/WxCardInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCardInfoMapper.xml index ffcd1a720..fba2e1a6d 100644 --- a/mallinkService/src/main/resources/mapper/WxCardInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCardInfoMapper.xml @@ -4,6 +4,7 @@ + @@ -20,7 +21,7 @@ - `id`,`tenant_id`,`coupon_id`,`transaction_id`, + `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`transaction_id`, `amount`,`sale_amount`,`remaining_amount`,`service_fee_amount`, `share_fee_amount`,`remaining_share_fee_amount`, `rate_amount`, `create_date`,`update_date`,`support_transfer` @@ -34,6 +35,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `coupon_id` = #{couponId} @@ -82,6 +86,7 @@ + @@ -119,7 +124,7 @@ - ci.`id`,ci.`tenant_id`,ci.`coupon_id`,ci.`transaction_id`, + ci.`id`,ci.`tenant_id`,ci.`sub_tenant_id`,ci.`coupon_id`,ci.`transaction_id`, ci.`amount`,ci.`sale_amount`,ci.`remaining_amount`,ci.`service_fee_amount`, ci.`share_fee_amount`,ci.`remaining_share_fee_amount`, ci.`rate_amount`, ci.`create_date`,ci.`update_date`, @@ -136,6 +141,9 @@ and ci.`tenant_id` = #{tenantId} + + and ci.`sub_tenant_id` = #{subTenantId} + and ci.`coupon_id` = #{couponId} diff --git a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml index b7121d856..06efc2f5f 100644 --- a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml @@ -4,6 +4,7 @@ + @@ -23,7 +24,7 @@ - `id`,`tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`pos_order_id`, + `id`,`tenant_id`,`sub_tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`pos_order_id`, `deduction_amount`,`payment`,`real_payment`, `card_remain_amount`, `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, `create_date`, `update_date`, `pay_status`, `pay_from` @@ -37,6 +38,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `card_id` = #{cardId} @@ -112,6 +116,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `create_date` between #{startdate} and #{enddate} @@ -147,6 +154,9 @@ and cs.`tenant_id` = #{tenantId} + + and cs.`sub_tenant_id` = #{subTenantId} + and cs.`create_date` between #{startdate} and #{enddate} @@ -190,6 +200,9 @@ and cs.`tenant_id` = #{tenantId} + + and cs.`sub_tenant_id` = #{subTenantId} + and cs.`create_date` between #{startdate} and #{enddate} @@ -236,6 +249,9 @@ and cs.`tenant_id` = #{tenantId} + + and cs.`sub_tenant_id` = #{subTenantId} + and cs.`create_date` between #{startdate} and #{enddate} @@ -273,6 +289,7 @@ + @@ -302,7 +319,7 @@ - cs.`id`,cs.`tenant_id`,cs.`card_id`,cs.`owner_id`,cs.`merchant_id`,cs.`order_id`,cs.`deduction_amount`,cs.`payment`,cs.`real_payment`, + cs.`id`,cs.`tenant_id`,cs.`sub_tenant_id`,cs.`card_id`,cs.`owner_id`,cs.`merchant_id`,cs.`order_id`,cs.`deduction_amount`,cs.`payment`,cs.`real_payment`, cs.`card_remain_amount`,cs.`card_before_amount`,cs.`card_remain_real_amount`,cs.`card_before_real_amount`, cs.`create_date`,cs.`update_date`, cs.`pay_status`, m.`name`, c.`title`, @@ -318,6 +335,9 @@ and cs.`tenant_id` = #{tenantId} + + and cs.`sub_tenant_id` = #{subTenantId} + and cs.`card_id` = #{cardId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index 658db8980..2bb63cff0 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` + `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` @@ -25,7 +26,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} @@ -68,7 +72,9 @@ @@ -77,11 +83,15 @@ (select Count(*) from wx_coupon_action_log c where DATE_FORMAT(create_time,'%m/%d')=xTime and c.channel_type=2 - and tenant_id=#{tenantId} ) as parkSendCount, + and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ) as parkSendCount, (select Count(*) from wx_coupon_action_log c where DATE_FORMAT(create_time,'%m/%d')=xTime and c.channel_type=3 - and tenant_id=#{tenantId}) as verifySendCount, + and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ) as verifySendCount, (select Count(*) from wx_coupon_action_log c where DATE_FORMAT(create_time,'%m/%d')=xTime and c.channel_type=4 @@ -89,9 +99,12 @@ (select Count(*) from wx_coupon_action_log c where DATE_FORMAT(create_time,'%m/%d')=xTime and c.channel_type=5 - and tenant_id=#{tenantId}) as orderSendCount + and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ) as orderSendCount from wx_coupon_action_log where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and channel_type in (2,3,4,5) and create_time >= #{startTime} and create_time <= #{endTime} @@ -103,6 +116,7 @@ select create_time_md as xTime, channel_type, count(create_time_md + '' + channel_type) as count from wx_coupon_action_log where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and channel_type in (2,3,4,5) and create_time >= #{startTime} and create_time <= #{endTime} @@ -113,16 +127,16 @@ update wx_coupon_action_log set create_time_md = DATE_FORMAT(create_time,'%m/%d') - where tenant_id = #{tenantId}; + where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} - - - select DATE_FORMAT(cal.create_time,'%Y-%m-%d') AS xTime, COUNT(co.id) as tempCount from wx_coupon_action_log cal left join wx_coupon_order co on cal.coupon_order_id=co.id where cal.tenant_id=#{tenantId} + and cal.`sub_tenant_id` = #{subTenantId} and co.coupon_order_status = 1 and cal.create_time >= #{startTime} @@ -170,6 +187,7 @@ select COUNT(*) FROM wx_coupon_action_log where tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and channel_type = #{channelType} and channel_id = #{channelId} @@ -188,6 +207,7 @@ FROM wx_coupon_action_log a, wx_coupon_order o WHERE a.coupon_order_id = o.id AND a.tenant_id = #{tenantId} + and a.`sub_tenant_id` = #{subTenantId} AND o.c_user_id = #{cUserId} AND date(a.create_time) = curdate() @@ -197,6 +217,7 @@ FROM wx_coupon_action_log a, wx_coupon_order o WHERE a.coupon_order_id = o.id AND a.tenant_id = #{tenantId} + and a.`sub_tenant_id` = #{subTenantId} AND o.c_user_id = #{cUserId} AND a.coupon_id = #{couponId} AND date(a.create_time) between date_sub(curdate(),interval #{dayNum} day) and curdate() @@ -207,6 +228,7 @@ FROM wx_coupon_action_log a, wx_coupon_order o WHERE a.coupon_order_id = o.id AND a.tenant_id = #{tenantId} + and a.`sub_tenant_id` = #{subTenantId} AND o.c_user_id = #{cUserId} AND a.coupon_id = #{couponId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml index df003c06b..6305021c4 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponCarMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`park_id`,`vendor_type`,`vendor_params`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,`park_id`,`vendor_type`,`vendor_params`,`create_date`,`update_date` @@ -25,7 +26,10 @@ and `tenant_id` = #{tenantId} - + + + + and `sub_tenant_id` = #{subTenantId} @@ -62,7 +66,9 @@ @@ -96,6 +102,7 @@ + @@ -125,18 +132,18 @@ - - c.id,c.tenant_id,c.type,c.cover_img,c.cover_picture,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, + + c.id,c.tenant_id,c.sub_tenant_id,c.type,c.cover_img,c.cover_picture,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, car.vendor_type, car.vendor_params,c.credit_price, c.`auto_refund` - - - - + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 63e426d54..4287c5c80 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -4,6 +4,7 @@ + @@ -20,7 +21,7 @@ - cc.`id`,cc.`tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code + cc.`id`,cc.`tenant_id`,cc.`sub_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code @@ -43,6 +44,10 @@ and cc.`tenant_id` = #{tenantId} + + and cc.`sub_tenant_id` = #{subTenantId} + + and cc.`coupon_id` = #{couponId} @@ -144,6 +149,7 @@ + @@ -216,7 +222,7 @@ cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time, - c.tenant_id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.sale_price,c.use_price, + c.tenant_id,c.sub_tenant_id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.sale_price,c.use_price, c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date, c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status, c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions, @@ -236,6 +242,7 @@ + diff --git a/mallinkService/src/main/resources/mapper/WxCouponInjectMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponInjectMapper.xml index 6309176f5..f140312fe 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponInjectMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponInjectMapper.xml @@ -4,6 +4,7 @@ + @@ -21,7 +22,7 @@ - `id`,`tenant_id`,`name`,`m_user_id`,`send_type`,`coupon_id`,`coupon_name`,`send_time`,`send_amount`,`status`,`error_msg`,`tags`,`msg_id`,`create_time`,`update_time`,`model_id` + `id`,`tenant_id`,`sub_tenant_id`,`name`,`m_user_id`,`send_type`,`coupon_id`,`coupon_name`,`send_time`,`send_amount`,`status`,`error_msg`,`tags`,`msg_id`,`create_time`,`update_time`,`model_id` @@ -34,7 +35,10 @@ and `tenant_id`= #{tenantId} - + + + + and `sub_tenant_id`= #{subTenantId} @@ -114,7 +118,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 162d69e04..6bacad4c4 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -4,6 +4,7 @@ + @@ -49,6 +50,7 @@ + @@ -93,7 +95,7 @@ - `id`,`tenant_id`,`type`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, + `id`,`tenant_id`,`sub_tenant_id`,`type`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`, `remark`,`status`,`create_date`,`update_date`,`business`,`sub_business`,`support_transfer`,`subsidy_num`,`subsidy_type`, `press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund`,`put_apply_status`,`stock_apply_status`,`cancle_apply_status`,`conditions`,approval_type @@ -114,6 +116,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `type` = #{type} @@ -272,9 +278,8 @@ `remain_inventory` = #{remainInventory}, `inventory` = #{inventory}, `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays} WHERE 1=1 - - and `tenant_id` = #{tenantId} - + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory} @@ -296,6 +301,10 @@ and c.`tenant_id` = #{tenantId} + + and c.`sub_tenant_id` = #{subTenantId} + + and c.`type` < 7 @@ -419,16 +428,32 @@ - and if(type=8,put_apply_status =2 or c.id in(select coupon_id from wx_coupon_channel where status=0 and tenant_id=#{tenantId}) ,1=1) + and if(type=8,put_apply_status =2 or c.id in ( + select coupon_id from wx_coupon_channel + where status=0 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ) ,1=1) - and if(type=9,put_apply_status =2 or c.id in(select coupon_id from wx_coupon_channel where status=0 and tenant_id=#{tenantId}),1=1) + and if(type=9,put_apply_status =2 or c.id in ( + select coupon_id from wx_coupon_channel + where status=0 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ),1=1) - and if(type=100,put_apply_status =2 or c.id in(select coupon_id from wx_coupon_channel where status=0 and tenant_id=#{tenantId}),1=1) + and if(type=100,put_apply_status =2 or c.id in ( + select coupon_id from wx_coupon_channel + where status=0 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ),1=1) - and if(type !=8 and type !=9 and type!=100,put_apply_status =2 or c.id in(select coupon_id from wx_coupon_channel where status=0 and tenant_id=#{tenantId}),1=1) + and if(type !=8 and type !=9 and type!=100,put_apply_status =2 or c.id in ( + select coupon_id from wx_coupon_channel + where status=0 and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + ),1=1) @@ -473,6 +498,7 @@ + @@ -830,12 +856,13 @@ @@ -846,6 +873,8 @@ max(case type when 10 then model_id else 0 end) cardModelId, max(case type when 11 then model_id else 0 end) groupModelId, max(case type when 12 then model_id else 0 end) pressModelId - from wx_flow_config where type in(9,10,11,12) and tenant_id=#{tenantId} + from wx_flow_config + where type in(9,10,11,12) and tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml index fd2f8ebca..3986fb533 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml @@ -3,6 +3,8 @@ + + @@ -20,9 +22,15 @@ and `id` = #{id} - - - + + + + and `tenant_id` = #{tenantId} + + + + and `sub_tenant_id` = #{subTenantId} + and `product_id` = #{productId} @@ -58,7 +66,9 @@ @@ -69,6 +79,8 @@ + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 7d380ac0d..ca95cc8a6 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -4,6 +4,7 @@ + @@ -20,7 +21,7 @@ - `id`,`tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund`, `verify_type` + `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund`, `verify_type` @@ -33,6 +34,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `coupon_id` = #{couponId} @@ -103,6 +107,7 @@ `update_date` = #{updateDate}, `verify_type` = #{verifyType} where `tenant_id`=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and id=#{id} and `b_user_id` is null @@ -114,6 +119,7 @@ `verify_type` = #{verifyType} where 1=1 and `tenant_id`=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and id=#{id} and `b_user_id` is null @@ -131,6 +137,7 @@ `update_date` = #{updateDate}, `verify_type` = null where `tenant_id`=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and id=#{id} @@ -143,6 +150,7 @@ where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime AND tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} AND c.update_date >= #{startTime} AND c.update_date <= #{endTime}) as verifyCount, (select Count(DISTINCT c_user_id) @@ -150,10 +158,12 @@ where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime AND tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} AND d.update_date >= #{startTime} AND d.update_date <= #{endTime}) as verifyUserCount from wx_coupon_order where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} AND create_date >= #{startTime} AND create_date <= #{endTime} GROUP BY createTime @@ -183,6 +193,7 @@ SELECT xTime, tenant_id, pv, uv, couponCount, userCount, verifyCount, verifyUserCount FROM view_touch_user WHERE view_touch_user.tenant_id=#{tenantId} + and view_touch_user.`sub_tenant_id` = #{subTenantId} and view_touch_user.xTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d') @@ -198,6 +209,7 @@ select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount from wx_coupon_order c where c.tenant_id = #{tenantId} + and c.`sub_tenant_id` = #{subTenantId} and c.coupon_order_status = 1 and c.update_date BETWEEN #{startTime} and #{endTime} @@ -209,6 +221,7 @@ select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount from wx_coupon_order c where c.tenant_id = #{tenantId} + and c.`sub_tenant_id` = #{subTenantId} and c.create_date BETWEEN #{startTime} and #{endTime} @@ -220,6 +233,9 @@ from wx_coupon_order c left join wx_coupon_action_log cal on cal.tenant_id = c.tenant_id where cal.coupon_order_id=c.id and c.tenant_id=#{tenantId} + + and c.`sub_tenant_id` = #{subTenantId} + and cal.channel_type=#{channelType} @@ -232,9 +248,8 @@ SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} AND create_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime @@ -550,6 +575,7 @@ + @@ -589,7 +615,7 @@ - co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, + co.id,co.tenant_id,co.sub_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num, (case when com.mc=1 then (select m.name from wx_merchant m, wx_coupon_merchant cm @@ -600,7 +626,7 @@ - co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, + co.id,co.tenant_id,co.sub_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num, bu.name, bu.phone as bphone, cu.phone, @@ -621,6 +647,7 @@ select bu.id as bu_id,m.name as verify_merchant_name from wx_merchant_b_user bu inner join wx_merchant m on bu.merchant_id=m.id where bu.tenant_id = #{tenantId} + and bu.`sub_tenant_id` = #{subTenantId} ) bu on bu.bu_id = co.b_user_id left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id left join wx_coupon_action_log cal on co.id = cal.coupon_order_id and co.coupon_id = cal.coupon_id @@ -636,6 +663,9 @@ and co.tenant_id = #{tenantId} + + and co.sub_tenant_id = #{subTenantId} + and co.coupon_order_status = #{couponOrderStatus} @@ -713,14 +743,14 @@ - co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, + co.id,co.tenant_id,co.sub_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, bu.name, cu.phone - co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, + co.id,co.tenant_id,co.sub_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, cu.phone @@ -769,7 +799,7 @@ - co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price + co.id,co.tenant_id,co.sub_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price select c.* from ( - select id,tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as + select id,tenant_id,sub_tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as coupon_order_status,create_date,update_date,'' cover_img,title,'' sub_title,'' detail,0 unit, '' remark,amount,remain_amount as remaining_amount,0 support_transfer from wx_card_transfer_info where 1=1 and tenant_id = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and from_user = #{ownerId} @@ -1072,6 +1112,9 @@ and co.tenant_id = #{tenantId} + + and co.sub_tenant_id = #{subTenantId} + and co.c_user_id = #{cUserId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml index 6468f0672..c5357abd8 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml @@ -4,6 +4,7 @@ + @@ -18,7 +19,7 @@ - `id`,`tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`sended_phone`,`card_id`,`create_date`,`update_date`,`expire_date`,`present_id` + `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`sended_phone`,`card_id`,`create_date`,`update_date`,`expire_date`,`present_id` @@ -28,7 +29,10 @@ and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} + and `coupon_id` = #{couponId} @@ -88,6 +92,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `coupon_id` = #{couponId} @@ -124,6 +131,7 @@ select `coupon_id`,`coupon_short` from wx_coupon_password where `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} group by `coupon_id`,`coupon_short` @@ -142,6 +150,7 @@ where tenant_id=#{tenantId} and status=0 group by coupon_id) cp inner join wx_coupon c on cp.coupon_id = c.id where c.tenant_id=#{tenantId} + and c.`sub_tenant_id` = #{subTenantId} and c.status=0 and c.put_apply_status in(0,2) and cp.`coupon_id` = #{couponId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponPresentMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponPresentMapper.xml index 2a4f76678..7d7d45ee0 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponPresentMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponPresentMapper.xml @@ -4,6 +4,7 @@ + @@ -13,7 +14,7 @@ - `id`,`tenant_id`,`coupon_id`,`coupon_name`,`user_id`,`create_time`,`update_time`,`send_amount` + `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`coupon_name`,`user_id`,`create_time`,`update_time`,`send_amount` @@ -24,6 +25,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `coupon_id` = #{couponId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponSendConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponSendConfigMapper.xml index 3b4abc187..58daac7e2 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponSendConfigMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponSendConfigMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`send_type`,`value`,`remark`,`create_time`,`update_time` + `id`,`tenant_id`,`sub_tenant_id`,`send_type`,`value`,`remark`,`create_time`,`update_time` @@ -25,7 +26,10 @@ and `tenant_id` = #{tenantId} - + + + + and `sub_tenant_id` = #{subTenantId} @@ -62,7 +66,8 @@ diff --git a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml index b5d888853..650728158 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml @@ -4,6 +4,7 @@ + @@ -24,7 +25,7 @@ - cs.id,cs.tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date, + cs.id,cs.tenant_id,cs.sub_tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date, cs.conditions -> '$.merchantSend' as merchantSend, cs.conditions -> '$.merchantLnventory' as merchantLnventory, cs.conditions -> '$.merchantRemain' as merchantRemain, @@ -43,12 +44,14 @@ and cs.id = #{id} - and cs.tenant_id = #{tenantId} + + + and cs.sub_tenant_id = #{subTenantId} diff --git a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml index a4f5210fa..23de47ada 100644 --- a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml @@ -4,6 +4,7 @@ + @@ -22,14 +23,20 @@ - `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`create_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend`,`change_purpose`,`ticket_number`,`buser_id` + `id`,`tenant_id`,`sub_tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`create_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend`,`change_purpose`,`ticket_number`,`buser_id` where 1 = 1 and `id` = #{id} - + + + and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `c_user_id` = #{cUserId} @@ -100,6 +107,9 @@ and credit.tenant_id = #{tenantId} + + and credit.sub_tenant_id = #{subTenantId} + and credit.operator_type = #{operatorType} @@ -140,6 +150,7 @@ basic.phone phone, basic.sex sex, credit.tenant_id tenantId, + credit.sub_tenant_id subTenantId, credit.c_user_id cUserId, credit.credit_amount creditAmount, credit.credit_num creditNum, @@ -170,6 +181,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `c_user_id` = #{cUserId} @@ -206,6 +220,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `c_user_id` = #{cUserId} @@ -218,6 +235,7 @@ update wx_credit_history set c_user_id=#{newUserId} where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and c_user_id = #{cUserId} diff --git a/mallinkService/src/main/resources/mapper/WxDataRuleTargetMapper.xml b/mallinkService/src/main/resources/mapper/WxDataRuleTargetMapper.xml index 89964ca47..3f160dbb3 100644 --- a/mallinkService/src/main/resources/mapper/WxDataRuleTargetMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxDataRuleTargetMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`parent`,`name`,`tag`,`create_time`,`update_time` + `id`,`tenant_id`,`sub_tenant_id`,`parent`,`name`,`tag`,`create_time`,`update_time` @@ -29,6 +30,10 @@ and `parent` = #{parent} + + + and `sub_tenant_id` = #{subTenantId} + and `name` like concat('%',#{name},'%') diff --git a/mallinkService/src/main/resources/mapper/WxDateAmountRecordMapper.xml b/mallinkService/src/main/resources/mapper/WxDateAmountRecordMapper.xml index 0c89c8320..197cd3e5f 100644 --- a/mallinkService/src/main/resources/mapper/WxDateAmountRecordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxDateAmountRecordMapper.xml @@ -3,11 +3,12 @@ + + - @@ -16,7 +17,7 @@ - `id`,`date`,`day_of_week`,`week_of_year`,`pay_price`,`tenant_id`,`month`,`merchant_id`,`create_date`,`update_date`,`type` + `id`,`tenant_id`,`sub_tenant_id`,`date`,`day_of_week`,`week_of_year`,`pay_price`,`month`,`merchant_id`,`create_date`,`update_date`,`type` @@ -24,9 +25,15 @@ and `id` = #{id} - - - + + + + and `tenant_id` = #{tenantId} + + + + and `sub_tenant_id` = #{subTenantId} + and `date` = #{date} @@ -47,11 +54,6 @@ - - and `tenant_id` = #{tenantId} - - - and `month` = #{month} @@ -86,13 +88,17 @@ update wx_date_amount_record set pay_price=pay_price+#{payPrice} - where tenant_id=#{tenantId} and merchant_id=#{merchantId} + where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + and merchant_id=#{merchantId} and type=#{type} and date = #{date} diff --git a/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml b/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml index 291092337..72373bcfa 100644 --- a/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml @@ -4,6 +4,7 @@ + @@ -20,7 +21,7 @@ - `id`, `tenant_id`, `device_id`, `type`, `status`, `location`, `name`, `version`, `create_date`, `update_date`, `online_status`, `first_hb_time`, `last_hb_time`, `hb_cmd`, `config` + `id`, `tenant_id`, `sub_tenant_id`,`device_id`, `type`, `status`, `location`, `name`, `version`, `create_date`, `update_date`, `online_status`, `first_hb_time`, `last_hb_time`, `hb_cmd`, `config` @@ -34,6 +35,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `device_id` = #{deviceId} diff --git a/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml b/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml index d3a71ad0c..795128634 100644 --- a/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml @@ -4,6 +4,7 @@ + @@ -14,7 +15,7 @@ - `id`, `tenant_id` , `cover_img` , `produce_id`, `page_path` , `status`, `create_time`, `update_time` + `id`, `tenant_id` , `sub_tenant_id`, `cover_img` , `produce_id`, `page_path` , `status`, `create_time`, `update_time` @@ -27,6 +28,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `status` = #{status} diff --git a/mallinkService/src/main/resources/mapper/WxFlowConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxFlowConfigMapper.xml index 985f78e91..519962cd9 100644 --- a/mallinkService/src/main/resources/mapper/WxFlowConfigMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxFlowConfigMapper.xml @@ -5,6 +5,7 @@ + @@ -13,7 +14,7 @@ - + @@ -21,6 +22,7 @@ where 1=1 and `parent_id` = #{parentId} and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `id` = #{id} and `model_id` = #{modelId} and `name` like concat('%', #{name},'%') @@ -33,7 +35,7 @@ - SELECT * FROM wx_flow_config WHERE parent_id = #{id} ORDER BY sort ASC diff --git a/mallinkService/src/main/resources/mapper/WxFlowModelMapper.xml b/mallinkService/src/main/resources/mapper/WxFlowModelMapper.xml index d5521c13f..a6abeb4dd 100644 --- a/mallinkService/src/main/resources/mapper/WxFlowModelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxFlowModelMapper.xml @@ -5,6 +5,7 @@ + @@ -19,6 +20,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `id` = #{id} and `name` like concat('%', #{name},'%') @@ -38,6 +42,11 @@ and w.tenant_id = #{tenantId} and m.tenant_id = #{tenantId} + + and w.`sub_tenant_id` = #{subTenantId} + and m.`sub_tenant_id` = #{subTenantId} + + diff --git a/mallinkService/src/main/resources/mapper/WxFlowRecordMapper.xml b/mallinkService/src/main/resources/mapper/WxFlowRecordMapper.xml index 03a7e65c1..42f58dac7 100644 --- a/mallinkService/src/main/resources/mapper/WxFlowRecordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxFlowRecordMapper.xml @@ -4,6 +4,8 @@ + + @@ -27,7 +29,7 @@ - `id`,`business_id`,`business_type`,`user_id`,`remark`,`status`,`task_id`,`process_instance_id`,`create_date`,`update_date`,`tenant_id`,`user_name`,task_key,task_name,curr_status,variables, + `id`,`tenant_id`,`sub_tenant_id`,`business_id`,`business_type`,`user_id`,`remark`,`status`,`task_id`,`process_instance_id`,`create_date`,`update_date`,`tenant_id`,`user_name`,task_key,task_name,curr_status,variables, REPLACE (JSON_EXTRACT(variables,'$.contractType'),'"','') contractType, REPLACE (JSON_EXTRACT(variables,'$.endProperty'),'"','') endProperty, REPLACE (JSON_EXTRACT(variables,'$.contractNumber'),'"','') contractNumber, @@ -39,6 +41,12 @@ and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `business_id` = #{businessId} @@ -48,9 +56,6 @@ and `status` = #{status} - - and `tenant_id` = #{tenantId} - and id in diff --git a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml index 20e4082f6..752137660 100644 --- a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml @@ -4,6 +4,7 @@ + @@ -11,7 +12,7 @@ - `id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` + `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` @@ -24,7 +25,9 @@ and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} @@ -67,7 +70,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxGameMapper.xml b/mallinkService/src/main/resources/mapper/WxGameMapper.xml index 06be2ead2..01728a57b 100644 --- a/mallinkService/src/main/resources/mapper/WxGameMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameMapper.xml @@ -4,6 +4,7 @@ + @@ -15,7 +16,7 @@ - `id`,`tenant_id`,`game_id`,`status`,`coupon_ids`,`valid_start_date`,`valid_end_date`,`triggle_action`,`play_limit`,`award_limit` + `id`,`tenant_id`,`sub_tenant_id`,`game_id`,`status`,`coupon_ids`,`valid_start_date`,`valid_end_date`,`triggle_action`,`play_limit`,`award_limit` @@ -25,7 +26,11 @@ - and `tenant_id` like concat('%', #{tenantId},'%') + and `tenant_id` = #{tenantId} + + + + and `sub_tenant_id` = #{subTenantId} diff --git a/mallinkService/src/main/resources/mapper/WxLevelMerchantMapper.xml b/mallinkService/src/main/resources/mapper/WxLevelMerchantMapper.xml index 649b0783a..a3b3fea9d 100644 --- a/mallinkService/src/main/resources/mapper/WxLevelMerchantMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxLevelMerchantMapper.xml @@ -4,6 +4,7 @@ + @@ -11,7 +12,7 @@ - `id`,`tenant_id`,`merchant_id`,`level_id`,`create_date`,`discount` + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`level_id`,`create_date`,`discount` @@ -25,6 +26,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `merchant_id` = #{merchantId} @@ -91,6 +96,10 @@ and lm.tenant_id = #{tenantId} + + and lm.`sub_tenant_id` = #{subTenantId} + + and lm.merchant_id = #{merchantId} diff --git a/mallinkService/src/main/resources/mapper/WxMallBuildingMapper.xml b/mallinkService/src/main/resources/mapper/WxMallBuildingMapper.xml index 57cd17b83..0e2c7dd28 100644 --- a/mallinkService/src/main/resources/mapper/WxMallBuildingMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMallBuildingMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`mall_id`,`building_name`,`floor_number`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,`mall_id`,`building_name`,`floor_number`,`create_date`,`update_date` @@ -25,7 +26,10 @@ and `tenant_id` = #{tenantId} - + + + + and `sub_tenant_id` = #{subTenantId} @@ -62,7 +66,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxMallFloorMapper.xml b/mallinkService/src/main/resources/mapper/WxMallFloorMapper.xml index 27e17f901..f689814e1 100644 --- a/mallinkService/src/main/resources/mapper/WxMallFloorMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMallFloorMapper.xml @@ -1,82 +1,76 @@ - - - - - - - - - - - - - - - `id`,`tenant_id`,`mall_id`,`building_id`,`floor_name`,`background_img`,`create_date`,`update_date`,`total_area`,`operating_area` - + + + + + + + + + + + + + - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` = #{tenantId} - - - - - and `mall_id` = #{mallId} - - - - - and `building_id` = #{buildingId} - - - - - and `floor_name` like concat('%', #{floorName},'%') - - - - - and `background_img` like concat('%', #{backgroundImg},'%') - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - and id in - - #{idItem} - - - order by ${sortColumns} + + `id`,`tenant_id`,`sub_tenant_id`,`mall_id`,`building_id`,`floor_name`,`background_img`,`create_date`,`update_date`,`total_area`,`operating_area` - - - - - - - - + + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + + + + and `mall_id` = #{mallId} + + + + and `building_id` = #{buildingId} + + + + and `floor_name` like concat('%', #{floorName},'%') + + + + and `background_img` like concat('%', #{backgroundImg},'%') + + + + and `create_date` = #{createDate} + + + + and `update_date` = #{updateDate} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxMallMapper.xml b/mallinkService/src/main/resources/mapper/WxMallMapper.xml index 3cb64fceb..d16c74f8f 100644 --- a/mallinkService/src/main/resources/mapper/WxMallMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMallMapper.xml @@ -4,6 +4,7 @@ + @@ -31,15 +32,19 @@ + + + - `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`, + `id`,`tenant_id`,`parent_tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`, `total_area`,`operating_area`,`park_area`,`park_place_number`,`service_phone`, `img_url`,`img_url_h`, `weap_note`, `img_qrcode_weapp`, `img_qrcode_wemp`, `weapp_share_title`,`weapp_share_cover_img`, `pos_qrcode_rule`, - `sale_type`, `valid_start`, `valid_end`,`business_hours`,`introduction`,`img` + `sale_type`, `valid_start`, `valid_end`,`business_hours`,`introduction`,`img`, + `group_support`,`latitude`,`longitude` @@ -53,6 +58,10 @@ and `tenant_id` = #{tenantId} + + and `parent_tenant_id` = #{parentTenantId} + + and `name` like concat('%', #{name},'%') @@ -121,6 +130,10 @@ and `valid_end` = #{validEnd} + + and `group_spport` = #{groupSupport} + + and id in @@ -143,6 +156,12 @@ from wx_mall where 1=1 and `tenant_id` = #{value} + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxMerchantBUserMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantBUserMapper.xml index 09c2d955f..3e0b19582 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantBUserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantBUserMapper.xml @@ -1,104 +1,118 @@ - - - - - - - - - - - - - - - - - `id`,`tenant_id`,`phone`,`user_pwd`,`merchant_id`,`create_date`,`update_date`,`app_id`,`token`,`expire_time`,`name`,`status` + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`sub_tenant_id`,`phone`,`user_pwd`,`merchant_id`,`create_date`,`update_date`,`app_id`,`token`,`expire_time`,`name`,`status` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` = #{tenantId} - - - - - and `phone` = #{phone} - - - - - and `user_pwd` like concat('%', #{userPwd},'%') - - - - - and `merchant_id` = #{merchantId} - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - - and `app_id` like concat('%', #{appId},'%') - - - - - and `token` like concat('%', #{token},'%') - - - - - and `expire_time` = #{expireTime} - - - - and `name` = #{name} - - - and `status` = #{status} - - - and id in - - #{idItem} - + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + + and `sub_tenant_id` = #{subTenantId} - order by ${sortColumns} - - - + + and `phone` = #{phone} + + + + and `user_pwd` like concat('%', #{userPwd},'%') + - + select + + from wx_merchant_b_user + + + + + + - - - - + + diff --git a/mallinkService/src/main/resources/mapper/WxMerchantCorpMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantCorpMapper.xml index a0e3d9bca..42f5c9d15 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantCorpMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantCorpMapper.xml @@ -4,6 +4,7 @@ + @@ -18,13 +19,14 @@ - `id`,`tenant_id`,`merchant_id`,`corp_papers_type`,`corp_papers_number`,`corp_papers_person`,`corp_papers_pic_face`,`corp_papers_pic_back`,`corp_papers_address`,`corp_papers_register_number`,`corp_papers_file`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`corp_papers_type`,`corp_papers_number`,`corp_papers_person`,`corp_papers_pic_face`,`corp_papers_pic_back`,`corp_papers_address`,`corp_papers_register_number`,`corp_papers_file`,`create_date`,`update_date` where 1 = 1 and `id` = #{id} - and `tenant_id` = #{tenantId} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `merchant_id` = #{merchantId} and `corp_papers_type` = #{corpPapersType} and `corp_papers_number` = #{corpPapersNumber} diff --git a/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml index 5e34a64fb..591f0af76 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml @@ -4,6 +4,7 @@ + @@ -38,13 +39,13 @@ - `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`, + `id`,`tenant_id`,`sub_tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`, `business_id`,`sub_business_id`,`shop_type`,`brand`,`type`,`is_public`,email,`title`,`cover_picture`,`is_admin`,`bill_setting`,`qr_code`, `introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone,credit_locked - m.`id`,m.`tenant_id`,m.`img_url`,m.`name`,m.`link_phone`,m.`create_date`,m.`update_date`,m.`car_vendor_type`,m.`car_params`,m.`status`,m.`link_person`, + m.`id`,m.`tenant_id`,m.`sub_tenant_id`,m.`img_url`,m.`name`,m.`link_phone`,m.`create_date`,m.`update_date`,m.`car_vendor_type`,m.`car_params`,m.`status`,m.`link_person`, m.`business_id`,m.`sub_business_id`,m.`shop_type`,m.`brand`,m.`type`,m.`is_public`,m.email,m.`title`,m.`cover_picture`,m.`is_admin`,m.`bill_setting`,m.`qr_code`, m.`introduction`,m.`action_desc`,m.`is_del`,m.`talk_user_main`,m.`talk_user_aux`,m.link_line_phone,r.rental_start_date,r.rental_end_date @@ -59,6 +60,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `img_url` like concat('%', #{imgUrl},'%') @@ -198,6 +202,10 @@ and m.`tenant_id` = #{tenantId} + + + and m.`sub_tenant_id` = #{subTenantId} + and m.`img_url` like concat('%', #{imgUrl},'%') @@ -348,6 +356,12 @@ left join wx_business bu on bu.id = m.business_id where 1=1 and m.is_del=0 + + and m.`tenant_id` = #{tenantId} + + + and m.`sub_tenant_id` = #{subTenantId} + and m.`name` like concat('%', #{merchantName},'%') @@ -405,6 +419,9 @@ and mb.id = #{buildingId} and m.tenant_id = #{tenantId} + + and m.sub_tenant_id = #{subTenantId} + and s.is_del = 0 and ms.is_del = 0 and m.status = 1 @@ -439,6 +456,9 @@ and co.tenant_id = #{tenantId} + + and o.sub_tenant_id = #{subTenantId} + and co.create_date >= #{starttime} @@ -447,7 +467,7 @@ group by m.id ) consume on consume.merchant_id=m.id - where m.status=1 + where m.status=1 and `name` like concat('%', #{name},'%') @@ -467,8 +487,12 @@ from wx_coupon_order o left join wx_coupon co on(o.`coupon_id`=co.id) left join wx_c_user_basic_info cb on o.c_user_id=cb.id + left join wx_c_user_basic_info cb on o.c_user_id=cb.id where o.coupon_order_status=1 and o.tenant_id=#{tenantId} + + and o.sub_tenant_id = #{subTenantId} + and o.b_user_id in( select id from wx_merchant_b_user where status=0 and merchant_id=#{id} diff --git a/mallinkService/src/main/resources/mapper/WxMerchantPowerBillConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantPowerBillConfigMapper.xml index 2b0fe0d2f..62512eb07 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantPowerBillConfigMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantPowerBillConfigMapper.xml @@ -5,6 +5,7 @@ + @@ -16,7 +17,7 @@ - `id`,`tenant_id`,`merchant_id`,`merchant_name`,`merchant_type`,`build_way`,`price`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`merchant_name`,`merchant_type`,`build_way`,`price`,`create_date`,`update_date` @@ -29,6 +30,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `merchant_name` like concat('%', #{merchantName},'%') diff --git a/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml index 715ee30b4..55fdb2afb 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml @@ -4,6 +4,7 @@ + @@ -13,7 +14,7 @@ - `id`,`tenant_id`,`merchant_id`,`shop_id`,`create_date`,`update_date`,`is_del` + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`shop_id`,`create_date`,`update_date`,`is_del` @@ -26,7 +27,10 @@ and `tenant_id` = #{tenantId} - + + + + and `sub_tenant_id` = #{subTenantId} @@ -62,7 +66,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxMerchantSubsidyMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantSubsidyMapper.xml index ebf599a41..cc8c36ce4 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantSubsidyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantSubsidyMapper.xml @@ -3,6 +3,8 @@ + + @@ -23,7 +25,7 @@ - `id`,`order_id`,`order_type`,`merchant_id`,`coupon_order_id`,`coupon_type`,`order_payment`,`receiver_payment`,`real_payment`,`subsidy`,`real_subsidy`,`status`,`create_date`,`update_date`,freeze,type,source + `id`,`tenant_id`,`sub_tenant_id`,`order_id`,`order_type`,`merchant_id`,`coupon_order_id`,`coupon_type`,`order_payment`,`receiver_payment`,`real_payment`,`subsidy`,`real_subsidy`,`status`,`create_date`,`update_date`,freeze,type,source @@ -34,6 +36,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `order_id` = #{orderId} @@ -111,6 +116,9 @@ and `tenant_id`=#{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `merchant_id`=#{merchantId} @@ -125,6 +133,8 @@ + + @@ -158,7 +168,7 @@ - ms.`id`,ms.`tenant_id`,ms.`order_id`,ms.`order_type`,ms.`merchant_id`,ms.`coupon_order_id`,ms.`coupon_type`, + ms.`id`,ms.`tenant_id`,ms.`sub_tenant_id`,ms.`order_id`,ms.`order_type`,ms.`merchant_id`,ms.`coupon_order_id`,ms.`coupon_type`, ms.`order_payment`,ms.`receiver_payment`,ms.`real_payment`, ms.`subsidy`,ms.`real_subsidy`,ms.`status`,ms.`create_date`,ms.`update_date`, c.`title`,c.`sub_title`,c.`unit`,m.`name`, @@ -172,6 +182,9 @@ and t.`tenant_id` = #{tenantId} + + and t.`sub_tenant_id` = #{subTenantId} + and t.`order_id` = #{orderId} diff --git a/mallinkService/src/main/resources/mapper/WxMerchantTaxMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantTaxMapper.xml index ff4cbcf1b..a6196b55d 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantTaxMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantTaxMapper.xml @@ -4,6 +4,7 @@ + @@ -21,13 +22,14 @@ - `id`,`tenant_id`,`merchant_id`,`taxpayer_type`,`tax_papers_type`,`tax_papers_number`,`invoice_type`,`invoice_buyer`,`taxpayer_identify_number`,`invoice_address_phone`,`bank_account_number`,`bank_account_person`,`bank_name`,`bank_account`,`create_date`,`update_date` + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`taxpayer_type`,`tax_papers_type`,`tax_papers_number`,`invoice_type`,`invoice_buyer`,`taxpayer_identify_number`,`invoice_address_phone`,`bank_account_number`,`bank_account_person`,`bank_name`,`bank_account`,`create_date`,`update_date` where 1 = 1 and `id` = #{id} - and `tenant_id` = #{tenantId} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `merchant_id` = #{merchantId} and `taxpayer_type` = #{taxpayerType} and `tax_papers_type` = #{taxPapersType} diff --git a/mallinkService/src/main/resources/mapper/WxMerchantTradeDailyMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantTradeDailyMapper.xml index 126387447..96136cdc6 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantTradeDailyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantTradeDailyMapper.xml @@ -4,6 +4,7 @@ + @@ -15,7 +16,7 @@ - `id`,`tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`,trade_count,proof + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`,trade_count,proof @@ -28,7 +29,10 @@ and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} + and `merchant_id` = #{merchantId} @@ -69,12 +73,16 @@ - select + select + from wx_merchant_trade_daily mtd inner join wx_merchant m on mtd.merchant_id = m.id left join wx_merchant_b_user mbu on mtd.b_user_id = mbu.id @@ -135,6 +150,9 @@ and mtd.merchant_id = #{merchantId} + + and mtd.`sub_tenant_id` = #{subTenantId} + and m.name like concat('%', #{merchantName},'%') @@ -150,6 +168,7 @@ inner join wx_merchant m on ms.merchant_id = m.id inner join wx_shop s on s.id=ms.shop_id where m.tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and s.is_del=0 and m.business_id in (${businessForRule}) @@ -172,6 +191,10 @@ and mtd.tenant_id = #{tenantId} + + + + and mtd.`sub_tenant_id` = #{subTenantId} @@ -190,13 +213,17 @@ - select report_date, IFNULL(sum(mtd.trade_amt),0) as trade_amt from wx_merchant_trade_daily mtd where 1 = 1 and mtd.tenant_id = #{tenantId} + + + and mtd.`sub_tenant_id` = #{subTenantId} and mtd.report_date = #{reportDate} diff --git a/mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml index 16eb52f33..cb19a46e0 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml @@ -4,6 +4,7 @@ + @@ -20,7 +21,7 @@ - `id`,`tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id`,`business_id` + `id`,`tenant_id`,`sub_tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id`,`business_id` @@ -85,12 +86,15 @@ - select * from wx_msg_callback where batch_no=#{batchNo} and phone=#{phone} diff --git a/mallinkService/src/main/resources/mapper/WxMsgConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgConfigMapper.xml index 89be3a91c..86e624394 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgConfigMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgConfigMapper.xml @@ -4,6 +4,7 @@ + @@ -23,7 +24,7 @@ - `id`,`tenant_id`,`secret`,`publickey`,`bid`,`recharge`,`remains`,`total`,`account`,`reminderstatus`,`reminder`,`phone`,`notifyurl`,`modelnotifyurl`,`verifynotifyurl`,`appid` + `id`,`tenant_id`,`sub_tenant_id`,`secret`,`publickey`,`bid`,`recharge`,`remains`,`total`,`account`,`reminderstatus`,`reminder`,`phone`,`notifyurl`,`modelnotifyurl`,`verifynotifyurl`,`appid` @@ -109,12 +110,16 @@ - update wx_msg_config set remains = if(remains - #{remains} < 0,0,remains - #{remains}) where `tenant_id` = #{tenantId} + update wx_msg_config set remains = if(remains - #{remains} < 0,0,remains - #{remains}) + where `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} diff --git a/mallinkService/src/main/resources/mapper/WxMsgLimitMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgLimitMapper.xml index e37124a23..fb2f82214 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgLimitMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgLimitMapper.xml @@ -4,6 +4,7 @@ + @@ -12,7 +13,7 @@ - `id`,`tenant_id`,`type`,`limit_id`,`limit_num`,`limit_date` + `id`,`tenant_id`,`sub_tenant_id`,`type`,`limit_id`,`limit_num`,`limit_date` diff --git a/mallinkService/src/main/resources/mapper/WxMsgMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgMapper.xml index 5c61fa1ac..8020fe32f 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgMapper.xml @@ -4,6 +4,7 @@ + @@ -26,7 +27,7 @@ - `id`,`tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`tags`,`status`,`way`,`coupon_inject_id` + `id`,`tenant_id`,`sub_tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`tags`,`status`,`way`,`coupon_inject_id` @@ -39,7 +40,10 @@ and `tenant_id` = #{tenantId} - + + + + and `sub_tenant_id` = #{subTenantId} @@ -127,7 +131,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml index 53762e162..44cc58b60 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml @@ -1,91 +1,88 @@ - - - - - - - - - + + + + + + + + + + - - - - `id`,`tenant_id`,`name`,`signature`,`content`,`createtime`,`status`,`model_id` + + + + `id`,`tenant_id`,`sub_tenant_id`,`name`,`signature`,`content`,`createtime`,`status`,`model_id` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id`=#{tenantId} - - - - - and `name` = #{name} - - - - - and `signature` = #{signature} - - - - - and `content` = #{content} - - - - - and `createtime` = #{createtime} - - - - - and `status` = #{status} - - - - and `model_id` = #{modelId} + + where 1 = 1 - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + and `id` = #{id} + + + + and `tenant_id`=#{tenantId} + + + and `sub_tenant_id`=#{subTenantId} + + + + and `name` = #{name} + + + + and `signature` = #{signature} + + + + and `content` = #{content} + + + + and `createtime` = #{createtime} + + + + and `status` = #{status} + + + and `model_id` = #{modelId} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + - - - - - diff --git a/mallinkService/src/main/resources/mapper/WxMsgRecordMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgRecordMapper.xml index ce39aff59..86c6ebc00 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgRecordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgRecordMapper.xml @@ -4,6 +4,7 @@ + @@ -28,7 +29,7 @@ - id,tenant_id,`domain`,msg_type,msg,send_time,model_id,sender,sender_user_id,sender_user_name,receiver,receiver_user_id, + id,tenant_id,sub_tenant_id,`domain`,msg_type,msg,send_time,model_id,sender,sender_user_id,sender_user_name,receiver,receiver_user_id, receiver_user_name,msg_status,status_message,createtime,updatetime,uuid,signature,model_type,msg_json @@ -41,6 +42,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `receiver_user_id` = #{receiverUserId} @@ -76,12 +80,12 @@ - INSERT INTO wx_msg_record( id,tenant_id,`uuid`, `msg_type`, + INSERT INTO wx_msg_record( id,tenant_id,sub_tenant_id,`uuid`, `msg_type`, `domain`, `msg`, `send_time`, `model_id`, `model_type`, `signature`, `sender`, `sender_user_id`, `sender_user_name`, `receiver`, `receiver_user_id`, `receiver_user_name`, `msg_status`, `status_message`, `msg_json`) - VALUES(#{id},#{tenantId},#{uuid},#{msgType}, + VALUES(#{id},#{tenantId},#{subTenantId},#{uuid},#{msgType}, #{domain},#{msg},#{sendTime},#{modelId},#{modelType},#{signature},#{sender}, #{senderUserId},#{senderUserName},#{receiver},#{receiverUserId},#{receiverUserName}, #{msgStatus},#{statusMessage},#{msgJson}); diff --git a/mallinkService/src/main/resources/mapper/WxMsgSignatureMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgSignatureMapper.xml index 6bfedbb74..e1eda0966 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgSignatureMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgSignatureMapper.xml @@ -4,12 +4,13 @@ + - `id`,`tenant_id`,`name`,`createtime` + `id`,`tenant_id`,`sub_tenant_id`,`name`,`createtime` @@ -22,7 +23,10 @@ and `tenant_id` = #{tenantId} - + + + + and `sub_tenant_id` = #{subTenantId} @@ -44,7 +48,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxMsgValidationcodeMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgValidationcodeMapper.xml index b3791f2b8..13fdee390 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgValidationcodeMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgValidationcodeMapper.xml @@ -3,30 +3,31 @@ + + - - - `id`,`phone`,`expiretime`,`createtime`,`type`,`tenant_id`,`msg`,`signature`,`code`,`appid` + `id`,`tenant_id`,`sub_tenant_id`,`phone`,`expiretime`,`createtime`,`type`,`msg`,`signature`,`code`,`appid` where 1 = 1 - and `id` = #{id} + and `id` = #{id} + and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `phone` = #{phone} and `expiretime` = #{expiretime} and `createtime` = #{createtime} - and `type` = #{type} - and `tenant_id` = #{tenantId} + and `type` = #{type} and `msg` = #{msg} and `signature` = #{signature} and `code` = #{code} diff --git a/mallinkService/src/main/resources/mapper/WxMsgValidationcodeModelMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgValidationcodeModelMapper.xml index dbcf6d198..e96fe11d6 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgValidationcodeModelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgValidationcodeModelMapper.xml @@ -12,6 +12,7 @@ + @@ -20,7 +21,7 @@ - `id`,`name`,`signature`,`content`,`createtime`,`status`,`minutes`,`model_id`,`type`,`tenant_id`,email_bg_img,`open`,msg_type,role_type + `id`,`name`,`signature`,`content`,`createtime`,`status`,`minutes`,`model_id`,`type`,`tenant_id`,`sub_tenant_id`,email_bg_img,`open`,msg_type,role_type @@ -35,6 +36,7 @@ and `model_id` = #{modelId} and `type` = #{type} and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `open` = #{open} and `msg_type` = #{msgType} and `role_type` = #{roleType} diff --git a/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml index 4814bc13c..b37c49be9 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml @@ -4,6 +4,7 @@ + @@ -16,7 +17,7 @@ - `id`,`tenant_id`,`order_id`,`coupon_id`,`remain_people`,`create_date`,`update_date`,`expired_date`,`status`,`user_id` + `id`,`tenant_id`,`sub_tenant_id`,`order_id`,`coupon_id`,`remain_people`,`create_date`,`update_date`,`expired_date`,`status`,`user_id` @@ -27,6 +28,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `order_id` = #{orderId} @@ -55,6 +59,7 @@ from wx_order o left join wx_c_user c on o.c_user_id=c.id where o.tenant_id=#{tenantId} + and o.`sub_tenant_id` = #{subTenantId} and o.id=#{orderId} @@ -63,7 +68,7 @@ select o.id orderId,o.order_status orderStatus,o.order_group_id orderGroupId,c.title,c.sub_title subTitle, c.sale_price salePrice,c.cover_img coverImg,g.remain_people remainPeople,c.id couponId,g.expired_date - expiredDate,g.status,g.user_id firstUser,u.nick_name nickName,u.avatar_url avatarUrl,o.tenant_id tenantId, + expiredDate,g.status,g.user_id firstUser,u.nick_name nickName,u.avatar_url avatarUrl,o.tenant_id tenantId,o.sub_tenant_id subTenantId, o.coupon_channel_id couponChannelId,c.press_limit_num pressLimitNum, (select status from wx_coupon_channel where id=o.coupon_channel_id) couponStatus from wx_order o @@ -71,6 +76,7 @@ left join wx_order_group g on o.order_group_id=g.id left join wx_c_user u on o.c_user_id=u.id where o.tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} and c.type=9 and o.c_user_id=#{cUserId} @@ -93,7 +99,7 @@ select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) triggerCount from wx_order o - where o.`tenant_id` = #{tenantId} and o.`type` = #{type} + where o.`tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} + and o.`type` = #{type} and o.`create_date` BETWEEN #{startTime} and #{endTime} @@ -449,6 +480,9 @@ and o.`tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and o.`type` = #{type} @@ -486,6 +520,7 @@ wm.id as id, wm.tenant_id as tenant_id, + wm.sub_tenant_id as sub_tenant_id, wm.name as merchant_name, wm.link_phone as merchant_phone, mo.xTime as report_date, @@ -526,6 +561,7 @@ + @@ -547,45 +583,53 @@ - select from wx_profit_sharing_order + select + + from wx_profit_sharing_order @@ -115,6 +121,7 @@ + @@ -137,6 +144,9 @@ and pso.tenant_id =#{tenantId} + + + and pso.sub_tenant_id =#{subTenantId} and pso.id =#{id} @@ -167,6 +177,9 @@ and tenant_id =#{tenantId} + + and sub_tenant_id =#{subTenantId} + and create_time between #{startdate} and #{enddate} @@ -180,6 +193,9 @@ and tenant_id =#{tenantId} + + and sub_tenant_id =#{subTenantId} + and create_time between #{startdate} and #{enddate} @@ -189,6 +205,7 @@ + @@ -204,7 +221,7 @@ - select from wx_profit_sharing_receiver - + select + + from wx_profit_sharing_receiver + diff --git a/mallinkService/src/main/resources/mapper/WxProfitSharingResultMapper.xml b/mallinkService/src/main/resources/mapper/WxProfitSharingResultMapper.xml index 07d1c5978..6ca7991cd 100644 --- a/mallinkService/src/main/resources/mapper/WxProfitSharingResultMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxProfitSharingResultMapper.xml @@ -4,6 +4,7 @@ + @@ -17,7 +18,7 @@ - `id`,`tenant_id`,`merchant_id`,`sharing_order_id`,`sharing_receiver_id`,`pay_amount`,`update_time`,`create_time`,`sharing_status`,`finish_time`,`failed_reason`,`description` + `id`,`tenant_id`,`sub_tenant_id`,`merchant_id`,`sharing_order_id`,`sharing_receiver_id`,`pay_amount`,`update_time`,`create_time`,`sharing_status`,`finish_time`,`failed_reason`,`description` @@ -30,7 +31,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} @@ -87,7 +91,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 9d7ea1f65..866922ac2 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -10,6 +10,7 @@ + @@ -50,7 +51,7 @@ `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`, - `sign_date`,`receive_period`,`tenant_id`,`filepath`,`status`,`contract_number`, + `sign_date`,`receive_period`,`tenant_id`,`sub_tenant_id`,`filepath`,`status`,`contract_number`, `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`, `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`, `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, @@ -68,6 +69,7 @@ and `sign_date` = #{signDate} and `receive_period` = #{receivePeriod} and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `filepath` = #{filepath} and `status` = #{status} and `contract_number` = #{contractNumber} diff --git a/mallinkService/src/main/resources/mapper/WxQuestionMapper.xml b/mallinkService/src/main/resources/mapper/WxQuestionMapper.xml index d51f066fc..6e4b0062b 100644 --- a/mallinkService/src/main/resources/mapper/WxQuestionMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxQuestionMapper.xml @@ -4,11 +4,12 @@ + - `id`,`tenant_id`,`content` + `id`,`tenant_id`,`sub_tenant_id`,`content` @@ -22,6 +23,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `content` = #{content} diff --git a/mallinkService/src/main/resources/mapper/WxRefundOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxRefundOrderMapper.xml index 4e6e62f3d..be72f43a3 100644 --- a/mallinkService/src/main/resources/mapper/WxRefundOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRefundOrderMapper.xml @@ -4,6 +4,7 @@ + @@ -21,7 +22,7 @@ - `id`,`tenant_id`,`create_time`,`update_time`,`transaction_id`,`order_id`,`pay_order_no`,`c_user_id`,`total_fee`,`refund_fee`,`refund_time_start`,`refund_time_end`,`refund_vendor`,`refund_order_status`,`refund_id`,`fail_reason` + `id`,`tenant_id`,`sub_tenant_id`,`create_time`,`update_time`,`transaction_id`,`order_id`,`pay_order_no`,`c_user_id`,`total_fee`,`refund_fee`,`refund_time_start`,`refund_time_end`,`refund_vendor`,`refund_order_status`,`refund_id`,`fail_reason` @@ -34,7 +35,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} @@ -48,7 +52,7 @@ - and `transaction_id` like concat('%', #{transactionId},'%') + and `transaction_id` = #{transactionId} @@ -117,7 +121,9 @@ diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 6f92b3e4b..a82749f8d 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -10,6 +10,7 @@ + @@ -80,7 +81,7 @@ `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`, - `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, + `tenant_id`,`sub_tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`, `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, `start_date`,`end_date`, @@ -100,6 +101,7 @@ and `sign_date` = #{signDate} and `receive_period` = #{receivePeriod} and `tenant_id` = #{tenantId} + and `sub_tenant_id` = #{subTenantId} and `filepath` = #{filepath} and `status` = #{status} and `contract_number` = #{contractNumber} @@ -250,7 +252,8 @@ )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and rent_shop_type=2 - select s.shop_id,s.shop_number,s.building_name building, s.floor_name floor,s.build_area,rc.* from ( select s.id shop_id,ms.merchant_id,s.shop_number,b.building_name,f.floor_name,s.build_area,s.floor,s.building from wx_shop s @@ -305,13 +308,18 @@ - update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and id in(select r.id from ( + update wx_rent_contract set status=#{status} + where tenant_id=#{tenantId} + and `sub_tenant_id` = #{subTenantId} + and id in(select r.id from ( select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and rent_shop_type=1 and status in(0,1) and status!=7)r) @@ -342,7 +350,9 @@ @@ -418,8 +428,9 @@ @@ -438,6 +449,7 @@ SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM `wx_rent_contract` rc WHERE tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} AND rc.`status` IN (2,3,4) AND status!=7 AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN @@ -452,6 +464,7 @@ SELECT count(*) FROM wx_rent_contract WHERE tenant_id = #{tenantId} + and `sub_tenant_id` = #{subTenantId} AND `status` = #{status} AND status!=7 AND ( `rent_shop_type` = 1 AND diff --git a/mallinkService/src/main/resources/mapper/WxScoreHistoryMapper.xml b/mallinkService/src/main/resources/mapper/WxScoreHistoryMapper.xml index 85162b0ff..424968973 100644 --- a/mallinkService/src/main/resources/mapper/WxScoreHistoryMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxScoreHistoryMapper.xml @@ -4,6 +4,7 @@ + @@ -16,7 +17,7 @@ - `id`,`tenant_id`,`c_user_id`,`create_date`,`score_type`,`valid_date`,`order_id`,`pay_type`,`pay_amount`,`score_amount`,`reason` + `id`,`tenant_id`,`sub_tenant_id`,`c_user_id`,`create_date`,`score_type`,`valid_date`,`order_id`,`pay_type`,`pay_amount`,`score_amount`,`reason` @@ -30,6 +31,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `c_user_id` = #{cUserId} @@ -90,6 +95,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `c_user_id` = #{cUserId} @@ -106,6 +114,9 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + and `c_user_id` = #{cUserId} @@ -118,7 +129,8 @@ update wx_score_history set c_user_id=#{newUserId} where tenant_id=#{tenantId} - and c_user_id = #{cUserId} + and `sub_tenant_id` = #{subTenantId} + and c_user_id = #{cUserId} diff --git a/mallinkService/src/main/resources/mapper/WxScreenAdMapper.xml b/mallinkService/src/main/resources/mapper/WxScreenAdMapper.xml index d45f64b4a..cc273d5b2 100644 --- a/mallinkService/src/main/resources/mapper/WxScreenAdMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxScreenAdMapper.xml @@ -4,6 +4,7 @@ + @@ -16,7 +17,7 @@ - `id`, `tenant_id`, `title`, `type`, `sub_type`, `status`, `create_date`, `update_date`, `cover_img`, `target_id`, `ext_info` + `id`, `tenant_id`, `sub_tenant_id`,`title`, `type`, `sub_type`, `status`, `create_date`, `update_date`, `cover_img`, `target_id`, `ext_info` @@ -30,6 +31,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `title` like concat('%', #{title},'%') @@ -86,6 +91,9 @@ and sa.tenant_id = #{tenantId} + + and sa.`sub_tenant_id` = #{subTenantId} + diff --git a/mallinkService/src/main/resources/mapper/WxShopMapper.xml b/mallinkService/src/main/resources/mapper/WxShopMapper.xml index 59f7e3ac1..9ebe86404 100644 --- a/mallinkService/src/main/resources/mapper/WxShopMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxShopMapper.xml @@ -4,6 +4,7 @@ + @@ -33,7 +34,7 @@ - `id`,`tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`,`floor`,`status`,`x`,`y`,`addr`, + `id`,`tenant_id`,`sub_tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`,`floor`,`status`,`x`,`y`,`addr`, `baidu_poi`,`longitude`,`latitude`,`create_date`,`update_date`,`img_url`,`manager`,`manager_phone`, `type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay,rent,rent_unit,business_id @@ -43,82 +44,69 @@ and `id` = #{id} - and `tenant_id` = #{tenantId} - + + + and `sub_tenant_id` = #{subTenantId} and `shop_number` like concat('%', #{shopNumber},'%') - and `build_area` like concat('%', #{buildArea},'%') - and `operation_area` like concat('%', #{operationArea},'%') - and `building` like concat('%', #{building},'%') - and `floor` = #{floor} - and `status` = #{status} - and `x` = #{x} - and `y` = #{y} - and `addr` like concat('%', #{addr},'%') - and `baidu_poi` like concat('%', #{baiduPoi},'%') - and `longitude` = #{longitude} - and `latitude` = #{latitude} - and `create_date` = #{createDate} - and `update_date` = #{updateDate} - and `manager` = #{manager} @@ -126,11 +114,11 @@ and `manager_phone` = #{managerPhone} - + and `type` = #{type} - + and `point_type` = #{pointType} @@ -152,7 +140,7 @@ select id,shop_number shopNumber from wx_shop where tenant_id=#{tenantId} and shop_number = #{shopNumber} and is_del=0 + and `sub_tenant_id` = #{subTenantId} - select * from wx_topic - - + - SELECT * FROM wx_topic WHERE wx_topic.tenant_id = #{tenantId} AND (`begin_time` >= #{beginTime} and `end_time` <= #{endTime}) AND `status` = 1 - select t.*,cc.id as couponChannelId from wx_topic t left join wx_coupon_channel cc on(cc.sub_target_id = t.id) where t.status = 1 and now() >= t.begin_time and now() <= t.end_time @@ -86,7 +90,7 @@ order by t.begin_time desc limit 1 - + update wx_topic set status = 3 where id in( select t.id from ( select id from wx_topic where status !=3 and now() >= end_time and tenant_id = #{tenantId} @@ -94,7 +98,7 @@ ) - + update wx_coupon_channel set status = 1 where status = 0 and target_ad = 8 and sub_target_id in( select id from wx_topic where status in(2,3) and tenant_id = #{tenantId} ) diff --git a/mallinkService/src/main/resources/mapper/WxUserDataRuleMapper.xml b/mallinkService/src/main/resources/mapper/WxUserDataRuleMapper.xml index c397ad676..89d33a9f1 100644 --- a/mallinkService/src/main/resources/mapper/WxUserDataRuleMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxUserDataRuleMapper.xml @@ -4,6 +4,7 @@ + @@ -14,7 +15,7 @@ - `id`,`tenant_id`,`user_id`,`type`,`business`,`target`,`create_time`,`update_time` + `id`,`tenant_id`,`sub_tenant_id`,`user_id`,`type`,`business`,`target`,`create_time`,`update_time` @@ -27,6 +28,10 @@ and `tenant_id` = #{tenantId} + + + and `sub_tenant_id` = #{subTenantId} + and `user_id` = #{userId} diff --git a/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml b/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml index 8a155bcc0..1e5adc388 100644 --- a/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxUserVisitMapper.xml @@ -97,11 +97,14 @@ - SELECT DATE_FORMAT(day_date,'%Y-%m-%d') as xTime,visit_pv as pv,visit_uv as uv from wx_user_visit where tenant_id=#{tenantId} diff --git a/mallinkService/src/main/resources/mapper/WxWiwideInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxWiwideInfoMapper.xml index 6898a08c4..36ff4ff53 100644 --- a/mallinkService/src/main/resources/mapper/WxWiwideInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxWiwideInfoMapper.xml @@ -4,6 +4,7 @@ + @@ -13,7 +14,7 @@ - `id`,`tenant_id`,`wiwide_id`,`wiwide_key`,`wiwide_url`, `token`,`expired_time`,`capability` + `id`,`tenant_id`,`sub_tenant_id`,`wiwide_id`,`wiwide_key`,`wiwide_url`, `token`,`expired_time`,`capability` @@ -27,6 +28,10 @@ and `tenant_id` = #{tenantId} + + and `sub_tenant_id` = #{subTenantId} + + and `wiwide_id` like concat('%', #{wiwideId},'%') diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/base/BaseController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/base/BaseController.java index 8e1168e78..a3796fc05 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/base/BaseController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/base/BaseController.java @@ -66,9 +66,11 @@ public class BaseController { public TenantEntity getTenantInfo(){ Session session = SecurityUtils.getSubject().getSession(); String tenantId = (String)session.getAttribute(UserSession.tenantId); + String subTenantId = (String)session.getAttribute(UserSession.subTenantId); TenantEntity tenantEntity = new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; return tenantEntity; } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgCallbackController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgCallbackController.java index 2a7770e4f..366912543 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgCallbackController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgCallbackController.java @@ -56,6 +56,7 @@ public class WxMsgCallbackController extends BaseController { @SystemControllerLog(description = "短信回调结果-更新") public ResultData update(@RequestBody WxMsgCallback wxMsgCallback) { logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::update"); + wxMsgCallback.updateTenantInfo(getTenantInfo()); wxMsgCallbackService.saveOrUpdate(wxMsgCallback); return new ResultData(); } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java index 9ebc89d08..a5ed39d66 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgModelController.java @@ -56,6 +56,7 @@ public class WxMsgModelController extends BaseController { @SystemControllerLog(description = "短信模板-更新") public ResultData update(@RequestBody WxMsgModel wxMsgModel) { logger.debug("[" + getIpAddr() + "] WxMsgModelController::update"); + wxMsgModel.updateTenantInfo(getTenantInfo()); return wxMsgModelService.saveOrUpdate(wxMsgModel); } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java index a63a75db7..f51b8fdc6 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgSignatureController.java @@ -56,6 +56,7 @@ public class WxMsgSignatureController extends BaseController { @SystemControllerLog(description = "消息签名-更新") public ResultData update(@RequestBody WxMsgSignature wxMsgSignature) { logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::update"); + wxMsgSignature.updateTenantInfo(getTenantInfo()); wxMsgSignatureService.saveOrUpdate(wxMsgSignature); return new ResultData(); } @@ -82,7 +83,7 @@ public class WxMsgSignatureController extends BaseController { @ApiOperation("获取所有数据") @GetMapping("getsignaturelist") @SystemControllerLog(description = "消息签名-获取所有") - public ResultData getmodellist() { + public ResultData getSignatureList() { logger.debug("[" + getIpAddr() + "] WxMsgSignatureController::getmodellist"); return wxMsgSignatureService.getSignatureList(getTenantInfo()); } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeModelController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeModelController.java index 4b29f1aff..4eb306af7 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeModelController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/msg/WxMsgValidationcodeModelController.java @@ -49,6 +49,7 @@ public class WxMsgValidationcodeModelController extends BaseController { @SystemControllerLog(description = "消息验证模板-更新") public ResultData update(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) { logger.debug("[" + getIpAddr() + "] WxMsgValidationcodeModelController::update"); + wxMsgValidationcodeModel.updateTenantInfo(getTenantInfo()); wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel); return new ResultData(); } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/HomeController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/HomeController.java index 4acaa91f5..730d4ce1b 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/HomeController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/HomeController.java @@ -345,7 +345,7 @@ public class HomeController extends BaseController { info.protectInfos(); mallUserActionService.saveActionInfo(info, EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户手机号登录"); - WxMall mall = mallService.getByTenantId(info.getTenantId()); + WxMall mall = mallService.getByTenantInfo(info); if (mall == null) { logger.error("未配置相应的mall"); return new ResultData(Result.ERROR, "未配置相应的mall"); diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallRoleController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallRoleController.java index 64eb4833b..eb762b9dc 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallRoleController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallRoleController.java @@ -6,10 +6,7 @@ import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; -import com.iformall.domain.po.MallRole; -import com.iformall.domain.po.MallRolePermission; -import com.iformall.domain.po.MallUserInfo; -import com.iformall.domain.po.MallUserRole; +import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.EnumUserAdmin; import com.iformall.service.MallRolePermissionService; @@ -56,13 +53,13 @@ public class MallRoleController extends BaseController { @SystemControllerLog(description = "用户管理-rule列表") public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] MallRoleController::list"); - String tenantId = getTenantId(); - sysRole.setTenantId(tenantId); + TenantEntity tenantEntity = getTenantInfo(); + sysRole.updateTenantInfo(tenantEntity); final PageInfo page = sysRoleService.listAsPage(sysRole, pageNum, pageSize); for (MallRole r : page.getList()) { MallRolePermission p = new MallRolePermission(); p.setRoleId(r.getId()); - p.setTenantId(tenantId); + p.updateTenantInfo(tenantEntity); List pers = sysRolePermissionService.getList(p); String menus = ""; for (MallRolePermission rp : pers) { diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallUserInfoController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallUserInfoController.java index 2655afec4..e550f600b 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallUserInfoController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/MallUserInfoController.java @@ -8,6 +8,7 @@ import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.*; import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.EnumMallUserStatus; import com.iformall.enums.EnumUserAdmin; import com.iformall.service.*; diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java index 4bd20a7aa..0a5645b7f 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/SysMenuController.java @@ -71,7 +71,7 @@ public class SysMenuController extends BaseController { logger.debug("[" + getIpAddr() + "] MallPermissionController::nav"); MallUserInfo user = getUser(); List menuList = mallPermissionService.getUserMenuList(user, 0L, true); - Set permissions = mallUserInfoService.getUserPermissions(user); + Set permissions = mallUserInfoService.getUserPermissions(user, true); Map map = new HashMap<>(); map.put("menuList", menuList); map.put("permissions", permissions); @@ -86,7 +86,7 @@ public class SysMenuController extends BaseController { logger.debug("[" + getIpAddr() + "] MallPermissionController::list"); MallUserInfo user = getUser(); List menuList = mallPermissionService.getUserMenuList(user, 0L, false);; - Set permissions = mallUserInfoService.getUserPermissions(user); + Set permissions = mallUserInfoService.getUserPermissions(user, false); Map map = new HashMap<>(); map.put("menuList", menuList); map.put("permissions", permissions); diff --git a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/UploadController.java b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/UploadController.java index f59d94a42..69124d82b 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/UploadController.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/controller/sys/UploadController.java @@ -15,7 +15,6 @@ import com.iformall.controller.base.BaseController; import com.iformall.domain.po.MallResource; import com.iformall.domain.po.base.TenantEntity; import com.iformall.service.MallResourceService; -import com.iformall.utils.Constant; import com.iformall.utils.ImgUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -47,9 +46,18 @@ public class UploadController extends BaseController { @Autowired private MallResourceService mallResourceService; + private String getFileName(TenantEntity tenantEntity, String fileName) { + if (StringUtils.isBlank(tenantEntity.getSubTenantId())) { + fileName = tenantEntity.getTenantId() + "/" + fileName; + } else { + fileName = tenantEntity.getTenantId() + "/" + tenantEntity.getSubTenantId() + "/" +fileName; + } + return fileName; + } + private AmazonS3 s3 = null; - private ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, String tenantId) { + private ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, TenantEntity tenantVEntity) { ResultData data = new ResultData(); try { if(s3 == null) { @@ -76,7 +84,7 @@ public class UploadController extends BaseController { logger.info(url.toString()); MallResource mr = new MallResource(); - mr.setTenantId(tenantId); + mr.updateTenantInfo(tenantVEntity); mr.setBucket(awsProperty.getBucketName()); mr.setS3Key(fileName); mr.setUrl(url.toString()); @@ -126,6 +134,8 @@ public class UploadController extends BaseController { public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) throws Exception { logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); + TenantEntity tenantEntity = getTenantInfo(); + ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentType(multiReq.getContentType()); metadata.setContentLength(multiReq.getSize()); @@ -136,12 +146,13 @@ public class UploadController extends BaseController { String fileName = UUID.randomUUID().toString(); int dot = multiReq.getOriginalFilename().lastIndexOf('.'); if (dot >= 0) { - fileName = getTenantId() + "/" + fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); + String fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); + fileName = getFileName(tenantEntity, fileName + fileFormat); } else { - fileName = getTenantId() + "/" + fileName; + fileName = getFileName(tenantEntity, fileName); } - ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); + ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, tenantEntity); return data; } @@ -157,6 +168,8 @@ public class UploadController extends BaseController { public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); + TenantEntity tenantEntity = getTenantInfo(); + String fileName = UUID.randomUUID().toString(); String tempFileName = fileName; String fileFormat = ""; @@ -164,9 +177,9 @@ public class UploadController extends BaseController { int dot = multiReq.getOriginalFilename().lastIndexOf('.'); if (dot >= 0) { fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); - fileName = getTenantId() + "/" + fileName + fileFormat; + fileName = getFileName(tenantEntity, fileName + fileFormat); } else { - fileName = getTenantId() + "/" + fileName; + fileName = getFileName(tenantEntity, fileName); } System.out.println(fileName); @@ -194,7 +207,7 @@ public class UploadController extends BaseController { ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentType(multiReq.getContentType()); metadata.setContentLength(newFile.length()); - ResultData data = awsUpload(new FileInputStream(newFile), metadata, fileName, getTenantId()); + ResultData data = awsUpload(new FileInputStream(newFile), metadata, fileName, tenantEntity); // 删除本地缓存 newFile.delete(); return data; @@ -202,7 +215,7 @@ public class UploadController extends BaseController { ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentType(multiReq.getContentType()); metadata.setContentLength(multiReq.getSize()); - ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); + ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, tenantEntity); return data; } } @@ -219,6 +232,8 @@ public class UploadController extends BaseController { public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) throws Exception { logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); + TenantEntity tenantEntity = getTenantInfo(); + if(files.length > 0){ ResultData data = new ResultData(); List> dataList = new ArrayList>(); @@ -237,12 +252,13 @@ public class UploadController extends BaseController { String fileName = UUID.randomUUID().toString(); int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); if (dot >= 0) { - fileName = getTenantId() + "/" + fileName + multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); + String fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); + fileName = getFileName(tenantEntity, fileName + fileFormat); } else { - fileName = getTenantId() + "/" + fileName; + fileName = getFileName(tenantEntity, fileName); } - ResultData data1 = awsUpload(multipartFile.getInputStream(), metadata, fileName, getTenantId()); + ResultData data1 = awsUpload(multipartFile.getInputStream(), metadata, fileName, tenantEntity); if(data1.code == ResultData.SUCCESS) { Map _data = (Map)data1.data; map.put("url", (String) _data.get("url")); @@ -280,7 +296,9 @@ public class UploadController extends BaseController { String fileName = multiReq.getOriginalFilename(); fileName = "cimg/" + fileName; - ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, "cimg"); + ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, new TenantEntity() {{ + setTenantId("cimg"); + }}); return data; } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java b/mallinkSysAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java index f3c80982c..0c1b7829c 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/shiro/MyShiroRealm.java @@ -30,7 +30,7 @@ public class MyShiroRealm extends AuthorizingRealm { @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal(); - Set permissionSet = userService.getUserPermissions(user); + Set permissionSet = userService.getUserPermissions(user, true); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setStringPermissions(permissionSet); return info; diff --git a/mallinkSysAdmin/src/main/java/com/iformall/shiro/UserSession.java b/mallinkSysAdmin/src/main/java/com/iformall/shiro/UserSession.java index 02a7aca87..aba5865b0 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/shiro/UserSession.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/shiro/UserSession.java @@ -8,4 +8,6 @@ public class UserSession { public static String tenantId ="TENANT_ID"; + public static String subTenantId ="SUB_TENANT_ID"; + } diff --git a/mallinkWebSocketServer/src/main/java/com/iformall/controller/BaseController.java b/mallinkWebSocketServer/src/main/java/com/iformall/controller/BaseController.java index f38ff1dae..1aa4af06b 100644 --- a/mallinkWebSocketServer/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkWebSocketServer/src/main/java/com/iformall/controller/BaseController.java @@ -2,10 +2,10 @@ package com.iformall.controller; import cn.binarywang.wx.miniapp.api.WxMaService; import com.iformall.common.ErrorCode; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxCUserBasicInfo; -import com.iformall.domain.po.base.TenantEntity; import com.iformall.exception.MallinkException; import com.iformall.interceptor.AuthHandshakeInterceptor; import com.iformall.service.WxAppinfoService; @@ -97,9 +97,11 @@ public class BaseController { public TenantEntity getTenantInfo(){ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String tenantId = (String)request.getAttribute(AuthHandshakeInterceptor.TENANT_ID); + String subTenantId = (String)request.getAttribute(AuthHandshakeInterceptor.SUB_TENANT_ID); TenantEntity tenantEntity = new TenantEntity(){{ setTenantId(tenantId); + setSubTenantId(subTenantId); }}; return tenantEntity; } diff --git a/mallinkWebSocketServer/src/main/java/com/iformall/interceptor/AuthHandshakeInterceptor.java b/mallinkWebSocketServer/src/main/java/com/iformall/interceptor/AuthHandshakeInterceptor.java index b60301658..cc5321beb 100644 --- a/mallinkWebSocketServer/src/main/java/com/iformall/interceptor/AuthHandshakeInterceptor.java +++ b/mallinkWebSocketServer/src/main/java/com/iformall/interceptor/AuthHandshakeInterceptor.java @@ -33,6 +33,7 @@ public class AuthHandshakeInterceptor implements HandshakeInterceptor { public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; public static final String TENANT_ID = "TENANT_ID"; + public static final String SUB_TENANT_ID = "SUB_TENANT_ID"; @Override public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map attributes) throws Exception { diff --git a/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/MultiTenancy.java b/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/MultiTenancy.java index 5a79c4984..b1d8097d4 100644 --- a/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/MultiTenancy.java +++ b/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/MultiTenancy.java @@ -1,13 +1,14 @@ package com.iformall.plugin; import net.sf.jsqlparser.JSQLParserException; -import net.sf.jsqlparser.expression.BinaryExpression; import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.Parenthesis; import net.sf.jsqlparser.expression.StringValue; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; import net.sf.jsqlparser.expression.operators.conditional.OrExpression; import net.sf.jsqlparser.expression.operators.relational.EqualsTo; import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.ItemsList; import net.sf.jsqlparser.expression.operators.relational.MultiExpressionList; import net.sf.jsqlparser.parser.CCJSqlParserUtil; import net.sf.jsqlparser.schema.Column; @@ -51,7 +52,39 @@ public class MultiTenancy implements Interceptor { //获取tenantId的接口 private TenantInfo tenantInfo; private String tenantIdColumn = "tenant_id"; + private String subTenantIdColumn = "sub_tenant_id"; private String dialect = "mysql"; + public TenantInfo getTenantInfo() { + return tenantInfo; + } + + public void setTenantInfo(TenantInfo tenantInfo) { + this.tenantInfo = tenantInfo; + } + + public String getTenantIdColumn() { + return tenantIdColumn; + } + + public void setTenantIdColumn(String tenantIdColumn) { + this.tenantIdColumn = tenantIdColumn; + } + + public String getSubTenantIdColumn() { + return subTenantIdColumn; + } + + public void setSubTenantIdColumn(String subTenantIdColumn) { + this.subTenantIdColumn = subTenantIdColumn; + } + + public String getDialect() { + return dialect; + } + + public void setDialect(String dialect) { + this.dialect = dialect; + } //属性参数信息 private Properties properties; @@ -99,110 +132,170 @@ public class MultiTenancy implements Interceptor { private String addWhere(String sql) throws Exception { Statement stmt = CCJSqlParserUtil.parse(sql); if (stmt instanceof Insert) { - //获得Insert对象 - Insert insert = (Insert) stmt; - if (getTenantInfo().doTableFilter(insert.getTable().getName())) - return insert.toString(); - boolean bExist = false; - for(Column col:insert.getColumns()) { - if(col.getColumnName().equalsIgnoreCase(getTenantIdColumn())) - bExist = true; - } - if (!bExist) { - insert.getColumns().add(new Column(getTenantIdColumn())); - - if (insert.getItemsList() instanceof MultiExpressionList){ - for (ExpressionList expressionList : ((MultiExpressionList) insert.getItemsList()).getExprList()) { - addTenantValue(expressionList); - } - }else { - addTenantValue(((ExpressionList) insert.getItemsList())); - } - } - return insert.toString(); + return processInsert((Insert) stmt); } if (stmt instanceof Delete) { - //获得Delete对象 - Delete deleteStatement = (Delete) stmt; - if (getTenantInfo().doTableFilter(deleteStatement.getTable().getName())) - return deleteStatement.toString(); - Expression where = deleteStatement.getWhere(); - if (where instanceof BinaryExpression) { - EqualsTo equalsTo = new EqualsTo(); - equalsTo.setLeftExpression(new Column(getTenantIdColumn())); - equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); - AndExpression andExpression = new AndExpression(equalsTo, where); - deleteStatement.setWhere(andExpression); - } - return deleteStatement.toString(); + return processDelete((Delete) stmt); } if (stmt instanceof Update) { - //获得Update对象 - Update updateStatement = (Update) stmt; - TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); - List tableList = tablesNamesFinder.getTableList(stmt); - if (tableList.size() == 0) { - return updateStatement.toString(); - } - //获得where条件表达式 - Expression where = updateStatement.getWhere(); - for (String table: tableList) { - if (getTenantInfo().doTableFilter(table)) - continue; + return processUpdate(sql, stmt); + } + + if (stmt instanceof Select) { + return processSelect(stmt); + } + + if (stmt instanceof CreateTable) { + return processCreateTable((CreateTable) stmt); + } + throw new RuntimeException("非法sql语句,请检查"+sql); + } + + private String processCreateTable(CreateTable stmt) { + CreateTable createTable = stmt; + ColDataType colDataType = new ColDataType(); + colDataType.setDataType("varchar(10)"); + + // add tenant_id + ColumnDefinition columnDefinition = new ColumnDefinition(); + columnDefinition.setColumnName(getTenantIdColumn()); + columnDefinition.setColDataType(colDataType); + createTable.getColumnDefinitions().add(columnDefinition); + // add sub_tenant_id + ColumnDefinition subColumnDefinition = new ColumnDefinition(); + subColumnDefinition.setColumnName(getSubTenantIdColumn()); + subColumnDefinition.setColDataType(colDataType); + createTable.getColumnDefinitions().add(subColumnDefinition); + return createTable.toString(); + } + + private String processSelect(Statement stmt) throws Exception { + //获得Select对象 + Select select = (Select) stmt; + PlainSelect ps = (PlainSelect) select.getSelectBody(); + TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); + List tableList = tablesNamesFinder.getTableList(select); + + if (tableList.size() == 0) { + return select.toString(); + } + for (String table : tableList) { + if (getTenantInfo().doTableFilter(table)) + continue; + if (ps.getWhere() != null) { + AndExpression where = addAndExpression(stmt, table, ps.getWhere()); + // form 和 join 中加载的表 if (where != null) { - AndExpression andE = addAndExpression(stmt, table, updateStatement.getWhere()); - if (andE != null) { - updateStatement.setWhere(andE); - } + ps.setWhere(where); } else { - throw new Exception("update语句不能没有where条件:" + sql + Arrays.toString(Thread.currentThread().getStackTrace())); + //子查询中的表 + findSubSelect(stmt, ps.getWhere()); } + } else { + String aliasName = getTableAlias(stmt, table); + EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); + ps.setWhere(equalsTo); } + } + return select.toString(); + } + + private String processUpdate(String sql, Statement stmt) throws Exception { + //获得Update对象 + Update updateStatement = (Update) stmt; + TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); + List tableList = tablesNamesFinder.getTableList(stmt); + if (tableList.size() == 0) { return updateStatement.toString(); } + //获得where条件表达式 + Expression where = updateStatement.getWhere(); + for (String table: tableList) { + if (getTenantInfo().doTableFilter(table)) + continue; + if (where != null) { + AndExpression andE = addAndExpression(stmt, table, updateStatement.getWhere()); + if (andE != null) { + updateStatement.setWhere(andE); + } + } else { + throw new Exception("update语句不能没有where条件:" + sql + Arrays.toString(Thread.currentThread().getStackTrace())); + } + } + return updateStatement.toString(); + } - if (stmt instanceof Select) { - //获得Select对象 - Select select = (Select) stmt; - PlainSelect ps = (PlainSelect) select.getSelectBody(); - TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); - List tableList = tablesNamesFinder.getTableList(select); + private String processDelete(Delete deleteStatement) { + //获得Delete对象 + if (getTenantInfo().doTableFilter(deleteStatement.getTable().getName())) + return deleteStatement.toString(); + Expression where = deleteStatement.getWhere(); + EqualsTo equalsTo = new EqualsTo(); + if (getTenantInfo().getTenantId() != null) { + equalsTo.setLeftExpression(new Column(getTenantIdColumn())); + equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); + } + if (!getTenantInfo().doTableFilterSub(deleteStatement.getTable().getName())) { + if (getTenantInfo().getSubTenantId() != null) { + equalsTo.setLeftExpression(new Column(getSubTenantIdColumn())); + equalsTo.setRightExpression(new StringValue(getTenantInfo().getSubTenantId())); + } + } + if (null != where) { + if (where instanceof OrExpression) { + AndExpression andExpression = new AndExpression(equalsTo, new Parenthesis(where)); + deleteStatement.setWhere(andExpression); + } else { + AndExpression andExpression = new AndExpression(equalsTo, where); + deleteStatement.setWhere(andExpression); + } + } + return deleteStatement.toString(); + } - if (tableList.size() == 0) { - return select.toString(); + /** + * 插入处理 + * @param insertStatement + * @return + * @throws Exception + */ + private String processInsert(Insert insertStatement) throws Exception { + // 非tenant表,直接返回 + if (getTenantInfo().doTableFilter(insertStatement.getTable().getName())) { + return insertStatement.toString(); + } + boolean bExist = insertStatement.getColumns().stream().anyMatch(col -> col.getColumnName().equalsIgnoreCase(getTenantIdColumn())); + if (!bExist) { + if (getTenantInfo().getTenantId() != null) { + insertStatement.getColumns().add(new Column(getTenantIdColumn())); } - for (String table : tableList) { - if (getTenantInfo().doTableFilter(table)) - continue; - if (ps.getWhere() != null) { - AndExpression where = addAndExpression(stmt, table, ps.getWhere()); - // form 和 join 中加载的表 - if (where != null) { - ps.setWhere(where); - } else { - //子查询中的表 - findSubSelect(stmt, ps.getWhere()); + if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { + if (getTenantInfo().getSubTenantId() != null) { + insertStatement.getColumns().add(new Column(getSubTenantIdColumn())); + } + } + ItemsList itemsList = insertStatement.getItemsList(); + if (itemsList instanceof MultiExpressionList){ + ((MultiExpressionList) itemsList).getExprList().forEach(el -> { + el.getExpressions().add(new StringValue(getTenantInfo().getTenantId())); + if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { + if (getTenantInfo().getSubTenantId() != null) { + el.getExpressions().add(new StringValue(getTenantInfo().getSubTenantId())); + } + } + }); + }else { + ((ExpressionList) itemsList).getExpressions().add(new StringValue(getTenantInfo().getTenantId())); + if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { + if (getTenantInfo().getSubTenantId() != null) { + ((ExpressionList) itemsList).getExpressions().add(new StringValue(getTenantInfo().getSubTenantId())); } - } else { - ps.setWhere(addEqualsTo(stmt, table)); } } - return select.toString(); } - - if (stmt instanceof CreateTable) { - CreateTable createTable = (CreateTable) stmt; - ColumnDefinition columnDefinition = new ColumnDefinition(); - columnDefinition.setColumnName(getTenantIdColumn()); - ColDataType colDataType = new ColDataType(); - colDataType.setDataType("varchar(50)"); - columnDefinition.setColDataType(colDataType); - createTable.getColumnDefinitions().add(columnDefinition); - return createTable.toString(); - } - throw new RuntimeException("非法sql语句,请检查"+sql); + return insertStatement.toString(); } /** @@ -222,7 +315,7 @@ public class MultiTenancy implements Interceptor { /** * 获取配置信息 - * {dialect=mysql, tenantInfo=org.xue.test.TenantInfoImpl, tenantIdColumn=tenant_id} + * {dialect=mysql, tenantInfo=org.xue.test.TenantInfoImpl, tenantIdColumn=tenant_id, subTenantIdColumn=sub_tenant_id} * @param properties */ public void setProperties(Properties properties) { @@ -231,6 +324,7 @@ public class MultiTenancy implements Interceptor { Class onwClass=Class.forName(this.properties.getProperty("tenantInfo")); this.tenantInfo = (TenantInfo)onwClass.newInstance(); this.tenantIdColumn = this.properties.getProperty("tenantIdColumn"); + this.subTenantIdColumn = this.properties.getProperty("subTenantIdColumn"); this.dialect = this.properties.getProperty("dialect"); } catch (ClassNotFoundException e) { throw new RuntimeException(e); @@ -241,15 +335,6 @@ public class MultiTenancy implements Interceptor { } } - /** - * 插入数据 添加租户id - * @param expressionList - * @throws Exception - */ - private void addTenantValue(ExpressionList expressionList) throws Exception { - expressionList.getExpressions().add(new StringValue(getTenantInfo().getTenantId())); - } - /** * 多条件情况下,使用AndExpression给where条件加上tenantid条件 * @@ -259,9 +344,21 @@ public class MultiTenancy implements Interceptor { * @throws Exception */ public AndExpression addAndExpression(Statement stmt, String table, Expression where) throws Exception { - EqualsTo equalsTo = addEqualsTo(stmt, table); + String aliasName = getTableAlias(stmt, table); + + EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); if (equalsTo != null) { - return new AndExpression(equalsTo, where); + AndExpression right = new AndExpression(equalsTo, where); + if (!getTenantInfo().doTableFilterSub(table)) { + EqualsTo equalsToSub = addEqualsToForSubTenantId(stmt, table, aliasName); + if (equalsToSub != null) { + return new AndExpression(equalsToSub, right); + } else { + return right; + } + } else { + return right; + } } else { return null; } @@ -275,14 +372,38 @@ public class MultiTenancy implements Interceptor { * @return “A=B” 单个where条件表达式 * @throws Exception */ - public EqualsTo addEqualsTo(Statement stmt, String table) throws Exception { - EqualsTo equalsTo = new EqualsTo(); - String aliasName; - aliasName = getTableAlias(stmt, table); + public EqualsTo addEqualsTo(Statement stmt, String table, String aliasName) throws Exception { if (aliasName != null) { - equalsTo.setLeftExpression(new Column(aliasName + '.' + getTenantIdColumn())); - equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); - return equalsTo; + if (getTenantInfo().getTenantId() != null) { + EqualsTo equalsTo = new EqualsTo(); + equalsTo.setLeftExpression(new Column(aliasName + '.' + getTenantIdColumn())); + equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); + return equalsTo; + } + return null; + } else { + return null; + } + } + + /** + * 创建一个 EqualsTo相同判断 条件 + * + * @param stmt 查询对象 + * @param table 表名 + * @return “A=B” 单个where条件表达式 + * @throws Exception + */ + public EqualsTo addEqualsToForSubTenantId(Statement stmt, String table, String aliasName) throws Exception { + if (aliasName != null) { + if (getTenantInfo().getSubTenantId() != null) { + EqualsTo equalsTo = new EqualsTo(); + equalsTo.setLeftExpression(new Column(aliasName + '.' + getSubTenantIdColumn())); + equalsTo.setRightExpression(new StringValue(getTenantInfo().getSubTenantId())); + return equalsTo; + } else { + return null; + } } else { return null; } @@ -434,7 +555,8 @@ public class MultiTenancy implements Interceptor { } } else { // sql 不含 where条件 新建一个EqualsTo设置为where条件 - EqualsTo equalsTo = addEqualsTo(stmt, table); + String aliasName = getTableAlias(stmt, table); + EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); ps.setWhere(equalsTo); } } @@ -525,30 +647,4 @@ public class MultiTenancy implements Interceptor { } return false; } - - public TenantInfo getTenantInfo() { - return tenantInfo; - } - - public void setTenantInfo(TenantInfo tenantInfo) { - this.tenantInfo = tenantInfo; - } - - public String getTenantIdColumn() { - return tenantIdColumn; - } - - public void setTenantIdColumn(String tenantIdColumn) { - this.tenantIdColumn = tenantIdColumn; - } - - public String getDialect() { - return dialect; - } - - public void setDialect(String dialect) { - this.dialect = dialect; - } - - } diff --git a/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/TenantInfo.java b/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/TenantInfo.java index 7170e995c..fdf651bb2 100644 --- a/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/TenantInfo.java +++ b/mybatis-multi-tenancy/src/main/java/com/iformall/plugin/TenantInfo.java @@ -7,9 +7,14 @@ import org.apache.ibatis.mapping.MappedStatement; * Created by Stormeye on 2018/10/22. */ public interface TenantInfo { + String getTenantId(); + String getSubTenantId(); + boolean doTableFilter(String tableName); + boolean doTableFilterSub(String tableName); + boolean doMappedStatementFIlter(MappedStatement ms); } diff --git a/mybatis-multi-tenancy/src/test/java/com/iformall/plugin/TenantInfoImpl.java b/mybatis-multi-tenancy/src/test/java/com/iformall/plugin/TenantInfoImpl.java index 5e7d212de..c833c7eaf 100644 --- a/mybatis-multi-tenancy/src/test/java/com/iformall/plugin/TenantInfoImpl.java +++ b/mybatis-multi-tenancy/src/test/java/com/iformall/plugin/TenantInfoImpl.java @@ -6,17 +6,28 @@ import org.apache.ibatis.mapping.MappedStatement; * 自行实现TenantInfo获取 * Created by Meara on 2016/3/20. */ -public class TenantInfoImpl implements TenantInfo{ +public class TenantInfoImpl implements TenantInfo { + @Override public String getTenantId() { return "2"; } + @Override + public String getSubTenantId() { + return "2"; + } + @Override public boolean doTableFilter(String tableName) { return false; } + @Override + public boolean doTableFilterSub(String tableName) { + return false; + } + @Override public boolean doMappedStatementFIlter(MappedStatement ms) { return false;