1_20240227.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*增加店铺表,同时为相关表添加店铺id*/
  2. /*增加店铺表*/
  3. CREATE TABLE `sale_shop` (
  4. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '店铺id',
  5. `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '店铺名称',
  6. `status` tinyint NOT NULL DEFAULT 1 COMMENT '店铺状态',
  7. `merchant_id` bigint NOT NULL DEFAULT 0 COMMENT '商户id',
  8. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  9. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  10. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  11. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  12. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  13. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  14. PRIMARY KEY (`id`) USING BTREE
  15. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;
  16. ALTER TABLE product_property ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 商品属性项表加店铺id
  17. ALTER TABLE product_property_value ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 商品属性值表加店铺id
  18. ALTER TABLE product_spu ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 商品SPU表加店铺id
  19. ALTER TABLE product_sku ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 商品SKU表加店铺id
  20. ALTER TABLE trade_order ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 订单主表加店铺id
  21. ALTER TABLE product_comment ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 商品评价表加店铺id
  22. ALTER TABLE trade_after_sale ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 售后订单表加店铺id
  23. ALTER TABLE trade_delivery_express_template ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 快递运费模板主表加店铺id
  24. ALTER TABLE trade_delivery_pick_up_store ADD COLUMN shop_id bigint COMMENT '店铺id'; -- 自提门店表加店铺id
  25. /*增加商户表*/
  26. CREATE TABLE `sale_merchant` (
  27. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商户id',
  28. `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商户名称',
  29. `status` tinyint NOT NULL DEFAULT 1 COMMENT '商户状态,关联商户状态表',
  30. `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '简介',
  31. `contact` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '负责人',
  32. `address` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '详细地址',
  33. `contact_number` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '负责人电话',
  34. `website` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '官网',
  35. `complaints_hotline` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '维权电话',
  36. `customer_service_hotline` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '客服电话',
  37. `email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '邮箱',
  38. `business_license_picture` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '营业执照图片路径',
  39. `expire_time` datetime NULL COMMENT '服务到期时间',
  40. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  41. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  42. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  43. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  44. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  45. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  46. PRIMARY KEY (`id`) USING BTREE
  47. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;
  48. ALTER TABLE product_property ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 商品属性项表加商户id
  49. ALTER TABLE product_property_value ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 商品属性值表加商户id
  50. ALTER TABLE product_spu ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 商品SPU表加商户id
  51. ALTER TABLE product_sku ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 商品SKU表加商户id
  52. ALTER TABLE trade_order ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 订单主表加商户id
  53. ALTER TABLE product_comment ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 商品评价表加商户id
  54. ALTER TABLE trade_after_sale ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 售后订单表加商户id
  55. ALTER TABLE trade_delivery_express_template ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 快递运费模板主表加商户id
  56. ALTER TABLE trade_delivery_pick_up_store ADD COLUMN merchant_id bigint COMMENT '商户id'; -- 自提门店表加商户id
  57. ALTER TABLE product_spu ADD COLUMN hidden bit(1) NOT NULL DEFAULT b'0' COMMENT '是否隐藏。隐藏:1,不隐藏:0'; -- 控制商品是否显示。
  58. /*增加店铺状态表*/
  59. CREATE TABLE `sale_shop_status` (
  60. `id` bigint NOT NULL COMMENT 'id',
  61. `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
  62. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  63. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  64. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  65. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  66. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  67. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  68. PRIMARY KEY (`id`) USING BTREE
  69. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺状态表' ROW_FORMAT = Dynamic;
  70. INSERT INTO sale_shop_status (id,name) VALUES(1,'营业中');
  71. INSERT INTO sale_shop_status (id,name) VALUES(2,'暂停营业');
  72. INSERT INTO sale_shop_status (id,name) VALUES(3,'停用');
  73. commit;
  74. /*增加用户类型表*/
  75. CREATE TABLE `system_user_category` (
  76. `id` bigint NOT NULL COMMENT 'id',
  77. `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
  78. `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  79. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  80. `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  81. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  82. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  83. `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  84. PRIMARY KEY (`id`) USING BTREE
  85. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺状态表' ROW_FORMAT = Dynamic;
  86. INSERT INTO system_user_category (id,name) VALUES(1,'系统用户');
  87. INSERT INTO system_user_category (id,name) VALUES(5,'店铺用户');
  88. commit;
  89. /*用户表、角色、菜单表 添加用户类型字段。*/
  90. ALTER TABLE system_users ADD COLUMN category_id bigint NULL COMMENT '用户类型'; -- 用户表添加用户类型字段
  91. ALTER TABLE system_role ADD COLUMN category_id bigint NULL COMMENT '用户类型'; -- 角色表添加用户类型字段
  92. ALTER TABLE system_menu ADD COLUMN category_id bigint NULL COMMENT '用户类型'; -- 菜单表添加用户类型字段
  93. /*用户表system_users还要添加店铺ID、商户ID字段*/
  94. ALTER TABLE system_users ADD COLUMN shop_id bigint NULL COMMENT '店铺id';
  95. ALTER TABLE system_users ADD COLUMN merchant_id bigint NULL COMMENT '商户id';
  96. ALTER TABLE `member_user` MODIFY COLUMN `future_member_worth_value` bigint(0) NULL DEFAULT NULL COMMENT '未来身价值,未来身价值=当前身价值+预增加身价值' AFTER `pre_added_member_worth_value`;
  97. ALTER TABLE `sale_merchant` ADD COLUMN `logo_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'logo地址' AFTER `id`;
  98. ALTER TABLE `sale_shop` ADD COLUMN `logo_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'logo地址' AFTER `id`;
  99. -- 修改spu以及sku表字段
  100. ALTER TABLE `product_sku` ADD COLUMN `Promotion_fee` int(0) NULL DEFAULT NULL COMMENT '推广费, 单位: 分' AFTER `price`;
  101. ALTER TABLE `product_sku` ADD COLUMN `mark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注' AFTER `Promotion_fee`;
  102. ALTER TABLE `product_spu` ADD COLUMN `producer_area` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '产地' AFTER `description`;
  103. ALTER TABLE `product_spu` ADD COLUMN `spu_type` bit(1) NULL DEFAULT NULL COMMENT '商品类别' AFTER `producer_area`;
  104. ALTER TABLE `member_user` MODIFY COLUMN `future_member_worth_value` bigint(0) NULL DEFAULT NULL COMMENT '未来身价值,未来身价值=当前身价值+预增加身价值' AFTER `pre_added_member_worth_value`;
  105. ALTER TABLE `sale_merchant` ADD COLUMN `logo_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'logo地址' AFTER `id`;
  106. ALTER TABLE `sale_shop` ADD COLUMN `logo_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'logo地址' AFTER `id`;
  107. -- 扩展商品sku表 推广费金额、推广费占比
  108. ALTER TABLE product_sku ADD COLUMN promotion_expenses int NULL COMMENT '推广费(以分为单位)';
  109. ALTER TABLE product_sku ADD COLUMN promotion_expenses_proportion int NULL COMMENT '推广费占比,推广费占比=推广费/销售价*100';
  110. -- 扩展商户表,增加“区域”字段,对应页面是省、市、区 级联菜单
  111. ALTER TABLE `sale_merchant` ADD COLUMN `area_id` bigint NULL DEFAULT NULL COMMENT '区域id,对应文件系统 src/main/resources/area.csv 中的id一列';
  112. ALTER TABLE `sale_shop` ADD COLUMN `website` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '店铺域名' AFTER `deleted`;
  113. ALTER TABLE `sale_merchant` MODIFY COLUMN `website` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '域名' AFTER `contact_number`;
  114. ALTER TABLE `sale_merchant` ADD COLUMN `business_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商户官网' AFTER `website`;
  115. -- 2024 04 01 给商户模板diy页面以及模板页面添加商户ID以及店铺ID
  116. ALTER TABLE `promotion_diy_template` ADD COLUMN `merchant_id` bigint(0) NULL DEFAULT NULL COMMENT '商户ID' AFTER `deleted`;
  117. ALTER TABLE `promotion_diy_template` ADD COLUMN `shop_id` bigint(0) NULL DEFAULT NULL COMMENT '店铺ID' AFTER `merchant_id`;
  118. ALTER TABLE `promotion_diy_page` ADD COLUMN `shop_id` bigint(0) NULL DEFAULT NULL COMMENT '店铺ID' AFTER `deleted`;
  119. ALTER TABLE `promotion_diy_page` ADD COLUMN `merchant_id` bigint(0) NULL DEFAULT NULL COMMENT '商户ID' AFTER `shop_id`;