ALTER TABLE `qimall_user_level`
ADD COLUMN `is_open_expired`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启会员期限',
ADD COLUMN `expired_day`  int(11) NOT NULL DEFAULT 0 COMMENT '会员有效期';

ALTER TABLE `qimall_order_marketing`
ADD COLUMN `user_card_id`  varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户会员卡id map';

INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('MembersCard', '亲友卡', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('MembersCard', '亲友卡', 'FromTypeMap', '1', '1', '1654569888', '1654569888');

INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('会员等级过期', 'user-level/level-expired', '2', '0 */30 * * * *', '0', '1', '1672645798', '1672645798');

-- 蕾伊生
ALTER TABLE `qimall_addons_cloud_stock_agent_order`
ADD COLUMN `remark`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户订单备注';

--华后美业
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('manage', '管理奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');

--酒多多
ALTER TABLE `qimall_user_level`
ADD COLUMN `member_price_is_show`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否展示下级会员价格 0 否 1 是';

--独立平级奖
ALTER TABLE `qimall_addons_agent_commission_level_setting`
ADD COLUMN `is_alone_agent_equal_prize`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启独立平级奖励 0 否 1 是',
ADD COLUMN `alone_agent_equal_prize_info`  varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '独立平级奖设置';

ALTER TABLE `qimall_addons_agent_commission_item_setting`
ADD COLUMN `is_alone_agent_equal_prize`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启独立平级奖励 0 否 1 是',
ADD COLUMN `alone_agent_equal_prize_type`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '独立平级奖励类型';

ALTER TABLE `qimall_addons_agent_commission_item_setting_detail`
ADD COLUMN `alone_agent_equal_prize_info`  varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '独立平级奖设置';


--门店独立结算金额
ALTER TABLE `qimall_addons_store_goods_extra`
ADD COLUMN `is_alone_settle`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启独立结算金额 [1是 0 否]',
ADD COLUMN `alone_settle_price`  decimal(10,2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '独立结算金额';
--亲友卡新增
ALTER TABLE `qimall_addons_members_card`
ADD COLUMN `is_enable_virtual`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '虚拟商品是否可用 0 否 1 是 ';

--加权分红
ALTER TABLE `qimall_addons_boss_weight`
ADD COLUMN `fixed_weight`  int(11) NOT NULL DEFAULT 0 COMMENT '固定权重';

--积分抵扣
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('goods_deduct', '购物抵扣', 'FromTypeMap', '0', '1', '1654569888', '1654569888');

--核销员
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('write_off_prize', '核销奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('manage_prize', '管理奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('promote_prize', '促销奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('achievement_promote_prize', '业绩促销奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('WriteOff', '核销员', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('WriteOff', '核销员', 'FromTypeMap', '1', '1', '1654569888', '1654569888');

INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('核销员促销业绩奖励结算', 'write-off/write-off-crontab/settle', '2', '0 */60 * * * *', '0', '1', '1691749140', '1693563705');

--云库存
INSERT INTO `qimall_global_var_map` ( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('buy_price_difference', '会员买货差价', 'CapitalTypeMap', 0, 1, 1654569888, 1654569888);
INSERT INTO `qimall_global_var_map` ( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('price_difference_equal', '云库存差价平级奖', 'CapitalTypeMap', 0, 1, 1654569888, 1654569888);
ALTER TABLE `qimall_user_bank_card`
ADD COLUMN `bank_address`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '开户行地址';
--服务商分红
ALTER TABLE `qimall_addons_servebonus_level_setting`
ADD COLUMN `is_cloud_stock_open`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '云库存加权分红 0关闭 1 开启',
ADD COLUMN `cloud_stock_achievement_percent`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '云库存业绩分红类型 0百分比 1 固定金额',
ADD COLUMN `cloud_stock_achievement_prize`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '云库存业绩分红奖励';

ALTER TABLE `qimall_addons_servebonus_reward_log`
ADD COLUMN `is_cloud_stock`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否云库存结算[0否; 1是]';

ALTER TABLE `qimall_addons_servebonus_commission_log`
ADD COLUMN `achievement_commission`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '业绩分红，单位：元';
ALTER TABLE `qimall_addons_servebonus`
ADD COLUMN `achievement_commission`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '累计业绩分红，单位：元';
ALTER TABLE `qimall_addons_servebonus_commission_item_setting`
ADD COLUMN `cloud_stock_achievement_percent`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '云库存业绩分红类型 0百分比 1 固定金额';
ALTER TABLE `qimall_addons_servebonus_commission_item_setting_detail`
ADD COLUMN `cloud_stock_achievement_prize`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '云库存业绩分红奖励';
ALTER TABLE `qimall_addons_servebonus_period`
ADD COLUMN `achievement_commission`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '业绩分红，单位：元';








--大古
INSERT INTO `qimall_global_var_map` ( `name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('fill_achievement', '个人团队补货奖励', 'CapitalTypeMap', 0, 1, 1654569888, 1654569888);
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('WholeBonus', '全民分红', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('WholeBonus', '全民分红', 'FromTypeMap', '1', '1', '1654569888', '1654569888');

--新建表 qimall_addons_cloud_stock_increase_by_platform_log
ALTER TABLE `qimall_addons_cloud_stock_fill_statistics`
ADD COLUMN `award_proportion_calculate_type`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '计算方式';

ALTER TABLE `qimall_addons_cloud_stock_fill_statistics`
MODIFY COLUMN `self_num`  decimal(12,2) NOT NULL COMMENT '自身补货数量',
MODIFY COLUMN `direct_num`  decimal(12,2) NOT NULL COMMENT '直推们的数量，等级一致',
MODIFY COLUMN `indirect_num`  decimal(12,2) NOT NULL COMMENT '间推们数量，等级一致';

INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('全民分红-分红池分红', 'whole-bonus/index/team-reward', '2', '0 */30 0-2 * * *', '0', '1', '1709287854', '1709287880');

--余额充值
INSERT INTO `qimall_menu` (`title`, `app_id`, `cate_id`, `addons_name`, `is_addon`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES ('充值审核', 'backend', '2', '', '0', '35', 'mall/finance/recharge-audit', '', '2', '1', '999', NULL, 'tr_0 tr_35', '1', '1694766835', '1694766835');

--开票
ALTER TABLE `qimall_order`
ADD COLUMN `is_bill`  tinyint(1) NULL DEFAULT 0 COMMENT '是否已开票 0 否 1 是',
ADD COLUMN `bill_time`  int(11) NULL DEFAULT 0 COMMENT '开票时间';

INSERT INTO `qimall_menu` (`title`, `app_id`, `cate_id`, `addons_name`, `is_addon`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES ('开票记录', 'backend', '2', '', '0', '33', 'mall/order/invoice', '', '2', '1', '999', NULL, ' tr_33', '1', '1695117641', '1695117641');




--核销员
ALTER TABLE `qimall_addons_write_off_member_log`
ADD COLUMN `code`  int(8) NOT NULL DEFAULT 0 COMMENT '核销码';

ALTER TABLE `qimall_addons_write_off_level`
ADD COLUMN `is_enable_promote_limit`  tinyint(4) NULL DEFAULT 0 COMMENT '核销限制[0:关闭;1启用]',
ADD COLUMN `promote_time`  int(10) NULL DEFAULT 0 COMMENT '每日核销次数';

--最高奖励
ALTER TABLE `qimall_addons_double_copy_user`
ADD COLUMN `is_height_commission`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否设置最高佣金奖励【0 否 1 是】',
ADD COLUMN `height_commission`  decimal(10,2) NOT NULL DEFAULT 0 COMMENT '最高奖励';

ALTER TABLE `qimall_addons_distribution`
ADD COLUMN `is_height_commission`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否设置最高佣金奖励【0 否 1 是】',
ADD COLUMN `height_commission`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '最高奖励';


--业绩平级奖励
ALTER TABLE `qimall_addons_achievement_commission_item_setting`
ADD COLUMN `is_alone_equal`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否独立平级奖励 【 0 否 1是】',
ADD COLUMN `is_alone_equal_percent`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '平级奖励类型 0百分比 1 固定金额',
ADD COLUMN `alone_equal_first`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '一级平级奖励/比例',
ADD COLUMN `alone_equal_second`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '二级平级奖励/比例';

ALTER TABLE `qimall_addons_achievement_order_log`
ADD COLUMN `is_alone_equal`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否独立平级奖励 【 0 否 1是】',
ADD COLUMN `equal_first`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '一级平级奖励/比例',
ADD COLUMN `equal_second`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '二级平级奖励/比例';
--乔迪安
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('boss_weight', '加权分红', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('BossWeightBonus', '股东加权分红', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('BossWeightBonus', '股东加权分红', 'FromTypeMap', '1', '1', '1654569888', '1654569888');

INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('股东加权分红', 'boss-weight-bonus/boss-weight-bonus-crontab/send-commission', '2', '0 30 0 * * *', '0', '1', '1699344672', '1699344672');
INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('股东加权分红积分自动转入', 'boss-weight-bonus/boss-weight-bonus-crontab/auto-change-score', '2', '*/30 * * * * *', '0', '1', '1699344787', '1699344787');
INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('股东加权分红自动转入股指', 'boss-weight-bonus/boss-weight-bonus-crontab/auto-change', '2', '0 0 1 1 * *', '0', '1', '1699344846', '1699344846');
ALTER TABLE `qimall_addons_achievement_grant_log`
ADD COLUMN `is_equal`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否开启平级奖励：0：否 1：是',
ADD COLUMN `equal_percent`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '平级奖励计算方式：0：百分比 1：固定金额',
ADD COLUMN `equal_price_first`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '一层平级奖励',
ADD COLUMN `equal_price_second`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '二层平级奖励';

ALTER TABLE `qimall_addons_achievement_award_log`
ADD COLUMN `equal_first`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '一层平级奖励',
ADD COLUMN `equal_second`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '二层平级奖励';

ALTER TABLE `qimall_addons_achievement_award_log`
ADD COLUMN `equal_info`  varchar(255) NOT NULL COMMENT '首次平级奖励内容';

ALTER TABLE `qimall_addons_achievement_award_log`
ADD COLUMN `equal_money`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '平级奖励金额';

ALTER TABLE `qimall_addons_achievement_grant_log`
ADD COLUMN `equal_money`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '平级奖励金额';

--新
ALTER TABLE `qimall_addons_achievement_award_log`
ADD COLUMN `team_equal_first`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '团队一层平级奖励',
ADD COLUMN `team_equal_second`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '团队二层平级奖励';
--卡券
INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('卡券状态修改', 'card-coupons/card-coupon-crontab/auto-change', '2', '0 */5 * * * *', '0', '1', '1697105153', '1697105153');
CREATE TABLE `qimall_payment_trade_group_order` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `trade_id` int(11) NOT NULL DEFAULT '0' COMMENT '流水表ID',
  `order_no` varchar(32) NOT NULL DEFAULT '' COMMENT '订单号',
  `order_type` varchar(32) NOT NULL DEFAULT '' COMMENT '订单类型',
  `pay_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单支付金额',
  `total_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单总金额，pay_fee+rand_fee',
  `rand_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单随机减金额',
  `is_pay` int(1) NOT NULL DEFAULT '0' COMMENT '支付状态：0=未支付，1=已支付',
  `pay_type` int(1) NOT NULL DEFAULT '0' COMMENT '支付方式：1=微信支付，2=货到付款，3=余额支付，4=支付宝支付，5=银联支付，6=汇聚聚合支付，7=汇聚快捷支付',
  `title` varchar(128) NOT NULL DEFAULT '' COMMENT '标题',
  `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT '0',
  `notify_class` varchar(512) NOT NULL DEFAULT '',
  `refund_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '退款金额',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `union_id` (`trade_id`) USING BTREE,
  KEY `order_no` (`order_no`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='订单组合支付记录表';

ALTER TABLE `qimall_payment_trade`
ADD COLUMN `is_pay_group`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否组合支付订单 0 否 1 是',
ADD COLUMN `parent_trade_id`  int(11) NOT NULL DEFAULT 0 COMMENT '关联上级支付流水id（组合支付子订单不为空）';


--云库存业绩奖励
ALTER TABLE `qimall_addons_cloud_stock_achievement_grant_log`
ADD COLUMN `wait_settlement_time`  int(11) NOT NULL DEFAULT 0 COMMENT '等待结算时间';

--门店股东2
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('113', '股东-团队', '0', '0', 'store/store-boss-agent/index/index', '', '2', '0', '999', NULL, '', '1', '0', '0', 'StoreBossAgent', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('114', '股东列表', '0', '113', 'store/store-boss-agent/index/index', '', '2', '0', '999', NULL, '', '1', '0', '0', 'StoreBossAgent', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('115', '股东等级', '0', '113', 'store/store-boss-agent/index/level', '', '2', '0', '999', NULL, '', '1', '0', '0', 'StoreBossAgent', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('116', '提成明细', '0', '113', 'store/store-boss-agent/index/settlement-list', '', '2', '0', '999', NULL, '', '1', '0', '0', 'StoreBossAgent', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('117', '基础设置', '0', '113', 'store/store-boss-agent/index/setting', '', '2', '0', '999', NULL, '', '1', '0', '0', 'StoreBossAgent', '1');

ALTER TABLE `qimall_addons_store_commission`
ADD COLUMN `store_agent_send_commission`  decimal(12,2) NOT NULL DEFAULT 0.00 COMMENT '门店股东-团队直接发放佣金，不包含平台设置的插件佣金';

INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('StoreBossAgent', '门店股东', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('StoreBossAgent', '门店股东', 'FromTypeMap', '1', '1', '1654569888', '1654569888');

INSERT INTO `qimall_addons_store_addons` (`title`, `name`, `cover`, `brief_introduction`, `status`, `created_at`, `updated_at`) VALUES ('股东-团队', 'StoreBossAgent', '', '单门店营销工具', '1', '1702975895', '1702975895');

INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('diff_parent', '极差平均分红(上级代理)', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('diff_area_commission', '极差平均分红(区域代理)', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('diff_user', '极差平均分红(指定用户)', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('equal_upgrade', '平级代理分红', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');

ALTER TABLE `qimall_addons_agent_commission_item_setting`
ADD COLUMN `is_equal_by_upgrade`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启代理平级奖励 0 否 1 是',
ADD COLUMN `is_self_buy_alone`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启经销内购独立设置 0 否 1 是',
ADD COLUMN `is_self_buy`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启经销内购 0 否 1 是',
ADD COLUMN `enable_goods_deduct`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启商品抵扣 0 否 1 是';
--公排
ALTER TABLE `qimall_addons_public_line_level_change_log`
ADD COLUMN `order_id`  int(10) NOT NULL DEFAULT 0 COMMENT '订单id';
ALTER TABLE `qimall_addons_public_line_order`
ADD COLUMN `reward_num`  int(10) NOT NULL DEFAULT 0 COMMENT '可获得奖励次数';

CREATE TABLE `qimall_addons_public_line_reward_log` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城ID',
  `from_order_no` varchar(100) NOT NULL DEFAULT '' COMMENT '来源订单编号',
  `reward_order_no` varchar(100) NOT NULL DEFAULT '' COMMENT '奖励订单编号',
  `status` tinyint(4) 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,
  KEY `mall_id` (`mall_id`) USING BTREE,
  KEY `mall_id+user_id` (`mall_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='公排奖励记录表';

--门店核销券
INSERT INTO `qimall_addons_store_addons` (`title`, `name`, `cover`, `brief_introduction`, `status`, `created_at`, `updated_at`) VALUES ('核销券', 'VerificationCoupon', '', '单门店核销工具', '1', '1702975895', '1702975895');
--组合支付
CREATE TABLE `qimall_payment_trade_group_order` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `trade_id` int(11) NOT NULL DEFAULT '0' COMMENT '流水表ID',
  `order_no` varchar(32) NOT NULL DEFAULT '' COMMENT '订单号',
  `order_type` varchar(32) NOT NULL DEFAULT '' COMMENT '订单类型',
  `pay_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单支付金额',
  `total_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单总金额，pay_fee+rand_fee',
  `rand_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单随机减金额',
  `is_pay` int(1) NOT NULL DEFAULT '0' COMMENT '支付状态：0=未支付，1=已支付',
  `pay_type` int(1) NOT NULL DEFAULT '0' COMMENT '支付方式：1=微信支付，2=货到付款，3=余额支付，4=支付宝支付，5=银联支付，6=汇聚聚合支付，7=汇聚快捷支付',
  `title` varchar(128) NOT NULL DEFAULT '' COMMENT '标题',
  `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT '0',
  `notify_class` varchar(512) NOT NULL DEFAULT '',
  `refund_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '退款金额',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `union_id` (`trade_id`) USING BTREE,
  KEY `order_no` (`order_no`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='订单组合支付记录表';
--蔚你而莱
 --表 qimall_addons_cloud_stock_rand_fee_order

ALTER TABLE `qimall_payment_trade`
ADD COLUMN `is_pay_group`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否组合支付订单 0 否 1 是',
ADD COLUMN `parent_trade_id`  int(11) NOT NULL DEFAULT 0 COMMENT '关联上级支付流水id（组合支付子订单不为空）';
ALTER TABLE `qimall_addons_cloud_stock_agent_order`
ADD COLUMN `trade_id`  int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '支付流水记录id',
ADD COLUMN `pay_money`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '支付金额',
ADD COLUMN `order_no`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '自提订单编号',
ADD COLUMN `trade_no`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付流水号';

ALTER TABLE `qimall_addons_cloud_stock_goods`
ADD COLUMN `is_find_equal`  tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否开启紧缩层级平级奖';


--门店核销券
INSERT INTO `qimall_addons_store_addons` (`title`, `name`, `cover`, `brief_introduction`, `status`, `created_at`, `updated_at`) VALUES ('核销券', 'Verification', '', '单门店核销工具', '1', '1702975895', '1702975895');

INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('108', '核销券', '0', '0', 'store/verification/index/index', '', '2', '0', '999', NULL, '', '1', '0', '0', 'Verification', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('109', '核销券', '0', '108', 'store/verification/index/index', '', '2', '0', '999', NULL, '', '1', '0', '0', 'Verification', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('110', '会员核销券', '0', '108', 'store/verification/index/user', '', '2', '0', '999', NULL, '', '1', '0', '0', 'Verification', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('111', '使用记录', '0', '108', 'store/verification/index/log', '', '2', '0', '999', NULL, '', '1', '0', '0', 'Verification', '1');
INSERT INTO `qimall_addons_store_menu` (`id`, `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ('112', '基础设置', '0', '108', 'store/verification/index/setting', '', '2', '0', '999', NULL, '', '1', '0', '0', 'Verification', '1');

CREATE TABLE `qimall_addons_store_verification_coupons` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城ID',
  `store_id` int(10) NOT NULL DEFAULT '0' COMMENT '门店ID',
  `name` varchar(100) NOT NULL DEFAULT '' COMMENT '核销券名称',
  `num` int(10) NOT NULL DEFAULT '0' COMMENT '发行数量',
  `start_at` int(10) NOT NULL DEFAULT '0' COMMENT '使用时间',
  `end_at` int(10) NOT NULL DEFAULT '0' COMMENT '使用时间',
  `style_pic_url` varchar(255) NOT NULL DEFAULT '' COMMENT '核销券海报',
  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
  `issued_num` int(10) NOT NULL DEFAULT '0' COMMENT '已发放数量',
  `used_num` int(10) NOT NULL DEFAULT '0' COMMENT '已核销数量',
  `status` tinyint(4) 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`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

CREATE TABLE `qimall_addons_store_verification_coupons_user` (
  `id` int(11) 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',
  `coupon_id` int(10) NOT NULL DEFAULT '0' COMMENT '核销券ID',
  `num` int(10) NOT NULL DEFAULT '0' COMMENT '发行数量',
  `used_num` int(10) NOT NULL DEFAULT '0' COMMENT '已核销数量',
  `status` tinyint(4) 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 '修改时间',
  `is_transfer` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否他人转赠',
  `from_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '来源用户ID',
  `from_coupon_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '来源券ID',
  PRIMARY KEY (`id`),
  KEY `store_id` (`store_id`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE,
  KEY `coupon_id` (`coupon_id`) USING BTREE,
  KEY `from_coupon_user_id` (`from_coupon_user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

CREATE TABLE `qimall_addons_store_verification_setting` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL,
  `store_id` int(11) NOT NULL DEFAULT '0',
  `key` varchar(255) NOT NULL,
  `value` longtext NOT NULL,
  `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `mall_id` (`mall_id`) USING BTREE,
  KEY `key` (`key`(191)) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT;

CREATE TABLE `qimall_store_verification_coupons_clerk_log` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL DEFAULT '0',
  `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
  `clerk_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员id',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
  `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  `coupon_id` int(10) NOT NULL DEFAULT '0' COMMENT '核销券ID',
  `from_coupon_user_id` int(10) NOT NULL DEFAULT '0' COMMENT '来源券ID',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `store_id` (`store_id`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE,
  KEY `coupon_id` (`coupon_id`) USING BTREE,
  KEY `from_coupon_user_id` (`from_coupon_user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='门店核销券明细';

--二二复制平级奖
ALTER TABLE `qimall_addons_double_copy_level_setting`
ADD COLUMN `equal_level_prize_type`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '平级奖类型 0百分比 1 固定金额',
ADD COLUMN `equal_level_prize`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '平级奖';

ALTER TABLE `qimall_addons_double_copy_commission_item_setting_detail`
ADD COLUMN `equal_level_prize`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '平级奖';

--二二复制门店商品升级
ALTER TABLE `qimall_addons_double_copy_level`
ADD COLUMN `upgrade_type_store_goods`  smallint(6) NOT NULL DEFAULT 0 COMMENT '购买门店商品升级  0关闭 1 开启',
ADD COLUMN `buy_store_goods_type`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '0订单完成 1下单 完成',
ADD COLUMN `store_goods_type`  smallint(6) NOT NULL DEFAULT 0 COMMENT '门店商品升级类型',
ADD COLUMN `store_goods_ids`  text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '门店商品仓库的ID',
ADD COLUMN `store_goods_list`  longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '门店商品列表';

--代理分红
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('agent_bonus_first', '直推奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('agent_bonus_team', '代理商分红', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('agent_bonus_order', '报单奖励', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('AgentBonus', '代理分红', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('AgentBonus', '代理分红', 'FromTypeMap', '1', '1', '1654569888', '1654569888');

INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('代理分红：佣金解冻', 'agent-bonus/agent-bonus/frozen-to-active', '2', '0 1 0 * * *', '0', '1', '1710054237', '1710054237');

--消费券拓客
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('ConsumerCoupons', '消费券拓客', 'IncomeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('ConsumerCoupons', '消费券拓客', 'FromTypeMap', '1', '1', '1654569888', '1654569888');
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('consumer_coupons_transfer', '消费券转入', 'CapitalTypeMap', '0', '1', '1654569888', '1654569888');

INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('消费券拓客：冻结消费券自动转激活消费券', 'consumer-coupons/consumer-coupons/frozen-to-active', '2', '0 1 0 * * *', '0', '1', '1710054166', '1710054166');

--推三返一
ALTER TABLE `qimall_addons_rebate`
ADD COLUMN `repeat_setting`  tinyint(2) NULL DEFAULT 0 COMMENT '是否开启触发奖励设置[0=否，1=是]',
ADD COLUMN `agent_limit_num`  int(11) NULL DEFAULT 0 COMMENT '渠道分红订单限制';

--order_settlement_status-- qimall_addons_rebate_buy表没有这个字段

CREATE TABLE `qimall_addons_agent_cancel_log` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) unsigned NOT NULL DEFAULT '0',
  `source_table` varchar(255) NOT NULL DEFAULT '' COMMENT '来源表',
  `source_table_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作来源业务id',
  `from_type` varchar(50) NOT NULL DEFAULT '' COMMENT '来源类型',
  `order_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '记录时订单状态[0:支付;1:完成]',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态，-1：失效，1：正常，2：冻结',
  `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间戳',
  `updated_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间戳',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_mall_user` (`mall_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='代理分红记录表';

--二二复制复购奖励
ALTER TABLE `qimall_addons_double_copy_level_setting` 
ADD COLUMN `repurchase_prize_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '复购奖励类型 0百分比 1 固定金额',
ADD COLUMN `repurchase_prize` decimal(10, 2) NOT NULL COMMENT '复购奖励';

ALTER TABLE `qimall_addons_double_copy_commission_item_setting_detail` 
ADD COLUMN `repurchase_prize` decimal(10, 2) NOT NULL COMMENT '复购奖励';