mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 11:49:19 +08:00
refactor: 重构订单,店铺,商品
This commit is contained in:
@@ -21,7 +21,7 @@ jwt:
|
||||
secret: staging-jwt-secret-key-must-be-at-least-64-bytes-long-for-hs512-algorithm
|
||||
|
||||
order-stat:
|
||||
nightly-rebuild-enabled: true
|
||||
nightly-rebuild-enabled: false
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
|
||||
@@ -22,7 +22,7 @@ jwt:
|
||||
secret: prod-jwt-secret-key-must-be-at-least-64-bytes-long-for-hs512-algorithm-security
|
||||
|
||||
order-stat:
|
||||
nightly-rebuild-enabled: true
|
||||
nightly-rebuild-enabled: false
|
||||
|
||||
knife4j:
|
||||
enable: false
|
||||
|
||||
@@ -34,12 +34,12 @@ spring:
|
||||
min-idle: 0
|
||||
max-wait: -1ms
|
||||
|
||||
# 订单统计读模型
|
||||
# 订单统计读模型(汇总表已删,待重构前关闭写入与 miss 补算)
|
||||
order-stat:
|
||||
stat-source: daily
|
||||
auto-refresh-on-miss: true
|
||||
auto-refresh-on-miss: false
|
||||
refresh-worker:
|
||||
enabled: true
|
||||
enabled: false
|
||||
pool-size: 4
|
||||
poll-interval-ms: 2000
|
||||
cache:
|
||||
@@ -47,6 +47,7 @@ order-stat:
|
||||
ttl-history-seconds: 86400
|
||||
ttl-today-seconds: 900
|
||||
nightly-rebuild-cron: "0 30 2 * * ?"
|
||||
nightly-rebuild-enabled: false
|
||||
|
||||
# 导入任务 Redis Stream 队列(DB 为真相源,Redis 负责调度)
|
||||
import-task:
|
||||
|
||||
@@ -3,56 +3,57 @@
|
||||
<mapper namespace="top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper">
|
||||
|
||||
<sql id="orderListFrom">
|
||||
ec_order
|
||||
ec_order o
|
||||
<choose>
|
||||
<when test="useShopTimeIndex">
|
||||
FORCE INDEX (idx_company_shop_time)
|
||||
FORCE INDEX (idx_ec_order_company_shop_time)
|
||||
</when>
|
||||
<otherwise>
|
||||
FORCE INDEX (idx_company_order_time)
|
||||
FORCE INDEX (idx_ec_order_company_order_time)
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="orderListWhere">
|
||||
WHERE company_id = #{companyId}
|
||||
WHERE o.company_id = #{companyId}
|
||||
<if test="shopId != null">
|
||||
AND shop_id = #{shopId}
|
||||
AND o.shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="platformOrderNo != null and platformOrderNo != ''">
|
||||
<choose>
|
||||
<when test="platformOrderNoPrefix">
|
||||
AND platform_order_no LIKE CONCAT(#{platformOrderNo}, '%')
|
||||
AND o.platform_order_no LIKE CONCAT(#{platformOrderNo}, '%')
|
||||
</when>
|
||||
<otherwise>
|
||||
AND platform_order_no LIKE CONCAT('%', #{platformOrderNo}, '%')
|
||||
AND o.platform_order_no LIKE CONCAT('%', #{platformOrderNo}, '%')
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="statusId != null">
|
||||
AND status_id = #{statusId}
|
||||
<if test="status != null and status != ''">
|
||||
AND o.status = #{status}
|
||||
</if>
|
||||
<if test="minReceivedAmount != null">
|
||||
AND received_amount >= #{minReceivedAmount}
|
||||
<if test="minPayAmount != null">
|
||||
AND o.pay_amount >= #{minPayAmount}
|
||||
</if>
|
||||
<if test="maxReceivedAmount != null">
|
||||
AND received_amount <= #{maxReceivedAmount}
|
||||
<if test="maxPayAmount != null">
|
||||
AND o.pay_amount <= #{maxPayAmount}
|
||||
</if>
|
||||
<if test="startOrderTime != null">
|
||||
AND order_time >= #{startOrderTime}
|
||||
AND o.order_time >= #{startOrderTime}
|
||||
</if>
|
||||
<if test="endOrderTime != null">
|
||||
AND order_time <= #{endOrderTime}
|
||||
AND o.order_time <= #{endOrderTime}
|
||||
</if>
|
||||
<if test="importTaskId != null">
|
||||
AND import_task_id = #{importTaskId}
|
||||
AND o.import_task_id = #{importTaskId}
|
||||
</if>
|
||||
<if test="confirm != null">
|
||||
AND confirm = #{confirm}
|
||||
AND o.confirm = #{confirm}
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
AND product_spec_id IN (
|
||||
SELECT id FROM ec_product_spec WHERE product_id = #{productId}
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM ec_order_item i
|
||||
WHERE i.order_id = o.id AND i.product_id = #{productId}
|
||||
)
|
||||
</if>
|
||||
</sql>
|
||||
@@ -64,7 +65,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectOrderListIds" resultType="long">
|
||||
SELECT id
|
||||
SELECT o.id
|
||||
FROM <include refid="orderListFrom"/>
|
||||
<include refid="orderListWhere"/>
|
||||
ORDER BY ${orderByClause}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderStatAggMapper">
|
||||
|
||||
<!-- 公司/店铺/时间(不含状态过滤,供 GMV 等全状态指标) -->
|
||||
<sql id="orderBaseFilter">
|
||||
o.company_id = #{companyId}
|
||||
<choose>
|
||||
@@ -16,63 +15,64 @@
|
||||
AND o.order_time <= #{end}
|
||||
</sql>
|
||||
|
||||
<!-- 订单过滤 + 状态口径 CASE 表达式(与 OrderStatusStatSets 一致) -->
|
||||
<sql id="orderFilter">
|
||||
<include refid="orderBaseFilter"/>
|
||||
<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 test="unionStatusCodes != null and unionStatusCodes.size() > 0">
|
||||
AND o.status IN
|
||||
<foreach collection="unionStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND 1 = 0</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="qty">IFNULL(NULLIF(o.quantity, 0), 1)</sql>
|
||||
<sql id="qty">IFNULL(NULLIF(i.quantity, 0), 1)</sql>
|
||||
|
||||
<sql id="lineSales">IFNULL(NULLIF(i.line_amount, 0), IFNULL(i.unit_price, 0) * <include refid="qty"/>)</sql>
|
||||
|
||||
<sql id="sumSales">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END)
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="lineSales"/> ELSE 0 END)
|
||||
</sql>
|
||||
<sql id="sumOrderCount">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN 1 ELSE 0 END)
|
||||
COUNT(DISTINCT CASE WHEN o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.id END)
|
||||
</sql>
|
||||
<sql id="sumSalesQuantity">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="salesStatusCodes" 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>
|
||||
THEN o.received_amount ELSE 0 END)
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="refundStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="lineSales"/> ELSE 0 END)
|
||||
</sql>
|
||||
<sql id="sumProductCost">
|
||||
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)
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="productCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.product_cost, 0) * <include refid="qty"/> ELSE 0 END)
|
||||
</sql>
|
||||
<sql id="sumFreightCost">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="freightCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.shipping_cost * <include refid="qty"/> ELSE 0 END)
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="freightCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.shipping_cost, 0) * <include refid="qty"/> ELSE 0 END)
|
||||
</sql>
|
||||
<sql id="sumOtherCost">
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="otherCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.other_cost * <include refid="qty"/> ELSE 0 END)
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="otherCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.other_cost, 0) * <include refid="qty"/> ELSE 0 END)
|
||||
</sql>
|
||||
|
||||
<select id="aggregateByShopProduct"
|
||||
resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderStatAggMapper$ShopProductRow">
|
||||
SELECT o.shop_id AS shopId, s.platform_id AS platformId,
|
||||
IFNULL(ps.product_id, -1) AS productId, IFNULL(p.category_id, 0) AS categoryId,
|
||||
SELECT o.shop_id AS shopId, s.platform_code AS platformCode,
|
||||
IFNULL(i.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,
|
||||
@@ -80,15 +80,15 @@
|
||||
<include refid="sumProductCost"/> AS productCost,
|
||||
<include refid="sumFreightCost"/> AS freightCost,
|
||||
<include refid="sumOtherCost"/> AS otherCost,
|
||||
SUM(o.received_amount) AS gmvAllStatus,
|
||||
COUNT(*) AS gmvOrderCount,
|
||||
SUM(<include refid="lineSales"/>) AS gmvAllStatus,
|
||||
COUNT(DISTINCT o.id) AS gmvOrderCount,
|
||||
<include refid="sumGmvQuantity"/> AS gmvQuantitySum
|
||||
FROM ec_order o
|
||||
INNER JOIN ec_order_item i ON i.order_id = o.id
|
||||
INNER JOIN ec_shop s ON s.id = o.shop_id
|
||||
LEFT JOIN ec_product_spec ps ON ps.id = o.product_spec_id
|
||||
LEFT JOIN ec_product p ON p.id = ps.product_id
|
||||
LEFT JOIN ec_product p ON p.id = i.product_id
|
||||
WHERE <include refid="orderBaseFilter"/>
|
||||
GROUP BY o.shop_id, s.platform_id, ps.product_id, p.category_id
|
||||
GROUP BY o.shop_id, s.platform_code, i.product_id, p.category_id
|
||||
</select>
|
||||
|
||||
<select id="aggregateDaily"
|
||||
@@ -100,6 +100,7 @@
|
||||
<include refid="sumFreightCost"/> AS freightCost,
|
||||
<include refid="sumOtherCost"/> AS otherCost
|
||||
FROM ec_order o
|
||||
INNER JOIN ec_order_item i ON i.order_id = o.id
|
||||
WHERE <include refid="orderFilter"/>
|
||||
GROUP BY DATE(o.order_time)
|
||||
ORDER BY statDate
|
||||
@@ -108,64 +109,65 @@
|
||||
<select id="aggregatePeriodKpi"
|
||||
resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderStatAggMapper$PeriodKpiRow">
|
||||
SELECT
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS curSalesAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN 1 ELSE 0 END) AS curOrderCount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status_id IN
|
||||
<foreach collection="refundStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS curRefundAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND 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 curProductCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status_id IN
|
||||
<foreach collection="freightCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.shipping_cost * <include refid="qty"/> ELSE 0 END) AS curFreightCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status_id IN
|
||||
<foreach collection="otherCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.other_cost * <include refid="qty"/> ELSE 0 END) AS curOtherCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} THEN o.received_amount ELSE 0 END) AS curGmvAllStatus,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS prevSalesAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN 1 ELSE 0 END) AS prevOrderCount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status_id IN
|
||||
<foreach collection="refundStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS prevRefundAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND 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 prevProductCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status_id IN
|
||||
<foreach collection="freightCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.shipping_cost * <include refid="qty"/> ELSE 0 END) AS prevFreightCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status_id IN
|
||||
<foreach collection="otherCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.other_cost * <include refid="qty"/> ELSE 0 END) AS prevOtherCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} THEN o.received_amount ELSE 0 END) AS prevGmvAllStatus,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS yoySalesAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN 1 ELSE 0 END) AS yoyOrderCount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status_id IN
|
||||
<foreach collection="refundStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS yoyRefundAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND 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 yoyProductCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status_id IN
|
||||
<foreach collection="freightCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.shipping_cost * <include refid="qty"/> ELSE 0 END) AS yoyFreightCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status_id IN
|
||||
<foreach collection="otherCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.other_cost * <include refid="qty"/> ELSE 0 END) AS yoyOtherCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} THEN o.received_amount ELSE 0 END) AS yoyGmvAllStatus
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS curSalesAmount,
|
||||
COUNT(DISTINCT CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.id END) AS curOrderCount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status IN
|
||||
<foreach collection="refundStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS curRefundAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status IN
|
||||
<foreach collection="productCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.product_cost, 0) * <include refid="qty"/> ELSE 0 END) AS curProductCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status IN
|
||||
<foreach collection="freightCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.shipping_cost, 0) * <include refid="qty"/> ELSE 0 END) AS curFreightCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND o.status IN
|
||||
<foreach collection="otherCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.other_cost, 0) * <include refid="qty"/> ELSE 0 END) AS curOtherCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{curStart} AND #{curEnd} AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS curGmvAllStatus,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS prevSalesAmount,
|
||||
COUNT(DISTINCT CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.id END) AS prevOrderCount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status IN
|
||||
<foreach collection="refundStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS prevRefundAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status IN
|
||||
<foreach collection="productCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.product_cost, 0) * <include refid="qty"/> ELSE 0 END) AS prevProductCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status IN
|
||||
<foreach collection="freightCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.shipping_cost, 0) * <include refid="qty"/> ELSE 0 END) AS prevFreightCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND o.status IN
|
||||
<foreach collection="otherCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.other_cost, 0) * <include refid="qty"/> ELSE 0 END) AS prevOtherCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{prevStart} AND #{prevEnd} AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS prevGmvAllStatus,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS yoySalesAmount,
|
||||
COUNT(DISTINCT CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.id END) AS yoyOrderCount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status IN
|
||||
<foreach collection="refundStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS yoyRefundAmount,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status IN
|
||||
<foreach collection="productCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.product_cost, 0) * <include refid="qty"/> ELSE 0 END) AS yoyProductCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status IN
|
||||
<foreach collection="freightCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.shipping_cost, 0) * <include refid="qty"/> ELSE 0 END) AS yoyFreightCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND o.status IN
|
||||
<foreach collection="otherCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.other_cost, 0) * <include refid="qty"/> ELSE 0 END) AS yoyOtherCost,
|
||||
SUM(CASE WHEN o.order_time BETWEEN #{yoyStart} AND #{yoyEnd} AND i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS yoyGmvAllStatus
|
||||
FROM ec_order o
|
||||
INNER JOIN ec_order_item i ON i.order_id = o.id
|
||||
WHERE o.company_id = #{companyId}
|
||||
<choose>
|
||||
<when test="shopIds != null and shopIds.size() > 0">
|
||||
@@ -175,8 +177,8 @@
|
||||
</choose>
|
||||
AND o.order_time BETWEEN #{scanStart} AND #{scanEnd}
|
||||
<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 test="unionStatusCodes != null and unionStatusCodes.size() > 0">
|
||||
AND o.status IN <foreach collection="unionStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND 1 = 0</otherwise>
|
||||
</choose>
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
|
||||
<insert id="upsertDailyShop">
|
||||
INSERT INTO ec_order_stat_daily_shop (
|
||||
company_id, shop_id, platform_id, stat_date,
|
||||
company_id, shop_id, platform_code, stat_date,
|
||||
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},
|
||||
#{companyId}, #{shopId}, #{platformCode}, #{statDate},
|
||||
#{salesAmount}, #{salesOrderCount}, #{salesQuantitySum},
|
||||
#{gmvAmount}, #{gmvOrderCount}, #{gmvQuantitySum},
|
||||
#{refundAmount}, #{productCost}, #{freightCost}, #{otherCost},
|
||||
#{statVersion}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
platform_id = VALUES(platform_id),
|
||||
platform_code = VALUES(platform_code),
|
||||
sales_amount = VALUES(sales_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
@@ -59,13 +59,13 @@
|
||||
|
||||
<insert id="batchInsertDailySpec">
|
||||
INSERT INTO ec_order_stat_daily_spec (
|
||||
company_id, shop_id, product_id, product_spec_id, stat_date,
|
||||
company_id, shop_id, product_id, product_sku_id, stat_date,
|
||||
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.companyId}, #{r.shopId}, #{r.productId}, #{r.productSkuId}, #{r.statDate},
|
||||
#{r.salesAmount}, #{r.salesOrderCount}, #{r.salesQuantitySum},
|
||||
#{r.gmvAmount}, #{r.gmvOrderCount}, #{r.gmvQuantitySum},
|
||||
#{r.refundAmount}, #{r.productCost}, #{r.freightCost}, #{r.otherCost}, #{r.statVersion})
|
||||
@@ -75,12 +75,12 @@
|
||||
<!-- 月/年 rollup:从日表 SUM 写入对应粒度表 -->
|
||||
<insert id="rollupMonthlyShop">
|
||||
INSERT INTO ec_order_stat_monthly_shop (
|
||||
company_id, shop_id, platform_id, stat_month,
|
||||
company_id, shop_id, platform_code, stat_month,
|
||||
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),
|
||||
SELECT company_id, shop_id, MAX(platform_code),
|
||||
#{statMonth},
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
@@ -92,7 +92,7 @@
|
||||
AND stat_date < DATE_ADD(#{statMonth}, INTERVAL 1 MONTH)
|
||||
GROUP BY company_id, shop_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
platform_id = VALUES(platform_id),
|
||||
platform_code = VALUES(platform_code),
|
||||
sales_amount = VALUES(sales_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
@@ -109,12 +109,12 @@
|
||||
|
||||
<insert id="rollupYearlyShop">
|
||||
INSERT INTO ec_order_stat_yearly_shop (
|
||||
company_id, shop_id, platform_id, stat_year,
|
||||
company_id, shop_id, platform_code, stat_year,
|
||||
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),
|
||||
SELECT company_id, shop_id, MAX(platform_code),
|
||||
#{statYear},
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
@@ -125,7 +125,7 @@
|
||||
AND YEAR(stat_month) = #{statYear}
|
||||
GROUP BY company_id, shop_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
platform_id = VALUES(platform_id),
|
||||
platform_code = VALUES(platform_code),
|
||||
sales_amount = VALUES(sales_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
sales_quantity_sum = VALUES(sales_quantity_sum),
|
||||
@@ -207,12 +207,12 @@
|
||||
|
||||
<insert id="rollupMonthlySpec">
|
||||
INSERT INTO ec_order_stat_monthly_spec (
|
||||
company_id, shop_id, product_id, product_spec_id, stat_month,
|
||||
company_id, shop_id, product_id, product_sku_id, stat_month,
|
||||
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,
|
||||
SELECT company_id, shop_id, product_id, product_sku_id,
|
||||
#{statMonth},
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
@@ -222,7 +222,7 @@
|
||||
WHERE company_id = #{companyId} AND shop_id = #{shopId}
|
||||
AND stat_date >= #{statMonth}
|
||||
AND stat_date < DATE_ADD(#{statMonth}, INTERVAL 1 MONTH)
|
||||
GROUP BY company_id, shop_id, product_id, product_spec_id
|
||||
GROUP BY company_id, shop_id, product_id, product_sku_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
sales_amount = VALUES(sales_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
@@ -240,12 +240,12 @@
|
||||
|
||||
<insert id="rollupYearlySpec">
|
||||
INSERT INTO ec_order_stat_yearly_spec (
|
||||
company_id, shop_id, product_id, product_spec_id, stat_year,
|
||||
company_id, shop_id, product_id, product_sku_id, stat_year,
|
||||
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,
|
||||
SELECT company_id, shop_id, product_id, product_sku_id,
|
||||
#{statYear},
|
||||
SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
@@ -254,7 +254,7 @@
|
||||
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
|
||||
GROUP BY company_id, shop_id, product_id, product_sku_id
|
||||
ON DUPLICATE KEY UPDATE
|
||||
sales_amount = VALUES(sales_amount),
|
||||
sales_order_count = VALUES(sales_order_count),
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<select id="sumDailyShopByShop" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
shop_id AS shopId,
|
||||
MAX(platform_id) AS platformId,
|
||||
MAX(platform_code) AS platformCode,
|
||||
<include refid="kpiSumShop"/>,
|
||||
COALESCE(SUM(product_cost), 0) AS productCost,
|
||||
COALESCE(SUM(freight_cost), 0) AS freightCost,
|
||||
@@ -201,38 +201,38 @@
|
||||
|
||||
<select id="sumDailySpecBySpec" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
product_spec_id AS productSpecId,
|
||||
product_sku_id AS productSkuId,
|
||||
<include refid="kpiSumSpec"/>
|
||||
FROM ec_order_stat_daily_spec
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND product_id = #{productId}
|
||||
AND stat_date >= #{startDate}
|
||||
AND stat_date <= #{endDate}
|
||||
GROUP BY product_spec_id
|
||||
GROUP BY product_sku_id
|
||||
</select>
|
||||
|
||||
<select id="sumMonthlySpecBySpec" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
product_spec_id AS productSpecId,
|
||||
product_sku_id AS productSkuId,
|
||||
<include refid="kpiSumSpec"/>
|
||||
FROM ec_order_stat_monthly_spec
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND product_id = #{productId}
|
||||
AND stat_month >= #{startMonth}
|
||||
AND stat_month <= #{endMonth}
|
||||
GROUP BY product_spec_id
|
||||
GROUP BY product_sku_id
|
||||
</select>
|
||||
|
||||
<select id="sumYearlySpecBySpec" resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.model.dto.OrderStatMetricsDTO">
|
||||
SELECT
|
||||
product_spec_id AS productSpecId,
|
||||
product_sku_id AS productSkuId,
|
||||
<include refid="kpiSumSpec"/>
|
||||
FROM ec_order_stat_yearly_spec
|
||||
WHERE <include refid="shopFilter"/>
|
||||
AND product_id = #{productId}
|
||||
AND stat_year >= #{startYear}
|
||||
AND stat_year <= #{endYear}
|
||||
GROUP BY product_spec_id
|
||||
GROUP BY product_sku_id
|
||||
</select>
|
||||
|
||||
<select id="countDailyShopRows" resultType="int">
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.mapper.OrderStatRefreshMapper">
|
||||
|
||||
<sql id="qty">IFNULL(NULLIF(o.quantity, 0), 1)</sql>
|
||||
<sql id="qty">IFNULL(NULLIF(i.quantity, 0), 1)</sql>
|
||||
<sql id="lineSales">IFNULL(NULLIF(i.line_amount, 0), IFNULL(i.unit_price, 0) * <include refid="qty"/>)</sql>
|
||||
|
||||
<insert id="insertPendingIgnore">
|
||||
INSERT IGNORE INTO ec_order_stat_refresh_queue (
|
||||
@@ -23,8 +24,6 @@
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- fetchAndLockPending 由 Service 层 MyBatis-Plus + FOR UPDATE SKIP LOCKED 实现 -->
|
||||
|
||||
<select id="countGmvOrdersByShopDay" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM ec_order o
|
||||
@@ -37,38 +36,38 @@
|
||||
<select id="aggregateSpecByShopDay"
|
||||
resultType="top.xyquan.ecomdmbbackend.modules.ecom.order.stat.mapper.OrderStatRefreshMapper$SpecDayRow">
|
||||
SELECT
|
||||
IFNULL(ps.product_id, 0) AS productId,
|
||||
IFNULL(o.product_spec_id, 0) AS productSpecId,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.received_amount ELSE 0 END) AS salesAmount,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="salesStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN 1 ELSE 0 END) AS orderCount,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="refundStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
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>
|
||||
IFNULL(i.product_id, 0) AS productId,
|
||||
IFNULL(i.product_sku_id, 0) AS productSkuId,
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="lineSales"/> ELSE 0 END) AS salesAmount,
|
||||
COUNT(DISTINCT CASE WHEN o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.id END) AS orderCount,
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="refundStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="lineSales"/> ELSE 0 END) AS refundAmount,
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="salesStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN <include refid="qty"/> ELSE 0 END) AS salesQuantitySum,
|
||||
SUM(o.received_amount) AS gmvAmount,
|
||||
COUNT(*) AS gmvOrderCount,
|
||||
SUM(CASE WHEN i.line_no = 1 THEN o.pay_amount ELSE 0 END) AS gmvAmount,
|
||||
COUNT(DISTINCT o.id) 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,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="freightCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.shipping_cost * <include refid="qty"/> ELSE 0 END) AS freightCost,
|
||||
SUM(CASE WHEN o.status_id IN
|
||||
<foreach collection="otherCostStatusIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN o.other_cost * <include refid="qty"/> ELSE 0 END) AS otherCost
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="productCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.product_cost, 0) * <include refid="qty"/> ELSE 0 END) AS productCost,
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="freightCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.shipping_cost, 0) * <include refid="qty"/> ELSE 0 END) AS freightCost,
|
||||
SUM(CASE WHEN o.status IN
|
||||
<foreach collection="otherCostStatusCodes" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
THEN IFNULL(i.other_cost, 0) * <include refid="qty"/> ELSE 0 END) AS otherCost
|
||||
FROM ec_order o
|
||||
LEFT JOIN ec_product_spec ps ON ps.id = o.product_spec_id
|
||||
INNER JOIN ec_order_item i ON i.order_id = o.id
|
||||
WHERE o.company_id = #{companyId}
|
||||
AND o.shop_id = #{shopId}
|
||||
AND o.order_time >= #{start}
|
||||
AND o.order_time <= #{end}
|
||||
GROUP BY IFNULL(o.product_spec_id, 0), IFNULL(ps.product_id, 0)
|
||||
GROUP BY IFNULL(i.product_sku_id, 0), IFNULL(i.product_id, 0)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -105,10 +105,6 @@ INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status
|
||||
SELECT 3300, (SELECT id FROM `sys_permission` WHERE `code` = 'MODULE:ecom' LIMIT 1), 'ecom:shop', '店铺管理', 'module', 1, '', 320
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'ecom:shop');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3400, (SELECT id FROM `sys_permission` WHERE `code` = 'MODULE:ecom' LIMIT 1), 'ecom:platform', '平台管理', 'module', 1, '', 330
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'ecom:platform');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3600, (SELECT id FROM `sys_permission` WHERE `code` = 'MODULE:ecom' LIMIT 1), 'biz:pdd', '拼多多', 'module', 1, '拼多多对接', 360
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd');
|
||||
@@ -313,14 +309,6 @@ INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status
|
||||
SELECT 3302, (SELECT id FROM `sys_permission` WHERE `code` = 'ecom:shop' LIMIT 1), 'ecom:shop:manage', '店铺管理', 'api', 1, '电商业务-店铺管理', 322
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'ecom:shop:manage');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3401, (SELECT id FROM `sys_permission` WHERE `code` = 'ecom:platform' LIMIT 1), 'ecom:platform:read', '平台查看', 'api', 1, '', 331
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'ecom:platform:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3402, (SELECT id FROM `sys_permission` WHERE `code` = 'ecom:platform' LIMIT 1), 'ecom:platform:manage', '平台管理', 'api', 1, '', 332
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'ecom:platform:manage');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 4101, (SELECT id FROM `sys_permission` WHERE `code` = 'data:import-group' LIMIT 1), 'data:import', '数据导入', 'api', 1, '数据管理-数据导入', 401
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'data:import');
|
||||
@@ -365,10 +353,6 @@ INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `co
|
||||
SELECT 12014, NULL, 0, '店铺管理', '店铺管理', 'shop/list', '/ecommerce/shop/list/index', '', 'lucide:store', 'menu', 1, 1, 0, 5
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '店铺管理');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 12015, NULL, 0, '平台管理', '平台管理', '/data/platform', 'ecommerce/platform/list/index', '', 'game-icons:platform', 'menu', 1, 1, 0, 6
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '平台管理');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 12016, NULL, 0, '商品管理', '商品管理', 'product/list', '/ecommerce/product/index', '', 'fluent-mdl2:product', 'menu', 1, 1, 1, 7
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '商品管理');
|
||||
@@ -473,10 +457,6 @@ INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `co
|
||||
SELECT 12003, (SELECT id FROM `sys_menu` WHERE `name` = '电商页面' LIMIT 1), 0, '店铺详情', '店铺详情', '/ecom/shop/details/:id', 'ecommerce/shop/details/index', '', 'material-symbols-light:shop-outline', 'embedded', 0, 1, 1, 200
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '店铺详情');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 13001, (SELECT id FROM `sys_menu` WHERE `name` = '配置管理' LIMIT 1), 0, '订单状态', '订单状态', '/order-status', '/ecommerce/config/order-status-config/index', '', 'pajamas:status', 'menu', 1, 1, 0, 11
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '订单状态');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 13002, (SELECT id FROM `sys_menu` WHERE `name` = '配置管理' LIMIT 1), 0, '商品类目', '商品类目', '/category', '/ecommerce/config/category-config/index', '', 'iconamoon:category-bold', 'menu', 1, 1, 0, 12
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '商品类目');
|
||||
@@ -546,9 +526,6 @@ SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'ecom
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'ecom:shop:%' WHERE m.name = '店铺管理';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'ecom:platform:%' WHERE m.name = '平台管理';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'ecom:category:%' WHERE m.name = '商品类目';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user