Commit 412da7be by 张富康

存量门店分析接口

1 parent f938ad23
......@@ -4,7 +4,6 @@ import lombok.Data;
/**
* BI记录实体
*
* 用于存储BI数据
*/
@Data
......
......@@ -3,13 +3,16 @@ package cn.com.glsx.dj.peanalysis.dto.res.UserdCarDataStats;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 存量门店分析
*/
@Data
public class StockStoreAnalysisRes {
public class StockStoreAnalysisRes implements Serializable {
private static final long serialVersionUID = 2507729541857822347L;
/**
......@@ -44,6 +47,12 @@ public class StockStoreAnalysisRes {
private BigDecimal newStoreCountHb;
/**
* 新店占比
*/
@ApiModelProperty(notes = "新店占比")
private BigDecimal newStoreRate;
/**
* 老店及占比:取统计业务+统计周期+统计品牌+统计区域下,存在“收车数”的门店中,若首个订单时间与统计周期开始时间比对,若大于90天即属于老店,统计对应的门店数,
* 门店数需展示对应的环比,即((本周期统计值-上周期统计值)/上周期统计值)*100%,保留百分比两位小数,即xx.xx%;
* 占比=(老店/总开单门店)*100%,保留百分比两位小数,即xx.xx%;
......@@ -59,6 +68,12 @@ public class StockStoreAnalysisRes {
private BigDecimal oldStoreCountHb;
/**
* 老店占比
*/
@ApiModelProperty(notes = "老店占比")
private BigDecimal oldStoreRate;
/**
* 多品类门店及占比:取统计业务+统计周期+统计品牌+统计区域下,存在“收车数”的门店中,若门店在其他业务存在产值,及属于多品类门店,统计对应的门店数,
* 门店数需展示对应的环比,即((本周期统计值-上周期统计值)/上周期统计值)*100%,保留百分比两位小数,即xx.xx%;
* 占比=(多品类门店/总开单门店)*100%,保留百分比两位小数,即xx.xx%;
......@@ -74,6 +89,12 @@ public class StockStoreAnalysisRes {
private BigDecimal multiCategoryStoreCountHb;
/**
* 多品类门店占比
*/
@ApiModelProperty(notes = "多品类门店占比")
private BigDecimal multiCategoryStoreRate;
/**
* 单品类门店及占比:取统计业务+统计周期+统计品牌+统计区域下,存在“收车数”的门店中,若门店在其他业务不存在产值,及属于单品类门店,统计对应的门店数,
* 门店数需展示对应的环比,即((本周期统计值-上周期统计值)/上周期统计值)*100%,保留百分比两位小数,
* 即xx.xx%;占比=(单品类门店/总开单门店)*100%,保留百分比两位小数,即xx.xx%;
......@@ -89,6 +110,12 @@ public class StockStoreAnalysisRes {
private BigDecimal singleCategoryStoreCountHb;
/**
* 单品类门店占比
*/
@ApiModelProperty(notes = "单品类门店占比")
private BigDecimal singleCategoryStoreRate;
/**
* 流失门店:取统计业务+统计周期+统计品牌+统计区域下,以统计周期的开始日期为基准,近30天无“收车数”且近60天存在“收车数”,则作为流失门店,统计对应的门店数;
*/
@ApiModelProperty(notes = "流失门店数量")
......
......@@ -103,4 +103,15 @@ public interface BusinessIntelligenceMapper {
@Param("merchantIds") List<Integer> merchantIds,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
/**
* 流失门店数统计-二手车
*/
Integer countLostMerchant(@Param("merchantIds") List<Integer> merchantIds, @Param("statDate") String statDate);
/**
* 历史门店总数-二手车
*/
Integer countHistoryMerchant(@Param("merchantIds") List<Integer> merchantIds, @Param("statDate") String statDate);
}
\ No newline at end of file
......@@ -609,5 +609,63 @@
</select>
<select id="countLostMerchant" resultType="java.lang.Integer">
SELECT
count(distinct merchant_id) AS lost_merchant_count
FROM dj_smartcarlife.dj_car_life_service_merchant_bi t1
WHERE
t1.deleted_flag = 'N'
<if test="merchantIds != null and merchantIds.size > 0">
and t1.merchant_id in
<foreach item="item" index="index" collection="merchantIds" separator="," open="(" close=")">
#{item}
</foreach>
</if>
AND EXISTS (
SELECT 1
FROM dj_smartcarlife.dj_car_life_service_merchant_bi t2
WHERE
t2.merchant_id = t1.merchant_id
<![CDATA[
AND t2.stat_date >= #{statDate} - INTERVAL 59 DAY -- 传入的统计日期
AND t2.stat_date <= #{statDate}
]]>
AND t2.has_used_car = 1
AND t2.deleted_flag = 'N'
)
AND NOT EXISTS (
SELECT 1
FROM dj_smartcarlife.dj_car_life_service_merchant_bi t3
WHERE
t3.merchant_id = t1.merchant_id
<![CDATA[
AND t3.stat_date >= #{statDate} - INTERVAL 29 DAY
AND t3.stat_date <= #{statDate}
]]>
AND t3.has_used_car = 1
AND t3.deleted_flag = 'N'
);
</select>
<select id="countHistoryMerchant" resultType="java.lang.Integer">
SELECT
COUNT(DISTINCT merchant_id) AS total_merchant_count
FROM dj_smartcarlife.dj_car_life_service_merchant_bi
WHERE
deleted_flag = 'N'
<if test="merchantIds != null and merchantIds.size > 0">
and merchant_id in
<foreach item="item" index="index" collection="merchantIds" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<![CDATA[
AND stat_date >= #{startDate} - INTERVAL 60 DAY
AND stat_date <= #{endDate} - INTERVAL 30 DAY
]]>
AND has_used_car = 1;
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!