CREATE TABLE `qimall_addons_business_activity` (
	`id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
	`created_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
	`updated_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '更新时间',
	`mall_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商城ID',
	`status` TINYINT (3) NOT NULL DEFAULT '1' COMMENT '状态，-1已删除，0禁用，1正常，100已完成',
	`name` VARCHAR (20) NOT NULL DEFAULT '' COMMENT '活动名称' COLLATE 'utf8_unicode_ci',
	`start_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动开始时间',
	`end_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动结束时间',
	`merchants_user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '招商负责人',
	`venue_user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '场地负责人',
	`participate_num` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '参会人数',
	`activity_status` TINYINT (3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动状态，0未开始，1进行中，100已完成',
	PRIMARY KEY (`id`) USING BTREE
) COMMENT = '活动' COLLATE = 'utf8_unicode_ci' ENGINE = INNODB;

CREATE TABLE `qimall_addons_business_activity_commission` (
	`id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
	`created_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
	`updated_at` INT (10) UNSIGNED NOT NULL COMMENT '更新时间',
	`mall_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商城ID',
	`status` TINYINT (3) NOT NULL DEFAULT '1' COMMENT '状态',
	`user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '奖励用户',
	`commission` BIGINT (20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '奖励佣金',
	`intro` VARCHAR (300) NOT NULL DEFAULT '' COMMENT '提成说明' COLLATE 'utf8_unicode_ci',
	`order_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '订单ID',
	`order_detail_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '订单商品ID',
	`activity_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动ID',
	`order_no` CHAR (36) NOT NULL DEFAULT '' COMMENT '订单编号' COLLATE 'utf8_unicode_ci',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `activity_id` (`activity_id`) USING BTREE,
	INDEX `user_id` (`user_id`) USING BTREE
) COMMENT = '分佣记录' COLLATE = 'utf8_unicode_ci' ENGINE = INNODB;

CREATE TABLE `qimall_addons_business_activity_goods` (
	`id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
	`created_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
	`updated_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '更新时间',
	`status` TINYINT (3) NOT NULL DEFAULT '1' COMMENT '状态-1已删除，0禁用，1正常',
	`mall_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商城ID',
	`activity_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动ID',
	`goods_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商品ID',
	`commission_type` TINYINT (3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '分佣类型1百分比，2固定金额',
	`merchants_commission` BIGINT (20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '招商负责人佣金',
	`merchants_parent_commission` BIGINT (20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '招商负责人上级佣金',
	`venue_commission` BIGINT (20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '场地负责人佣金',
	`venue_parent_commission` BIGINT (20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '场地负责人上级佣金',
	`is_alone_commission` TINYINT (3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '独立设置分佣0不走独立，1走独立',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `activity_id` (`activity_id`) USING BTREE
) COMMENT = '活动商品' COLLATE = 'utf8_unicode_ci' ENGINE = INNODB;

CREATE TABLE `qimall_addons_business_activity_order` (
	`id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
	`created_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
	`updated_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '更新时间',
	`mall_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '所属商城',
	`status` TINYINT (3) NOT NULL DEFAULT '1' COMMENT '状态',
	`activity_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动ID',
	`order_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '订单ID',
	`order_status` TINYINT (3) NOT NULL DEFAULT '0' COMMENT '订单状态',
	`user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '用户ID',
	`goods_ids` TEXT NOT NULL COMMENT '可获得奖励的商品ID' COLLATE 'utf8_unicode_ci',
	PRIMARY KEY (`id`) USING BTREE
) COMMENT = '活动订单' COLLATE = 'utf8_unicode_ci' ENGINE = INNODB;

CREATE TABLE `qimall_addons_business_activity_signin` (
	`id` INT (10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
	`created_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
	`updated_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '更新时间',
	`mall_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '商城ID',
	`status` TINYINT (3) NOT NULL DEFAULT '1' COMMENT '状态',
	`user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '用户ID',
	`activity_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '活动ID',
	`expire_at` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '绑定关系过期时间',
	`merchants_user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '招商负责人',
	`venue_user_id` INT (10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '场地负责人',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `user_id` (`user_id`) USING BTREE,
	INDEX `activity_id` (`activity_id`) USING BTREE,
	INDEX `merchants_user_id` (`merchants_user_id`) USING BTREE,
	INDEX `venue_user_id` (`venue_user_id`) USING BTREE
) COMMENT = '活动签到' COLLATE = 'utf8_unicode_ci' ENGINE = INNODB;


INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `created_at`, `updated_at`) VALUES ('BusinessActivity', '招商活动', 'FromTypeMap', 1, 1654569888, 1654569888);
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `created_at`, `updated_at`) VALUES ('business_activity_prize', '招商活动', 'CapitalTypeMap', 1, 1654569888, 1654569888);
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `created_at`, `updated_at`) VALUES ('BusinessActivity', '招商活动', 'IncomeMap', 1, 1654569888, 1654569888);
INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `created_at`, `updated_at`) VALUES ('BusinessActivity', '招商活动', 'MarketingTypeMap', 1, 1654569888, 1654569888);
