CREATE TABLE `qimall_addons_secondary_card` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `mall_id` int(10) unsigned NOT NULL, `name` varchar(150) NOT NULL DEFAULT '' COMMENT '次卡名称', `font_color` varchar(255) NOT NULL DEFAULT '' COMMENT '字体颜色', `background_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '次卡背景类型,0:默认背景,1:自定义', `background` varchar(255) NOT NULL DEFAULT '' COMMENT '次卡背景', `total_redemption` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '累计兑卡张数', `total_sales` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '累计售卡数', `total_sales_price` decimal(14, 2) unsigned NOT NULL DEFAULT '0.00' COMMENT '累计售卡金额', `sell_time_start` int(11) NOT NULL DEFAULT '0' COMMENT '售卖开始时间', `sell_time_end` int(11) NOT NULL DEFAULT '0' COMMENT '售卖结束时间', `expire_type` tinyint(1) NOT NULL DEFAULT '2' COMMENT '次卡有效期类型:1=购买时起N天内有效,2=指定有效期', `begin_at` varchar(255) NOT NULL DEFAULT '' COMMENT '有效期开始时间', `end_at` varchar(255) NOT NULL DEFAULT '' COMMENT '有效期结束时间', `expire_day` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '有效天数,expire_type=1时', `price` decimal(12, 2) unsigned DEFAULT '0.00' COMMENT '售价', `original_price` decimal(12, 2) unsigned DEFAULT '0.00' COMMENT '原价', `verifiable_times` bigint(20) unsigned DEFAULT '0' COMMENT '可核销次数', `max_times` bigint(20) unsigned DEFAULT '0' COMMENT '最大开卡数', `virtual_sales` bigint(20) unsigned DEFAULT '0' COMMENT '虚拟销量', `service` text COMMENT '卡服务设置', `reservation_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否需要预约,0:不需要,1:需要', `reservation_model` tinyint(1) NOT NULL DEFAULT '1' COMMENT '预约模式:1:预约门店;2:预约服务人', `reservation_service_type` tinyint(1) NOT NULL DEFAULT '2' COMMENT '服务方式:1:上门服务;2:到店服务;3:上门/到店', `reservation_day` varchar(255) NOT NULL DEFAULT '' COMMENT '可预约日期:0-6对应周日至周六', `reservation_time_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '可预约时间段类型:1:指定时间段;2:整天', `reservation_time` text COMMENT '预约时间段', `appointment_interval_duration` int(11) NOT NULL DEFAULT '0' COMMENT '项目时间', `reservation_cancel_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '预约取消:1:不允许取消;2:服务开始前N小时,取消并扣除m次可服务数', `reservation_cancel_hour` int(11) NOT NULL DEFAULT '0' COMMENT '服务开始前N小时', `reservation_cancel_deduct` int(11) NOT NULL DEFAULT '0' COMMENT '取消并扣除m次可服务数', `reservation_limit_people` int(11) NOT NULL DEFAULT '0' COMMENT '同时段可预约N人', `reservation_limit_repeat` int(11) NOT NULL DEFAULT '0' COMMENT '反复预约限制N次', `refund_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '退款类型,0:未使用到期自动退,1:不允许退款,2:允许退款', `limit_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '限购类型,0:不限开卡次数(用户可重复开卡,不限制领卡次数),1:有效期内限开卡次数', `limit_times` int(11) NOT NULL DEFAULT '0' COMMENT 'limit_type==1,次数,领取次数仅统计用户领卡的次数,不统计商家发卡', `create_source_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '创建来源类型:0:平台;1:门店', `create_source_id` int(11) NOT NULL DEFAULT '0' COMMENT '创建来源id', `is_on_sales` tinyint(1) NOT NULL DEFAULT '1' COMMENT '卡次状态:0:下架;1:正常', `rule` text COMMENT '使用规则', `store_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '店铺类型:1:o2o门店', `use_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '使用范围:0:全部店铺;1:指定店铺', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用;]', `created_at` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` bigint(20) unsigned NOT NULL DEFAULT '0', `applet_code` varchar(255) NOT NULL DEFAULT '' COMMENT '小程序推广码', PRIMARY KEY (`id`) USING BTREE, KEY `idx_mall_id` (`mall_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='次卡'; CREATE TABLE `qimall_addons_secondary_card_order` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `mall_id` int(10) unsigned NOT NULL, `user_id` int(11) unsigned NOT NULL COMMENT '会员id', `secondary_card_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '次卡id', `use_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '使用范围:0:全部店铺;1:指定店铺', `order_no` varchar(255) NOT NULL DEFAULT '' COMMENT '次卡号', `clerk_code` varchar(12) NOT NULL DEFAULT '' COMMENT '核销码', `order_status` tinyint(1) DEFAULT '0' COMMENT '状态:0:待核销;1:已失效;2:已过期;3:已退款;4:已停卡', `open_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '开卡时间:需要支付时,支付时间', `open_type` tinyint(20) unsigned NOT NULL DEFAULT '1' COMMENT '开卡方式:1:下单购买;2:兑换码兑换', `pay_money` decimal(12, 2) unsigned NOT NULL DEFAULT '0.00' COMMENT '购卡实收金额', `pay_type` int(1) NOT NULL DEFAULT '0' COMMENT '支付方式:1=微信支付,2=货到付款,3=余额支付,4=支付宝支付,5=银联支付,6=汇聚聚合支付,7=汇聚快捷支付', `expire_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '过期时间', `refund_source` tinyint(1) NOT NULL DEFAULT '0' COMMENT '退款来源:1:会员申请;2:过期,后台操作退款', `refund_money` decimal(12, 2) unsigned NOT NULL DEFAULT '0.00' COMMENT '退款金额', `refund_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '退款时间', `verifiable_times` int(11) NOT NULL DEFAULT '0' COMMENT '可核销次数', `code` varchar(255) NOT NULL DEFAULT '' COMMENT '兑换码', `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用;]', `created_at` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` bigint(20) unsigned NOT NULL DEFAULT '0', `trade_id` int(11) NOT NULL DEFAULT '0' COMMENT '流水表ID', `start_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '有效期开始时间', `create_source_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '创建来源类型:0:平台;1:门店', `create_source_id` int(11) NOT NULL DEFAULT '0' COMMENT '创建来源id', PRIMARY KEY (`id`) USING BTREE, KEY `idx_mall_id` (`mall_id`) USING BTREE, KEY `idx_secondary_card_id` (`secondary_card_id`) USING BTREE, KEY `idx_order_no` (`order_no`) USING BTREE, KEY `idx_clerk_code` (`clerk_code`) USING BTREE, KEY `idx_trade_id` (`trade_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开卡记录'; CREATE TABLE `qimall_addons_secondary_card_redemption_code` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `mall_id` int(10) unsigned NOT NULL, `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id', `code` varchar(255) NOT NULL DEFAULT '' COMMENT '兑换码', `remarks` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', `secondary_card_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '次卡id', `is_use` tinyint(1) DEFAULT '0' COMMENT '状态:0:未使用;1:已使用', `use_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '使用时间', `order_no` varchar(255) NOT NULL DEFAULT '' COMMENT '兑换次卡号', `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用;]', `created_at` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` bigint(20) unsigned NOT NULL DEFAULT '0', `use_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '使用范围:0:全部店铺;1:指定店铺', `create_source_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '创建来源类型:0:平台;1:门店', `create_source_id` int(11) NOT NULL DEFAULT '0' COMMENT '创建来源id', PRIMARY KEY (`id`) USING BTREE, KEY `idx_mall_id` (`mall_id`) USING BTREE, KEY `idx_secondary_card_id` (`secondary_card_id`) USING BTREE, KEY `idx_mall_id_code` (`mall_id`,`code`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='兑换码管理'; CREATE TABLE `qimall_addons_secondary_card_relate_store` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `mall_id` int(10) unsigned NOT NULL, `create_source_type` tinyint(3) NOT NULL DEFAULT '0' COMMENT '创建来源类型:0:平台;1:门店', `store_type` tinyint(3) NOT NULL DEFAULT '1' COMMENT '店铺类型:1:o2o门店', `secondary_card_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '次卡id', `store_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '门店id', `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用;]', `created_at` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` bigint(20) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`) USING BTREE, KEY `idx_mall_id` (`mall_id`) USING BTREE, KEY `idx_secondary_card_id` (`secondary_card_id`) USING BTREE, KEY `idx_secondary_type_store_id` (`store_type`,`store_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='次卡关联门店'; CREATE TABLE `qimall_addons_secondary_card_reservation_service` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `mall_id` int(10) unsigned NOT NULL COMMENT '商城ID', `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID', `secondary_card_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '绑定的次卡ID', `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态0禁用,-1删除,1正常', `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, KEY `user_id` (`user_id`) USING BTREE, KEY `secondary_card_id` (`secondary_card_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='技师绑定的次卡项目'; CREATE TABLE `qimall_addons_secondary_card_use_log` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `mall_id` int(10) unsigned NOT NULL, `user_id` int(11) unsigned NOT NULL COMMENT '会员id', `order_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'order_id', `secondary_card_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '次卡id', `order_no` varchar(255) NOT NULL DEFAULT '' COMMENT '兑换次卡号', `clerk_nums` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '单次核销数', `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '类型:1:o2o门店;', `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '核销门店id', `status` tinyint(1) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用;]', `open_time` int(11) NOT NULL DEFAULT '0' COMMENT '开卡时间', `created_at` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` bigint(20) unsigned NOT NULL DEFAULT '0', `clerk_money` decimal(12, 2) NOT NULL DEFAULT '0.00' COMMENT '订单核销金额', `clerk_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '核销人user_id', `reservation_service_order_id` int(11) NOT NULL DEFAULT '0' COMMENT '预约服务插件,服务订单id', `service_income` decimal(12, 2) NOT NULL DEFAULT '0.00' COMMENT '技师服务收入', `clerk_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '核销类型:1:门店核销;2:技师核销', `clerk_log_id` int(11) NOT NULL DEFAULT '0' COMMENT '公共核销记录id', PRIMARY KEY (`id`) USING BTREE, KEY `idx_mall_id` (`mall_id`) USING BTREE, KEY `idx_secondary_card_id` (`secondary_card_id`) USING BTREE, KEY `idx_order_id` (`order_id`) USING BTREE, KEY `idx_reservation_service_order_id` (`reservation_service_order_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='使用记录';