feat(order-stat,workbench): 订单统计日表扩展 GMV/销售单量件数并贯通刷新读写,工作台经营 KPI 扩至 22 项及前端展示配置

This commit is contained in:
小蟑螂
2026-06-03 20:51:26 +08:00
parent 28fba73928
commit b2a25a236f
23 changed files with 1192 additions and 455 deletions
@@ -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 &gt;= #{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 &gt;= #{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 &gt;= #{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),