mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 02:29:19 +08:00
feat(order-stat,workbench): 订单统计日表扩展 GMV/销售单量件数并贯通刷新读写,工作台经营 KPI 扩至 22 项及前端展示配置
This commit is contained in:
@@ -40,6 +40,14 @@
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN 1 ELSE 0 END)
|
||||
</sql>
|
||||
<sql id="sumSalesQuantity">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="qty"/> ELSE 0 END)
|
||||
</sql>
|
||||
<sql id="sumGmvQuantity">
|
||||
SUM(<include refid="qty"/>)
|
||||
</sql>
|
||||
<sql id="sumRefund">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="refundStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
@@ -67,11 +75,14 @@
|
||||
IFNULL(ps.product_id, -1) AS productId, IFNULL(p.category_id, 0) AS categoryId,
|
||||
<include refid="sumSales"/> AS salesAmount,
|
||||
<include refid="sumOrderCount"/> AS orderCount,
|
||||
<include refid="sumSalesQuantity"/> AS salesQuantitySum,
|
||||
<include refid="sumRefund"/> AS refundAmount,
|
||||
<include refid="sumProductCost"/> AS productCost,
|
||||
<include refid="sumFreightCost"/> AS freightCost,
|
||||
<include refid="sumOtherCost"/> AS otherCost,
|
||||
SUM(o.received_amount) AS gmvAllStatus
|
||||
SUM(o.received_amount) AS gmvAllStatus,
|
||||
COUNT(*) AS gmvOrderCount,
|
||||
<include refid="sumGmvQuantity"/> AS gmvQuantitySum
|
||||
FROM ec_order o
|
||||
INNER JOIN ec_shop s ON s.id = o.shop_id
|
||||
LEFT JOIN ec_product_spec ps ON ps.id = o.product_spec_id
|
||||
|
||||
@@ -5,25 +5,29 @@
|
||||
<insert id="upsertDailyShop">
|
||||
INSERT INTO ec_order_stat_daily_shop (
|
||||
company_id, shop_id, platform_id, stat_date,
|
||||
sales_amount, refund_amount, sales_order_count,
|
||||
product_cost, freight_cost, other_cost,
|
||||
gmv_amount, gmv_order_count, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost,
|
||||
stat_version
|
||||
) VALUES (
|
||||
#{companyId}, #{shopId}, #{platformId}, #{statDate},
|
||||
#{salesAmount}, #{refundAmount}, #{salesOrderCount},
|
||||
#{productCost}, #{freightCost}, #{otherCost},
|
||||
#{gmvAmount}, #{gmvOrderCount}, #{statVersion}
|
||||
#{salesAmount}, #{salesOrderCount}, #{salesQuantitySum},
|
||||
#{gmvAmount}, #{gmvOrderCount}, #{gmvQuantitySum},
|
||||
#{refundAmount}, #{productCost}, #{freightCost}, #{otherCost},
|
||||
#{statVersion}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
platform_id = VALUES(platform_id),
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
stat_version = VALUES(stat_version),
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
</insert>
|
||||
@@ -36,13 +40,15 @@
|
||||
<insert id="batchInsertDailyProduct">
|
||||
INSERT INTO ec_order_stat_daily_product (
|
||||
company_id, shop_id, product_id, category_id, stat_date,
|
||||
sales_amount, refund_amount, sales_order_count,
|
||||
product_cost, freight_cost, other_cost, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
) VALUES
|
||||
<foreach collection="list" item="r" separator=",">
|
||||
(#{r.companyId}, #{r.shopId}, #{r.productId}, #{r.categoryId}, #{r.statDate},
|
||||
#{r.salesAmount}, #{r.refundAmount}, #{r.salesOrderCount},
|
||||
#{r.productCost}, #{r.freightCost}, #{r.otherCost}, #{r.statVersion})
|
||||
#{r.salesAmount}, #{r.salesOrderCount}, #{r.salesQuantitySum},
|
||||
#{r.gmvAmount}, #{r.gmvOrderCount}, #{r.gmvQuantitySum},
|
||||
#{r.refundAmount}, #{r.productCost}, #{r.freightCost}, #{r.otherCost}, #{r.statVersion})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -54,13 +60,15 @@
|
||||
<insert id="batchInsertDailySpec">
|
||||
INSERT INTO ec_order_stat_daily_spec (
|
||||
company_id, shop_id, product_id, product_spec_id, stat_date,
|
||||
sales_amount, refund_amount, sales_order_count, quantity_sum,
|
||||
product_cost, freight_cost, other_cost, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
) VALUES
|
||||
<foreach collection="list" item="r" separator=",">
|
||||
(#{r.companyId}, #{r.shopId}, #{r.productId}, #{r.productSpecId}, #{r.statDate},
|
||||
#{r.salesAmount}, #{r.refundAmount}, #{r.salesOrderCount}, #{r.quantitySum},
|
||||
#{r.productCost}, #{r.freightCost}, #{r.otherCost}, #{r.statVersion})
|
||||
#{r.salesAmount}, #{r.salesOrderCount}, #{r.salesQuantitySum},
|
||||
#{r.gmvAmount}, #{r.gmvOrderCount}, #{r.gmvQuantitySum},
|
||||
#{r.refundAmount}, #{r.productCost}, #{r.freightCost}, #{r.otherCost}, #{r.statVersion})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -68,14 +76,16 @@
|
||||
<insert id="rollupMonthlyShop">
|
||||
INSERT INTO ec_order_stat_monthly_shop (
|
||||
company_id, shop_id, platform_id, stat_month,
|
||||
sales_amount, refund_amount, sales_order_count,
|
||||
product_cost, freight_cost, other_cost, gmv_amount, gmv_order_count, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
)
|
||||
SELECT company_id, shop_id, MAX(platform_id),
|
||||
#{statMonth},
|
||||
SUM(sales_amount), SUM(refund_amount), SUM(sales_order_count),
|
||||
SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), MAX(stat_version)
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
SUM(refund_amount), SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
MAX(stat_version)
|
||||
FROM ec_order_stat_daily_shop
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND stat_date >= #{statMonth}
|
||||
@@ -84,13 +94,15 @@
|
||||
ON DUPLICATE KEY UPDATE
|
||||
platform_id = VALUES(platform_id),
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
stat_version = VALUES(stat_version),
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
</insert>
|
||||
@@ -98,14 +110,16 @@
|
||||
<insert id="rollupYearlyShop">
|
||||
INSERT INTO ec_order_stat_yearly_shop (
|
||||
company_id, shop_id, platform_id, stat_year,
|
||||
sales_amount, refund_amount, sales_order_count,
|
||||
product_cost, freight_cost, other_cost, gmv_amount, gmv_order_count, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
)
|
||||
SELECT company_id, shop_id, MAX(platform_id),
|
||||
#{statYear},
|
||||
SUM(sales_amount), SUM(refund_amount), SUM(sales_order_count),
|
||||
SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), MAX(stat_version)
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
SUM(refund_amount), SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
MAX(stat_version)
|
||||
FROM ec_order_stat_monthly_shop
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND YEAR(stat_month) = #{statYear}
|
||||
@@ -113,13 +127,15 @@
|
||||
ON DUPLICATE KEY UPDATE
|
||||
platform_id = VALUES(platform_id),
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
stat_version = VALUES(stat_version),
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
</insert>
|
||||
@@ -127,13 +143,16 @@
|
||||
<insert id="rollupMonthlyProduct">
|
||||
INSERT INTO ec_order_stat_monthly_product (
|
||||
company_id, shop_id, product_id, category_id, stat_month,
|
||||
sales_amount, refund_amount, sales_order_count,
|
||||
product_cost, freight_cost, other_cost, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
)
|
||||
SELECT company_id, shop_id, product_id, category_id,
|
||||
#{statMonth},
|
||||
SUM(sales_amount), SUM(refund_amount), SUM(sales_order_count),
|
||||
SUM(product_cost), SUM(freight_cost), SUM(other_cost), MAX(stat_version)
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
SUM(refund_amount), SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
MAX(stat_version)
|
||||
FROM ec_order_stat_daily_product
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND stat_date >= #{statMonth}
|
||||
@@ -141,8 +160,12 @@
|
||||
GROUP BY company_id, shop_id, product_id, category_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
@@ -153,21 +176,28 @@
|
||||
<insert id="rollupYearlyProduct">
|
||||
INSERT INTO ec_order_stat_yearly_product (
|
||||
company_id, shop_id, product_id, category_id, stat_year,
|
||||
sales_amount, refund_amount, sales_order_count,
|
||||
product_cost, freight_cost, other_cost, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
)
|
||||
SELECT company_id, shop_id, product_id, category_id,
|
||||
#{statYear},
|
||||
SUM(sales_amount), SUM(refund_amount), SUM(sales_order_count),
|
||||
SUM(product_cost), SUM(freight_cost), SUM(other_cost), MAX(stat_version)
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
SUM(refund_amount), SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
MAX(stat_version)
|
||||
FROM ec_order_stat_monthly_product
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND YEAR(stat_month) = #{statYear}
|
||||
GROUP BY company_id, shop_id, product_id, category_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
@@ -178,13 +208,16 @@
|
||||
<insert id="rollupMonthlySpec">
|
||||
INSERT INTO ec_order_stat_monthly_spec (
|
||||
company_id, shop_id, product_id, product_spec_id, stat_month,
|
||||
sales_amount, refund_amount, sales_order_count, quantity_sum,
|
||||
product_cost, freight_cost, other_cost, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
)
|
||||
SELECT company_id, shop_id, product_id, product_spec_id,
|
||||
#{statMonth},
|
||||
SUM(sales_amount), SUM(refund_amount), SUM(sales_order_count), SUM(quantity_sum),
|
||||
SUM(product_cost), SUM(freight_cost), SUM(other_cost), MAX(stat_version)
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
SUM(refund_amount), SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
MAX(stat_version)
|
||||
FROM ec_order_stat_daily_spec
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND stat_date >= #{statMonth}
|
||||
@@ -192,9 +225,12 @@
|
||||
GROUP BY company_id, shop_id, product_id, product_spec_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
quantity_sum = VALUES(quantity_sum),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
@@ -205,22 +241,28 @@
|
||||
<insert id="rollupYearlySpec">
|
||||
INSERT INTO ec_order_stat_yearly_spec (
|
||||
company_id, shop_id, product_id, product_spec_id, stat_year,
|
||||
sales_amount, refund_amount, sales_order_count, quantity_sum,
|
||||
product_cost, freight_cost, other_cost, stat_version
|
||||
sales_amount, sales_order_count, sales_quantity_sum,
|
||||
gmv_amount, gmv_order_count, gmv_quantity_sum,
|
||||
refund_amount, product_cost, freight_cost, other_cost, stat_version
|
||||
)
|
||||
SELECT company_id, shop_id, product_id, product_spec_id,
|
||||
#{statYear},
|
||||
SUM(sales_amount), SUM(refund_amount), SUM(sales_order_count), SUM(quantity_sum),
|
||||
SUM(product_cost), SUM(freight_cost), SUM(other_cost), MAX(stat_version)
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
SUM(refund_amount), SUM(product_cost), SUM(freight_cost), SUM(other_cost),
|
||||
MAX(stat_version)
|
||||
FROM ec_order_stat_monthly_spec
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND YEAR(stat_month) = #{statYear}
|
||||
GROUP BY company_id, shop_id, product_id, product_spec_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
sales_amount = VALUES(sales_amount),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
quantity_sum = VALUES(quantity_sum),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
gmv_amount = VALUES(gmv_amount),
|
||||
gmv_order_count = VALUES(gmv_order_count),
|
||||
gmv_quantity_sum = VALUES(gmv_quantity_sum),
|
||||
refund_amount = VALUES(refund_amount),
|
||||
product_cost = VALUES(product_cost),
|
||||
freight_cost = VALUES(freight_cost),
|
||||
other_cost = VALUES(other_cost),
|
||||
|
||||
@@ -8,16 +8,48 @@
|
||||
<foreach collection="shopIds" item="sid" open="(" separator="," close=")">#{sid}</foreach>
|
||||
</sql>
|
||||
|
||||
<sql id="kpiSumShop">
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(sales_quantity_sum), 0) AS salesQuantitySum,
|
||||
COALESCE(SUM(gmv_amount), 0) AS gmvAmount,
|
||||
COALESCE(SUM(gmv_order_count), 0) AS gmvOrderCount,
|
||||
COALESCE(SUM(gmv_quantity_sum), 0) AS gmvQuantitySum
|
||||
</sql>
|
||||
|
||||
<sql id="kpiSumProduct">
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(sales_quantity_sum), 0) AS salesQuantitySum,
|
||||
COALESCE(SUM(gmv_amount), 0) AS gmvAmount,
|
||||
COALESCE(SUM(gmv_order_count), 0) AS gmvOrderCount,
|
||||
COALESCE(SUM(gmv_quantity_sum), 0) AS gmvQuantitySum,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
</sql>
|
||||
|
||||
<sql id="kpiSumSpec">
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(sales_quantity_sum), 0) AS salesQuantitySum,
|
||||
COALESCE(SUM(gmv_amount), 0) AS gmvAmount,
|
||||
COALESCE(SUM(gmv_order_count), 0) AS gmvOrderCount,
|
||||
COALESCE(SUM(gmv_quantity_sum), 0) AS gmvQuantitySum,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
</sql>
|
||||
|
||||
<select id="sumDailyShop" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
<include refid="kpiSumShop"/>,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost,
|
||||
COALESCE(SUM(gmv_amount), 0) AS gmvAmount,
|
||||
COALESCE(SUM(gmv_order_count), 0) AS gmvOrderCount
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
FROM ec_order_stat_daily_shop
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_date >= #{startDate}
|
||||
@@ -27,14 +59,10 @@
|
||||
<select id="sumDailyShopByDay" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
stat_date AS statDate,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
<include refid="kpiSumShop"/>,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost,
|
||||
COALESCE(SUM(gmv_amount), 0) AS gmvAmount,
|
||||
COALESCE(SUM(gmv_order_count), 0) AS gmvOrderCount
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
FROM ec_order_stat_daily_shop
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_date >= #{startDate}
|
||||
@@ -47,14 +75,10 @@
|
||||
SELECT
|
||||
shop_id AS shopId,
|
||||
MAX(platform_id) AS platformId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
<include refid="kpiSumShop"/>,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost,
|
||||
COALESCE(SUM(gmv_amount), 0) AS gmvAmount,
|
||||
COALESCE(SUM(gmv_order_count), 0) AS gmvOrderCount
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
FROM ec_order_stat_daily_shop
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_date >= #{startDate}
|
||||
@@ -65,12 +89,7 @@
|
||||
<select id="sumDailyProductByCategory" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
category_id AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_daily_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_date >= #{startDate}
|
||||
@@ -82,12 +101,7 @@
|
||||
SELECT
|
||||
product_id AS productId,
|
||||
MAX(category_id) AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_daily_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_date >= #{startDate}
|
||||
@@ -100,12 +114,7 @@
|
||||
shop_id AS shopId,
|
||||
product_id AS productId,
|
||||
MAX(category_id) AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_daily_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_date >= #{startDate}
|
||||
@@ -115,12 +124,7 @@
|
||||
|
||||
<select id="sumDailyProductForOneProduct" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_daily_product
|
||||
WHERE company_id = #{companyId}
|
||||
AND product_id = #{productId}
|
||||
@@ -135,12 +139,7 @@
|
||||
<select id="sumDailyProductByDayForOneProduct" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
stat_date AS statDate,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_daily_product
|
||||
WHERE company_id = #{companyId}
|
||||
AND product_id = #{productId}
|
||||
@@ -157,12 +156,7 @@
|
||||
<select id="sumMonthlyProductByCategory" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
category_id AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_monthly_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_month >= #{startMonth}
|
||||
@@ -174,12 +168,7 @@
|
||||
SELECT
|
||||
product_id AS productId,
|
||||
MAX(category_id) AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_monthly_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_month >= #{startMonth}
|
||||
@@ -190,12 +179,7 @@
|
||||
<select id="sumYearlyProductByCategory" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
category_id AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_yearly_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_year >= #{startYear}
|
||||
@@ -207,12 +191,7 @@
|
||||
SELECT
|
||||
product_id AS productId,
|
||||
MAX(category_id) AS categoryId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumProduct"/>
|
||||
FROM ec_order_stat_yearly_product
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND stat_year >= #{startYear}
|
||||
@@ -223,13 +202,7 @@
|
||||
<select id="sumDailySpecBySpec" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
product_spec_id AS productSpecId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(quantity_sum), 0) AS quantitySum,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumSpec"/>
|
||||
FROM ec_order_stat_daily_spec
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND product_id = #{productId}
|
||||
@@ -241,13 +214,7 @@
|
||||
<select id="sumMonthlySpecBySpec" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
product_spec_id AS productSpecId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(quantity_sum), 0) AS quantitySum,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumSpec"/>
|
||||
FROM ec_order_stat_monthly_spec
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND product_id = #{productId}
|
||||
@@ -259,13 +226,7 @@
|
||||
<select id="sumYearlySpecBySpec" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
product_spec_id AS productSpecId,
|
||||
COALESCE(SUM(sales_amount), 0) AS salesAmount,
|
||||
COALESCE(SUM(refund_amount), 0) AS refundAmount,
|
||||
COALESCE(SUM(sales_order_count), 0) AS salesOrderCount,
|
||||
COALESCE(SUM(quantity_sum), 0) AS quantitySum,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
COALESCE(SUM(other_cost), 0) AS otherCost
|
||||
<include refid="kpiSumSpec"/>
|
||||
FROM ec_order_stat_yearly_spec
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND product_id = #{productId}
|
||||
|
||||
@@ -50,7 +50,10 @@
|
||||
THEN o.received_amount ELSE 0 END) AS refundAmount,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="qty"/> ELSE 0 END) AS quantitySum,
|
||||
THEN <include refid="qty"/> ELSE 0 END) AS salesQuantitySum,
|
||||
SUM(o.received_amount) AS gmvAmount,
|
||||
COUNT(*) AS gmvOrderCount,
|
||||
SUM(<include refid="qty"/>) AS gmvQuantitySum,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="productCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.product_cost * <include refid="qty"/> ELSE 0 END) AS productCost,
|
||||
@@ -66,13 +69,6 @@
|
||||
AND o.shop_id = #{shopId}
|
||||
AND o.order_time >= #{start}
|
||||
AND o.order_time <= #{end}
|
||||
<choose>
|
||||
<when test="unionStatusIds != null and unionStatusIds.size() > 0">
|
||||
AND o.status_id IN
|
||||
<foreach collection="unionStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND 1 = 0</otherwise>
|
||||
</choose>
|
||||
GROUP BY IFNULL(o.product_spec_id, 0), IFNULL(ps.product_id, 0)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user