Просмотр исходного кода

优化券每日报表

release_toaliyun_real
winter 4 лет назад
Родитель
Сommit
bb5b79aaef
5 измененных файлов: 195 добавлений и 56 удалений
  1. +3
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java
  2. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java
  3. +34
    -11
      mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java
  4. +110
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  5. +45
    -44
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 3
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java Просмотреть файл

@@ -57,7 +57,9 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> {
WxCouponOrder findDetailOfAdmin(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("finalTenantId")String finalTenantId);

//营销报表 券数据图表
List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params);
//List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params);
HashMap<String,Integer> findCreateDateCouponOrderCount(HashMap<String,Object> params);
HashMap<String,Integer> findCreateDateCouponOrderUserCount(HashMap<String,Object> params);

//营销报表 券数据报表
List<MarkingCouponDataReportVo> couponDataList(HashMap<String,Object> params); //返回日期格式yy-MM-dd


+ 3
- 0
mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java Просмотреть файл

@@ -13,6 +13,7 @@ import com.iformall.service.order.entity.WxComposeOrder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@@ -226,4 +227,6 @@ public interface WxCouponOrderService {
Integer findCount(WxCouponOrder wxCouponOrder);

PageInfo<WxCouponOrderBVo> goodsListAsPage(WxCouponOrderBVo couponOrderBvo, Integer pageNum, Integer pageSize);
List<MarkingCouponDataReportVo> couponDataMap(TenantEntity tenantEntity,Date startTime,Date endTime);
}

+ 34
- 11
mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java Просмотреть файл

@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
@@ -70,8 +71,11 @@ public class WxChartServiceImpl implements WxChartDataService {
WxLevelConfigMapper wxLevelConfigMapper;
@Autowired
WxCUserTagsMapper wxCUserTagsMapper;
@Lazy
@Autowired
WxCouponService wxCouponService;
@Autowired
WxOrderGroupMapper wxOrderGroupMapper;
@Autowired
@@ -82,23 +86,40 @@ public class WxChartServiceImpl implements WxChartDataService {
WxBillOtherMapper wxBillOtherMapper;
@Autowired
WxBillAllMapper wxBillAllMapper;
@Lazy
@Autowired
MarkingDataReportService markingDataReportService;
@Lazy
@Autowired
WxBusinessService wxBusinessService;

@Lazy
@Autowired
WxCouponOrderService wxCouponOrderService;
@Lazy
@Autowired
KwMeterDataService kwMeterDataService;
@Lazy
@Autowired
KwMerchantMeterService kwMerchantMeterService;
@Lazy
@Autowired
KwMeterService kwMeterService;
@Lazy
@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;
@Lazy
@Autowired
private WxCUserService wxCUserService;
@Lazy
@Autowired
private WxCUserCarService wxCUserCarService;

@@ -1893,17 +1914,19 @@ public class WxChartServiceImpl implements WxChartDataService {
String startdate;
String enddate;
HashMap<String, Object> datamap = new HashMap<>();
List<TenantEntity> tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity);
//couponData
HashMap<String, Object> params = new HashMap<>();
params.put("tenantEntitys",tenantEntitys);
params.put("tenantId", tenantEntity.getTenantId());
if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) {
params.put("tenantId", tenantEntity.getParentTenantId());
}
params.put("startTime", addDay(-30));
params.put("endTime", addDay(1));
List<MarkingCouponDataReportVo> couponDatalist = wxCouponOrderMapper.couponDataMap(params);
// List<TenantEntity> tenantEntitys = wxMallMapper.getTenantEntitys(tenantEntity);
// //couponData
// HashMap<String, Object> params = new HashMap<>();
// params.put("tenantEntitys",tenantEntitys);
// params.put("tenantId", tenantEntity.getTenantId());
// if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) {
// params.put("tenantId", tenantEntity.getParentTenantId());
// }
// params.put("startTime", addDay(-30));
// params.put("endTime", addDay(1));
List<MarkingCouponDataReportVo> couponDatalist = wxCouponOrderService.couponDataMap(tenantEntity,addDay(-30),addDay(1));
//查询券领取人数
startdate = DateUtils.getTimeBefore(30, new Date());
enddate = DateUtils.getTimeBefore(1, new Date());


+ 110
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -42,6 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@@ -82,12 +83,15 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired
WxCUserBasicInfoMapper wxCUserBasicInfoMapper;

@Lazy
@Autowired
WxOrderService wxOrderService;

@Lazy
@Autowired
WxCouponSendService wxCouponSendService;

@Lazy
@Autowired
WxProfitSharingOrderService wxProfitSharingOrderService;
@@ -106,6 +110,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired
WxCouponMapper wxCouponMapper;

@Lazy
@Autowired
WxAppinfoService wxAppinfoService;

@@ -133,12 +138,15 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired
ExcelService excelService;

@Lazy
@Autowired
WxCreditHistoryService wxCreditHistoryService;

@Lazy
@Autowired
WxScoreRulesService wxScoreRulesService;

@Lazy
@Autowired
WxMsgLimitService wxMsgLimitService;

@@ -151,6 +159,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired
PayServiceFactory payServiceFactory;
@Lazy
@Autowired
WxCashOutService cashOutService;

@@ -164,10 +173,15 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Autowired
OrderFactory orderFactory;
@Lazy
@Autowired
WxCUserBasicInfoService wxCUserBasicInfoService;
@Lazy
@Autowired
SysConfigService sysConfigService;
@Lazy
@Autowired
WxMerchantBUserService wxMerchantBUserService;
@@ -2379,5 +2393,101 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
public PageInfo<WxCouponOrderBVo> goodsListAsPage(WxCouponOrderBVo record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findGoodsList(record));
}
@Override
public List<MarkingCouponDataReportVo> couponDataMap(TenantEntity tenantEntity,Date startTime,Date endTime) {
List<String> dateList = new ArrayList<String>();
//券数量
HashMap<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("tenantId", tenantEntity.getTenantId());
paramMap.put("parentTenantId", tenantEntity.getParentTenantId());
paramMap.put("startCreateDateTimes", startTime.getTime());
paramMap.put("endCreateDateTimes", endTime.getTime());
Map<String,Integer> couponCount = wxCouponOrderMapper.findCreateDateCouponOrderCount(paramMap);
if (null != couponCount) {
for (Iterator<String> it = couponCount.keySet().iterator();it.hasNext();) {
String date = it.next();
if (!dateList.contains(date)){
dateList.add(date);
}
}
}
//券领取人数
Map<String,Integer> couponUserCount = wxCouponOrderMapper.findCreateDateCouponOrderUserCount(paramMap);
if (null != couponUserCount) {
for (Iterator<String> it = couponUserCount.keySet().iterator();it.hasNext();) {
String date = it.next();
if (!dateList.contains(date)){
dateList.add(date);
}
}
}
//核销数量
HashMap<String,Object> verfiyParamMap = new HashMap<String,Object>();
verfiyParamMap.put("tenantId", tenantEntity.getTenantId());
verfiyParamMap.put("parentTenantId", tenantEntity.getParentTenantId());
verfiyParamMap.put("couponOrderStatus", 1);
verfiyParamMap.put("updateStartTime", startTime);
verfiyParamMap.put("updateEndTime", endTime);
Map<String,Integer> verfiyCount = wxCouponOrderMapper.findCreateDateCouponOrderCount(verfiyParamMap);
if (null != verfiyCount) {
for (Iterator<String> it = verfiyCount.keySet().iterator();it.hasNext();) {
String date = it.next();
if (!dateList.contains(date)){
dateList.add(date);
}
}
}
//券核销人数
Map<String,Integer> verfiyUserCount = wxCouponOrderMapper.findCreateDateCouponOrderUserCount(verfiyParamMap);
if (null != verfiyUserCount) {
for (Iterator<String> it = verfiyUserCount.keySet().iterator();it.hasNext();) {
String date = it.next();
if (!dateList.contains(date)){
dateList.add(date);
}
}
}
if (dateList.size() > 0) {
List<MarkingCouponDataReportVo> volist = new ArrayList<MarkingCouponDataReportVo>();
for (int i = 0 ; i < dateList.size(); i ++) {
String date = dateList.get(i);
MarkingCouponDataReportVo vo = new MarkingCouponDataReportVo();
if (null != couponCount && couponCount.containsKey(date)) {
vo.setCouponCount(couponCount.get(date));
}else {
vo.setCouponCount(0);
}
if (null != couponUserCount && couponUserCount.containsKey(date)) {
vo.setCouponUserCount(couponUserCount.get(date));;
}else {
vo.setCouponUserCount(0);
}
if (null != verfiyCount && verfiyCount.containsKey(date)) {
vo.setVerifyCount(verfiyCount.get(date));
}else {
vo.setVerifyCount(0);
}
if (null != verfiyUserCount && verfiyUserCount.containsKey(date)) {
vo.setVerifyUserCount(verfiyUserCount.get(date));
}else {
vo.setVerifyUserCount(0);
}
volist.add(vo);
}
return volist;
}
return null;
}

}

+ 45
- 44
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -186,20 +186,19 @@
co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`
from wx_coupon_order co
where co.tenant_id = #{tenantId}
<if test="startDateTimes != null">
AND co.create_date_times &gt; #{startDateTimes}
</if>
<if test="endDateTimes != null">
AND co.create_date_times &lt; #{endDateTimes}
</if>
<if test=" null != couponIds ">
and co.coupon_id in
<foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
#{couponIdItem}
</foreach>
</if>
<if test="startDateTimes != null">
AND co.create_date_times &gt; #{startDateTimes}
</if>
<if test="endDate != null">
AND co.create_date_times &lt; #{endDateTimes}
</if>
order by co.create_date_times desc

</select>
<update id="updateVerifyCouponOrder" parameterType="com.iformall.domain.po.WxCouponOrder">
@@ -293,53 +292,55 @@
where id=#{id}
</update>

<select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
COUNT(DISTINCT c_user_id) as couponUserCount,
count(*) as couponCount,
(select Count(*)
from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
</foreach>) c
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>

<select id = "findCreateDateCouponOrderCount" resultType="hashmap" parameterType="hashmap">
select DATE_FORMAT(create_date,'%m/%d') as createTime ,count(1) as count from wx_coupon_order
where `tenant_id` = #{tenantId}
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>
AND c.update_date &gt;= #{startTime}
AND c.update_date &lt;= #{endTime}) as verifyCount,
(select Count(DISTINCT c_user_id)
from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
</foreach>) d
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
<if test="startCreateDateTimes != null">
AND co.create_date_times &gt;= #{startCreateDateTimes}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
<if test="endCreateDateTimes != null">
AND co.create_date_times &lt;= #{endCreateDateTimes}
</if>
AND d.update_date &gt;= #{startTime}
AND d.update_date &lt;= #{endTime}) as verifyUserCount
from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
</foreach>) wx_coupon_order
where 1=1
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
<if test="couponOrderStatus != null">
and co.coupon_order_status = #{couponOrderStatus}
</if>
<if test="updateStartTime != null">
AND co.update_date &gt;= #{updateStartTime}
</if>
<if test="updateEndTime != null">
AND co.update_date &lt;= #{updateEndTime}
</if>
group by DATE_FORMAT(create_date,'%m/%d')
</select>
<select id = "findCreateDateCouponOrderUserCount" resultType="hashmap" parameterType="hashmap">
select DATE_FORMAT(create_date,'%m/%d') as createTime ,count(DISTINCT c_user_id) as count from wx_coupon_order
where `tenant_id` = #{tenantId}
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>
AND create_date &gt;= #{startTime}
AND create_date &lt;= #{endTime}
GROUP BY createTime
<if test="startCreateDateTimes != null">
AND co.create_date_times &gt;= #{startCreateDateTimes}
</if>
<if test="endCreateDateTimes != null">
AND co.create_date_times &lt;= #{endCreateDateTimes}
</if>
<if test="couponOrderStatus != null">
and co.coupon_order_status = #{couponOrderStatus}
</if>
<if test="updateStartTime != null">
AND co.update_date &gt;= #{updateStartTime}
</if>
<if test="updateEndTime != null">
AND co.update_date &lt;= #{updateEndTime}
</if>
group by DATE_FORMAT(create_date,'%m/%d')
</select>

<select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT createTime,couponId,sum(couponCount) couponCount,sum(couponUserCount) couponUserCount,sum(verifyCount) verifyCount,sum(verifyUserCount) verifyUserCount
from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">


Загрузка…
Отмена
Сохранить