-- ******************************************************************
-- 表 kku_transfer_fee_daily_stats 的创建SQL
-- 对应的Model: App\Module\Transfer\Models\TransferFeeDailyStats
-- 警告: 此文件由系统自动生成，禁止修改！
-- ******************************************************************

CREATE TABLE `kku_transfer_fee_daily_stats` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `stat_date` date NOT NULL COMMENT '统计日期',
  `transfer_app_id` int unsigned NOT NULL COMMENT '划转应用ID',
  `in_order_count` int unsigned NOT NULL DEFAULT '0' COMMENT '转入订单数量',
  `in_total_amount` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '转入总金额',
  `in_fee_amount` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '转入手续费总额',
  `in_avg_fee_rate` decimal(8,5) NOT NULL DEFAULT '0.00000' COMMENT '转入平均手续费率',
  `out_order_count` int unsigned NOT NULL DEFAULT '0' COMMENT '转出订单数量',
  `out_total_amount` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '转出总金额',
  `out_fee_amount` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '转出手续费总额',
  `out_avg_fee_rate` decimal(8,5) NOT NULL DEFAULT '0.00000' COMMENT '转出平均手续费率',
  `total_order_count` int unsigned NOT NULL DEFAULT '0' COMMENT '总订单数量',
  `total_amount` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '总交易金额',
  `total_fee_amount` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '总手续费金额',
  `avg_fee_rate` decimal(8,5) NOT NULL DEFAULT '0.00000' COMMENT '平均手续费率',
  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_stat_date_app` (`stat_date`,`transfer_app_id`) USING BTREE,
  KEY `idx_stat_date` (`stat_date`) USING BTREE,
  KEY `idx_transfer_app_id` (`transfer_app_id`) USING BTREE,
  KEY `idx_created_at` (`created_at`) USING BTREE,
  KEY `idx_total_fee_amount` (`total_fee_amount`,`stat_date`) USING BTREE,
  KEY `idx_app_date_range` (`transfer_app_id`,`stat_date`,`total_fee_amount`) USING BTREE,
  CONSTRAINT `fk_fee_daily_stats_app` FOREIGN KEY (`transfer_app_id`) REFERENCES `kku_transfer_apps` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='手续费每日统计表';
