CREATE TABLE `trade_shop_settlement` (
                                         `id` bigint NOT NULL AUTO_INCREMENT COMMENT '结算id',
                                         `shop_id` bigint NOT NULL COMMENT '店铺id',
                                         `merchant_id` bigint NOT NULL COMMENT '商户id',
                                         `platform_collection_amount` int NOT NULL DEFAULT '0' COMMENT '销售额（积分 + 支付金额）',
                                         `shop_amount` bigint NOT NULL DEFAULT '0' COMMENT '抵扣积分',
                                         `shop_total_high_amount` decimal(20,6) DEFAULT '0.000000' COMMENT '共计成本价格(高精度 + 成本)',
                                         `pt_settlement_id` bigint NOT NULL COMMENT '平台结算ID',
                                         `attachment` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '转账凭证附件',
                                         `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '创建者',
                                         `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                         `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '更新者',
                                         `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                         `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                         PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单结算信息表，记录店铺的结算信息';


ALTER TABLE trade_order_item
    ADD COLUMN `settlement_time` datetime DEFAULT NULL COMMENT '是否结算账单';

CREATE TABLE trade_order_settlement (
                                        `id` bigint NOT NULL AUTO_INCREMENT COMMENT '结算二级表ID',
                                        `trade_shop_settlement_id` bigint NOT NULL COMMENT '结算表ID',
                                        `trade_order_id` bigint NOT NULL COMMENT '订单ID',
                                        `creator` VARCHAR ( 64 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '创建者',
                                        `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                        `updater` VARCHAR ( 64 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '更新者',
                                        `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                        `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                        PRIMARY KEY ( `id` ) USING BTREE
) AUTO_INCREMENT = 3 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '订单结算表,记录有那些订单参与了本次结算';

CREATE TABLE trade_order_item_settlement (
                                             `id` bigint NOT NULL AUTO_INCREMENT COMMENT '结算二级表ID',
                                             `trade_shop_settlement_id` bigint NOT NULL COMMENT '结算表ID',
                                             `trade_order_item_id` bigint NOT NULL COMMENT '订单项ID',
                                             `creator` VARCHAR ( 64 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '创建者',
                                             `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                             `updater` VARCHAR ( 64 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '更新者',
                                             `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                             `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                             PRIMARY KEY ( `id` ) USING BTREE
) AUTO_INCREMENT = 3 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '订单结算表,记录有那些订单项参与了本次结算';



CREATE TABLE `trade_pt_settlement` (
                                       `id` bigint NOT NULL AUTO_INCREMENT COMMENT '结算id',
                                       `platform_collection_amount` int NOT NULL DEFAULT '0' COMMENT '销售额（积分 + 支付金额）',
                                       `shop_amount` bigint NOT NULL DEFAULT '0' COMMENT '抵扣积分',
                                       `shop_total_high_amount` decimal(20,6) DEFAULT '0.000000' COMMENT '共计成本价格(高精度 + 成本)',
                                       `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '创建者',
                                       `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                       `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '更新者',
                                       `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                       `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                       `platform_transfer_confirm` bit(1) DEFAULT b'0' COMMENT '是否结账',
                                       PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='平台每日结算信息表，记录店铺的结算信息';