CREATE TABLE `qimall_addons_electron_coupon` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `mall_id` int(11) DEFAULT '0' COMMENT '商城id', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '电子券名称', `amount` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发行数量;单张券为张', `receive_times` int(11) NOT NULL DEFAULT '0' COMMENT '最多领取次数', `unlimit_receive_times` tinyint(4) NOT NULL DEFAULT '0' COMMENT '领取次数不限制', `pieces_type` int(4) NOT NULL DEFAULT '1' COMMENT '1单张2多张;', `pieces_amount` int(11) NOT NULL DEFAULT '0' COMMENT '多张数量;单位张', `receive_codition` int(4) NOT NULL DEFAULT '1' COMMENT '领取条件;1全体会员;2指定会员等级;', `receive_member_level` int(4) DEFAULT '0' COMMENT '指定会员等级;默认为null', `receive_begin_time` int(11) DEFAULT '0' COMMENT '领取开始时间', `receive_end_time` int(11) DEFAULT '0' COMMENT '领取结束时间', `use_begin_time` int(11) DEFAULT '0' COMMENT '使用开始时间', `use_end_time` int(11) DEFAULT '0' COMMENT '使用结束时间', `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '激活金额', `use_way` int(4) NOT NULL DEFAULT '1' COMMENT '适用范围;1扫描核销', `is_can_receive` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否可以被领取', `is_show_in_center` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否出现在领取中心', `rules` text COMMENT '电子券规则', `pic` varchar(255) DEFAULT NULL COMMENT '缩略图', `receive_amount` int(11) NOT NULL DEFAULT '0' COMMENT '领取数量;单张券为张;', `used_amount` int(11) NOT NULL DEFAULT '0' COMMENT '兑换数量;单位张或多张', `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序;由大到小', `is_give` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否赠送电子券', `is_proper` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否专有券', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', `give_score` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '赠送积分', `give_price` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '赠送佣金', PRIMARY KEY (`id`), KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='电子券'; CREATE TABLE `qimall_addons_electron_coupon_approval_income_log` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `e_coupon_code_id` int(11) NOT NULL COMMENT '核销码id', `user_e_coupon_id` int(11) NOT NULL COMMENT '会员电子券id', `e_coupon_id` int(11) NOT NULL COMMENT '电子券id', `created_at` int(11) NOT NULL DEFAULT '0', `updated_at` int(11) NOT NULL DEFAULT '0', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', `user_id` int(11) NOT NULL COMMENT '使用会员user_id', `e_coupon_name` varchar(255) NOT NULL COMMENT '电子券名称', `amount` int(11) NOT NULL DEFAULT '1' COMMENT '数量', `mall_id` int(11) DEFAULT NULL COMMENT '商城id', `price_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '收益类型1积分2佣金', `commission` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '积分或佣金金额', `clerk_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员user_id', `clerk_admin_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员admin_id(后台核销)', PRIMARY KEY (`id`), KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='电子券核销收益明细表'; CREATE TABLE `qimall_addons_electron_coupon_code` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `user_e_coupon_id` int(11) NOT NULL COMMENT '会员电子券id', `user_id` int(11) NOT NULL COMMENT '会员电子券所有者', `amount` int(11) NOT NULL COMMENT '数量', `code` bigint(20) NOT NULL COMMENT '核销码唯一', `created_at` int(11) NOT NULL DEFAULT '0', `updated_at` int(11) NOT NULL DEFAULT '0', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', `coupon_status` int(11) NOT NULL DEFAULT '0' COMMENT '状态;1已核销;0未核销', `clerk_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员用户id', `clerk_admin_id` int(11) DEFAULT '0' COMMENT '核销管理员id', `approval_at` int(11) DEFAULT '0' COMMENT '核销时间', `mall_id` int(11) NOT NULL COMMENT '商城id', `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id', PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`) USING BTREE COMMENT '核销码', KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='电子券核销码表'; CREATE TABLE `qimall_addons_electron_coupon_give_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mall_id` int(11) NOT NULL COMMENT '商城id', `e_coupon_id` int(11) NOT NULL COMMENT '电子券id', `user_id` int(11) NOT NULL COMMENT '接收者id', `give_user_id` int(11) NOT NULL COMMENT '赠送者id', `e_coupon_name` varchar(255) NOT NULL DEFAULT '' COMMENT '电子券名称', `amount` int(11) NOT NULL DEFAULT '1' COMMENT '赠送数量', `is_proper` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否专有者', `proper_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '专有者id', `created_at` int(11) NOT NULL DEFAULT '0', `updated_at` int(11) NOT NULL DEFAULT '0', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', PRIMARY KEY (`id`) USING BTREE, KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='电子券赠送记录'; CREATE TABLE `qimall_addons_electron_coupon_goods` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id', `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `goods_id` int(11) NOT NULL COMMENT '商品id', `e_coupon_id` int(11) DEFAULT '0' COMMENT '电子券id', `is_open` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否开启', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', `mall_id` int(11) NOT NULL COMMENT '商城id', `num` int(11) DEFAULT '0' COMMENT '赠送数量', PRIMARY KEY (`id`), KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='商品发放电子券表'; CREATE TABLE `qimall_addons_electron_coupon_order` ( `id` int(11) NOT NULL AUTO_INCREMENT, `trade_no` varchar(32) DEFAULT '' COMMENT '流水号', `order_no` varchar(32) NOT NULL DEFAULT '' COMMENT '订单号', `user_id` int(11) NOT NULL COMMENT '用户id', `user_e_coupon_id` int(11) NOT NULL COMMENT '会员电子券id', `price` decimal(10,2) NOT NULL COMMENT '金额', `created_at` int(11) NOT NULL DEFAULT '0', `updated_at` int(11) NOT NULL DEFAULT '0', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id', `is_pay` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否支付', `pay_type` varchar(32) DEFAULT '' COMMENT '支付方式', `pay_time` int(11) DEFAULT '0' COMMENT '支付时间', `number` int(11) NOT NULL DEFAULT '0' COMMENT '数量', PRIMARY KEY (`id`), KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='电子券订单'; CREATE TABLE `qimall_addons_electron_coupon_usage_log` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id', `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id', `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '使用者', `user_e_coupon_id` int(11) DEFAULT NULL COMMENT '会员电子券id', `e_coupon_id` int(11) NOT NULL DEFAULT '0' COMMENT '电子券ID', `e_coupon_name` varchar(128) NOT NULL DEFAULT '' COMMENT '电子券名称', `clerk_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销员', `clerk_admin_id` int(11) DEFAULT '0' COMMENT '核销管理员', `proper_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '专有者', `receive_time` int(11) NOT NULL DEFAULT '0' COMMENT '领取时间', `usage_time` int(11) NOT NULL DEFAULT '0' COMMENT '使用时间', `amount` int(11) NOT NULL DEFAULT '0' COMMENT '使用数量', `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`), KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='电子券使用记录'; CREATE TABLE `qimall_addons_electron_coupon_user_coupon` ( `id` int(11) NOT NULL AUTO_INCREMENT, `e_coupon_id` int(11) NOT NULL COMMENT '电子券id', `receive_begin_time` int(11) DEFAULT '0' COMMENT '领取开始时间', `receive_end_time` int(11) DEFAULT '0' COMMENT '领取结束时间', `use_begin_time` int(11) DEFAULT '0' COMMENT '使用开始时间', `use_end_time` int(11) DEFAULT '0' COMMENT '使用结束时间', `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '金额', `get_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '获取方式,1是领取,2是购买商品获得,3是系统发放', `use_way` tinyint(4) NOT NULL DEFAULT '1' COMMENT '适用范围;1扫描核销', `receive_times` int(11) NOT NULL DEFAULT '0' COMMENT '领取次数', `receive_amount` int(11) NOT NULL DEFAULT '0' COMMENT '领取数量;未激活', `active_amount` int(11) NOT NULL DEFAULT '0' COMMENT '激活数量;', `used_amount` int(11) NOT NULL DEFAULT '0' COMMENT '兑换数量;即使用数量', `num` int(11) NOT NULL DEFAULT '0' COMMENT '电子卷总数', `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id', `user_id` int(11) NOT NULL COMMENT '用户id', `last_used_time` int(11) DEFAULT '0' COMMENT '最新兑换时间', `last_receive_time` int(11) DEFAULT '0' COMMENT '最新领取时间', `last_active_time` int(11) DEFAULT '0' COMMENT '最新激活时间', `is_proper` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否专有券', `giver_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '赠送者id', `proper_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '专有者id', `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]', PRIMARY KEY (`id`), KEY `mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='会员电子券';