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 a499d4768..cafbdf8df 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserDataController.java @@ -16,7 +16,7 @@ import com.iformall.domain.dto.MarkingCouponDataReportDto; import com.iformall.domain.po.WxCouponOrder; import com.iformall.domain.po.base.TenantEntity; import com.iformall.mapper.WxCUserBasicInfoMapper; -import com.iformall.service.WxCUserBasicInfoService; +import com.iformall.service.*; import com.iformall.utils.DataUtil; import com.iformall.utils.DateUtils; import org.apache.commons.lang3.StringUtils; @@ -32,9 +32,6 @@ import com.iformall.domain.dto.WxCUserBasicInfoDto; import com.iformall.domain.vo.CUserDateAmountVo; import com.iformall.domain.vo.TouchUsersReportVo; import com.iformall.domain.vo.UserStructureVo; -import com.iformall.service.WxCUserService; -import com.iformall.service.WxCouponOrderService; -import com.iformall.service.WxUserVisitService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -53,6 +50,8 @@ public class WxCUserDataController extends BaseController { private WxCouponOrderService wxCouponOrderService; @Autowired private WxCUserBasicInfoService wxCUserBasicInfoService; + @Autowired + WxMallService wxMallService; @GetMapping("findUserCountData") @ApiOperation("查询用户数量接口") @@ -277,11 +276,12 @@ public class WxCUserDataController extends BaseController { Date endTime = c.getTime();//明天0点 c.add(Calendar.DAY_OF_YEAR, -30);//三十天前 Date startTime = c.getTime(); + List tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); WxCouponOrder wxCouponOrder = new WxCouponOrder(); wxCouponOrder.updateTenantInfo(tenantEntity); wxCouponOrder.setStartTime(startTime); wxCouponOrder.setEndTime(endTime); - int thisMonthCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder);//月消费金额 + int thisMonthCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder,tenantEntitys);//月消费金额 c.clear(); c.setTime(endTime); Date eTime = c.getTime(); diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java index c5f36c230..6dd88e600 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/ChartDataSchedule.java @@ -218,17 +218,23 @@ public class ChartDataSchedule { } public void carPayFeeData(HashMap params, Date createtime, Date date, TenantEntity tenantEntity) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + params.put("tenantEntitys",tenantEntitys); List> weekCarPayHistoryList = wxCarCmdLogMapper.queryWeekCarPay(params); BigDecimal fee = weekCarPayHistoryList.isEmpty() ? new BigDecimal(0) : (BigDecimal) weekCarPayHistoryList.get(0).get("fee"); addChartData(tenantEntity, fee.toString(), EnumChartType.CAR_PAY_FEE.getCode(), date, createtime); } public void carPaidData(HashMap params, Date createtime, Date date, TenantEntity tenantEntity) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + params.put("tenantEntitys",tenantEntitys); Long carPayFeeCount = wxCarCmdLogMapper.queryWeekCarPayCount(params); addChartData(tenantEntity, carPayFeeCount.toString(), EnumChartType.CAR_PAID.getCode(), date, createtime); } public void carOutData(HashMap params, Date createtime, Date date, TenantEntity tenantEntity) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + params.put("tenantEntitys",tenantEntitys); List> historylist = wxCarCmdLogMapper.queryHistory(params); Long carOutCount = historylist.isEmpty() ? 0L : (Long) historylist.get(0).get("carcount"); addChartData(tenantEntity, carOutCount.toString(), EnumChartType.CAR_OUT.getCode(), date, createtime); diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/MarkingCouponDataReportDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/MarkingCouponDataReportDto.java index de3d9593d..947668291 100644 --- a/mallinkService/src/main/java/com/iformall/domain/dto/MarkingCouponDataReportDto.java +++ b/mallinkService/src/main/java/com/iformall/domain/dto/MarkingCouponDataReportDto.java @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import java.util.Date; +import java.util.List; /** * Created by syf on 2018/8/30. @@ -24,6 +25,9 @@ public class MarkingCouponDataReportDto extends TenantEntity { private String couponTitle; private Integer channelType; + @TableField(exist = false) + private List tenantEntitys; + @TableField(exist = false) @SortColumn(column = "xTime") private String xTime; 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 697b6b5e6..86bf20909 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 @@ -29,6 +29,7 @@ public class BaseTenantEntity extends BaseEntity { public void updateTenantInfo(TenantEntity info) { log.info("info.tenantId:"+info.getTenantId()+". info.parentTenantId:"+info.getParentTenantId()+"."); setTenantId(info.getTenantId()); + setParentTenantId(null); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); } @@ -36,6 +37,7 @@ public class BaseTenantEntity extends BaseEntity { public void updateTenantInfo(BaseTenantEntity info) { setTenantId(info.getTenantId()); + setParentTenantId(null); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); } 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 04fa8c3bc..70a88d31c 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 @@ -21,8 +21,12 @@ public class TenantEntity extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value="父租户ID",name="parentTenantId") protected String parentTenantId; + @TableField(exist = false) + protected String shardTableSuffix; + public void updateTenantInfo(TenantEntity info) { setTenantId(info.getTenantId()); + setParentTenantId(null); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); } @@ -30,6 +34,7 @@ public class TenantEntity extends BaseEntity { public void updateTenantInfo(BaseTenantEntity info) { setTenantId(info.getTenantId()); + setParentTenantId(null); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); } @@ -41,6 +46,10 @@ public class TenantEntity extends BaseEntity { } return tenantId; } + + public String getShardTableSuffix() { + return "_" + Integer.parseInt(this.getTenantId())%100; + } public String getTenantId() { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/base/TenantVEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/base/TenantVEntity.java index 165753fcb..6f4f357b4 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/base/TenantVEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/base/TenantVEntity.java @@ -27,6 +27,7 @@ public class TenantVEntity extends BaseEntity { public void updateTenantInfo(TenantEntity info) { setTenantId(info.getTenantId()); + setParentTenantId(null); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); } @@ -34,6 +35,7 @@ public class TenantVEntity extends BaseEntity { public void updateTenantInfo(TenantVEntity info) { setTenantId(info.getTenantId()); + setParentTenantId(null); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java index 588caef75..c501f3681 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java @@ -3,6 +3,7 @@ package com.iformall.mapper; import java.util.*; import com.iformall.common.CommonMapper; import com.iformall.domain.dto.MarkingCouponDataReportDto; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.MarkingSceneDataReportTVo; import com.iformall.domain.vo.MarkingSceneDataReportVo; import com.iformall.domain.vo.MarkingSceneDataVo; @@ -26,18 +27,20 @@ public interface WxCouponActionLogMapper extends CommonMapper sceneDataMapJoinCouponOrder(HashMap params); - List sceneDataList(MarkingCouponDataReportDto markingCouponDataReportDto); + List sceneDataList(@Param("markingCouponDataReportDto") MarkingCouponDataReportDto markingCouponDataReportDto); List sceneDataJoinCouponOrderList(HashMap params); /** * 查询场景投放发券数 - * @param tenantId - * @param startTime - * @param endTime - * @return + * + * @param tenantEntitys + * @param tenantId + * @param startTime + * @param endTime + * @return */ - int getCountByDateLimit(@Param("tenantId")String tenantId,@Param("parentTenantId")String parentTenantId,@Param("startTime") Date startTime,@Param("endTime")Date endTime); + int getCountByDateLimit(@Param("tenantEntitys") List tenantEntitys, @Param("tenantId") String tenantId, @Param("parentTenantId") String parentTenantId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); int getCountByChannelId(@Param("tenantId")String tenantId,@Param("parentTenantId")String parentTenantId,@Param("channelType") int channelType,@Param("channelId")Long channelId); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java index bcb026545..9fd66f379 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java @@ -3,6 +3,7 @@ package com.iformall.mapper; import java.util.*; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxTopic; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponStatisVo; import org.apache.ibatis.annotations.Param; @@ -34,17 +35,21 @@ public interface WxCouponMapper extends CommonMapper { /** * 查询时间段内销售金额 - * @param wxCoupon - * @return + * + * @param tenantEntitys + * @param wxCoupon + * @return */ - List findSaleMoneyByDate(WxCoupon wxCoupon); + List findSaleMoneyByDate(@Param("tenantEntitys") List tenantEntitys, @Param("wxCoupon") WxCoupon wxCoupon); /** * 查询时间段内核销金额 + * + * @param tenantEntitys * @param wxCoupon * @return */ - List findPaymentByDate(WxCoupon wxCoupon); + List findPaymentByDate(@Param("tenantEntitys") List tenantEntitys, @Param("wxCoupon") WxCoupon wxCoupon); Long findSaleCardCount(WxCoupon wxCoupon); @@ -54,31 +59,31 @@ public interface WxCouponMapper extends CommonMapper { //-------券-------- - List findCouponOrderCount(WxCoupon wxCoupon); + List findCouponOrderCount(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); - List findCouponPaymentCount(WxCoupon wxCoupon); + List findCouponPaymentCount(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); - List priceCouponSaleCount(WxCoupon wxCoupon); + List priceCouponSaleCount(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); - List priceCouponPaymentCount(WxCoupon wxCoupon); + List priceCouponPaymentCount(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon") WxCoupon wxCoupon); String findSumPriceSaleMoney(WxCoupon wxCoupon); String findSumPricePayMent(WxCoupon wxCoupon); String findSumSubsidyMoney(WxCoupon wxCoupon); //-------砍价-------- - List pressSendHistory(WxCoupon wxCoupon); - List pressSuccHistory(WxCoupon wxCoupon); - List pressPaymentHistory(WxCoupon wxCoupon); - String pressSuccRate(WxCoupon wxCoupon); - Long sumJoin(WxCoupon wxCoupon); + List pressSendHistory(@Param("tenantEntitys") List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); + List pressSuccHistory(@Param("tenantEntitys") List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); + List pressPaymentHistory(@Param("tenantEntitys") List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); + String pressSuccRate(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); + Long sumJoin(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); List findCouponByTopic(WxTopic wxTopic); Long priceCouponCancelCount(WxCoupon wxCoupon); - List findSaleCardCountHistory(WxCoupon wxCoupon); + List findSaleCardCountHistory(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); // 库存,有效期修改 int updateStockAndValidDate(WxCoupon wxCoupon); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java index adb426c9d..7c3407ce4 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCouponOrder; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.*; import org.apache.ibatis.annotations.Param; @@ -62,12 +63,14 @@ public interface WxCouponOrderMapper extends CommonMapper { /** * 日期分组 消费总数 + * + * @param tenantEntitys * @param tenantId * @param startTime * @param endTime * @return */ - List queryPriceTotalGroup(@Param("tenantId")String tenantId, @Param("parentTenantId")String parentTenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); + List queryPriceTotalGroup(@Param("tenantEntitys") List tenantEntitys, @Param("tenantId") String tenantId, @Param("parentTenantId") String parentTenantId, @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 3fb5a70ef..6afafd1e9 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxMall; +import com.iformall.domain.po.base.TenantEntity; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -21,4 +22,6 @@ public interface WxMallMapper extends CommonMapper { void undateSubmall(@Param(value = "parentTenantId")String parentTenantId, @Param(value = "tenantIds")List tenantIds); List listAsSelectMall(@Param(value = "id")Long id); + + List getTenantEntitys(TenantEntity tenantEntity); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxOrderGroupMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxOrderGroupMapper.java index 19ece63a1..e7cac8714 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxOrderGroupMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxOrderGroupMapper.java @@ -4,6 +4,7 @@ import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxOrder; import com.iformall.domain.po.WxOrderGroup; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponStatisVo; import com.iformall.domain.vo.WxOrderGroupMarketing; @@ -39,7 +40,7 @@ public interface WxOrderGroupMapper extends CommonMapper { long queryOrderGroupVerifyCount(Map params); - List queryOrderGroupCountHistory(WxCoupon wxCoupon); + List queryOrderGroupCountHistory(@Param("tenantEntitys")List tenantEntitys, @Param("wxCoupon")WxCoupon wxCoupon); long queryOrderGroupSuccessPeopleCount(Map params); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxOrderMapper.java index 0b730a78a..ce86ac340 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxOrderMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxOrderMapper.java @@ -3,6 +3,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.dto.WxOrderReportDto; import com.iformall.domain.po.WxOrder; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.*; import java.util.HashMap; @@ -41,7 +42,7 @@ public interface WxOrderMapper extends CommonMapper { List listMicroPayOrderReportByDateAndMerchant(HashMap params); - List findListOfMerchantMicroPayOrderByDate(WxOrderReportDto wxOrderReportDto); + List findListOfMerchantMicroPayOrderByDate(@Param("wxOrderReportDto") WxOrderReportDto wxOrderReportDto, @Param("tenantEntitys")List tenantEntitys); List findListOrder(WxOrderQueryVo record); diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index 7f852a5ef..a92651080 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -2,6 +2,7 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCouponOrder; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.vo.WxCouponCVo; @@ -76,4 +77,6 @@ public interface WxCouponChannelService { ResultData change(WxCouponChannel wxCouponChannel); + int countCoupon(WxCouponChannel wxCouponChannel, List tenantEntitys); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java index 4d99ac8ee..8921ddbea 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java @@ -176,7 +176,7 @@ public interface WxCouponOrderService { * 查询消费额 * @return */ - int queryPriceTotal(WxCouponOrder wxCouponOrder); + int queryPriceTotal(WxCouponOrder wxCouponOrder,List tenantEntitys); ////// ------- 卡 @@ -215,4 +215,6 @@ public interface WxCouponOrderService { */ Integer shangAnVerify(Long couponOrderId,TenantEntity tenantinfo); + int findCount(WxCouponOrder wxCouponOrder,List tenantEntitys); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index f059741ba..39ac3eee8 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -4,9 +4,9 @@ import java.util.*; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.WxCoupon; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponStatisVo; -import org.apache.ibatis.annotations.Param; public interface WxCouponService { @@ -82,35 +82,39 @@ public interface WxCouponService { /** * 查询时间段内销售金额 + * + * @param tenantEntitys * @param wxCoupon * @return */ - List findSaleMoneyByDate(WxCoupon wxCoupon); + List findSaleMoneyByDate(List tenantEntitys, WxCoupon wxCoupon); /** * 查询时间段内核销金额 + * + * @param tenantEntitys * @param wxCoupon * @return */ - List findPaymentByDate(WxCoupon wxCoupon); + List findPaymentByDate(List tenantEntitys, WxCoupon wxCoupon); /** * 查询售出卡数量 * @return */ - Long findSaleCardCount(WxCoupon wxCoupon); + Long findSaleCardCount(List tenantEntitys, WxCoupon wxCoupon); /** * 查询转增数量 * @return */ - Long findTranCardCount(WxCoupon wxCoupon); + Long findTranCardCount(List tenantEntitys, WxCoupon wxCoupon); /** * 查询补贴金额 * @return */ - String findSubsidyMoney(WxCoupon wxCoupon); + String findSubsidyMoney(List tenantEntitys, WxCoupon wxCoupon); //----------------券-------------- /** @@ -123,7 +127,7 @@ public interface WxCouponService { * 券购买数量 * @return */ - List findCouponOrderCount(WxCoupon wxCoupon); + List findCouponOrderCount(List tenantEntitys, WxCoupon wxCoupon); /** * 券领取数量 @@ -135,62 +139,64 @@ public interface WxCouponService { * 券核销数量 * @return */ - List findCouponPaymentCount(WxCoupon wxCoupon); + List findCouponPaymentCount(List tenantEntitys, WxCoupon wxCoupon); /** * 有价券销售数量 * @return */ - List priceCouponSaleCount(WxCoupon wxCoupon); + List priceCouponSaleCount(List tenantEntitys, WxCoupon wxCoupon); /** * 有价券核销数量 * @return */ - List priceCouponPaymentCount(WxCoupon wxCoupon); + List priceCouponPaymentCount(List tenantEntitys, WxCoupon wxCoupon); /** * 有价券退款数量 * @return */ - Long priceCouponCancelCount(WxCoupon wxCoupon); + Long priceCouponCancelCount(List tenantEntitys, WxCoupon wxCoupon); /** * 有价券销售总额 + * + * @param tenantEntitys * @param wxCoupon * @return */ - String findSumPriceSaleMoney(WxCoupon wxCoupon); - String findSumPricePayMent(WxCoupon wxCoupon); - String findSumSubsidyMoney(WxCoupon wxCoupon); + String findSumPriceSaleMoney(List tenantEntitys, WxCoupon wxCoupon); + String findSumPricePayMent(List tenantEntitys, WxCoupon wxCoupon); + String findSumSubsidyMoney(List tenantEntitys, WxCoupon wxCoupon); /** * 砍价发起次数走势 * @return */ - List pressSendHistory(WxCoupon wxCoupon); + List pressSendHistory(List tenantEntitys, WxCoupon wxCoupon); /** * 砍价成功次数走势 * @return */ - List pressSuccHistory(WxCoupon wxCoupon); + List pressSuccHistory(List tenantEntitys, WxCoupon wxCoupon); /** * 砍价核销数量走势 * @return */ - List pressPaymentHistory(WxCoupon wxCoupon); + List pressPaymentHistory(List tenantEntitys, WxCoupon wxCoupon); /** * 砍价转化率 * @return */ - String pressSuccRate(WxCoupon wxCoupon); + String pressSuccRate(List tenantEntitys, WxCoupon wxCoupon); /** * 砍价参与人数 * @return */ - Long sumJoin(WxCoupon wxCoupon); + Long sumJoin(List tenantEntitys, WxCoupon wxCoupon); @@ -198,7 +204,7 @@ public interface WxCouponService { * 查询售出卡数量历史 * @return */ - List findSaleCardCountHistory(WxCoupon wxCoupon); + List findSaleCardCountHistory(List tenantEntitys, WxCoupon wxCoupon); /** * 增加库存及修改有效时间 @@ -231,4 +237,5 @@ public interface WxCouponService { * @return */ ResultData cardDefer(Long id,String tenantId,Date validEndDate); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxMallService.java b/mallinkService/src/main/java/com/iformall/service/WxMallService.java index 801ffc5f7..0b9f59408 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMallService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMallService.java @@ -83,4 +83,5 @@ public interface WxMallService { List listAsSelectMall(Long id); + List getTenantEntitys(TenantEntity tenantEntity); } 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 25380fa61..53e9aedbc 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java @@ -12,6 +12,8 @@ import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; import com.iformall.service.DataTowerService; +import com.iformall.service.WxCouponChannelService; +import com.iformall.service.WxCouponOrderService; import com.iformall.sms.wiwide.WiwideUtil; import com.iformall.utils.DateUtils; import org.apache.commons.lang3.StringUtils; @@ -73,6 +75,15 @@ public class DataTowerServiceImpl implements DataTowerService { @Autowired StringRedisTemplate stringRedisTemplate; + @Autowired + private WxMallMapper wxMallMapper; + + @Autowired + private WxCouponOrderService wxCouponOrderService; + + @Autowired + private WxCouponChannelService wxCouponChannelService; + //出租与未出租*********************************************** private Map shopRunning(TenantEntity tenantEntity) { @@ -181,7 +192,9 @@ public class DataTowerServiceImpl implements DataTowerService { //今日车流量*********************************************** private Map carRunning(TenantEntity tenantEntity) { HashMap carMap = new HashMap<>(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); HashMap paramsCar = new HashMap<>(); + paramsCar.put("tenantEntitys",tenantEntitys); paramsCar.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { paramsCar.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -255,19 +268,20 @@ public class DataTowerServiceImpl implements DataTowerService { cal.add(Calendar.DAY_OF_YEAR, 1); Date endTime = cal.getTime(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); WxCouponOrder wxCouponOrder = new WxCouponOrder(); - wxCouponOrder.updateTenantInfo(tenantEntity); + //wxCouponOrder.updateTenantInfo(tenantEntity); wxCouponOrder.setStartTime(startTime); wxCouponOrder.setEndTime(endTime); - long orderedCount = wxCouponOrderMapper.findCount(wxCouponOrder); + long orderedCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); - long verifiedCount = wxCouponOrderMapper.findCount(wxCouponOrder); + long verifiedCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); couponMap.put("verifiedCount", verifiedCount); couponMap.put("orderedCount", orderedCount); WxCouponChannel wxCouponChannel = new WxCouponChannel(); - wxCouponChannel.updateTenantInfo(tenantEntity); +// wxCouponChannel.updateTenantInfo(tenantEntity); wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); - long couponCount = wxCouponChannelMapper.countCoupon(wxCouponChannel); + long couponCount = wxCouponChannelService.countCoupon(wxCouponChannel,tenantEntitys); couponMap.put("couponCount", couponCount); return couponMap; @@ -494,7 +508,10 @@ public class DataTowerServiceImpl implements DataTowerService { @Override public Map queryCar(TenantEntity tenantEntity) { logger.info("停车-月统计-开始"); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + HashMap params = new HashMap<>(); + params.put("tenantEntitys",tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -532,6 +549,7 @@ public class DataTowerServiceImpl implements DataTowerService { // 查询近一周的缴费车辆----start------ logger.info("停车-查询近一周的缴费车辆-开始"); HashMap weekParams = new HashMap<>(); + weekParams.put("tenantEntitys",tenantEntitys); weekParams.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { weekParams.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -848,6 +866,4 @@ public class DataTowerServiceImpl implements DataTowerService { return timemap; } - - } 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 277c7ffdc..4f58c5c89 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/MarkingDataReportServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/MarkingDataReportServiceImpl.java @@ -15,6 +15,7 @@ import com.iformall.enums.EnumOrderType; import com.iformall.mapper.*; import com.iformall.service.ExcelService; import com.iformall.service.MarkingDataReportService; +import com.iformall.service.WxCouponOrderService; import com.iformall.utils.DateUtils; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.StringUtils; @@ -49,8 +50,13 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { private WxCouponMapper wxCouponMapper; @Autowired private WxOrderMapper wxOrderMapper; + + @Autowired + private WxMallMapper wxMallMapper; @Autowired private ExcelService excelService; + @Autowired + private WxCouponOrderService wxCouponOrderService; private Date addDay(int addDayAmount) { Calendar c = Calendar.getInstance(); @@ -79,19 +85,20 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //取的当月券数据 @Override public Map getCouponData(TenantEntity tenantEntity) { + + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); //今日领取券数 //查询coupon order表 WxCouponOrder wxCouponOrder = new WxCouponOrder(); - wxCouponOrder.updateTenantInfo(tenantEntity); wxCouponOrder.setStartTime(addDay(0)); wxCouponOrder.setEndTime(addDay(1)); - int todayCouponCount = wxCouponOrderMapper.findCount(wxCouponOrder); + int todayCouponCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); wxCouponOrder.setStartTime(addDay(-1)); wxCouponOrder.setEndTime(addDay(0)); - int yesterdayCount = wxCouponOrderMapper.findCount(wxCouponOrder); + int yesterdayCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); wxCouponOrder.setStartTime(addDay(-7)); wxCouponOrder.setEndTime(addDay(-6)); - int lastWeekCount = wxCouponOrderMapper.findCount(wxCouponOrder); + int lastWeekCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 @@ -106,6 +113,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //couponData HashMap params = new HashMap<>(); + params.put("tenantEntitys",tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -148,10 +156,11 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { @Override public Map getSceneData(TenantEntity tenantEntity) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); //今日营销投放券数 - int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(0), addDay(1)); - int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-1), addDay(0)); - int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-7), addDay(-6)); + int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntitys, tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(0), addDay(1)); + int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntitys, tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-1), addDay(0)); + int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntitys, tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-7), addDay(-6)); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 @@ -165,18 +174,24 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { } HashMap params = new HashMap<>(); + params.put("tenantEntitys", tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); - if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { - params.put("parentTenantId", tenantEntity.getParentTenantId()); - } +// if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { +// params.put("parentTenantId", tenantEntity.getParentTenantId()); +// } params.put("startTime", addDay(-30)); params.put("endTime", addDay(1)); //停车发券数 停车发券被核销数 核销发券数 核销发券被核销数 - wxCouponActionLogMapper.updateCreateTimeMd(params); + for (TenantEntity t:tenantEntitys) { + params.put("tenantId", t.getTenantId()); + wxCouponActionLogMapper.updateCreateTimeMd(params); + } + List sceneList = wxCouponActionLogMapper.getSceneDataMap(params); //停车发券被核销数 HashMap params1 = new HashMap<>(); + params1.put("tenantEntitys", tenantEntitys); params1.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params1.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -189,6 +204,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { //核销发券被核销数 HashMap params2 = new HashMap<>(); + params2.put("tenantEntitys", tenantEntitys); params2.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params2.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -201,6 +217,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { // B端刷卡支付被核销数 HashMap params3 = new HashMap<>(); + params3.put("tenantEntitys", tenantEntitys); params3.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params3.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -213,6 +230,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { // 购买发券被核销数 HashMap params4 = new HashMap<>(); + params4.put("tenantEntitys", tenantEntitys); params4.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params4.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -323,7 +341,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { @Override public PageInfo getSceneDataList(TenantEntity tenantEntity, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); MarkingCouponDataReportDto queryDto = new MarkingCouponDataReportDto(); + queryDto.setTenantEntitys(tenantEntitys); org.springframework.beans.BeanUtils.copyProperties(markingCouponDataReportDto, queryDto); queryDto.updateTenantInfo(tenantEntity); @@ -491,8 +511,10 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { @Override public Map getSceneDataHistory(TenantEntity tenantEntity, String startDate, String endDate) { Map result = new HashedMap(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); MarkingCouponDataReportDto markingCouponDataReportDto = new MarkingCouponDataReportDto(); + markingCouponDataReportDto.setTenantEntitys(tenantEntitys); markingCouponDataReportDto.updateTenantInfo(tenantEntity); Date starttime = DateUtils.stringToDate(startDate); @@ -578,8 +600,10 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { @Override public Map listOrderReportByDate(WxOrderReportDto wxOrderReportDto) { + List tenantEntitys = wxMallMapper.getTenantEntitys(wxOrderReportDto); HashMap params = new HashMap<>(); - params.put("tenantId", wxOrderReportDto.getTenantId()); + params.put("tenantEntitys",tenantEntitys); +// params.put("tenantId", wxOrderReportDto.getTenantId()); if (wxOrderReportDto.getStartTime() != null) { params.put("startTime", convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); } else { @@ -702,6 +726,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { @Override public PageInfo listMerchantMicroPayOrderReportByDate(WxOrderReportDto wxOrderReportDto,Integer pageIndex, Integer pageSize) { + List tenantEntitys = wxMallMapper.getTenantEntitys(wxOrderReportDto); if (wxOrderReportDto.getStartTime() != null) { wxOrderReportDto.setStartTime(convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); } else { @@ -713,7 +738,7 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { wxOrderReportDto.setEndTime(addDay(0)); } PageHelper.startPage(pageIndex, pageSize); - List list = wxOrderMapper.findListOfMerchantMicroPayOrderByDate(wxOrderReportDto); + List list = wxOrderMapper.findListOfMerchantMicroPayOrderByDate(wxOrderReportDto,tenantEntitys); return new PageInfo<>(list); } 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 356c0ba7c..254865bf9 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java @@ -40,6 +40,8 @@ import java.util.stream.Collectors; public class WxChartServiceImpl implements WxChartDataService { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + private WxMallMapper wxMallMapper; @Autowired WxShopMapper wxShopMapper; @Autowired @@ -85,6 +87,8 @@ public class WxChartServiceImpl implements WxChartDataService { @Autowired WxBusinessService wxBusinessService; + @Autowired + WxCouponOrderService wxCouponOrderService; @Autowired KwMeterDataService kwMeterDataService; @Autowired @@ -302,12 +306,12 @@ public class WxChartServiceImpl implements WxChartDataService { } //卡营销数据 if (chart.equals(EnumChart.SALE_CARD.getCode())) { - return getSaleCardAnalysis(paramsMap, startdate, enddate); + return getSaleCardAnalysis(tenantEntity,paramsMap, startdate, enddate); } //券营销数据 if (chart.equals(EnumChart.SALE_COUPON.getCode())) { - return getSaleCouponAnalysis(paramsMap, startdate, enddate); + return getSaleCouponAnalysis(tenantEntity,paramsMap, startdate, enddate); } //砍价营销数据 @@ -793,11 +797,14 @@ public class WxChartServiceImpl implements WxChartDataService { * @return */ private ResultData getCarDataCurrent(TenantEntity tenantEntity) { + HashMap datamap = new HashMap<>(); String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); String yesterday = DateUtils.getTimeBefore(1, new Date()); String lastweek = DateUtils.getTimeBefore(7, new Date()); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); HashMap params = new HashMap<>(); + params.put("tenantEntitys",tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -869,7 +876,9 @@ public class WxChartServiceImpl implements WxChartDataService { private ResultData getCarHistoryAndTodayAndHB(TenantEntity tenantEntity, boolean withOthers ) { String startdate; HashMap datamap = new HashMap<>(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); HashMap params = new HashMap<>(); + params.put("tenantEntitys",tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -946,7 +955,9 @@ public class WxChartServiceImpl implements WxChartDataService { */ private ResultData getCarPayCarCountInWeek(TenantEntity tenantEntity) { HashMap datamap = new HashMap<>(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); HashMap weekParams = new HashMap<>(); + weekParams.put("tenantEntitys", tenantEntitys); weekParams.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { weekParams.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -967,7 +978,9 @@ public class WxChartServiceImpl implements WxChartDataService { */ private ResultData getCarPayCountInWeek(TenantEntity tenantEntity) { HashMap datamap = new HashMap<>(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); HashMap weekParams = new HashMap<>(); + weekParams.put("tenantEntitys",tenantEntitys); weekParams.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { weekParams.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -1115,19 +1128,20 @@ public class WxChartServiceImpl implements WxChartDataService { */ private ResultData getTodayCouponCount(TenantEntity tenantEntity) { HashMap datamap = new HashMap<>(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); //今日领取券数 //查询coupon order表 WxCouponOrder wxCouponOrder = new WxCouponOrder(); - wxCouponOrder.updateTenantInfo(tenantEntity); +// wxCouponOrder.updateTenantInfo(tenantEntity); wxCouponOrder.setStartTime(addDay(0)); wxCouponOrder.setEndTime(addDay(1)); - int todayCouponCount = wxCouponOrderMapper.findCount(wxCouponOrder); + int todayCouponCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); wxCouponOrder.setStartTime(addDay(-1)); wxCouponOrder.setEndTime( addDay(0)); - int yesterdayCount = wxCouponOrderMapper.findCount(wxCouponOrder); + int yesterdayCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); wxCouponOrder.setStartTime(addDay(-7)); wxCouponOrder.setEndTime( addDay(-6)); - int lastWeekCount = wxCouponOrderMapper.findCount(wxCouponOrder); + int lastWeekCount = wxCouponOrderService.findCount(wxCouponOrder,tenantEntitys); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 String couponUpDay = "--"; @@ -1151,9 +1165,10 @@ public class WxChartServiceImpl implements WxChartDataService { */ private ResultData getSaleSceneCount(TenantEntity tenantEntity) { HashMap datamap = new HashMap<>(); - int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(0), addDay(1)); - int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-1), addDay(0)); - int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-7), addDay(-6)); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + int todaySceneCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntitys,tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(0), addDay(1)); + int yesterdayCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntitys,tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-1), addDay(0)); + int lastWeekCount = wxCouponActionLogMapper.getCountByDateLimit(tenantEntitys,tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), addDay(-7), addDay(-6)); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点 String sceneDownDay = "--"; @@ -1219,8 +1234,9 @@ public class WxChartServiceImpl implements WxChartDataService { String startdate; String enddate; HashMap datamap = new HashMap<>(); - + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); HashMap params = new HashMap<>(); + params.put("tenantEntitys", tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -1232,6 +1248,7 @@ public class WxChartServiceImpl implements WxChartDataService { //停车发券被核销数 HashMap params1 = new HashMap<>(); + params1.put("tenantEntitys", tenantEntitys); params1.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params1.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -1244,6 +1261,7 @@ public class WxChartServiceImpl implements WxChartDataService { //核销发券被核销数 HashMap params2 = new HashMap<>(); + params2.put("tenantEntitys", tenantEntitys); params2.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params2.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -1256,6 +1274,7 @@ public class WxChartServiceImpl implements WxChartDataService { // B端刷卡支付被核销数 HashMap params3 = new HashMap<>(); + params3.put("tenantEntitys", tenantEntitys); params3.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params3.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -1268,6 +1287,7 @@ public class WxChartServiceImpl implements WxChartDataService { // 购买发券被核销数 HashMap params4 = new HashMap<>(); + params4.put("tenantEntitys", tenantEntitys); params4.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params4.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -1395,11 +1415,12 @@ public class WxChartServiceImpl implements WxChartDataService { Date endTime = c.getTime();//明天0点 c.add(Calendar.DAY_OF_YEAR, -30); Date startTime = c.getTime(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); WxCouponOrder wxCouponOrder = new WxCouponOrder(); wxCouponOrder.setStartTime(startTime); wxCouponOrder.setEndTime(endTime); - wxCouponOrder.updateTenantInfo(tenantEntity); - int thisMonthCount = wxCouponOrderMapper.queryPriceTotal(wxCouponOrder);//月消费金额 +// wxCouponOrder.updateTenantInfo(tenantEntity); + int thisMonthCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder,tenantEntitys);//月消费金额 c.clear(); c.add(Calendar.DAY_OF_YEAR, -1); c.set(Calendar.HOUR_OF_DAY, 0); @@ -1408,8 +1429,8 @@ public class WxChartServiceImpl implements WxChartDataService { startTime = c.getTime(); wxCouponOrder.setStartTime(startTime); wxCouponOrder.setEndTime(endTime); - wxCouponOrder.updateTenantInfo(tenantEntity); - int todayCount = wxCouponOrderMapper.queryPriceTotal(wxCouponOrder);//月消费金额 +// wxCouponOrder.updateTenantInfo(tenantEntity); + int todayCount = wxCouponOrderService.queryPriceTotal(wxCouponOrder,tenantEntitys);//月消费金额 DecimalFormat df = new DecimalFormat("0.00"); datamap.put("todayCount", df.format((float) todayCount / 100));//今日消费金额 String thisMonthCountStr = df.format((float) thisMonthCount / 100); @@ -1520,7 +1541,8 @@ 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(), tenantEntity.getParentTenantId(), sTime, eTime); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntitys, tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), sTime, eTime); Map dataMap = new HashMap<>(); for (CUserDateAmountVo v : datas) { dataMap.put(v.getXTime(), v.getPrice()); @@ -1561,7 +1583,8 @@ 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(), tenantEntity.getParentTenantId(), sTime, eTime); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntitys,tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), sTime, eTime); List monthVos = new ArrayList<>();//周消费金额 Map dataMap = new HashMap<>(); for (CUserDateAmountVo v : datas) { @@ -1699,7 +1722,8 @@ 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(), tenantEntity.getParentTenantId(), sTime, eTime); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + List datas = wxCouponOrderMapper.queryPriceTotalGroup(tenantEntitys, tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), sTime, eTime); Map dataMap = new HashMap<>(); for (CUserDateAmountVo v : datas) { dataMap.put(v.getXTime(), v.getPrice()); @@ -1834,8 +1858,10 @@ public class WxChartServiceImpl implements WxChartDataService { String startdate; String enddate; HashMap datamap = new HashMap<>(); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); //couponData HashMap params = new HashMap<>(); + params.put("tenantEntitys",tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("tenantId", tenantEntity.getParentTenantId()); @@ -2263,7 +2289,8 @@ public class WxChartServiceImpl implements WxChartDataService { * @param enddate * @return */ - private ResultData getSaleCardAnalysis(Map paramsMap, String startdate, String enddate) { + private ResultData getSaleCardAnalysis(TenantEntity tenantEntity,Map paramsMap, String startdate, String enddate) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); WxCoupon wxCoupon = new WxCoupon(); //默认时间本月第一天,截止到当天 @@ -2281,8 +2308,8 @@ public class WxChartServiceImpl implements WxChartDataService { } Map result = new HashedMap(); - List saleMoneyList = wxCouponService.findSaleMoneyByDate(wxCoupon); - List paymentList = wxCouponService.findPaymentByDate(wxCoupon); + List saleMoneyList = wxCouponService.findSaleMoneyByDate(tenantEntitys,wxCoupon); + List paymentList = wxCouponService.findPaymentByDate(tenantEntitys,wxCoupon); Map saleMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); Map payMentMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); @@ -2294,20 +2321,23 @@ public class WxChartServiceImpl implements WxChartDataService { } result.put("saleHistory",saleMap); result.put("paymentHistory",payMentMap); - result.put("saleCardCount",wxCouponService.findSaleCardCount(wxCoupon)); - result.put("tranCount",wxCouponService.findTranCardCount(wxCoupon)); - result.put("subsidyCount",wxCouponService.findSubsidyMoney(wxCoupon)); + result.put("saleCardCount",wxCouponService.findSaleCardCount(tenantEntitys,wxCoupon)); + result.put("tranCount",wxCouponService.findTranCardCount(tenantEntitys,wxCoupon)); + result.put("subsidyCount",wxCouponService.findSubsidyMoney(tenantEntitys,wxCoupon)); return new ResultData(result); } /** * 券营销数据 + * + * @param tenantEntity * @param paramsMap * @param startdate * @param enddate * @return */ - private ResultData getSaleCouponAnalysis(Map paramsMap, String startdate, String enddate) { + private ResultData getSaleCouponAnalysis(TenantEntity tenantEntity, Map paramsMap, String startdate, String enddate) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); WxCoupon wxCoupon = new WxCoupon(); Map result = new HashedMap(); @@ -2324,11 +2354,11 @@ public class WxChartServiceImpl implements WxChartDataService { Date endTime = DateUtils.stringToDate(enddate, "yyyy-MM-dd HH:mm:ss"); wxCoupon.setEnddate(endTime); } - List orderCountList = wxCouponService.findCouponOrderCount(wxCoupon); - List paymentCountList = wxCouponService.findCouponPaymentCount(wxCoupon); - List priceCouponSaleCountList = wxCouponService.priceCouponSaleCount(wxCoupon); - List priceCouponPaymentCountList = wxCouponService.priceCouponPaymentCount(wxCoupon); - Long priceCouponCancelCount = wxCouponService.priceCouponCancelCount(wxCoupon); + List orderCountList = wxCouponService.findCouponOrderCount(tenantEntitys,wxCoupon); + List paymentCountList = wxCouponService.findCouponPaymentCount(tenantEntitys,wxCoupon); + List priceCouponSaleCountList = wxCouponService.priceCouponSaleCount(tenantEntitys,wxCoupon); + List priceCouponPaymentCountList = wxCouponService.priceCouponPaymentCount(tenantEntitys,wxCoupon); + Long priceCouponCancelCount = wxCouponService.priceCouponCancelCount(tenantEntitys,wxCoupon); Map orderCountMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); Map paymentCountMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); @@ -2351,9 +2381,9 @@ public class WxChartServiceImpl implements WxChartDataService { result.put("paymentCountList",paymentCountMap); result.put("priceCouponSaleCountList",priceCouponSaleCountMap); result.put("priceCouponPaymentCountList",priceCouponPaymentCountMap); - result.put("sumPriceSaleMoney",wxCouponService.findSumPriceSaleMoney(wxCoupon)); - result.put("sumPricePayMent",wxCouponService.findSumPricePayMent(wxCoupon)); - result.put("sumSubsidyMoney",wxCouponService.findSumSubsidyMoney(wxCoupon)); + result.put("sumPriceSaleMoney",wxCouponService.findSumPriceSaleMoney(tenantEntitys,wxCoupon)); + result.put("sumPricePayMent",wxCouponService.findSumPricePayMent(tenantEntitys,wxCoupon)); + result.put("sumSubsidyMoney",wxCouponService.findSumSubsidyMoney(tenantEntitys,wxCoupon)); result.put("priceCouponCancelCount",priceCouponCancelCount);//有价券退款数量 //有价券售出数量 @@ -2374,6 +2404,7 @@ public class WxChartServiceImpl implements WxChartDataService { * @return */ private ResultData getSalePressAnalysis(Map paramsMap, TenantEntity tenantEntity, String startdate, String enddate) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); WxCoupon wxCoupon = new WxCoupon(); Map result = new HashedMap(); @@ -2390,9 +2421,9 @@ public class WxChartServiceImpl implements WxChartDataService { Date endTime = DateUtils.stringToDate(enddate, "yyyy-MM-dd HH:mm:ss"); wxCoupon.setEnddate(endTime); } - List pressSendHistory = wxCouponService.pressSendHistory(wxCoupon); - List pressSuccHistory = wxCouponService.pressSuccHistory(wxCoupon); - List pressPaymentHistory = wxCouponService.pressPaymentHistory(wxCoupon); + List pressSendHistory = wxCouponService.pressSendHistory(tenantEntitys,wxCoupon); + List pressSuccHistory = wxCouponService.pressSuccHistory(tenantEntitys,wxCoupon); + List pressPaymentHistory = wxCouponService.pressPaymentHistory(tenantEntitys,wxCoupon); Map pressSendHistoryMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); Map pressSuccHistoryMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); @@ -2417,8 +2448,8 @@ public class WxChartServiceImpl implements WxChartDataService { result.put("pressSuccHistoryCount",getTotal(pressSuccHistoryMap)); result.put("pressPaymentHistoryCount",getTotal(pressPaymentHistoryMap)); - result.put("pressSuccRate",wxCouponService.pressSuccRate(wxCoupon)); - result.put("sumJoin",wxCouponService.sumJoin(wxCoupon)); + result.put("pressSuccRate",wxCouponService.pressSuccRate(tenantEntitys,wxCoupon)); + result.put("sumJoin",wxCouponService.sumJoin(tenantEntitys,wxCoupon)); return new ResultData(result); } @@ -2438,7 +2469,9 @@ public class WxChartServiceImpl implements WxChartDataService { * @return */ private ResultData getSaleGroupAnalysis(Map paramsMap, TenantEntity tenantEntity, String startdate) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); Map params = new HashMap<>(); + params.put("tenantEntitys",tenantEntitys); params.put("tenantId", tenantEntity.getTenantId()); if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { params.put("parentTenantId", tenantEntity.getParentTenantId()); @@ -2931,6 +2964,7 @@ public class WxChartServiceImpl implements WxChartDataService { * @return */ private ResultData getSaleDataHistory(TenantEntity tenantEntity, String startdate,String enddate) { + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); Date startDate = DateUtils.getDateFromString(startdate,"yyyy-MM-dd HH:mm:ss").getTime(); Date endDate = DateUtils.getDateFromString(enddate,"yyyy-MM-dd HH:mm:ss").getTime(); @@ -2944,7 +2978,7 @@ public class WxChartServiceImpl implements WxChartDataService { couponQuery.setEnddate(endDate); //卡数据 - List couponStatisVoList = wxCouponService.findSaleCardCountHistory(couponQuery); + List couponStatisVoList = wxCouponService.findSaleCardCountHistory(tenantEntitys,couponQuery); countMap = couponStatisVoList.stream().collect(Collectors.toMap(WxCouponStatisVo::getXtime, p -> Integer.parseInt(p.getXcount()))); historyMap = new TreeMap<>(); for (String date:days) { @@ -2957,7 +2991,7 @@ public class WxChartServiceImpl implements WxChartDataService { datamap.put("cardHistory",historyMap); //砍价数据 - List wxCouponStatisVoList = wxCouponService.pressSendHistory(couponQuery); + List wxCouponStatisVoList = wxCouponService.pressSendHistory(tenantEntitys,couponQuery); Map countHistoryMap = getDateMap(startDate,endDate); for (WxCouponStatisVo coupon:wxCouponStatisVoList){ countHistoryMap.put(coupon.getXtime(),coupon.getXcount()); @@ -2965,7 +2999,7 @@ public class WxChartServiceImpl implements WxChartDataService { datamap.put("pressSendHistory",countHistoryMap); //拼团 - wxCouponStatisVoList = wxOrderGroupMapper.queryOrderGroupCountHistory(couponQuery); + wxCouponStatisVoList = wxOrderGroupMapper.queryOrderGroupCountHistory(tenantEntitys,couponQuery); countHistoryMap = getDateMap(startDate,endDate); for (WxCouponStatisVo coupon:wxCouponStatisVoList){ countHistoryMap.put(coupon.getXtime(),coupon.getXcount()); @@ -2973,7 +3007,7 @@ public class WxChartServiceImpl implements WxChartDataService { datamap.put("groupHistory",countHistoryMap); //券数据 - wxCouponStatisVoList = wxCouponService.findCouponOrderCount(couponQuery); + wxCouponStatisVoList = wxCouponService.findCouponOrderCount(tenantEntitys, couponQuery); countHistoryMap = getDateMap(startDate,endDate); for (WxCouponStatisVo coupon:wxCouponStatisVoList){ countHistoryMap.put(coupon.getXtime(),coupon.getXcount()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index bff8e0e8a..6c624b784 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -200,6 +200,17 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return new ResultData(Result.SUCCESS, "查询成功", data); } + @Override + public int countCoupon(WxCouponChannel wxCouponChannel, List tenantEntitys) { + int count = 0; + for (TenantEntity tenantEntity:tenantEntitys) { + wxCouponChannel.updateTenantInfo(tenantEntity); + int count1 = wxCouponChannelMapper.countCoupon(wxCouponChannel); + count += count1; + } + return count; + } + private boolean isCouponMerchantValid(Long couponId,String tenantId) { List merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){ 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 f7a13b1b8..dd33f42e2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -1019,12 +1019,19 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { @Override public List queryPriceTotalGroup(TenantEntity tenantEntity, Date startTime, Date endTime) { - return wxCouponOrderMapper.queryPriceTotalGroup(tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), startTime, endTime); + List tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity); + return wxCouponOrderMapper.queryPriceTotalGroup(tenantEntitys, tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), startTime, endTime); } @Override - public int queryPriceTotal(WxCouponOrder wxCouponOrder) { - return wxCouponOrderMapper.queryPriceTotal(wxCouponOrder); + public int queryPriceTotal(WxCouponOrder wxCouponOrder,List tenantEntitys) { + int count = 0; + for (TenantEntity tenantEntity:tenantEntitys) { + wxCouponOrder.updateTenantInfo(tenantEntity); + int i = wxCouponOrderMapper.queryPriceTotal(wxCouponOrder); + count += i; + } + return count; } @@ -1481,4 +1488,14 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { return 0; } + public int findCount(WxCouponOrder wxCouponOrder,List tenantEntitys){ + int count = 0; + for (TenantEntity tenantEntity:tenantEntitys) { + wxCouponOrder.updateTenantInfo(tenantEntity); + int count1 = wxCouponOrderMapper.findCount(wxCouponOrder); + count += count1; + } + return count; + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index b9fcf171f..7d77567f7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -497,31 +497,48 @@ public class WxCouponServiceImpl implements WxCouponService { } @Override - public List findSaleMoneyByDate(WxCoupon wxCoupon) { - return wxCouponMapper.findSaleMoneyByDate(wxCoupon); + public List findSaleMoneyByDate(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.findSaleMoneyByDate(tenantEntitys,wxCoupon); } @Override - public List findPaymentByDate(WxCoupon wxCoupon) { - return wxCouponMapper.findPaymentByDate(wxCoupon); + public List findPaymentByDate(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.findPaymentByDate(tenantEntitys,wxCoupon); } @Override - public Long findSaleCardCount(WxCoupon wxCoupon) { - Long count = wxCouponMapper.findSaleCardCount(wxCoupon); - return (count==null)?0l:count; + public Long findSaleCardCount(List tenantEntitys, WxCoupon wxCoupon) { + long count = 0l; + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + long saleCardCount = wxCouponMapper.findSaleCardCount(wxCoupon).longValue(); + count += saleCardCount; + } + return count; } @Override - public Long findTranCardCount(WxCoupon wxCoupon) { - Long count = wxCouponMapper.findTranCardCount(wxCoupon); - return (count==null)?0l:count; + public Long findTranCardCount(List tenantEntitys, WxCoupon wxCoupon) { + long count = 0l; + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + long saleCardCount = wxCouponMapper.findTranCardCount(wxCoupon).longValue(); + count += saleCardCount; + } + return count; } @Override - public String findSubsidyMoney(WxCoupon wxCoupon) { - String count = wxCouponMapper.findSubsidyMoney(wxCoupon); - return (count==null)?"0":count; + public String findSubsidyMoney(List tenantEntitys, WxCoupon wxCoupon) { + BigDecimal a = new BigDecimal("0"); + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + String subsidyMoney = wxCouponMapper.findSubsidyMoney(wxCoupon); + if(StringUtils.isNotBlank(subsidyMoney)){ + a = a.add(new BigDecimal(subsidyMoney)); + } + } + return a.toPlainString(); } @Override @@ -530,42 +547,65 @@ public class WxCouponServiceImpl implements WxCouponService { } @Override - public List findCouponOrderCount(WxCoupon wxCoupon) { - return wxCouponMapper.findCouponOrderCount(wxCoupon); + public List findCouponOrderCount(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.findCouponOrderCount(tenantEntitys,wxCoupon); } @Override - public List findCouponPaymentCount(WxCoupon wxCoupon) { - return wxCouponMapper.findCouponPaymentCount(wxCoupon); + public List findCouponPaymentCount(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.findCouponPaymentCount(tenantEntitys,wxCoupon); } @Override - public List priceCouponSaleCount(WxCoupon wxCoupon) { - return wxCouponMapper.priceCouponSaleCount(wxCoupon); + public List priceCouponSaleCount(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.priceCouponSaleCount(tenantEntitys,wxCoupon); } @Override - public List priceCouponPaymentCount(WxCoupon wxCoupon) { - return wxCouponMapper.priceCouponPaymentCount(wxCoupon); + public List priceCouponPaymentCount(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.priceCouponPaymentCount(tenantEntitys,wxCoupon); } @Override - public String findSumPriceSaleMoney(WxCoupon wxCoupon) { - String count = wxCouponMapper.findSumPriceSaleMoney(wxCoupon); - return (count==null)?"0":count; + public String findSumPriceSaleMoney(List tenantEntitys, WxCoupon wxCoupon) { + + BigDecimal a = new BigDecimal("0"); + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + String subsidyMoney = wxCouponMapper.findSumPriceSaleMoney(wxCoupon); + if(StringUtils.isNotBlank(subsidyMoney)){ + a = a.add(new BigDecimal(subsidyMoney)); + } + } + return a.toPlainString(); + } @Override - public String findSumPricePayMent(WxCoupon wxCoupon) { - String count = wxCouponMapper.findSumPricePayMent(wxCoupon); - return (count==null)?"0":count; + public String findSumPricePayMent(List tenantEntitys, WxCoupon wxCoupon) { + BigDecimal a = new BigDecimal("0"); + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + String subsidyMoney = wxCouponMapper.findSumPricePayMent(wxCoupon); + if(StringUtils.isNotBlank(subsidyMoney)){ + a = a.add(new BigDecimal(subsidyMoney)); + } + } + return a.toPlainString(); } @Override - public String findSumSubsidyMoney(WxCoupon wxCoupon) { - String count = wxCouponMapper.findSumSubsidyMoney(wxCoupon); - return (count==null)?"0":count; + public String findSumSubsidyMoney(List tenantEntitys, WxCoupon wxCoupon) { + BigDecimal a = new BigDecimal("0"); + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + String subsidyMoney = wxCouponMapper.findSumSubsidyMoney(wxCoupon); + if(StringUtils.isNotBlank(subsidyMoney)){ + a = a.add(new BigDecimal(subsidyMoney)); + } + } + return a.toPlainString(); } @Override @@ -574,23 +614,23 @@ public class WxCouponServiceImpl implements WxCouponService { } @Override - public List pressSendHistory(WxCoupon wxCoupon) { - return wxCouponMapper.pressSendHistory(wxCoupon); + public List pressSendHistory(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.pressSendHistory(tenantEntitys,wxCoupon); } @Override - public List pressSuccHistory(WxCoupon wxCoupon) { - return wxCouponMapper.pressSuccHistory(wxCoupon); + public List pressSuccHistory(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.pressSuccHistory(tenantEntitys,wxCoupon); } @Override - public List pressPaymentHistory(WxCoupon wxCoupon) { - return wxCouponMapper.pressPaymentHistory(wxCoupon); + public List pressPaymentHistory(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.pressPaymentHistory(tenantEntitys,wxCoupon); } @Override - public String pressSuccRate(WxCoupon wxCoupon) { - String count = wxCouponMapper.pressSuccRate(wxCoupon); + public String pressSuccRate(List tenantEntitys, WxCoupon wxCoupon) { + String count = wxCouponMapper.pressSuccRate(tenantEntitys,wxCoupon); if (StringUtils.isBlank(count) || "0.00".equals(count)) { return "0%"; } else { @@ -599,20 +639,25 @@ public class WxCouponServiceImpl implements WxCouponService { } @Override - public Long sumJoin(WxCoupon wxCoupon) { - Long count = wxCouponMapper.sumJoin(wxCoupon); + public Long sumJoin(List tenantEntitys, WxCoupon wxCoupon) { + Long count = wxCouponMapper.sumJoin(tenantEntitys,wxCoupon); return (count==null)?0l:count; } @Override - public Long priceCouponCancelCount(WxCoupon wxCoupon) { - Long count = wxCouponMapper.priceCouponCancelCount(wxCoupon); - return (count==null)?0l:count; + public Long priceCouponCancelCount(List tenantEntitys, WxCoupon wxCoupon) { + Long count = 0l; + for (TenantEntity tenantEntity:tenantEntitys) { + wxCoupon.updateTenantInfo(tenantEntity); + Long aLong = wxCouponMapper.priceCouponCancelCount(wxCoupon); + count += (aLong==null)?0l:aLong; + } + return count; } @Override - public List findSaleCardCountHistory(WxCoupon wxCoupon) { - return wxCouponMapper.findSaleCardCountHistory(wxCoupon); + public List findSaleCardCountHistory(List tenantEntitys, WxCoupon wxCoupon) { + return wxCouponMapper.findSaleCardCountHistory(tenantEntitys,wxCoupon); } @Override 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 ec674dda0..e24fb4eec 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java @@ -234,6 +234,11 @@ public class WxMallServiceImpl implements WxMallService { return wxMallMapper.listAsSelectMall(id); } + @Override + public List getTenantEntitys(TenantEntity tenantEntity) { + return wxMallMapper.getTenantEntitys(tenantEntity); + } + private void deleteRedis(TenantEntity tenantEntity){ String key1 = Constant.mallinfoPrev + tenantEntity.getTenantId(); if(mallRedisTemplate.hasKey(key1)){ diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index 5c4ba6567..8714c42d6 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -226,7 +226,7 @@ #{idItem} - order by ${sortColumns} + order by ${basicInfo.sortColumns} diff --git a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml index c288886c4..3a7a3fe42 100644 --- a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml @@ -76,7 +76,10 @@ 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 cmd_type=#{cmdType} + from ( + SELECT * from wx_car_cmd_log${tenantEntity.shardTableSuffix} + ) where cmd_type=#{cmdType} and `tenant_id` = #{tenantId} @@ -104,7 +109,9 @@ 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 cmd_type=#{cmdType} + from ( + SELECT * from wx_car_cmd_log${tenantEntity.shardTableSuffix} + ) where cmd_type=#{cmdType} and `tenant_id` = #{tenantId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index d9ee40e4e..0464b9faf 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -87,7 +87,9 @@ select create_time_md as xTime, channel_type, count(create_time_md + '' + channel_type) as count - from wx_coupon_action_log + from ( + SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix} + ) where channel_type in (2,3,4,5) and `tenant_id` = #{tenantId} @@ -172,8 +184,12 @@ select DATE_FORMAT(create_time,'%Y-%m-%d') as xtime, Count(*) as sendCount - from wx_coupon_action_log + from ( + SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix} + ) where channel_type=#{channelType} and `tenant_id` = #{tenantId} @@ -236,7 +254,9 @@ select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci - left join wx_coupon c on c.id = ci.coupon_id + left join ( + SELECT * from wx_coupon${tenantEntity.shardTableSuffix} + ) c on c.id = ci.coupon_id where c.type = 100 - and ci.create_date between #{startdate} and #{enddate} + and ci.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate} group by xtime - - - - - @@ -938,69 +962,83 @@ - - - - select round( - (select count(wo.id) from wx_coupon wc - left join wx_order wo on wo.product_id = wc.id + (select count(wo.id) from ( + SELECT * from wx_coupon${tenantEntity.shardTableSuffix} + ) wc + left join ( + SELECT * from wx_order${tenantEntity.shardTableSuffix} + ) wo on wo.product_id = wc.id where wo.order_status = 1 and wc.type = 8 - and wo.create_date between #{startdate} and #{enddate} - - and wo.`tenant_id` = #{tenantId} - - - and wo.`parent_tenant_id` = #{parentTenantId} - + and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate} ) / (select count(wop.id) from wx_coupon wc - left join wx_order wo on wo.product_id = wc.id - left join wx_order_press wop on wop.order_id = wo.id + left join ( + SELECT * from wx_order${tenantEntity.shardTableSuffix} + ) wo on wo.product_id = wc.id + left join ( + SELECT * from wx_order_press${tenantEntity.shardTableSuffix} + ) wop on wop.order_id = wo.id where wop.first = 1 and wc.type = 8 - and wop.create_date between #{startdate} and #{enddate} - - and wo.`tenant_id` = #{tenantId} - and wop.`tenant_id` = #{tenantId} - - - and wo.`parent_tenant_id` = #{parentTenantId} - and wop.`parent_tenant_id` = #{parentTenantId} - + and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate} ) * 100 ,2) - + select count(wop.id) from ( + SELECT * from wx_coupon${tenantEntity.shardTableSuffix} + ) wc + left join ( + SELECT * from wx_order${tenantEntity.shardTableSuffix} + ) wo on wo.product_id = wc.id + left join ( + SELECT * from wx_order_press${tenantEntity.shardTableSuffix} + ) wop on wop.order_id = wo.id where wc.type = 8 - and wop.create_date between #{startdate} and #{enddate} + and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate} - diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index eac358bcb..c9aa960c2 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -181,7 +181,9 @@ COUNT(DISTINCT c_user_id) as couponUserCount, count(*) as couponCount, (select Count(*) - from wx_coupon_order c + from ( + SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix} + ) c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime @@ -193,7 +195,9 @@ AND c.update_date >= #{startTime} AND c.update_date <= #{endTime}) as verifyCount, (select Count(DISTINCT c_user_id) - from wx_coupon_order d + from ( + SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix} + ) d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime @@ -204,7 +208,9 @@ AND d.update_date >= #{startTime} AND d.update_date <= #{endTime}) as verifyUserCount - from wx_coupon_order + from ( + SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix} + ) where 1=1 and `tenant_id` = #{tenantId} @@ -628,7 +634,10 @@ + select `tenant_id`,`parent_tenant_id` from wx_mall where id > 1 + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + diff --git a/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml index f35d900cf..fcc7bacc8 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderGroupMapper.xml @@ -145,7 +145,9 @@ select count(1) total,DATE_FORMAT(create_date,'%Y-%m-%d') time - from wx_coupon_order where coupon_type=9 and coupon_order_status=1 + from ( + SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix} + ) where coupon_type=9 and coupon_order_status=1 and `tenant_id` = #{tenantId} @@ -181,7 +185,9 @@ - select DATE_FORMAT(create_date,'%Y-%m-%d') xtime,count(*) xcount - from wx_order_group + from ( + SELECT * from wx_order_group${tenantEntity.shardTableSuffix} + ) - - and `tenant_id` = #{tenantId} - - - and `parent_tenant_id` = #{parentTenantId} - - - and create_date BETWEEN #{startdate} and #{enddate} + + + and create_date BETWEEN #{wxCoupon.startdate} and #{wxCoupon.enddate} group by xtime