install.sql 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. -- ----------------------------
  2. -- Table structure for qimall_addons_coupon
  3. -- ----------------------------
  4. DROP TABLE IF EXISTS `qimall_addons_coupon`;
  5. CREATE TABLE `qimall_addons_coupon` (
  6. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  7. `mall_id` int(10) UNSIGNED NOT NULL,
  8. `mch_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户id',
  9. `store_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '门店id',
  10. `name` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '优惠券名称',
  11. `type` tinyint(1) NOT NULL DEFAULT 2 COMMENT '优惠券类型,1:折扣,2:满减',
  12. `discount` decimal(3, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '折扣率',
  13. `discount_limit` decimal(10, 2) UNSIGNED NULL DEFAULT NULL COMMENT '折扣优惠金额上限',
  14. `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '优惠券图片(未使用)',
  15. `desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '优惠券简述(未使用)',
  16. `min_price` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '最低消费金额',
  17. `sub_price` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '优惠金额',
  18. `total_count` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '优惠券总数量',
  19. `sort` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序按升序排列',
  20. `expire_type` tinyint(1) NOT NULL DEFAULT 2 COMMENT '到期类型:1=领取后n天过期,2=指定有效期,3=领取后n天生效,生效后m天过期',
  21. `expire_day` int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT '有效天数,expire_type=1和3时',
  22. `effect_days` tinyint(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT '领取到生效之间间隔的天数(领取后n天生效)',
  23. `begin_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '有效期开始时间',
  24. `end_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '有效期结束时间',
  25. `appoint_type` tinyint(4) NOT NULL DEFAULT 3 COMMENT '1 指定分类 2 指定商品 3全部',
  26. `rule` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '使用说明',
  27. `is_remind` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否开启提醒',
  28. `remind_days` tinyint(4) NOT NULL DEFAULT 3 COMMENT '提前提醒天数(到期前多少天提醒),is_remind=1 时有效',
  29. `is_receive_limit` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否限制领取',
  30. `receive_count` int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT '每人可以领取的数量,is_receive_limit=1时有意义',
  31. `is_member` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否指定会员等级',
  32. `is_original_use` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否原价购买使用(如果是,则只有原价购买商品时可以使用该优惠券)',
  33. `is_public_receive` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否公开领取,公开领取的优惠券会展示在商品详情页',
  34. `is_giving` tinyint(1) NOT NULL DEFAULT 0 COMMENT '启用优惠券转送功能:0-否;1-是;',
  35. `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  36. `coupon_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '优惠券状态,1:未开始,2:领取中,3:已过期,4:已失效(后台操作失效)',
  37. `is_giving_reward` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否开启转赠奖励,开启后转赠优惠券自己可以获得额外奖励;is_giving=1 时有效',
  38. `is_consume_reward` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否开启使用奖励,开启后使用该优惠券可以获得额外奖励;is_giving=1 时有效',
  39. `qrcode_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '优惠券分享二维码保存路径,二维码包含内容:页面路径+优惠券id',
  40. `poster_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '优惠券分享海报图片保存路径',
  41. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  42. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  43. PRIMARY KEY (`id`) USING BTREE,
  44. INDEX `idx_mall_id`(`mall_id`) USING BTREE,
  45. INDEX `idx_type`(`type`) USING BTREE,
  46. INDEX `idx_sort`(`sort`) USING BTREE,
  47. INDEX `idx_expire_time`(`begin_at`, `end_at`) USING BTREE
  48. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '优惠券' ROW_FORMAT = Dynamic;
  49. -- ----------------------------
  50. -- Table structure for qimall_addons_coupon_cat_relate
  51. -- ----------------------------
  52. DROP TABLE IF EXISTS `qimall_addons_coupon_cat_relate`;
  53. CREATE TABLE `qimall_addons_coupon_cat_relate` (
  54. `id` int(11) NOT NULL AUTO_INCREMENT,
  55. `coupon_id` int(11) NOT NULL COMMENT '优惠券id',
  56. `cate_id` int(11) NOT NULL COMMENT '分类id',
  57. `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  58. `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  59. PRIMARY KEY (`id`) USING BTREE
  60. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '分类下相关优惠券' ROW_FORMAT = DYNAMIC;
  61. -- ----------------------------
  62. -- Table structure for qimall_addons_coupon_give_item_setting
  63. -- ----------------------------
  64. DROP TABLE IF EXISTS `qimall_addons_coupon_give_item_setting`;
  65. CREATE TABLE `qimall_addons_coupon_give_item_setting` (
  66. `id` int(11) NOT NULL AUTO_INCREMENT,
  67. `mall_id` int(11) NOT NULL COMMENT '商城ID',
  68. `is_enable` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否独立设置:0:否;1是',
  69. `item_id` int(11) NOT NULL DEFAULT 0 COMMENT '项目id',
  70. `item_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '项目类型:商品goods',
  71. `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  72. `created_at` int(11) NOT NULL DEFAULT 0,
  73. `updated_at` int(11) NOT NULL DEFAULT 0,
  74. PRIMARY KEY (`id`) USING BTREE,
  75. INDEX `mall_id`(`mall_id`) USING BTREE
  76. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '优惠券项目赠送设置' ROW_FORMAT = DYNAMIC;
  77. -- ----------------------------
  78. -- Table structure for qimall_addons_coupon_give_item_setting_detail
  79. -- ----------------------------
  80. DROP TABLE IF EXISTS `qimall_addons_coupon_give_item_setting_detail`;
  81. CREATE TABLE `qimall_addons_coupon_give_item_setting_detail` (
  82. `id` int(11) NOT NULL AUTO_INCREMENT,
  83. `mall_id` int(11) NOT NULL COMMENT '商城ID',
  84. `coupon_give_item_setting_id` int(11) NOT NULL DEFAULT 0 COMMENT '设置id',
  85. `coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT '优惠券id',
  86. `num` int(11) NOT NULL DEFAULT 0 COMMENT '赠送数量',
  87. `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  88. `created_at` int(11) NOT NULL DEFAULT 0,
  89. `updated_at` int(11) NOT NULL DEFAULT 0,
  90. PRIMARY KEY (`id`) USING BTREE,
  91. INDEX `mall_id`(`mall_id`) USING BTREE
  92. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '优惠券项目赠送设置详情' ROW_FORMAT = DYNAMIC;
  93. -- ----------------------------
  94. -- Table structure for qimall_addons_coupon_good_statistics
  95. -- ----------------------------
  96. DROP TABLE IF EXISTS `qimall_addons_coupon_good_statistics`;
  97. CREATE TABLE `qimall_addons_coupon_good_statistics` (
  98. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  99. `mall_id` int(10) UNSIGNED NOT NULL,
  100. `coupon_id` int(10) UNSIGNED NOT NULL,
  101. `good_id` int(10) UNSIGNED NOT NULL,
  102. `booking_number` int(11) NOT NULL DEFAULT 0 COMMENT '该商品使用该优惠券下单的总数量',
  103. `payed_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '使用该优惠券已支付的该商品数量',
  104. `booking_user_number` int(11) NOT NULL DEFAULT 0 COMMENT '该商品使用该优惠券下单的总人数',
  105. `buyed_user_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '使用该优惠券已购买该商品人数',
  106. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  107. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  108. PRIMARY KEY (`id`) USING BTREE,
  109. INDEX `idx_mall_coupon_id`(`mall_id`, `coupon_id`) USING BTREE
  110. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '使用优惠券购买的商品的相关数据统计' ROW_FORMAT = DYNAMIC;
  111. -- ----------------------------
  112. -- Table structure for qimall_addons_coupon_goods_relate
  113. -- ----------------------------
  114. DROP TABLE IF EXISTS `qimall_addons_coupon_goods_relate`;
  115. CREATE TABLE `qimall_addons_coupon_goods_relate` (
  116. `id` int(11) NOT NULL AUTO_INCREMENT,
  117. `coupon_id` int(11) NOT NULL COMMENT '优惠券id',
  118. `goods_id` int(11) NOT NULL COMMENT '商品id',
  119. `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  120. `updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
  121. PRIMARY KEY (`id`) USING BTREE
  122. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品优惠券表' ROW_FORMAT = DYNAMIC;
  123. -- ----------------------------
  124. -- Table structure for qimall_addons_coupon_member_relate
  125. -- ----------------------------
  126. DROP TABLE IF EXISTS `qimall_addons_coupon_member_relate`;
  127. CREATE TABLE `qimall_addons_coupon_member_relate` (
  128. `id` int(11) NOT NULL AUTO_INCREMENT,
  129. `mall_id` int(11) NOT NULL,
  130. `coupon_id` int(11) NOT NULL COMMENT '优惠券id',
  131. `member_level` int(11) NOT NULL COMMENT '会员等级',
  132. `created_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
  133. `updated_at` int(11) NOT NULL DEFAULT 0,
  134. PRIMARY KEY (`id`) USING BTREE
  135. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员等级下优惠券表' ROW_FORMAT = DYNAMIC;
  136. -- ----------------------------
  137. -- Table structure for qimall_addons_coupon_remind
  138. -- ----------------------------
  139. DROP TABLE IF EXISTS `qimall_addons_coupon_remind`;
  140. CREATE TABLE `qimall_addons_coupon_remind` (
  141. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  142. `mall_id` int(10) UNSIGNED NOT NULL,
  143. `coupon_id` int(10) UNSIGNED NOT NULL,
  144. `user_id` int(10) UNSIGNED NOT NULL,
  145. `expire_time` int(10) UNSIGNED NOT NULL,
  146. `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态[-1:删除;0:禁用;1启用]',
  147. `send_status` tinyint(4) NOT NULL DEFAULT 2 COMMENT '提醒状态,1:未发送提醒,2:已发送提醒,3:不需要发送提醒,已使用或者已转赠或者优惠券已过期或者优惠券已经失效',
  148. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  149. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  150. PRIMARY KEY (`id`) USING BTREE,
  151. INDEX `idx_mall_coupon_user_id`(`mall_id`, `coupon_id`, `user_id`) USING BTREE
  152. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '优惠券过期提醒记录表' ROW_FORMAT = DYNAMIC;
  153. -- ----------------------------
  154. -- Table structure for qimall_addons_coupon_reward
  155. -- ----------------------------
  156. DROP TABLE IF EXISTS `qimall_addons_coupon_reward`;
  157. CREATE TABLE `qimall_addons_coupon_reward` (
  158. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  159. `mall_id` int(10) UNSIGNED NOT NULL,
  160. `coupon_id` int(10) UNSIGNED NOT NULL COMMENT '优惠券id',
  161. `reward_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '奖励类型,1:转赠奖励,2:使用奖励',
  162. `balance` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '奖励余额',
  163. `score` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '奖励积分',
  164. `red_packet` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '奖励红包',
  165. `reward_currency_type` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '奖励货币种类,记录货币 code',
  166. `number` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '奖励货币数量',
  167. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  168. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  169. PRIMARY KEY (`id`) USING BTREE,
  170. INDEX `idx_mallcoupon_id`(`mall_id`, `coupon_id`) USING BTREE
  171. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '优惠券奖励记录表' ROW_FORMAT = DYNAMIC;
  172. -- ----------------------------
  173. -- Table structure for qimall_addons_coupon_reward_log
  174. -- ----------------------------
  175. DROP TABLE IF EXISTS `qimall_addons_coupon_reward_log`;
  176. CREATE TABLE `qimall_addons_coupon_reward_log` (
  177. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  178. `mall_id` int(10) UNSIGNED NOT NULL,
  179. `user_id` int(10) UNSIGNED NOT NULL,
  180. `coupon_id` int(10) UNSIGNED NOT NULL COMMENT '优惠券id',
  181. `reward_number` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '奖励数额',
  182. `reward_scenarios` tinyint(4) NOT NULL DEFAULT 0 COMMENT '奖励场景,1:转赠奖励,2:使用奖励',
  183. `reward_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '奖励类型,1:余额,2:红包,3:积分,4:系统虚拟货币',
  184. `reward_type_code` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '奖励类型代码,balance:余额,red_packet:红包,score:积分,如果是虚拟货币,则记录其 code',
  185. `source_table` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '数据来源表',
  186. `source_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '数据来源id',
  187. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  188. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  189. PRIMARY KEY (`id`) USING BTREE,
  190. INDEX `idx_mall_user_coupon_id`(`mall_id`, `user_id`, `coupon_id`) USING BTREE
  191. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '优惠券奖励发放记录' ROW_FORMAT = DYNAMIC;
  192. -- ----------------------------
  193. -- Table structure for qimall_addons_coupon_share_log
  194. -- ----------------------------
  195. DROP TABLE IF EXISTS `qimall_addons_coupon_share_log`;
  196. CREATE TABLE `qimall_addons_coupon_share_log` (
  197. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  198. `mall_id` int(10) UNSIGNED NOT NULL,
  199. `coupon_id` int(10) UNSIGNED NOT NULL,
  200. `user_coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT '赠送者coupon_user_relate表的id',
  201. `get_user_coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT '领取者coupon_user_relate表的id',
  202. `giving_user_id` int(10) UNSIGNED NOT NULL COMMENT '转出会员id,值为 0 说明是平台赠送的优惠券',
  203. `receive_user_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '受赠会员id,尚未被领取此字段值为0',
  204. `giving_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '转赠状态,1:转赠中(已分享出去,未被领取),2:已被领取',
  205. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  206. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  207. PRIMARY KEY (`id`) USING BTREE,
  208. INDEX `idx_mall_coupon_id`(`mall_id`, `coupon_id`) USING BTREE,
  209. INDEX `idx_gr_user_id`(`giving_user_id`, `receive_user_id`) USING BTREE
  210. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '优惠券分享记录表' ROW_FORMAT = DYNAMIC;
  211. -- ----------------------------
  212. -- Table structure for qimall_addons_coupon_statistics
  213. -- ----------------------------
  214. DROP TABLE IF EXISTS `qimall_addons_coupon_statistics`;
  215. CREATE TABLE `qimall_addons_coupon_statistics` (
  216. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  217. `mall_id` int(10) UNSIGNED NOT NULL,
  218. `coupon_id` int(10) UNSIGNED NOT NULL,
  219. `received_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已领取数量',
  220. `used_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已使用数量',
  221. `giveing_times` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '优惠券被转赠的次数',
  222. `use_probability` decimal(5, 2) NOT NULL DEFAULT 0.00 COMMENT '优惠券使用率,等于领取数量比使用数量',
  223. `total_discount_amount` decimal(12, 2) NOT NULL DEFAULT 0.00 COMMENT '累计优惠金额',
  224. `receive_user_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '领券会员总数量',
  225. `use_user_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用券会员总数量',
  226. `giving_user_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '转赠优惠券的会员总数量',
  227. `use_order_number` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '使用优惠券支付的订单总数量',
  228. `total_use_coupon_payed_amount` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '使用优惠券后实际支付的总金额',
  229. `total_payed_amount` decimal(12, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '使用优惠券支付的订单原价总金额',
  230. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  231. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  232. PRIMARY KEY (`id`) USING BTREE,
  233. INDEX `idx_mall_coupon_id`(`mall_id`, `coupon_id`) USING BTREE
  234. ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '优惠券相关数据统计记录表' ROW_FORMAT = DYNAMIC;
  235. -- ----------------------------
  236. -- Table structure for qimall_addons_coupon_use_log
  237. -- ----------------------------
  238. DROP TABLE IF EXISTS `qimall_addons_coupon_use_log`;
  239. CREATE TABLE `qimall_addons_coupon_use_log` (
  240. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  241. `mall_id` int(11) NOT NULL DEFAULT 0 COMMENT 'mall_id',
  242. `user_id` int(11) NOT NULL DEFAULT 0 COMMENT 'user_id',
  243. `order_id` int(11) NOT NULL DEFAULT 0 COMMENT 'order_id',
  244. `coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT 'coupon_id',
  245. `user_coupon_id` int(11) NOT NULL DEFAULT 0 COMMENT 'user_coupon_id',
  246. `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  247. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  248. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改时间',
  249. PRIMARY KEY (`id`) USING BTREE,
  250. INDEX `idx_user_coupon_id`(`user_coupon_id`) USING BTREE
  251. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '优惠券使用记录表' ROW_FORMAT = DYNAMIC;
  252. -- ----------------------------
  253. -- Table structure for qimall_addons_coupon_user_relate
  254. -- ----------------------------
  255. DROP TABLE IF EXISTS `qimall_addons_coupon_user_relate`;
  256. CREATE TABLE `qimall_addons_coupon_user_relate` (
  257. `id` int(11) NOT NULL AUTO_INCREMENT,
  258. `mall_id` int(11) NOT NULL,
  259. `user_id` int(11) NOT NULL COMMENT '用户',
  260. `coupon_id` int(11) NOT NULL COMMENT '优惠卷',
  261. `coupon_status` tinyint(4) NOT NULL DEFAULT 2 COMMENT '优惠券状态,2:领取中,3:已过期,4:已失效(后台操作失效、转赠被领取后、使用之后)',
  262. `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  263. `start_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '优惠券开始生效时间',
  264. `end_time` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '优惠券过期时间',
  265. `is_use` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已使用:0=未使用,1=已使用',
  266. `is_giving` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否已赠送:0-否;1-是;',
  267. `giving_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '转赠状态,0:未转赠,1:转赠中,2:已被领取(转赠完成)',
  268. `receive_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '获取方式,如\"商品详情页领取\"',
  269. `receive_platform` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'h5' COMMENT '领取来源,从哪个平台领取的,wechat:微信,mp-wx:微信小程序,h5,app,work-wx:企业微信',
  270. `is_force_failure` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否强制失效,后台操作用户已领取的优惠券失效',
  271. `is_send_reward` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否已经发放优惠券奖励,1:是,0:否',
  272. `created_at` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
  273. `updated_at` int(10) UNSIGNED NOT NULL DEFAULT 0,
  274. PRIMARY KEY (`id`) USING BTREE,
  275. INDEX `idx_cpid`(`coupon_id`) USING BTREE,
  276. INDEX `idx_cpstatus`(`coupon_status`) USING BTREE,
  277. INDEX `idx_user_id`(`user_id`) USING BTREE
  278. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户优惠券表' ROW_FORMAT = DYNAMIC;
  279. -- ----------------------------
  280. -- 插入定时任务表
  281. -- ----------------------------
  282. INSERT INTO `qimall_crontab_task`(`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES
  283. ('定时清理过期的优惠券', 'coupon-crontab/clear', 2, '0 */30 * * * *', 0, 0, 1638599725, 1640861509),
  284. ('自动更新优惠券状态', 'coupon/coupon-crontab/update-coupon-status', 2, '0 */1 * * * *', 0, 1, 1640861018, 1644290563),
  285. ('优惠券相关统计', 'coupon/coupon-crontab/coupon-statistics', 2, '0 */3 * * * *', 0, 1, 1640861071, 1644290607),
  286. ('统计商品使用优惠券相关数据', 'coupon/coupon-crontab/coupon-good-stat', 2, '0 */3 * * * *', 0, 1, 1640861143, 1644290634);
  287. alter table qimall_addons_coupon add `is_open_screen` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否开屏显示';