CREATE TABLE `qimall_addons_seed_capital_statistics`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `total_seed_num` int(10) NULL DEFAULT 0 COMMENT '累计种子金总数量',
  `collect_seed_num` int(10) NULL DEFAULT 0 COMMENT '已收取种子金总数量',
  `refund_seed_num` int(10) NULL DEFAULT 0 COMMENT '退款种子金总数量',
  `bad_seed_num` int(10) NULL DEFAULT 0 COMMENT '坏账种子金数量',
  `total_energy_pool` decimal(17, 7) NULL DEFAULT 0.0000000 COMMENT '当前能量池总额',
  `cumulative_energy_pool` decimal(17, 7) NULL DEFAULT 0.0000000 COMMENT '累计能量池总额',
  `release_energy_pool` decimal(17, 7) NULL DEFAULT 0.0000000 COMMENT '已释放能量池总额',
  `release_num` int(10) NULL DEFAULT 0 COMMENT '已释放能量池次数',
  `last_release_at` int(10) NULL DEFAULT 0 COMMENT '上次释放时间',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态，-1：失效，1：正常，2：冻结',
  `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间戳',
  `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间戳',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '资金统计表' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_energy_pool`  (
  `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `mall_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商城ID',
  `release_num` int(10) NULL DEFAULT 0 COMMENT '第N次能量池释放',
  `total_seed_num` int(10) NULL DEFAULT 0 COMMENT '当前种子金总数量',
  `release_energy_pool` decimal(17, 7) NULL DEFAULT 0.0000000 COMMENT '释放能量池总额',
  `unit_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '释放的增长值，单位：元',
  `release_at` int(10) NULL DEFAULT 0 COMMENT '释放时间',
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '失败原因',
  `release_status` tinyint(1) NULL DEFAULT 0 COMMENT '[0:释放中,1:释放成功,2:释放失败]',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态【1启用 0禁用 -1删除】',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新数据时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '能量池释放记录' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_log`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `seed_order_id` int(11) NULL DEFAULT 0 COMMENT '对应seed_order.id',
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `store_id` int(10) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户ID',
  `order_id` int(10) NOT NULL DEFAULT 0 COMMENT '订单ID',
  `event_pay` tinyint(2) NULL DEFAULT 1 COMMENT '事件类型[1=普通订单,2=收银台订单]',
  `seed_num` int(10) NULL DEFAULT 0 COMMENT '种子金数量',
  `seed_cost` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '种子金总价值，单位：元',
  `change_unit_price` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '变动的单价',
  `after_unit_price` decimal(12, 2) NULL DEFAULT 0.00 COMMENT '变动后单价',
  `desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '变动说明',
  `capital_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '资金类型',
  `pool_id` int(10) NULL DEFAULT 0 COMMENT '能量池ID',
  `setting` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '生成数据的设置',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态，-1：失效，1：正常，2：冻结',
  `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间戳',
  `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间戳',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_mall_user`(`mall_id`, `user_id`) USING BTREE,
  INDEX `order_id`(`order_id`) USING BTREE,
  INDEX `pool_id`(`pool_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '种子金变动记录表' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_order`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `store_id` int(10) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户ID',
  `identity` int(10) NULL DEFAULT 1 COMMENT '身份[1:消费者,2:店长]',
  `order_id` int(10) NOT NULL DEFAULT 0 COMMENT '订单ID',
  `order_no` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '订单号',
  `event_pay` tinyint(2) NULL DEFAULT 1 COMMENT '事件类型[1=普通订单,2=收银台订单]',
  `is_credit` tinyint(1) NULL DEFAULT 0 COMMENT '是否是赊账订单[0:否,1:是]',
  `credit_money` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '赊账金额，单位：元',
  `goods_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '第一个商品名称',
  `seed_num` int(10) NULL DEFAULT 0 COMMENT '种子金数量',
  `basic_unit_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '种子金基础单价，单位：元',
  `unit_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '种子金现单价，单位：元',
  `seed_cost` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '种子金总价值，单位：元',
  `increase_num` int(10) NULL DEFAULT 0 COMMENT '增长次数',
  `join_pool_money` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '存放到能量池的金额，单位：元',
  `can_send_at` int(10) NULL DEFAULT 0 COMMENT '可发放能量池时间',
  `last_send_at` int(10) NULL DEFAULT 0 COMMENT '上次能量池释放时间',
  `seed_status` tinyint(4) NULL DEFAULT 0 COMMENT '状态[0:冻结中，1:增长中，2:已收取]',
  `is_able_collect` tinyint(1) NULL DEFAULT 1 COMMENT '是否允许收取[0:不允许,1:允许]',
  `status` tinyint(4) NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE,
  INDEX `user_id`(`user_id`) USING BTREE,
  INDEX `order_id`(`order_id`) USING BTREE,
  INDEX `order_no`(`order_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '种子金订单表' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_refund`  (
  `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `seed_order_id` int(10) NOT NULL DEFAULT 0 COMMENT 'seed_order.id',
  `seed_num` int(10) NOT NULL DEFAULT 0 COMMENT '退款种子金数量',
  `seed_cost` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '退款种子金总价值，单位：元',
  `percent` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '退款比例，单位：百分比',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态【-1删除 0禁用，1正常】',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新数据时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `seed_order_id`(`seed_order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '种子金退单记录表' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_store_setting`  (
  `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `store_id` int(10) NOT NULL DEFAULT 0 COMMENT '店铺ID',
  `percent` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '设置比例，单位：百分比',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态【-1删除 0禁用，1正常】',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '更新数据时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id+store_id`(`mall_id`, `store_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '店长种子金独立设置表' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_user`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户ID',
  `total_seed_num` int(10) NULL DEFAULT 0 COMMENT '累计种子金总数量',
  `total_seed_cost` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '种子金总价值，单位：元',
  `collect_seed_num` int(10) NULL DEFAULT 0 COMMENT '已收取种子金总数量',
  `refund_seed_num` int(10) NULL DEFAULT 0 COMMENT '退款种子金总数量',
  `total_change_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '累计转换金额，单位：元',
  `status` tinyint(4) NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  `updated_at` int(10) NOT NULL DEFAULT 0 COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `mall_id`(`mall_id`) USING BTREE,
  INDEX `user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '种子金用户表' ROW_FORMAT = Dynamic;

CREATE TABLE `qimall_addons_seed_user_statistics`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT 0 COMMENT '商城ID',
  `store_id` int(10) NOT NULL DEFAULT 0 COMMENT '门店id',
  `user_id` int(10) NOT NULL DEFAULT 0 COMMENT '用户ID',
  `pay_order_num` int(10) NULL DEFAULT 0 COMMENT '支付订单总数',
  `finish_order_num` int(10) NULL DEFAULT 0 COMMENT '完成订单总数',
  `seed_num` int(10) NULL DEFAULT 0 COMMENT '新增种子金数量',
  `collect_seed_num` int(10) NULL DEFAULT 0 COMMENT '已收取种子金总数量',
  `refund_seed_num` int(10) NULL DEFAULT 0 COMMENT '退款种子金总数量',
  `date` int(10) NULL DEFAULT 0 COMMENT '日期，如20220726',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态，-1：失效，1：正常，2：冻结',
  `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '添加时间戳',
  `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间戳',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_mall_user_date`(`mall_id`, `user_id`, `date`) USING BTREE,
  INDEX `date`(`date`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户种子金每日统计表' ROW_FORMAT = Dynamic;

