mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 04:29:21 +08:00
refactor: 重构订单,店铺,商品
This commit is contained in:
@@ -59,7 +59,7 @@ CREATE TABLE `ec_order_stat_daily_shop` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`shop_id` bigint UNSIGNED NOT NULL COMMENT '店铺ID',
|
||||
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID(写入时快照 ec_shop.platform_id)',
|
||||
`platform_code` varchar(32) NULL DEFAULT NULL COMMENT '平台代码(写入时快照 ec_shop.platform_code)',
|
||||
`stat_date` date NOT NULL COMMENT '自然日(Asia/Shanghai,与 order_time 的 DATE 一致)',
|
||||
|
||||
`sales_amount` decimal(16, 2) NOT NULL DEFAULT 0.00 COMMENT '实际销售额',
|
||||
@@ -80,7 +80,7 @@ CREATE TABLE `ec_order_stat_daily_shop` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_company_shop_date` (`company_id`, `shop_id`, `stat_date`) USING BTREE,
|
||||
INDEX `idx_company_date` (`company_id`, `stat_date`) USING BTREE,
|
||||
INDEX `idx_company_platform_date` (`company_id`, `platform_id`, `stat_date`) USING BTREE,
|
||||
INDEX `idx_company_platform_date` (`company_id`, `platform_code`, `stat_date`) USING BTREE,
|
||||
INDEX `idx_shop_date` (`shop_id`, `stat_date`) USING BTREE,
|
||||
CONSTRAINT `fk_oss_daily_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_oss_daily_shop_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
@@ -92,7 +92,7 @@ CREATE TABLE `ec_order_stat_monthly_shop` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`shop_id` bigint UNSIGNED NOT NULL COMMENT '店铺ID',
|
||||
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID(月 rollup 时取当月最后写入快照)',
|
||||
`platform_code` varchar(32) NULL DEFAULT NULL COMMENT '平台代码(月 rollup 时取当月最后写入快照)',
|
||||
`stat_month` date NOT NULL COMMENT '自然月首日,如 2024-03-01',
|
||||
|
||||
`sales_amount` decimal(16, 2) NOT NULL DEFAULT 0.00 COMMENT '实际销售额',
|
||||
@@ -113,7 +113,7 @@ CREATE TABLE `ec_order_stat_monthly_shop` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_company_shop_month` (`company_id`, `shop_id`, `stat_month`) USING BTREE,
|
||||
INDEX `idx_company_month` (`company_id`, `stat_month`) USING BTREE,
|
||||
INDEX `idx_company_platform_month` (`company_id`, `platform_id`, `stat_month`) USING BTREE,
|
||||
INDEX `idx_company_platform_month` (`company_id`, `platform_code`, `stat_month`) USING BTREE,
|
||||
CONSTRAINT `fk_oss_monthly_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_oss_monthly_shop_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单统计-店铺-月汇总(由日表 SUM 或订单直算)';
|
||||
@@ -124,7 +124,7 @@ CREATE TABLE `ec_order_stat_yearly_shop` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`shop_id` bigint UNSIGNED NOT NULL COMMENT '店铺ID',
|
||||
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID',
|
||||
`platform_code` varchar(32) NULL DEFAULT NULL COMMENT '平台代码',
|
||||
`stat_year` smallint NOT NULL COMMENT '自然年,如 2024',
|
||||
|
||||
`sales_amount` decimal(16, 2) NOT NULL DEFAULT 0.00 COMMENT '实际销售额',
|
||||
@@ -145,7 +145,7 @@ CREATE TABLE `ec_order_stat_yearly_shop` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uk_company_shop_year` (`company_id`, `shop_id`, `stat_year`) USING BTREE,
|
||||
INDEX `idx_company_year` (`company_id`, `stat_year`) USING BTREE,
|
||||
INDEX `idx_company_platform_year` (`company_id`, `platform_id`, `stat_year`) USING BTREE,
|
||||
INDEX `idx_company_platform_year` (`company_id`, `platform_code`, `stat_year`) USING BTREE,
|
||||
CONSTRAINT `fk_oss_yearly_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_oss_yearly_shop_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '订单统计-店铺-年汇总(3~5 年 KPI / 平台占比主读表)';
|
||||
@@ -541,7 +541,7 @@ CREATE TABLE `ec_order_stat_refresh_queue` (
|
||||
--
|
||||
-- 月表 ← 日表(店铺):
|
||||
-- INSERT INTO ec_order_stat_monthly_shop (...)
|
||||
-- SELECT company_id, shop_id, MAX(platform_id),
|
||||
-- SELECT company_id, shop_id, MAX(platform_code),
|
||||
-- DATE_FORMAT(stat_date, '%Y-%m-01'),
|
||||
-- SUM(sales_amount), SUM(sales_order_count), SUM(sales_quantity_sum),
|
||||
-- SUM(gmv_amount), SUM(gmv_order_count), SUM(gmv_quantity_sum),
|
||||
@@ -553,7 +553,7 @@ CREATE TABLE `ec_order_stat_refresh_queue` (
|
||||
--
|
||||
-- 年表 ← 月表(店铺):
|
||||
-- INSERT INTO ec_order_stat_yearly_shop (...)
|
||||
-- SELECT company_id, shop_id, MAX(platform_id), YEAR(stat_month),
|
||||
-- SELECT company_id, shop_id, MAX(platform_code), YEAR(stat_month),
|
||||
-- SUM(sales_amount), ...
|
||||
-- FROM ec_order_stat_monthly_shop
|
||||
-- WHERE company_id=? AND stat_year BETWEEN ? AND ?
|
||||
|
||||
Reference in New Issue
Block a user