فهرست منبع

!265 商品模块 60%
Merge pull request !265 from 芋道源码/feature/1.8.0-uniapp

芋道源码 2 سال پیش
والد
کامیت
c8cc3a57f7
100فایلهای تغییر یافته به همراه4715 افزوده شده و 1347 حذف شده
  1. 85 0
      sql/optional/mall/coupon.sql
  2. 274 246
      sql/optional/mall/mall.sql
  3. 76 0
      sql/optional/mall/order.sql
  4. 39 0
      yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/TerminalEnum.java
  5. 17 0
      yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
  6. 211 80
      yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptor.java
  7. 205 42
      yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java
  8. 5 1
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java
  9. 6 2
      yudao-module-mall/pom.xml
  10. 35 0
      yudao-module-mall/yudao-module-coupon-api/pom.xml
  11. 29 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponExpireTimeTypeEnum.java
  12. 29 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponFetchTypeEnum.java
  13. 29 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponForbidPreferenceEnum.java
  14. 30 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponGoodsTypeEnum.java
  15. 30 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponStatusTypeEnum.java
  16. 30 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponTypeEnum.java
  17. 29 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponUseLimitEnum.java
  18. 29 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponValidityTypeEnum.java
  19. 27 0
      yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java
  20. 62 0
      yudao-module-mall/yudao-module-coupon-biz/pom.xml
  21. 88 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java
  22. 110 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponBaseVO.java
  23. 3 3
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponCreateReqVO.java
  24. 90 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponExcelVO.java
  25. 91 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponExportReqVO.java
  26. 93 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponPageReqVO.java
  27. 4 4
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponRespVO.java
  28. 18 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponUpdateReqVO.java
  29. 81 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/CouponTempleteController.java
  30. 172 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteBaseVO.java
  31. 12 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteCreateReqVO.java
  32. 119 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteExcelVO.java
  33. 119 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteExportReqVO.java
  34. 122 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempletePageReqVO.java
  35. 19 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteRespVO.java
  36. 17 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteUpdateReqVO.java
  37. 38 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/convert/CouponTemplete/CouponTempleteConvert.java
  38. 34 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/convert/coupon/CouponConvert.java
  39. 158 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/dataobject/CouponTemplete/CouponTempleteDO.java
  40. 118 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/dataobject/coupon/CouponDO.java
  41. 98 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/mysql/CouponTemplete/CouponTempleteMapper.java
  42. 76 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/mysql/coupon/CouponMapper.java
  43. 6 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/package-info.java
  44. 70 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteService.java
  45. 134 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java
  46. 70 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java
  47. 107 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java
  48. 12 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/resources/mapper/CouponTemplete/CouponTempleteMapper.xml
  49. 12 0
      yudao-module-mall/yudao-module-coupon-biz/src/main/resources/mapper/coupon/CouponMapper.xml
  50. 7 0
      yudao-module-mall/yudao-module-market-api/pom.xml
  51. 21 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/PriceApi.java
  52. 56 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/dto/PriceCalculateReqDTO.java
  53. 202 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/dto/PriceCalculateRespDTO.java
  54. 0 51
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/activity/MarketActivityStatusEnum.java
  55. 0 44
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/activity/MarketActivityTypeEnum.java
  56. 39 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionActivityStatusEnum.java
  57. 37 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionConditionTypeEnum.java
  58. 37 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionLevelEnum.java
  59. 38 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionProductScopeEnum.java
  60. 37 0
      yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionTypeEnum.java
  61. 0 25
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/MarketTestController.java
  62. 0 77
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/ActivityController.java
  63. 0 59
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityBaseVO.java
  64. 0 17
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityCreateReqVO.java
  65. 0 57
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityPageReqVO.java
  66. 0 18
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityUpdateReqVO.java
  67. 4 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/discount/package-info.java
  68. 0 32
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/activity/ActivityConvert.java
  69. 4 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/discount/package-info.java
  70. 0 64
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/activity/ActivityDO.java
  71. 55 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/discount/DiscountActivityDO.java
  72. 65 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/discount/DiscountProductDO.java
  73. 116 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/reward/RewardActivityDO.java
  74. 0 35
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/activity/ActivityMapper.java
  75. 4 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/discount/package-info.java
  76. 3 3
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/package-info.java
  77. 0 62
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/activity/ActivityService.java
  78. 0 77
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/activity/ActivityServiceImpl.java
  79. 4 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/discount/package-info.java
  80. 24 0
      yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/price/PriceApiImpl.java
  81. 0 197
      yudao-module-mall/yudao-module-market-biz/src/test/java/cn/iocoder/yudao/module/market/service/activity/ActivityServiceImplTest.java
  82. 30 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java
  83. 45 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuDecrementStockBatchReqDTO.java
  84. 93 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuInfoRespDTO.java
  85. 23 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java
  86. 124 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/SpuInfoRespDTO.java
  87. 19 11
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java
  88. 38 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java
  89. 38 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/delivery/DeliveryTypeEnum.java
  90. 38 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/group/ProductGroupStyleEnum.java
  91. 37 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuSpecTypeEnum.java
  92. 38 0
      yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java
  93. 2 8
      yudao-module-mall/yudao-module-product-biz/pom.xml
  94. 1 0
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java
  95. 26 0
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java
  96. 20 0
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java
  97. 22 29
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java
  98. 0 45
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/BrandExcelVO.java
  99. 0 28
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/BrandExportReqVO.java
  100. 0 30
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/BrandPageReqVO.java

+ 85 - 0
sql/optional/mall/coupon.sql

@@ -0,0 +1,85 @@
+DROP TABLE IF EXISTS `coupon`;
+CREATE TABLE `coupon`
+(
+    `id`                        bigint                                                         NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+    `type`                      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '优惠券类型 reward-满减 discount-折扣 random-随机',
+    `name`                      varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   NOT NULL COMMENT '优惠券名称',
+    `coupon_type_id`            bigint UNSIGNED                                                         DEFAULT 0 COMMENT '优惠券类型id',
+    `coupon_code`               varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT '优惠券编码',
+    `member_id`                 bigint UNSIGNED                                                NOT NULL DEFAULT 0 COMMENT '领用人',
+    `use_order_id`              bigint UNSIGNED                                                NOT NULL DEFAULT 0 COMMENT '优惠券使用订单id',
+    `goods_type`                tinyint(1) UNSIGNED                                            NOT NULL DEFAULT 0 COMMENT '适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用',
+    `goods_ids`                 varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '适用商品id',
+    `at_least`                  decimal(10, 2) UNSIGNED                                        NOT NULL DEFAULT 0 COMMENT '最小金额',
+    `money`                     decimal(10, 2) UNSIGNED                                        NOT NULL DEFAULT 0 COMMENT '面额',
+    `discount`                  decimal(10, 2) UNSIGNED                                        NOT NULL DEFAULT 0 COMMENT '1 =< 折扣 <= 9.9 当type为discount时需要添加',
+    `discount_limit`            decimal(10, 2) UNSIGNED                                        NOT NULL DEFAULT 0 COMMENT '最多折扣金额 当type为discount时可选择性添加',
+    `whether_forbid_preference` tinyint(1) UNSIGNED                                            NOT NULL DEFAULT 0 COMMENT '优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用',
+    `whether_expire_notice`     tinyint(1) UNSIGNED                                            NOT NULL DEFAULT 0 COMMENT '是否开启过期提醒0-不开启 1-开启',
+    `expire_notice_fixed_term`  int(11) UNSIGNED                                               NOT NULL DEFAULT 0 COMMENT '过期前N天提醒',
+    `whether_noticed`           tinyint(1) UNSIGNED                                            NOT NULL DEFAULT 0 COMMENT '是否已提醒',
+    `state`                     tinyint(4) UNSIGNED                                            NOT NULL DEFAULT 0 COMMENT '优惠券状态 1已领用(未使用) 2已使用 3已过期',
+    `get_type`                  tinyint(1) UNSIGNED                                            NOT NULL DEFAULT 0 COMMENT '获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取',
+    `fetch_time`                datetime                                                       NOT NULL DEFAULT 0 COMMENT '领取时间',
+    `use_time`                  datetime                                                       NOT NULL DEFAULT 0 COMMENT '使用时间',
+    `start_time`                datetime                                                       NOT NULL DEFAULT 0 COMMENT '可使用的开始时间',
+    `end_time`                  datetime                                                       NOT NULL DEFAULT 0 COMMENT '有效期结束时间',
+    `creator`                   varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   NULL     DEFAULT '' COMMENT '创建者',
+    `create_time`               datetime                                                       NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    `updater`                   varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci   NULL     DEFAULT '' COMMENT '更新者',
+    `update_time`               datetime                                                       NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    `deleted`                   bit(1)                                                         NOT NULL DEFAULT b'0' COMMENT '是否删除',
+    `tenant_id`                 bigint                                                         NOT NULL DEFAULT 0 COMMENT '租户编号',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB
+  AUTO_INCREMENT = 119
+  CHARACTER SET = utf8mb4
+  COLLATE = utf8mb4_unicode_ci COMMENT = '优惠券';
+
+DROP TABLE IF EXISTS `coupon_templete`;
+CREATE TABLE `coupon_templete`
+(
+    `id`                        bigint                                                       NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+    `type`                      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '优惠券类型 reward-满减 discount-折扣 random-随机',
+    `name`                      varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '优惠券名称',
+    `coupon_name_remark`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '名称备注',
+    `image`                     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '优惠券图片',
+    `count`                     int(11)                                                      NOT NULL DEFAULT 0 COMMENT '发放数量',
+    `lead_count`                int(11)                                                      NOT NULL DEFAULT 0 COMMENT '已领取数量',
+    `used_count`                int(11) UNSIGNED                                             NOT NULL DEFAULT 0 COMMENT '已使用数量',
+    `goods_type`                tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 1 COMMENT '适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用',
+    `product_ids`               varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '适用商品id',
+    `has_use_limit`             tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 0 COMMENT '使用门槛0-无门槛 1-有门槛',
+    `at_least`                  decimal(10, 2)                                               NOT NULL DEFAULT 0 COMMENT '满多少元使用 0代表无限制',
+    `money`                     decimal(10, 2)                                               NOT NULL DEFAULT 0 COMMENT '发放面额 当type为reward时需要添加',
+    `discount`                  decimal(10, 2) UNSIGNED                                      NOT NULL DEFAULT 0 COMMENT '1 =< 折扣 <= 9.9 当type为discount时需要添加',
+    `discount_limit`            decimal(10, 2)                                               NOT NULL DEFAULT 0 COMMENT '最多折扣金额 当type为discount时可选择性添加',
+    `min_money`                 decimal(10, 2) UNSIGNED                                      NOT NULL DEFAULT 0 COMMENT '最低金额 当type为radom时需要添加',
+    `max_money`                 decimal(10, 2) UNSIGNED                                      NOT NULL DEFAULT 0 COMMENT '最大金额 当type为radom时需要添加',
+    `validity_type`             tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 0 COMMENT '过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期',
+    `start_use_time`            datetime COMMENT '使用开始日期 过期类型1时必填',
+    `end_use_time`              datetime COMMENT '使用结束日期 过期类型1时必填',
+    `fixed_term`                int(11) UNSIGNED                                             NOT NULL DEFAULT 0 COMMENT '当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效',
+    `whether_limitless`         tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 0 COMMENT '是否无限制0-否 1是',
+    `max_fetch`                 int(11) UNSIGNED                                             NOT NULL DEFAULT 0 COMMENT '每人最大领取个数',
+    `whether_expire_notice`     tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 0 COMMENT '是否开启过期提醒0-不开启 1-开启',
+    `expire_notice_fixed_term`  int(11) UNSIGNED                                             NOT NULL DEFAULT 0 COMMENT '过期前N天提醒',
+    `whether_forbid_preference` tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 0 COMMENT '优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用',
+    `whether_show`              int(11) UNSIGNED                                             NOT NULL DEFAULT 0 COMMENT '是否显示',
+    `discount_order_money`      decimal(10, 2) UNSIGNED                                      NOT NULL DEFAULT 0 COMMENT '订单的优惠总金额',
+    `order_money`               decimal(10, 2) UNSIGNED                                      NOT NULL DEFAULT 0 COMMENT '用券总成交额',
+    `whether_forbidden`         tinyint(1) UNSIGNED                                          NOT NULL DEFAULT 0 COMMENT '是否禁止发放0-否 1-是',
+    `order_goods_num`           int(11) UNSIGNED                                             NOT NULL DEFAULT 0 COMMENT '使用优惠券购买的商品数量',
+    `status`                    tinyint(11)                                                  NOT NULL DEFAULT 0 COMMENT '状态(1进行中2已结束-1已关闭)',
+    `end_time`                  datetime COMMENT '有效日期结束时间',
+    `creator`                   varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL     DEFAULT '' COMMENT '创建者',
+    `create_time`               datetime                                                     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    `updater`                   varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL     DEFAULT '' COMMENT '更新者',
+    `update_time`               datetime                                                     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    `deleted`                   bit(1)                                                       NOT NULL DEFAULT b'0' COMMENT '是否删除',
+    `tenant_id`                 bigint                                                       NOT NULL DEFAULT 0 COMMENT '租户编号',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB
+  AUTO_INCREMENT = 119
+  CHARACTER SET = utf8mb4
+  COLLATE = utf8mb4_unicode_ci COMMENT = '优惠券模板';

+ 274 - 246
sql/optional/mall/mall.sql

@@ -1,7 +1,7 @@
 /*
  Navicat Premium Data Transfer
 
- Source Server         : 127.0.0.1
+ Source Server         : 127.0.0.1 MySQL
  Source Server Type    : MySQL
  Source Server Version : 80026
  Source Host           : localhost:3306
@@ -11,277 +11,305 @@
  Target Server Version : 80026
  File Encoding         : 65001
 
- Date: 05/02/2022 00:50:30
+ Date: 01/08/2022 23:01:36
 */
-SET
-FOREIGN_KEY_CHECKS = 0;
+
 SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
 
 -- ----------------------------
--- Table structure for product_category
+-- Table structure for market_activity
 -- ----------------------------
-DROP TABLE IF EXISTS `product_category`;
-CREATE TABLE `product_category`
-(
-    `id`          bigint       NOT NULL AUTO_INCREMENT COMMENT '分类编号',
-    `parent_id`   bigint       NOT NULL COMMENT '父分类编号',
-    `name`        varchar(255) NOT NULL COMMENT '分类名称',
-    `icon`        varchar(100) NOT NULL DEFAULT '#' COMMENT '分类图标',
-    `banner_url`  varchar(255) NOT NULL COMMENT '分类图片',
-    `sort`        int                   DEFAULT '0' COMMENT '分类排序',
-    `description` varchar(1024)         DEFAULT NULL COMMENT '分类描述',
-    `status`      tinyint      NOT NULL COMMENT '开启状态',
-    `creator`     varchar(64)           DEFAULT '' COMMENT '创建者',
-    `create_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-    `updater`     varchar(64)           DEFAULT '' COMMENT '更新者',
-    `update_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
-    `deleted`     bit(1)       NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    `tenant_id`   bigint       NOT NULL DEFAULT '0' COMMENT '租户编号',
-    PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB COMMENT='商品分类';
+DROP TABLE IF EXISTS `market_activity`;
+CREATE TABLE `market_activity`  (
+                                    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '活动编号',
+                                    `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '活动标题',
+                                    `activity_type` tinyint NOT NULL COMMENT '活动类型',
+                                    `status` tinyint NOT NULL DEFAULT -1 COMMENT '活动状态',
+                                    `start_time` datetime NOT NULL COMMENT '开始时间',
+                                    `end_time` datetime NOT NULL COMMENT '结束时间',
+                                    `invalid_time` datetime NULL DEFAULT NULL COMMENT '失效时间',
+                                    `delete_time` datetime NULL DEFAULT NULL COMMENT '删除时间',
+                                    `time_limited_discount` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
+                                    `full_privilege` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
+                                    `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
+                                    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                    `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
+                                    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                    `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                    `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '促销活动';
 
 -- ----------------------------
--- Table structure for product_brand
+-- Records of market_activity
 -- ----------------------------
-DROP TABLE IF EXISTS `product_brand`;
-CREATE TABLE `product_brand`
-(
-    `id`          bigint       NOT NULL AUTO_INCREMENT COMMENT '品牌编号',
-    `category_id` bigint       NOT NULL COMMENT '分类编号',
-    `name`        varchar(255) NOT NULL COMMENT '品牌名称',
-    `banner_url`  varchar(255) NOT NULL COMMENT '品牌图片',
-    `sort`        int                   DEFAULT '0' COMMENT '品牌排序',
-    `description` varchar(1024)         DEFAULT NULL COMMENT '品牌描述',
-    `status`      tinyint      NOT NULL COMMENT '状态',
-    `creator`     varchar(64)           DEFAULT '' COMMENT '创建者',
-    `create_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-    `updater`     varchar(64)           DEFAULT '' COMMENT '更新者',
-    `update_time` datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
-    `deleted`     bit(1)       NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    `tenant_id`   bigint       NOT NULL DEFAULT '0' COMMENT '租户编号',
-    PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB COMMENT='品牌';
+BEGIN;
+COMMIT;
 
--- TODO 父级菜单的 id 处理: 2000 、 2001
-INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES (2000, '商城', '', 1, 1, 0, '/mall', 'merchant', NULL, 0);
-INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES (2001, '商品', '', 1, 1, 2000, 'product', 'dict', NULL, 0);
--- 商品分类 菜单 SQL
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('分类管理', '', 2, 0, 2001, 'category', '', 'mall/product/category/index', 0);
--- 按钮父菜单ID
-SELECT @parentId := LAST_INSERT_ID();
--- 按钮 SQL
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0);
--- 品牌管理 菜单 SQL
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('品牌管理', '', 2, 1, 2001, 'brand', '', 'mall/product/brand/index', 0);
--- 按钮父菜单ID
-SELECT @parentId := LAST_INSERT_ID();
--- 按钮 SQL
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0);
+-- ----------------------------
+-- Table structure for market_banner
+-- ----------------------------
+DROP TABLE IF EXISTS `market_banner`;
+CREATE TABLE `market_banner`  (
+                                  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Banner编号',
+                                  `title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'Banner标题',
+                                  `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '图片URL',
+                                  `status` tinyint NOT NULL DEFAULT -1 COMMENT '活动状态',
+                                  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '跳转地址',
+                                  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者',
+                                  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者',
+                                  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                  `sort` tinyint NULL DEFAULT NULL COMMENT '排序',
+                                  `memo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
+                                  PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Banner管理';
 
+-- ----------------------------
+-- Records of market_banner
+-- ----------------------------
+BEGIN;
+COMMIT;
 
 -- ----------------------------
--- Table structure for market_activity
+-- Table structure for member_address
 -- ----------------------------
-DROP TABLE IF EXISTS `market_activity`;
-CREATE TABLE `market_activity`
-(
-    `id`                    bigint      NOT NULL AUTO_INCREMENT COMMENT '活动编号',
-    `title`                 varchar(50) NOT NULL DEFAULT '' COMMENT '活动标题',
-    `activity_type`         tinyint(4) NOT NULL COMMENT '活动类型',
-    `status`                tinyint(4) NOT NULL DEFAULT '-1' COMMENT '活动状态',
-    `start_time`            datetime    NOT NULL COMMENT '开始时间',
-    `end_time`              datetime    NOT NULL COMMENT '结束时间',
-    `invalid_time`          datetime             DEFAULT NULL COMMENT '失效时间',
-    `delete_time`           datetime             DEFAULT NULL COMMENT '删除时间',
-    `time_limited_discount` varchar(2000)        DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
-    `full_privilege`        varchar(2000)        DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
-    `creator`               varchar(64)          DEFAULT '' COMMENT '创建者',
-    `create_time`           datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-    `updater`               varchar(64)          DEFAULT '' COMMENT '更新者',
-    `update_time`           datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
-    `deleted`               bit(1)      NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    `tenant_id`             bigint      NOT NULL DEFAULT '0' COMMENT '租户编号',
-    PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='促销活动';
+DROP TABLE IF EXISTS `member_address`;
+CREATE TABLE `member_address`  (
+                                   `id` bigint NOT NULL AUTO_INCREMENT COMMENT '收件地址编号',
+                                   `user_id` bigint NOT NULL COMMENT '用户编号',
+                                   `name` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '收件人名称',
+                                   `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '手机号',
+                                   `area_id` bigint NOT NULL COMMENT '地区编码',
+                                   `post_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '邮编',
+                                   `detail_address` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '收件详细地址',
+                                   `defaulted` bit(1) NOT NULL COMMENT '是否默认',
+                                   `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
+                                   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                   `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
+                                   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                   `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                   `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                   PRIMARY KEY (`id`) USING BTREE,
+                                   INDEX `idx_userId`(`user_id` ASC) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户收件地址';
 
+-- ----------------------------
+-- Records of member_address
+-- ----------------------------
+BEGIN;
+INSERT INTO `member_address` (`id`, `user_id`, `name`, `mobile`, `area_id`, `post_code`, `detail_address`, `defaulted`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (21, 1, 'yunai', '15601691300', 610632, '200000', '芋道源码 233 号 666 室', b'1', '1', '2022-08-01 22:46:35', '1', '2022-08-01 22:46:35', b'0', 1);
+COMMIT;
 
--- 规格菜单 SQL
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('规格管理', '', 2, 3, 2001, 'property', '', 'mall/product/property/index', 0);
+-- ----------------------------
+-- Table structure for product_brand
+-- ----------------------------
+DROP TABLE IF EXISTS `product_brand`;
+CREATE TABLE `product_brand`  (
+                                  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号',
+                                  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '品牌名称',
+                                  `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '品牌图片',
+                                  `sort` int NULL DEFAULT 0 COMMENT '品牌排序',
+                                  `description` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '品牌描述',
+                                  `status` tinyint NOT NULL COMMENT '状态',
+                                  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
+                                  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
+                                  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                  PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品品牌';
 
--- 按钮父菜单ID
-SELECT @parentId := LAST_INSERT_ID();
+-- ----------------------------
+-- Records of product_brand
+-- ----------------------------
+BEGIN;
+INSERT INTO `product_brand` (`id`, `name`, `pic_url`, `sort`, `description`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '苹果', 'http://test.yudao.iocoder.cn/e3726713fa56db5717c78c011762fcc7a251db12735c3581470638b8e1fa17e2.jpeg', 0, '是上市', 0, '1', '2022-07-30 22:12:18', '1', '2022-07-30 22:13:55', b'0', 1);
+COMMIT;
 
--- 按钮 SQL
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('规格查询', 'product:property:query', 3, 1, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('规格创建', 'product:property:create', 3, 2, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('规格更新', 'product:property:update', 3, 3, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('规格删除', 'product:property:delete', 3, 4, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('规格导出', 'product:property:export', 3, 5, @parentId, '', '', '', 0);
+-- ----------------------------
+-- Table structure for product_category
+-- ----------------------------
+DROP TABLE IF EXISTS `product_category`;
+CREATE TABLE `product_category`  (
+                                     `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号',
+                                     `parent_id` bigint NOT NULL COMMENT '父分类编号',
+                                     `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '分类名称',
+                                     `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '分类图片',
+                                     `sort` int NULL DEFAULT 0 COMMENT '分类排序',
+                                     `description` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '分类描述',
+                                     `status` tinyint NOT NULL COMMENT '开启状态',
+                                     `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
+                                     `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                     `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
+                                     `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                     `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                     `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                     PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品分类';
 
+-- ----------------------------
+-- Records of product_category
+-- ----------------------------
+BEGIN;
+INSERT INTO `product_category` (`id`, `parent_id`, `name`, `pic_url`, `sort`, `description`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 0, '电脑办公', 'http://test.yudao.iocoder.cn/122d548e1b3cd5dec72fe8075c6977a70f9cc13541a684ab3685f1b5df42f6bd.jpeg', 1, '1234', 0, '1', '2022-07-30 16:36:35', '1', '2022-07-30 20:27:16', b'0', 1), (2, 1, '笔记本', 'http://test.yudao.iocoder.cn/72713ac7b947600a019a18786ed0e6562e8692e253dbd35110a0a85c2469bbec.jpg', 1, '<p>测试一下</p>', 0, '1', '2022-07-30 16:38:09', '1', '2022-07-30 16:38:09', b'0', 1), (3, 1, '游戏本', 'http://test.yudao.iocoder.cn/287c50dd9f5f575f57329a0c57b2095be6d1aeba83867b905fe549f54a296feb.jpg', 2, '<p>测试一下</p>', 0, '1', '2022-07-30 16:39:09', '1', '2022-07-30 20:26:59', b'0', 1), (4, 0, '手机', 'http://test.yudao.iocoder.cn/e1b63900c78dbb661b3e383960cee5cfea7e1dd2fb22cff2e317ff025faaf8b2.jpeg', 2, '<p>123</p>', 0, '1', '2022-07-30 16:40:00', '1', '2022-07-30 16:40:09', b'0', 1), (5, 4, '5G手机', 'http://test.yudao.iocoder.cn/3af6557ac7def6423f046f5b2e920b644793420b466959aaa996a2e19068bbde.jpeg', 1, '<p><br></p>', 0, '1', '2022-07-30 16:43:00', '1', '2022-07-30 16:43:00', b'0', 1), (6, 4, '游戏手机', 'http://test.yudao.iocoder.cn/964fe9ccd1710d64ede261dc36d231918a017641986c15293c367f9f66d94d05.jpeg', 2, NULL, 0, '1', '2022-07-30 16:43:44', '1', '2022-07-30 16:43:44', b'0', 1), (7, 5, '厉害的 5G 手机', 'http://test.yudao.iocoder.cn/b287122f277838e8de368769b96217918605743bc45f3a29bda3cc7359dc66e1.png', 0, '123', 0, '1', '2022-07-30 20:38:09', '1', '2022-07-30 20:38:09', b'0', 1);
+COMMIT;
 
--- 商品菜单 SQL
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('商品管理', '', 2, 2, 2001, 'spu', '', 'mall/product/spu/index', 0);
+-- ----------------------------
+-- Table structure for product_property
+-- ----------------------------
+DROP TABLE IF EXISTS `product_property`;
+CREATE TABLE `product_property`  (
+                                     `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                                     `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '规格名称',
+                                     `status` tinyint NULL DEFAULT NULL COMMENT '状态: 0 开启 ,1 禁用',
+                                     `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                     `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                     `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
+                                     `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
+                                     `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                     `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                     PRIMARY KEY (`id`) USING BTREE,
+                                     INDEX `idx_name`(`name`(32) ASC) USING BTREE COMMENT '规格名称索引'
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '规格名称';
 
--- 按钮父菜单ID
-SELECT @parentId := LAST_INSERT_ID();
+-- ----------------------------
+-- Records of product_property
+-- ----------------------------
+BEGIN;
+COMMIT;
 
--- 按钮 SQL
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('商品查询', 'product:spu:query', 3, 1, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('商品创建', 'product:spu:create', 3, 2, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('商品更新', 'product:spu:update', 3, 3, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('商品删除', 'product:spu:delete', 3, 4, @parentId, '', '', '', 0);
-INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
-VALUES ('商品导出', 'product:spu:export', 3, 5, @parentId, '', '', '', 0);
+-- ----------------------------
+-- Table structure for product_property_value
+-- ----------------------------
+DROP TABLE IF EXISTS `product_property_value`;
+CREATE TABLE `product_property_value`  (
+                                           `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                                           `property_id` bigint NULL DEFAULT NULL COMMENT '规格键id',
+                                           `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '规格值名字',
+                                           `status` tinyint NULL DEFAULT NULL COMMENT '状态: 1 开启 ,2 禁用',
+                                           `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                           `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                           `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
+                                           `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
+                                           `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+                                           `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                           PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '规格值';
 
+-- ----------------------------
+-- Records of product_property_value
+-- ----------------------------
+BEGIN;
+COMMIT;
 
--- 规格名称表
-drop table if exists product_property;
-create table product_property
-(
-    id          bigint NOT NULL AUTO_INCREMENT comment '主键',
-    name        varchar(64) comment '规格名称',
-    status      tinyint comment '状态: 0 开启 ,1 禁用',
-    create_time datetime        default current_timestamp comment '创建时间',
-    update_time datetime        default current_timestamp on update current_timestamp comment '更新时间',
-    creator     varchar(64) comment '创建人',
-    updater     varchar(64) comment '更新人',
-    tenant_id   bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
-    deleted   bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    primary key (id),
-    key         idx_name ( name (32)) comment '规格名称索引'
-) comment '规格名称' character set utf8mb4
-                 collate utf8mb4_general_ci;
+-- ----------------------------
+-- Table structure for product_sku
+-- ----------------------------
+DROP TABLE IF EXISTS `product_sku`;
+CREATE TABLE `product_sku` (
+                               `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                               `spu_id` bigint NOT NULL COMMENT 'spu编号',
+                               `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
+                               `name` varchar(128)  DEFAULT NULL COMMENT '商品 SKU 名字',
+                               `properties` varchar(128)  DEFAULT NULL COMMENT '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]',
+                               `price` int NOT NULL DEFAULT '-1' COMMENT '销售价格,单位:分',
+                               `market_price` int DEFAULT NULL COMMENT '市场价',
+                               `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分',
+                               `pic_url` varchar(128)  NOT NULL COMMENT '图片地址',
+                               `stock` int DEFAULT NULL COMMENT '库存',
+                               `warn_stock` int DEFAULT NULL COMMENT '预警库存',
+                               `volume` double DEFAULT NULL COMMENT '商品体积',
+                               `weight` double DEFAULT NULL COMMENT '商品重量',
+                               `bar_code` varchar(64)  DEFAULT NULL COMMENT '条形码',
+                               `status` tinyint DEFAULT NULL COMMENT '状态: 0-正常 1-禁用',
+                               `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                               `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                               `creator` varchar(64) DEFAULT NULL COMMENT '创建人',
+                               `updater` double(64,0) DEFAULT NULL COMMENT '更新人',
+`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB COMMENT='商品sku';
 
--- 规格值表
-drop table if exists product_property_value;
-create table product_property_value
-(
-    id          bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
-    property_id bigint comment '规格键id',
-    name        varchar(128) comment '规格值名字',
-    status      tinyint comment '状态: 1 开启 ,2 禁用',
-    create_time datetime        default current_timestamp comment '创建时间',
-    update_time datetime        default current_timestamp on update current_timestamp comment '更新时间',
-    creator     varchar(64) comment '创建人',
-    updater     varchar(64) comment '更新人',
-    tenant_id   bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
-    deleted   bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    primary key (id)
-) comment '规格值' character set utf8mb4
-                collate utf8mb4_general_ci;
+-- ----------------------------
+-- Records of product_sku
+-- ----------------------------
+BEGIN;
+COMMIT;
 
--- spu
-drop table if exists product_spu;
-create table product_spu
-(
-    id          bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
-    name        varchar(128) comment '商品名称',
-    sell_point  varchar(128)  not null comment '卖点',
-    description text          not null comment '描述',
-    category_id bigint        not null comment '分类id',
-    pic_urls    varchar(1024) not null default '' comment '商品主图地址\n     *\n     * 数组,以逗号分隔\n 最多上传15张',
-    sort        int           not null default 0 comment '排序字段',
-    like_count  int comment '点赞初始人数',
-    price       int comment '价格 单位使用:分',
-    quantity    int comment '库存数量',
-    status      bit(1) comment '上下架状态: 0 上架(开启) 1 下架(禁用)',
-    create_time datetime               default current_timestamp comment '创建时间',
-    update_time datetime               default current_timestamp on update current_timestamp comment '更新时间',
-    creator     varchar(64) comment '创建人',
-    updater     varchar(64) comment '更新人',
-    tenant_id   bigint        NOT NULL DEFAULT '0' COMMENT '租户编号',
-    deleted   bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    primary key (id)
-) comment '商品spu' character set utf8mb4
-                  collate utf8mb4_general_ci;
+-- ----------------------------
+-- Table structure for product_spu
+-- ----------------------------
+DROP TABLE IF EXISTS `product_spu`;
+CREATE TABLE `product_spu` (
+                               `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                               `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
+                               `brand_id` int DEFAULT NULL COMMENT '商品品牌编号',
+                               `category_id` bigint NOT NULL COMMENT '分类id',
+                               `spec_type` int NOT NULL COMMENT '规格类型:0 单规格 1 多规格',
+                               `code` varchar(128)  DEFAULT NULL COMMENT '商品编码',
+                               `name` varchar(128)  NOT NULL COMMENT '商品名称',
+                               `sell_point` varchar(128)  DEFAULT NULL COMMENT '卖点',
+                               `description` text  COMMENT '描述',
+                               `pic_urls` varchar(1024)  DEFAULT '' COMMENT '商品轮播图地址\n 数组,以逗号分隔\n 最多上传15张',
+                               `video_url` varchar(128)  DEFAULT NULL COMMENT '商品视频',
+                               `market_price` int DEFAULT NULL COMMENT '市场价,单位使用:分',
+                               `min_price` int DEFAULT NULL COMMENT '最小价格,单位使用:分',
+                               `max_price` int DEFAULT NULL COMMENT '最大价格,单位使用:分',
+                               `total_stock` int NOT NULL DEFAULT '0' COMMENT '总库存',
+                               `show_stock` int DEFAULT '0' COMMENT '是否展示库存',
+                               `sales_count` int DEFAULT '0' COMMENT '商品销量',
+                               `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量',
+                               `click_count` int DEFAULT '0' COMMENT '商品点击量',
+                               `status` bit(1) DEFAULT NULL COMMENT '上下架状态: 0 上架(开启) 1 下架(禁用)-1 回收',
+                               `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段',
+                               `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                               `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                               `creator` varchar(64)  DEFAULT NULL COMMENT '创建人',
+                               `updater` varchar(64)  DEFAULT NULL COMMENT '更新人',
+                               `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                               PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB COMMENT='商品spu';
 
+-- ----------------------------
+-- Records of product_spu
+-- ----------------------------
+BEGIN;
+COMMIT;
 
--- sku
-drop table if exists product_sku;
-create table product_sku
-(
-    id             bigint       NOT NULL AUTO_INCREMENT COMMENT '主键',
-    spu_id         bigint       not null comment 'spu编号',
-    properties     varchar(64)  not null comment '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]',
-    price          int          not null DEFAULT -1 comment '销售价格,单位:分',
-    original_price int          not null DEFAULT -1 comment '原价, 单位: 分',
-    cost_price     int          not null DEFAULT -1 comment '成本价,单位: 分',
-    bar_code       varchar(64)  not null comment '条形码',
-    pic_url        VARCHAR(128) not null comment '图片地址',
-    status         tinyint comment '状态: 0-正常 1-禁用',
-    create_time    datetime              default current_timestamp comment '创建时间',
-    update_time    datetime              default current_timestamp on update current_timestamp comment '更新时间',
-    creator        varchar(64) comment '创建人',
-    updater        varchar(64) comment '更新人',
-    tenant_id      bigint       NOT NULL DEFAULT '0' COMMENT '租户编号',
-    deleted      bit(1)       NOT NULL DEFAULT b'0' COMMENT '是否删除',
-    primary key (id)
-) comment '商品sku' character set utf8mb4
-                  collate utf8mb4_general_ci;
+SET FOREIGN_KEY_CHECKS = 1;
 
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2000, '商品中心', '', 1, 60, 0, '/product', 'merchant', NULL, 0, b'1', b'1', '', '2022-07-29 15:53:53', '1', '2022-07-30 22:26:19', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2002, '商品分类', '', 2, 2, 2000, 'category', 'dict', 'mall/product/category/index', 0, b'1', b'1', '', '2022-07-29 15:53:53', '1', '2022-07-30 22:23:37', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2003, '分类查询', 'product:category:query', 3, 1, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2004, '分类创建', 'product:category:create', 3, 2, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2005, '分类更新', 'product:category:update', 3, 3, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2006, '分类删除', 'product:category:delete', 3, 4, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2007, '分类导出', 'product:category:export', 3, 5, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-30 13:52:13', b'1');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2008, '商品品牌', '', 2, 1, 2000, 'brand', 'dashboard', 'mall/product/brand/index', 0, b'1', b'1', '', '2022-07-30 13:52:44', '1', '2022-07-30 22:23:43', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2009, '品牌查询', 'product:brand:query', 3, 1, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2010, '品牌创建', 'product:brand:create', 3, 2, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2011, '品牌更新', 'product:brand:update', 3, 3, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2012, '品牌删除', 'product:brand:delete', 3, 4, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2013, '品牌导出', 'product:brand:export', 3, 5, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 14:15:00', b'1');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2014, '商品管理', '', 2, 0, 2000, 'spu', 'link', 'mall/product/spu/index', 0, b'1', b'1', '', '2022-07-30 14:22:58', '1', '2022-07-30 22:26:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2015, '商品查询', 'product:spu:query', 3, 1, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2016, '商品创建', 'product:spu:create', 3, 2, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2017, '商品更新', 'product:spu:update', 3, 3, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2018, '商品删除', 'product:spu:delete', 3, 4, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2019, '规格管理', '', 2, 3, 2000, 'property', '', 'mall/product/property/index', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2020, '规格查询', 'product:property:query', 3, 1, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2021, '规格创建', 'product:property:create', 3, 2, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2022, '规格更新', 'product:property:update', 3, 3, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2023, '规格删除', 'product:property:delete', 3, 4, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2024, '规格导出', 'product:property:export', 3, 5, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2025, 'Banner管理', '', 2, 1, 2000, 'brand', '', 'mall/market/banner/index', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2026, 'Banner查询', 'market:banner:query', 3, 1, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2027, 'Banner创建', 'market:banner:create', 3, 2, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2028, 'Banner更新', 'market:banner:update', 3, 3, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
+INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2029, 'Banner删除', 'market:banner:delete', 3, 4, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
 
--- Market-Banner管理SQL
-drop table if exists market_banner;
-CREATE TABLE `market_banner` (
-  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Banner编号',
-  `title` varchar(64) NOT NULL DEFAULT '' COMMENT 'Banner标题',
-  `pic_url` varchar(255) NOT NULL COMMENT '图片URL',
-  `status` tinyint(4) NOT NULL DEFAULT '-1' COMMENT '活动状态',
-  `url` varchar(255) NOT NULL COMMENT '跳转地址',
-  `creator` varchar(64) DEFAULT '' COMMENT '创建者',
-  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-  `updater` varchar(64) DEFAULT '' COMMENT '更新者',
-  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
-  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
-  `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
-  `sort` tinyint(4) DEFAULT NULL COMMENT '排序',
-  `memo` varchar(255) DEFAULT NULL COMMENT '描述',
-  PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='Banner管理';
--- 菜单 SQL
-INSERT INTO `system_menu`(`id`,`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES (2026, 'Banner管理', '', 2, 1, 2000, 'brand', '', 'mall/market/banner/index', 0);
--- 按钮父菜单ID
-SELECT @parentId := LAST_INSERT_ID();
--- 按钮 SQL
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('Banner查询', 'market:banner:query', 3, 1, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('Banner创建', 'market:banner:create', 3, 2, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('Banner更新', 'market:banner:update', 3, 3, @parentId, '', '', '', 0);
-INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
-VALUES ('Banner删除', 'market:banner:delete', 3, 4, @parentId, '', '', '', 0);

+ 76 - 0
sql/optional/mall/order.sql

@@ -0,0 +1,76 @@
+/**todo cancelType 设置默认值 0?*/
+CREATE TABLE `trade_order`
+(
+    `id`                      bigint          NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+    `sn`                      varchar(32)     NOT NULL COMMENT '订单流水号',
+    `type`                    int             NOT NULL DEFAULT '0' COMMENT '订单类型:[0:普通订单 1:秒杀订单 2:拼团订单 3:砍价订单]',
+    `terminal`                int             NOT NULL COMMENT '订单来源终端:[1:小程序 2:H5 3:iOS 4:安卓]',
+    `user_id`                 bigint unsigned NOT NULL COMMENT '用户编号',
+    `user_ip`                 varchar(30)     NOT NULL DEFAULT '' COMMENT '用户 IP',
+    `user_remark`             varchar(200)             DEFAULT NULL COMMENT '用户备注',
+    `status`                  int             NOT NULL DEFAULT '0' COMMENT '订单状态:[0:待付款 1:待发货 2:待收货 3:已完成 4:已关闭]',
+    `product_count`           int             NOT NULL COMMENT '购买的商品数量',
+    `cancel_type`             int             NOT NULL COMMENT '取消类型:[10:超时未支付 20:退款关闭 30:买家取消 40:已通过货到付款交易]',
+    `remark`                  varchar(200)             DEFAULT NULL COMMENT '商家备注',
+    `payed`                   bit(1)          NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]',
+    `finish_time`             datetime                 DEFAULT NULL COMMENT '订单完成时间',
+    `cancel_time`             datetime                 DEFAULT NULL COMMENT '订单取消时间',
+    `sku_original_price`      int             NOT NULL DEFAULT '0' COMMENT '商品原价(总),单位:分',
+    `sku_promotion_price`     int             NOT NULL DEFAULT '0' COMMENT '商品优惠(总),单位:分',
+    `order_promotion_price`   int             NOT NULL DEFAULT '0' COMMENT '订单优惠(总),单位:分',
+    `delivery_price`          int             NOT NULL DEFAULT '0' COMMENT '运费金额,单位:分',
+    `pay_price`               int             NOT NULL DEFAULT '0' COMMENT '应付金额(总),单位:分',
+    `pay_order_id`            int             NOT NULL COMMENT '支付订单编号',
+    `pay_channel`             int             NOT NULL COMMENT '支付成功的支付渠道',
+    `delivery_type`           int             NOT NULL DEFAULT '1' COMMENT '配送方式:[1:快递发货 2:自提]',
+    `actual_delivery_type`    int             NOT NULL DEFAULT '1' COMMENT '实际的配送方式:[1:快递发货 2:自提]',
+    `delivery_templateid`     int                      DEFAULT NULL COMMENT '配置模板的编号',
+    `express_no`              int                      DEFAULT NULL COMMENT '物流公司单号',
+    `delivery_status`         bit(1)          NOT NULL DEFAULT b'0' COMMENT '发货状态[0:未发货 1:已发货]',
+    `delivery_time`           datetime                 DEFAULT NULL COMMENT '发货时间',
+    `receive_time`            datetime                 DEFAULT NULL COMMENT '收货时间',
+    `receiver_name`           varchar(20)     NOT NULL COMMENT '收件人名称',
+    `receiver_mobile`         varchar(20)     NOT NULL COMMENT '收件人手机',
+    `receiver_area_id`        int             NOT NULL COMMENT '收件人地区编号',
+    `receiver_post_code`      int                      DEFAULT NULL COMMENT '收件人邮编',
+    `receiver_detail_address` varchar(255)    NOT NULL COMMENT '收件人详细地址',
+    `refund_status`           int             NOT NULL DEFAULT '0' COMMENT '订单状态:[0:未退款 1:部分退款 2:全部退款]',
+    `refund_price`            int             NOT NULL DEFAULT '0' COMMENT '退款金额,单位:分',
+    `coupon_id`               bigint unsigned NOT NULL COMMENT '优惠劵编号',
+    `creator`                 varchar(64)              DEFAULT '' COMMENT '创建者',
+    `create_time`             datetime        NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    `updater`                 varchar(64)              DEFAULT '' COMMENT '更新者',
+    `update_time`             datetime        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    `deleted`                 bit(1)          NOT NULL DEFAULT b'0' COMMENT '是否删除',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB COMMENT ='交易订单表';
+
+
+DROP TABLE IF EXISTS `trade_order_item`;
+CREATE TABLE `trade_order_item`
+(
+    `id`                    bigint          NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+    `user_id`               bigint unsigned NOT NULL COMMENT '用户编号',
+    `order_Id`              bigint unsigned NOT NULL COMMENT '订单编号',
+    `spu_id`                bigint unsigned NOT NULL COMMENT '商品 SPU 编号',
+    `sku_id`                bigint unsigned NOT NULL COMMENT '商品 SKU 编号',
+    `properties`            json                     DEFAULT NULL COMMENT '规格值数组,JSON 格式',
+    `name`                  varchar(128)    NOT NULL DEFAULT '' COMMENT '商品名称',
+    `pic_url`               varchar(200)             DEFAULT NULL COMMENT '商品图片',
+    `count`                 int             NOT NULL COMMENT '购买数量',
+    `commented`             bit(1)          NOT NULL DEFAULT b'0' COMMENT '是否评论:[0:未评论 1:已评论]',
+    `original_price`        int             NOT NULL DEFAULT '0' COMMENT '商品原价(单),单位:分',
+    `total_original_price`  int             NOT NULL DEFAULT '0' COMMENT '商品原价(总),单位:分',
+    `total_promotion_price` int             NOT NULL DEFAULT '0' COMMENT '商品级优惠(总),单位:分',
+    `present_price`         int             NOT NULL DEFAULT '0' COMMENT '最终购买金额(单),单位:分。',
+    `total_present_price`   int             NOT NULL DEFAULT '0' COMMENT '最终购买金额(总),单位:分。',
+    `total_pay_price`       int             NOT NULL DEFAULT '0' COMMENT '应付金额(总),单位:分',
+    `refund_status`         int             NOT NULL DEFAULT '0' COMMENT '退款状态:[0:未申请退款 1:申请退款 2:等待退款 3:退款成功]',
+    `refund_total`          int             NOT NULL DEFAULT '0' COMMENT '退款总金额,单位:分',
+    `creator`               varchar(64)              DEFAULT '' COMMENT '创建者',
+    `create_time`           datetime        NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    `updater`               varchar(64)              DEFAULT '' COMMENT '更新者',
+    `update_time`           datetime        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    `deleted`               bit(1)          NOT NULL DEFAULT b'0' COMMENT '是否删除',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB COMMENT ='交易订单明细表';

+ 39 - 0
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/TerminalEnum.java

@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.framework.common.enums;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+import java.util.Arrays;
+
+/**
+ * 终端的枚举
+ *
+ * @author 芋道源码
+ */
+@RequiredArgsConstructor
+@Getter
+public enum TerminalEnum implements IntArrayValuable {
+
+    //TODO terminal 重复,请参考 '订单来源终端:[1:小程序 2:H5 3:iOS 4:安卓]'
+    MINI_PROGRAM(1, "小程序"),
+    H5(2, "H5"),
+    IOS(3, "iOS"),
+    ANDROID(3, "安卓"),;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TerminalEnum::getTerminal).toArray();
+
+    /**
+     * 终端
+     */
+    private final Integer terminal;
+    /**
+     * 终端名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+}

+ 17 - 0
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java

@@ -173,6 +173,23 @@ public class CollectionUtils {
         return valueFunc.apply(t);
     }
 
+    public static <T, V extends Comparable<? super V>> V getMinValue(List<T> from, Function<T, V> valueFunc) {
+        if (CollUtil.isEmpty(from)) {
+            return null;
+        }
+        assert from.size() > 0; // 断言,避免告警
+        T t = from.stream().min(Comparator.comparing(valueFunc)).get();
+        return valueFunc.apply(t);
+    }
+
+    public static <T, V extends Comparable<? super V>> V getSumValue(List<T> from, Function<T, V> valueFunc, BinaryOperator<V> accumulator) {
+        if (CollUtil.isEmpty(from)) {
+            return null;
+        }
+        assert from.size() > 0; // 断言,避免告警
+        return from.stream().map(valueFunc).reduce(accumulator).get();
+    }
+
     public static <T> void addIfNotNull(Collection<T> coll, T item) {
         if (item == null) {
             return;

+ 211 - 80
yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptor.java

@@ -18,7 +18,6 @@ import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
 import net.sf.jsqlparser.expression.operators.relational.ExistsExpression;
 import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
 import net.sf.jsqlparser.expression.operators.relational.InExpression;
-import net.sf.jsqlparser.expression.operators.relational.ItemsList;
 import net.sf.jsqlparser.schema.Table;
 import net.sf.jsqlparser.statement.delete.Delete;
 import net.sf.jsqlparser.statement.select.*;
@@ -37,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * 数据权限拦截器,通过 {@link DataPermissionRule} 数据权限规则,重写 SQL 的方式来实现
- * 主要的 SQL 重写方法,可见 {@link #builderExpression(Expression, Table)} 方法
+ * 主要的 SQL 重写方法,可见 {@link #builderExpression(Expression, List)} 方法
  *
  * 整体的代码实现上,参考 {@link com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor} 实现。
  * 所以每次 MyBatis Plus 升级时,需要 Review 下其具体的实现是否有变更!
@@ -53,8 +52,7 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
     private final MappedStatementCache mappedStatementCache = new MappedStatementCache();
 
     @Override // SELECT 场景
-    public void beforeQuery(Executor executor, MappedStatement ms, Object parameter,
-                            RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
+    public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
         // 获得 Mapper 对应的数据权限的规则
         List<DataPermissionRule> rules = ruleFactory.getDataPermissionRule(ms.getId());
         if (mappedStatementCache.noRewritable(ms, rules)) { // 如果无需重写,则跳过
@@ -68,12 +66,14 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
             // 处理 SQL
             mpBs.sql(parserSingle(mpBs.sql(), null));
         } finally {
+            // 添加是否需要重写的缓存
             addMappedStatementCache(ms);
+            // 清空上下文
             ContextHolder.clear();
         }
     }
 
-    @Override // 只处理 UPDATE / DELETE 场景,不处理 INSERT 场景
+    @Override // 只处理 UPDATE / DELETE 场景,不处理 INSERT 场景(因为 INSERT 不需要数据权限)
     public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
         PluginUtils.MPStatementHandler mpSh = PluginUtils.mpStatementHandler(sh);
         MappedStatement ms = mpSh.mappedStatement();
@@ -92,7 +92,9 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
                 // 处理 SQL
                 mpBs.sql(parserMulti(mpBs.sql(), null));
             } finally {
+                // 添加是否需要重写的缓存
                 addMappedStatementCache(ms);
+                // 清空上下文
                 ContextHolder.clear();
             }
         }
@@ -107,24 +109,6 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
         }
     }
 
-    protected void processSelectBody(SelectBody selectBody) {
-        if (selectBody == null) {
-            return;
-        }
-        if (selectBody instanceof PlainSelect) {
-            processPlainSelect((PlainSelect) selectBody);
-        } else if (selectBody instanceof WithItem) {
-            WithItem withItem = (WithItem) selectBody;
-            processSelectBody(withItem.getSubSelect().getSelectBody());
-        } else {
-            SetOperationList operationList = (SetOperationList) selectBody;
-            List<SelectBody> selectBodys = operationList.getSelects();
-            if (CollectionUtils.isNotEmpty(selectBodys)) {
-                selectBodys.forEach(this::processSelectBody);
-            }
-        }
-    }
-
     /**
      * update 语句处理
      */
@@ -142,28 +126,77 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
         delete.setWhere(this.builderExpression(delete.getWhere(), delete.getTable()));
     }
 
+    // ========== 和 TenantLineInnerInterceptor 一致的逻辑 ==========
+
+    protected void processSelectBody(SelectBody selectBody) {
+        if (selectBody == null) {
+            return;
+        }
+        if (selectBody instanceof PlainSelect) {
+            processPlainSelect((PlainSelect) selectBody);
+        } else if (selectBody instanceof WithItem) {
+            WithItem withItem = (WithItem) selectBody;
+            processSelectBody(withItem.getSubSelect().getSelectBody());
+        } else {
+            SetOperationList operationList = (SetOperationList) selectBody;
+            List<SelectBody> selectBodyList = operationList.getSelects();
+            if (CollectionUtils.isNotEmpty(selectBodyList)) {
+                selectBodyList.forEach(this::processSelectBody);
+            }
+        }
+    }
+
     /**
      * 处理 PlainSelect
      */
     protected void processPlainSelect(PlainSelect plainSelect) {
-        FromItem fromItem = plainSelect.getFromItem();
-        Expression where = plainSelect.getWhere();
-        processWhereSubSelect(where);
-        if (fromItem instanceof Table) {
-            Table fromTable = (Table) fromItem;
-            plainSelect.setWhere(builderExpression(where, fromTable));
-        } else {
-            processFromItem(fromItem);
-        }
         //#3087 github
         List<SelectItem> selectItems = plainSelect.getSelectItems();
         if (CollectionUtils.isNotEmpty(selectItems)) {
             selectItems.forEach(this::processSelectItem);
         }
+
+        // 处理 where 中的子查询
+        Expression where = plainSelect.getWhere();
+        processWhereSubSelect(where);
+
+        // 处理 fromItem
+        FromItem fromItem = plainSelect.getFromItem();
+        List<Table> list = processFromItem(fromItem);
+        List<Table> mainTables = new ArrayList<>(list);
+
+        // 处理 join
         List<Join> joins = plainSelect.getJoins();
         if (CollectionUtils.isNotEmpty(joins)) {
-            processJoins(joins);
+            mainTables = processJoins(mainTables, joins);
+        }
+
+        // 当有 mainTable 时,进行 where 条件追加
+        if (CollectionUtils.isNotEmpty(mainTables)) {
+            plainSelect.setWhere(builderExpression(where, mainTables));
+        }
+    }
+
+    private List<Table> processFromItem(FromItem fromItem) {
+        // 处理括号括起来的表达式
+        while (fromItem instanceof ParenthesisFromItem) {
+            fromItem = ((ParenthesisFromItem) fromItem).getFromItem();
+        }
+
+        List<Table> mainTables = new ArrayList<>();
+        // 无 join 时的处理逻辑
+        if (fromItem instanceof Table) {
+            Table fromTable = (Table) fromItem;
+            mainTables.add(fromTable);
+        } else if (fromItem instanceof SubJoin) {
+            // SubJoin 类型则还需要添加上 where 条件
+            List<Table> tables = processSubJoin((SubJoin) fromItem);
+            mainTables.addAll(tables);
+        } else {
+            // 处理下 fromItem
+            processOtherFromItem(fromItem);
         }
+        return mainTables;
     }
 
     /**
@@ -191,7 +224,7 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
             return;
         }
         if (where instanceof FromItem) {
-            processFromItem((FromItem) where);
+            processOtherFromItem((FromItem) where);
             return;
         }
         if (where.toString().indexOf("SELECT") > 0) {
@@ -204,9 +237,9 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
             } else if (where instanceof InExpression) {
                 // in
                 InExpression expression = (InExpression) where;
-                ItemsList itemsList = expression.getRightItemsList();
-                if (itemsList instanceof SubSelect) {
-                    processSelectBody(((SubSelect) itemsList).getSelectBody());
+                Expression inExpression = expression.getRightExpression();
+                if (inExpression instanceof SubSelect) {
+                    processSelectBody(((SubSelect) inExpression).getSelectBody());
                 }
             } else if (where instanceof ExistsExpression) {
                 // exists
@@ -239,7 +272,7 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
      * <p>支持: 1. select fun(args..) 2. select fun1(fun2(args..),args..)<p>
      * <p> fixed gitee pulls/141</p>
      *
-     * @param function 函数
+     * @param function
      */
     protected void processFunction(Function function) {
         ExpressionList parameters = function.getParameters();
@@ -257,22 +290,19 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
     /**
      * 处理子查询等
      */
-    protected void processFromItem(FromItem fromItem) {
-        if (fromItem instanceof SubJoin) {
-            SubJoin subJoin = (SubJoin) fromItem;
-            if (subJoin.getJoinList() != null) {
-                processJoins(subJoin.getJoinList());
-            }
-            if (subJoin.getLeft() != null) {
-                processFromItem(subJoin.getLeft());
-            }
-        } else if (fromItem instanceof SubSelect) {
+    protected void processOtherFromItem(FromItem fromItem) {
+        // 去除括号
+        while (fromItem instanceof ParenthesisFromItem) {
+            fromItem = ((ParenthesisFromItem) fromItem).getFromItem();
+        }
+
+        if (fromItem instanceof SubSelect) {
             SubSelect subSelect = (SubSelect) fromItem;
             if (subSelect.getSelectBody() != null) {
                 processSelectBody(subSelect.getSelectBody());
             }
         } else if (fromItem instanceof ValuesList) {
-            logger.debug("Perform a subquery, if you do not give us feedback");
+            logger.debug("Perform a subQuery, if you do not give us feedback");
         } else if (fromItem instanceof LateralSubSelect) {
             LateralSubSelect lateralSubSelect = (LateralSubSelect) fromItem;
             if (lateralSubSelect.getSubSelect() != null) {
@@ -284,75 +314,176 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
         }
     }
 
+    /**
+     * 处理 sub join
+     *
+     * @param subJoin subJoin
+     * @return Table subJoin 中的主表
+     */
+    private List<Table> processSubJoin(SubJoin subJoin) {
+        List<Table> mainTables = new ArrayList<>();
+        if (subJoin.getJoinList() != null) {
+            List<Table> list = processFromItem(subJoin.getLeft());
+            mainTables.addAll(list);
+            mainTables = processJoins(mainTables, subJoin.getJoinList());
+        }
+        return mainTables;
+    }
+
     /**
      * 处理 joins
      *
-     * @param joins join 集合
+     * @param mainTables 可以为 null
+     * @param joins      join 集合
+     * @return List<Table> 右连接查询的 Table 列表
      */
-    private void processJoins(List<Join> joins) {
+    private List<Table> processJoins(List<Table> mainTables, List<Join> joins) {
+        // join 表达式中最终的主表
+        Table mainTable = null;
+        // 当前 join 的左表
+        Table leftTable = null;
+
+        if (mainTables == null) {
+            mainTables = new ArrayList<>();
+        } else if (mainTables.size() == 1) {
+            mainTable = mainTables.get(0);
+            leftTable = mainTable;
+        }
+
         //对于 on 表达式写在最后的 join,需要记录下前面多个 on 的表名
-        Deque<Table> tables = new LinkedList<>();
+        Deque<List<Table>> onTableDeque = new LinkedList<>();
         for (Join join : joins) {
             // 处理 on 表达式
-            FromItem fromItem = join.getRightItem();
-            if (fromItem instanceof Table) {
-                Table fromTable = (Table) fromItem;
+            FromItem joinItem = join.getRightItem();
+
+            // 获取当前 join 的表,subJoint 可以看作是一张表
+            List<Table> joinTables = null;
+            if (joinItem instanceof Table) {
+                joinTables = new ArrayList<>();
+                joinTables.add((Table) joinItem);
+            } else if (joinItem instanceof SubJoin) {
+                joinTables = processSubJoin((SubJoin) joinItem);
+            }
+
+            if (joinTables != null) {
+
+                // 如果是隐式内连接
+                if (join.isSimple()) {
+                    mainTables.addAll(joinTables);
+                    continue;
+                }
+
+                // 当前表是否忽略
+                Table joinTable = joinTables.get(0);
+
+                List<Table> onTables = null;
+                // 如果不要忽略,且是右连接,则记录下当前表
+                if (join.isRight()) {
+                    mainTable = joinTable;
+                    if (leftTable != null) {
+                        onTables = Collections.singletonList(leftTable);
+                    }
+                } else if (join.isLeft()) {
+                    onTables = Collections.singletonList(joinTable);
+                } else if (join.isInner()) {
+                    if (mainTable == null) {
+                        onTables = Collections.singletonList(joinTable);
+                    } else {
+                        onTables = Arrays.asList(mainTable, joinTable);
+                    }
+                    mainTable = null;
+                }
+
+                mainTables = new ArrayList<>();
+                if (mainTable != null) {
+                    mainTables.add(mainTable);
+                }
+
                 // 获取 join 尾缀的 on 表达式列表
                 Collection<Expression> originOnExpressions = join.getOnExpressions();
                 // 正常 join on 表达式只有一个,立刻处理
-                if (originOnExpressions.size() == 1) {
-                    processJoin(join);
+                if (originOnExpressions.size() == 1 && onTables != null) {
+                    List<Expression> onExpressions = new LinkedList<>();
+                    onExpressions.add(builderExpression(originOnExpressions.iterator().next(), onTables));
+                    join.setOnExpressions(onExpressions);
+                    leftTable = joinTable;
                     continue;
                 }
-                tables.push(fromTable);
+                // 表名压栈,忽略的表压入 null,以便后续不处理
+                onTableDeque.push(onTables);
                 // 尾缀多个 on 表达式的时候统一处理
                 if (originOnExpressions.size() > 1) {
                     Collection<Expression> onExpressions = new LinkedList<>();
                     for (Expression originOnExpression : originOnExpressions) {
-                        Table currentTable = tables.poll();
-                        onExpressions.add(builderExpression(originOnExpression, currentTable));
+                        List<Table> currentTableList = onTableDeque.poll();
+                        if (CollectionUtils.isEmpty(currentTableList)) {
+                            onExpressions.add(originOnExpression);
+                        } else {
+                            onExpressions.add(builderExpression(originOnExpression, currentTableList));
+                        }
                     }
                     join.setOnExpressions(onExpressions);
                 }
+                leftTable = joinTable;
             } else {
-                // 处理右边连接的子表达式
-                processFromItem(fromItem);
+                processOtherFromItem(joinItem);
+                leftTable = null;
             }
         }
+
+        return mainTables;
     }
 
+    // ========== 和 TenantLineInnerInterceptor 存在差异的逻辑:关键,实现权限条件的拼接 ==========
+
     /**
-     * 处理联接语句
+     * 处理条件
+     *
+     * @param currentExpression 当前 where 条件
+     * @param table             单个表
      */
-    protected void processJoin(Join join) {
-        if (join.getRightItem() instanceof Table) {
-            Table fromTable = (Table) join.getRightItem();
-            Expression originOnExpression = CollUtil.getFirst(join.getOnExpressions());
-            originOnExpression = builderExpression(originOnExpression, fromTable);
-            join.setOnExpressions(CollUtil.newArrayList(originOnExpression));
-        }
+    protected Expression builderExpression(Expression currentExpression, Table table) {
+        return this.builderExpression(currentExpression, Collections.singletonList(table));
     }
 
     /**
      * 处理条件
+     *
+     * @param currentExpression 当前 where 条件
+     * @param tables 多个表
      */
-    protected Expression builderExpression(Expression currentExpression, Table table) {
-        // 获得 Table 对应的数据权限条件
-        Expression equalsTo = buildDataPermissionExpression(table);
-        if (equalsTo == null) { // 如果没条件,则返回 currentExpression 默认
+    protected Expression builderExpression(Expression currentExpression, List<Table> tables) {
+        // 没有表需要处理直接返回
+        if (CollectionUtils.isEmpty(tables)) {
             return currentExpression;
         }
 
-        // 表达式为空,则直接返回 equalsTo
+        // 第一步,获得 Table 对应的数据权限条件
+        Expression dataPermissionExpression = null;
+        for (Table table : tables) {
+            // 构建每个表的权限 Expression 条件
+            Expression expression = buildDataPermissionExpression(table);
+            if (expression == null) {
+                continue;
+            }
+            // 合并到 dataPermissionExpression 中
+            dataPermissionExpression = dataPermissionExpression == null ? expression
+                    : new AndExpression(dataPermissionExpression, expression);
+        }
+
+        // 第二步,合并多个 Expression 条件
+        if (dataPermissionExpression == null) {
+            return currentExpression;
+        }
         if (currentExpression == null) {
-            return equalsTo;
+            return dataPermissionExpression;
         }
-        // 如果表达式为 Or,则需要 (currentExpression) AND equalsTo
+        // 如果表达式为 Or,则需要 (currentExpression) AND dataPermissionExpression
         if (currentExpression instanceof OrExpression) {
-            return new AndExpression(new Parenthesis(currentExpression), equalsTo);
+            return new AndExpression(new Parenthesis(currentExpression), dataPermissionExpression);
         }
-        // 如果表达式为 And,则直接返回 currentExpression AND equalsTo
-        return new AndExpression(currentExpression, equalsTo);
+        // ② 如果表达式为 And,则直接返回 where AND dataPermissionExpression
+        return new AndExpression(currentExpression, dataPermissionExpression);
     }
 
     /**

+ 205 - 42
yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java

@@ -46,7 +46,7 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
 
             @Override
             public Set<String> getTableNames() {
-                return asSet("entity", "entity1", "entity2", "t1", "t2", // 支持 MyBatis Plus 的单元测试
+                return asSet("entity", "entity1", "entity2", "entity3", "t1", "t2", "sys_dict_item", // 支持 MyBatis Plus 的单元测试
                         "t_user", "t_role"); // 满足自己的单元测试
             }
 
@@ -84,30 +84,30 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
     @Test
     void delete() {
         assertSql("delete from entity where id = ?",
-                "DELETE FROM entity WHERE id = ? AND tenant_id = 1");
+                "DELETE FROM entity WHERE id = ? AND entity.tenant_id = 1");
     }
 
     @Test
     void update() {
         assertSql("update entity set name = ? where id = ?",
-                "UPDATE entity SET name = ? WHERE id = ? AND tenant_id = 1");
+                "UPDATE entity SET name = ? WHERE id = ? AND entity.tenant_id = 1");
     }
 
     @Test
     void selectSingle() {
         // 单表
         assertSql("select * from entity where id = ?",
-                "SELECT * FROM entity WHERE id = ? AND tenant_id = 1");
+                "SELECT * FROM entity WHERE id = ? AND entity.tenant_id = 1");
 
         assertSql("select * from entity where id = ? or name = ?",
-                "SELECT * FROM entity WHERE (id = ? OR name = ?) AND tenant_id = 1");
+                "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1");
 
         assertSql("SELECT * FROM entity WHERE (id = ? OR name = ?)",
-                "SELECT * FROM entity WHERE (id = ? OR name = ?) AND tenant_id = 1");
+                "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1");
 
         /* not */
         assertSql("SELECT * FROM entity WHERE not (id = ? OR name = ?)",
-                "SELECT * FROM entity WHERE NOT (id = ? OR name = ?) AND tenant_id = 1");
+                "SELECT * FROM entity WHERE NOT (id = ? OR name = ?) AND entity.tenant_id = 1");
     }
 
     @Test
@@ -167,10 +167,12 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
         assertSql("SELECT * FROM entity e WHERE e.id >= (select e1.id from entity1 e1 where e1.id = ?)",
                 "SELECT * FROM entity e WHERE e.id >= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1");
 
+
         /* <= */
         assertSql("SELECT * FROM entity e WHERE e.id <= (select e1.id from entity1 e1 where e1.id = ?)",
                 "SELECT * FROM entity e WHERE e.id <= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1");
 
+
         /* <> */
         assertSql("SELECT * FROM entity e WHERE e.id <> (select e1.id from entity1 e1 where e1.id = ?)",
                 "SELECT * FROM entity e WHERE e.id <> (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1");
@@ -204,6 +206,14 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
                 "SELECT * FROM entity e " +
                         "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
                         "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1");
+
+        assertSql("SELECT * FROM entity e " +
+                        "left join entity1 e1 on e1.id = e.id " +
+                        "left join entity2 e2 on e1.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
+                        "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " +
+                        "WHERE e.tenant_id = 1");
     }
 
     @Test
@@ -212,17 +222,125 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
         assertSql("SELECT * FROM entity e " +
                         "right join entity1 e1 on e1.id = e.id",
                 "SELECT * FROM entity e " +
-                        "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE e.tenant_id = 1");
+                        "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " +
+                        "WHERE e1.tenant_id = 1");
+
+        assertSql("SELECT * FROM with_as_1 e " +
+                        "right join entity1 e1 on e1.id = e.id",
+                "SELECT * FROM with_as_1 e " +
+                        "RIGHT JOIN entity1 e1 ON e1.id = e.id " +
+                        "WHERE e1.tenant_id = 1");
 
         assertSql("SELECT * FROM entity e " +
                         "right join entity1 e1 on e1.id = e.id " +
                         "WHERE e.id = ? OR e.name = ?",
                 "SELECT * FROM entity e " +
-                        "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1");
+                        "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " +
+                        "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1");
+
+        assertSql("SELECT * FROM entity e " +
+                        "right join entity1 e1 on e1.id = e.id " +
+                        "right join entity2 e2 on e1.id = e2.id ",
+                "SELECT * FROM entity e " +
+                        "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " +
+                        "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " +
+                        "WHERE e2.tenant_id = 1");
+    }
+
+    @Test
+    void selectMixJoin() {
+        assertSql("SELECT * FROM entity e " +
+                        "right join entity1 e1 on e1.id = e.id " +
+                        "left join entity2 e2 on e1.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " +
+                        "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " +
+                        "WHERE e1.tenant_id = 1");
+
+        assertSql("SELECT * FROM entity e " +
+                        "left join entity1 e1 on e1.id = e.id " +
+                        "right join entity2 e2 on e1.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
+                        "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " +
+                        "WHERE e2.tenant_id = 1");
+
+        assertSql("SELECT * FROM entity e " +
+                        "left join entity1 e1 on e1.id = e.id " +
+                        "inner join entity2 e2 on e1.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
+                        "INNER JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 AND e2.tenant_id = 1");
     }
 
+
+    @Test
+    void selectJoinSubSelect() {
+        assertSql("select * from (select * from entity) e1 " +
+                        "left join entity2 e2 on e1.id = e2.id",
+                "SELECT * FROM (SELECT * FROM entity WHERE entity.tenant_id = 1) e1 " +
+                        "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1");
+
+        assertSql("select * from entity1 e1 " +
+                        "left join (select * from entity2) e2 " +
+                        "on e1.id = e2.id",
+                "SELECT * FROM entity1 e1 " +
+                        "LEFT JOIN (SELECT * FROM entity2 WHERE entity2.tenant_id = 1) e2 " +
+                        "ON e1.id = e2.id " +
+                        "WHERE e1.tenant_id = 1");
+    }
+
+    @Test
+    void selectSubJoin() {
+
+        assertSql("select * FROM " +
+                        "(entity1 e1 right JOIN entity2 e2 ON e1.id = e2.id)",
+                "SELECT * FROM " +
+                        "(entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " +
+                        "WHERE e2.tenant_id = 1");
+
+        assertSql("select * FROM " +
+                        "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id)",
+                "SELECT * FROM " +
+                        "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " +
+                        "WHERE e1.tenant_id = 1");
+
+
+        assertSql("select * FROM " +
+                        "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id) " +
+                        "right join entity3 e3 on e1.id = e3.id",
+                "SELECT * FROM " +
+                        "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " +
+                        "RIGHT JOIN entity3 e3 ON e1.id = e3.id AND e1.tenant_id = 1 " +
+                        "WHERE e3.tenant_id = 1");
+
+
+        assertSql("select * FROM entity e " +
+                        "LEFT JOIN (entity1 e1 right join entity2 e2 ON e1.id = e2.id) " +
+                        "on e.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "LEFT JOIN (entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " +
+                        "ON e.id = e2.id AND e2.tenant_id = 1 " +
+                        "WHERE e.tenant_id = 1");
+
+        assertSql("select * FROM entity e " +
+                        "LEFT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " +
+                        "on e.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "LEFT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " +
+                        "ON e.id = e2.id AND e1.tenant_id = 1 " +
+                        "WHERE e.tenant_id = 1");
+
+        assertSql("select * FROM entity e " +
+                        "RIGHT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " +
+                        "on e.id = e2.id",
+                "SELECT * FROM entity e " +
+                        "RIGHT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " +
+                        "ON e.id = e2.id AND e.tenant_id = 1 " +
+                        "WHERE e1.tenant_id = 1");
+    }
+
+
     @Test
     void selectLeftJoinMultipleTrailingOn() {
         // 多个 on 尾缀的
@@ -256,51 +374,97 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
                         "inner join entity1 e1 on e1.id = e.id " +
                         "WHERE e.id = ? OR e.name = ?",
                 "SELECT * FROM entity e " +
-                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1");
+                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " +
+                        "WHERE e.id = ? OR e.name = ?");
 
         assertSql("SELECT * FROM entity e " +
                         "inner join entity1 e1 on e1.id = e.id " +
                         "WHERE (e.id = ? OR e.name = ?)",
                 "SELECT * FROM entity e " +
-                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1");
+                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " +
+                        "WHERE (e.id = ? OR e.name = ?)");
+
+        // 隐式内连接
+        assertSql("SELECT * FROM entity,entity1 " +
+                        "WHERE entity.id = entity1.id",
+                "SELECT * FROM entity, entity1 " +
+                        "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1");
+
+        // 隐式内连接
+        assertSql("SELECT * FROM entity a, with_as_entity1 b " +
+                        "WHERE a.id = b.id",
+                "SELECT * FROM entity a, with_as_entity1 b " +
+                        "WHERE a.id = b.id AND a.tenant_id = 1");
+
+        assertSql("SELECT * FROM with_as_entity a, with_as_entity1 b " +
+                        "WHERE a.id = b.id",
+                "SELECT * FROM with_as_entity a, with_as_entity1 b " +
+                        "WHERE a.id = b.id");
+
+        // SubJoin with 隐式内连接
+        assertSql("SELECT * FROM (entity,entity1) " +
+                        "WHERE entity.id = entity1.id",
+                "SELECT * FROM (entity, entity1) " +
+                        "WHERE entity.id = entity1.id " +
+                        "AND entity.tenant_id = 1 AND entity1.tenant_id = 1");
+
+        assertSql("SELECT * FROM ((entity,entity1),entity2) " +
+                        "WHERE entity.id = entity1.id and entity.id = entity2.id",
+                "SELECT * FROM ((entity, entity1), entity2) " +
+                        "WHERE entity.id = entity1.id AND entity.id = entity2.id " +
+                        "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1");
+
+        assertSql("SELECT * FROM (entity,(entity1,entity2)) " +
+                        "WHERE entity.id = entity1.id and entity.id = entity2.id",
+                "SELECT * FROM (entity, (entity1, entity2)) " +
+                        "WHERE entity.id = entity1.id AND entity.id = entity2.id " +
+                        "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1");
+
+        // 沙雕的括号写法
+        assertSql("SELECT * FROM (((entity,entity1))) " +
+                        "WHERE entity.id = entity1.id",
+                "SELECT * FROM (((entity, entity1))) " +
+                        "WHERE entity.id = entity1.id " +
+                        "AND entity.tenant_id = 1 AND entity1.tenant_id = 1");
 
-        // 垃圾 inner join todo
-//        assertSql("SELECT * FROM entity,entity1 " +
-//                "WHERE entity.id = entity1.id",
-//            "SELECT * FROM entity e " +
-//                "INNER JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-//                "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1");
     }
 
+
     @Test
     void selectWithAs() {
         assertSql("with with_as_A as (select * from entity) select * from with_as_A",
-                "WITH with_as_A AS (SELECT * FROM entity WHERE tenant_id = 1) SELECT * FROM with_as_A");
+                "WITH with_as_A AS (SELECT * FROM entity WHERE entity.tenant_id = 1) SELECT * FROM with_as_A");
+    }
+
+
+    @Test
+    void selectIgnoreTable() {
+        assertSql(" SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)",
+                "SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id AND item.tenant_id = 1 WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)");
     }
 
     private void assertSql(String sql, String targetSql) {
         assertEquals(targetSql, interceptor.parserSingle(sql, null));
     }
 
+
     // ========== 额外的测试 ==========
 
     @Test
     public void testSelectSingle() {
         // 单表
         assertSql("select * from t_user where id = ?",
-                "SELECT * FROM t_user WHERE id = ? AND tenant_id = 1 AND dept_id IN (10, 20)");
+                "SELECT * FROM t_user WHERE id = ? AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)");
 
         assertSql("select * from t_user where id = ? or name = ?",
-                "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND tenant_id = 1 AND dept_id IN (10, 20)");
+                "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)");
 
         assertSql("SELECT * FROM t_user WHERE (id = ? OR name = ?)",
-                "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND tenant_id = 1 AND dept_id IN (10, 20)");
+                "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)");
 
         /* not */
         assertSql("SELECT * FROM t_user WHERE not (id = ? OR name = ?)",
-                "SELECT * FROM t_user WHERE NOT (id = ? OR name = ?) AND tenant_id = 1 AND dept_id IN (10, 20)");
+                "SELECT * FROM t_user WHERE NOT (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)");
     }
 
     @Test
@@ -329,16 +493,16 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
                         "right join t_role e1 on e1.id = e.id " +
                         "WHERE e.id = ? OR e.name = ?",
                 "SELECT * FROM t_user e " +
-                        "RIGHT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)");
+                        "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " +
+                        "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1");
 
         // 条件 e.id = ? OR e.name = ? 带括号
         assertSql("SELECT * FROM t_user e " +
                         "right join t_role e1 on e1.id = e.id " +
                         "WHERE (e.id = ? OR e.name = ?)",
                 "SELECT * FROM t_user e " +
-                        "RIGHT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)");
+                        "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " +
+                        "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1");
     }
 
     @Test
@@ -348,23 +512,22 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest
                         "inner join entity1 e1 on e1.id = e.id " +
                         "WHERE e.id = ? OR e.name = ?",
                 "SELECT * FROM t_user e " +
-                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)");
+                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " +
+                        "WHERE e.id = ? OR e.name = ?");
 
         // 条件 e.id = ? OR e.name = ? 带括号
         assertSql("SELECT * FROM t_user e " +
-                        "inner join t_role e1 on e1.id = e.id " +
+                        "inner join entity1 e1 on e1.id = e.id " +
                         "WHERE (e.id = ? OR e.name = ?)",
                 "SELECT * FROM t_user e " +
-                        "INNER JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-                        "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)");
-
-        // 垃圾 inner join todo
-//        assertSql("SELECT * FROM entity,entity1 " +
-//                "WHERE entity.id = entity1.id",
-//            "SELECT * FROM entity e " +
-//                "INNER JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " +
-//                "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1");
+                        "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " +
+                        "WHERE (e.id = ? OR e.name = ?)");
+
+        // 没有 On 的 inner join
+        assertSql("SELECT * FROM entity,entity1 " +
+                "WHERE entity.id = entity1.id",
+            "SELECT * FROM entity, entity1 " +
+                    "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1");
     }
 
 }

+ 5 - 1
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.SortingField;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -78,7 +79,10 @@ public class MyBatisUtils {
      * @return Column 对象
      */
     public static Column buildColumn(String tableName, Alias tableAlias, String column) {
-        return new Column(tableAlias != null ? tableAlias.getName() + "." + column : column);
+        if (tableAlias != null) {
+            tableName = tableAlias.getName();
+        }
+        return new Column(tableName + StringPool.DOT + column);
     }
 
 }

+ 6 - 2
yudao-module-mall/pom.xml

@@ -15,14 +15,18 @@
     <name>${project.artifactId}</name>
 
     <description>
-        market模块,主要实现营销相关功能
-        例如:营销活动、banner广告、优惠券、优惠码等功能。
+        商城大模块,由 product 商品、market 营销、trade 交易 coupon等组成
     </description>
     <modules>
+        <module>yudao-module-coupon-api</module>
+        <module>yudao-module-coupon-biz</module>
         <module>yudao-module-market-api</module>
         <module>yudao-module-market-biz</module>
         <module>yudao-module-product-api</module>
         <module>yudao-module-product-biz</module>
+        <module>yudao-module-trade-api</module>
+        <module>yudao-module-trade-biz</module>
+
     </modules>
 
 </project>

+ 35 - 0
yudao-module-mall/yudao-module-coupon-api/pom.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>cn.iocoder.boot</groupId>
+        <artifactId>yudao-module-mall</artifactId>
+        <version>${revision}</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>yudao-module-coupon-api</artifactId>
+    <packaging>jar</packaging>
+
+
+    <name>${project.artifactId}</name>
+    <description>
+        coupon 模块 API,暴露给其它模块调用
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-common</artifactId>
+        </dependency>
+
+        <!-- 参数校验 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+</project>

+ 29 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponExpireTimeTypeEnum.java

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券 - 是否开启过期提醒
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponExpireTimeTypeEnum {
+
+    OPEN(1,"不开启"),
+    CLOSE(0,"开启"),;
+
+    /**
+     * 是否开启过期提醒
+     */
+    private final Integer type;
+    /**
+     * 是否开启过期提醒
+     */
+    private final String name;
+
+}

+ 29 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponFetchTypeEnum.java

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券 - 领取是否无限制 0
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponFetchTypeEnum {
+
+    LIMIT(1,"限制"),
+    NOT_LIMIT(0,"不限制"),;
+
+    /**
+     * 是否开启过期提醒
+     */
+    private final Integer type;
+    /**
+     * 是否开启过期提醒
+     */
+    private final String name;
+
+}

+ 29 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponForbidPreferenceEnum.java

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券 - 优惠叠加类型
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponForbidPreferenceEnum {
+
+    UN_FORBID(0,"不限制"),
+    FORBID(1,"优惠券仅原价购买商品时可用");
+
+    /**
+     * 优惠券类型
+     */
+    private final Integer type;
+    /**
+     * 优惠券类型名
+     */
+    private final String name;
+
+}

+ 30 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponGoodsTypeEnum.java

@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券 - 优惠券商品使用类型
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponGoodsTypeEnum {
+
+    ALL(1,"全部商品可用"),
+    POINT_PRODUCT(2,"指定商品可用"),
+    POINT_PRODUCT_NOT(3,"指定商品不可用"),;
+
+    /**
+     * 优惠券商品使用类型
+     */
+    private final Integer type;
+    /**
+     * 优惠券商品使用类型名
+     */
+    private final String name;
+
+}

+ 30 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponStatusTypeEnum.java

@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券 - 优惠券状态类型
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponStatusTypeEnum {
+
+    PROCESSING(1,"进行中"),
+    END(2,"已结束"),
+    CLOSE(3,"已关闭"),;
+
+    /**
+     * 优惠券类型
+     */
+    private final Integer type;
+    /**
+     * 优惠券类型名
+     */
+    private final String name;
+
+}

+ 30 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponTypeEnum.java

@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券 - 优惠券类型
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponTypeEnum {
+
+    REWARD(1,"满减"),
+    DISCOUNT(2,"折扣"),
+    RANDOW(3,"随机"),;
+
+    /**
+     * 优惠券类型
+     */
+    private final Integer type;
+    /**
+     * 优惠券类型名
+     */
+    private final String name;
+
+}

+ 29 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponUseLimitEnum.java

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+
+/**
+ * 优惠券使用类型 - 优惠券使用类型类型
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponUseLimitEnum {
+
+    HAS_LIMIT(1,"无门槛"),
+    NO_LIMIT(2,"有门槛"),;
+
+    /**
+     * 优惠券使用类型
+     */
+    private final Integer type;
+    /**
+     * 优惠券使用类型名
+     */
+    private final String name;
+
+}

+ 29 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/CouponValidityTypeEnum.java

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 过期类型 - 状态
+ *
+ * @author Sin
+ */
+@RequiredArgsConstructor
+@Getter
+public enum CouponValidityTypeEnum {
+
+    TIME_RANGE_EXPIRTED(1,"时间范围过期"),
+    EXPIRES_AFTER_FIXED_DATE(2,"领取之日固定日期后过期"),
+    EXPIRES_DATE_NEXT_FIEXD_DATE(3,"领取次日固定日期后过期"),;
+
+
+    /**
+     * 状态值
+     */
+    private final Integer status;
+    /**
+     * 状态名
+     */
+    private final String name;
+
+}

+ 27 - 0
yudao-module-mall/yudao-module-coupon-api/src/main/java/cn/iocoder/yudao/module/CouponTemplete/enums/ErrorCodeConstants.java

@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.CouponTemplete.enums;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+
+/**
+ * coupon 优惠券错误码枚举类
+ *
+ * coupon 优惠券系统,使用 1-010-000-000 段
+ */
+public interface ErrorCodeConstants {
+    // ========== COUPON分类相关 1010001000 ============
+
+    ErrorCode COUPON_TEMPLETE_NOT_EXISTS = new ErrorCode(1010001000, "优惠券模板不存在");
+    ErrorCode MONEY_NOT_NULL = new ErrorCode(1010001001, "当type为reward时需要添加发放面额不能为空");
+    ErrorCode DISCOUNT_NOT_NULL = new ErrorCode(1010001001, "当type为discount时需要添加折扣不能为空");
+    ErrorCode DISCOUNT_LIMIT_NOT_NULL = new ErrorCode(1010001001, "当type为discount时可选择性添加最多折扣金额不能为空");
+    ErrorCode MIN_MAX_NOT_NULL = new ErrorCode(1010001001, "当type为radom时需要添加最低金额");
+    ErrorCode START_END_TIME_NOT_NULL = new ErrorCode(1010001001, "使用开始日期,使用结束日期不能为空");
+    ErrorCode FIXED_TERM_NOT_NULL = new ErrorCode(1010001001, "领取之日起或者次日N天内有效不能为空");
+
+
+    // ========== COUPON分类相关 1010002000 ============
+    ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1010001000, "优惠券模板不存在");
+
+
+}
+

+ 62 - 0
yudao-module-mall/yudao-module-coupon-biz/pom.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>cn.iocoder.boot</groupId>
+        <artifactId>yudao-module-mall</artifactId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>jar</packaging>
+    <artifactId>yudao-module-coupon-biz</artifactId>
+
+    <name>${project.artifactId}</name>
+
+    <description>
+        coupon模块,主要负责优惠券的一些业务,含发布优惠券模板,分发优惠券等
+    </description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-module-coupon-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
+
+        <!-- 业务组件 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
+        </dependency>
+
+        <!-- Web 相关 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-excel</artifactId>
+        </dependency>
+
+        <!-- DB 相关 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-mybatis</artifactId>
+        </dependency>
+
+        <!-- Test 测试相关 -->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-spring-boot-starter-test</artifactId>
+        </dependency>
+
+    </dependencies>
+
+</project>

+ 88 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/CouponController.java

@@ -0,0 +1,88 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon;
+
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.annotations.*;
+
+import javax.validation.*;
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+
+import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO;
+import cn.iocoder.yudao.module.coupon.convert.coupon.CouponConvert;
+import cn.iocoder.yudao.module.coupon.service.coupon.CouponService;
+
+@Api(tags = "管理后台 - 优惠券")
+@RestController
+@RequestMapping("/coupon/item")
+@Validated
+public class CouponController {
+
+    @Resource
+    private CouponService couponService;
+
+
+    //todo 用户优惠券
+    @PostMapping("/create")
+    @ApiOperation("用户领取优惠券")
+    @PreAuthorize("@ss.hasPermission('coupon::create')")
+    public CommonResult<Long> create(@RequestParam("couponTemplateId") Long couponTemplateId) {
+
+        return success(couponService.create(couponTemplateId));
+    }
+
+
+    @PutMapping("/update")
+    @ApiOperation("更新优惠券")
+    @PreAuthorize("@ss.hasPermission('coupon::update')")
+    public CommonResult<Boolean> update(@Valid @RequestBody CouponUpdateReqVO updateReqVO) {
+        couponService.update(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @ApiOperation("删除优惠券")
+    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+    @PreAuthorize("@ss.hasPermission('coupon::delete')")
+    public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
+        couponService.delete(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @ApiOperation("获得优惠券")
+    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+    @PreAuthorize("@ss.hasPermission('coupon::query')")
+    public CommonResult<CouponRespVO> get(@RequestParam("id") Long id) {
+        CouponDO couponDO = couponService.get(id);
+        return success(CouponConvert.INSTANCE.convert(couponDO));
+    }
+
+
+
+    @GetMapping("/list")
+    @ApiOperation("获得优惠券列表")
+    @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+    @PreAuthorize("@ss.hasPermission('coupon::query')")
+    public CommonResult<List<CouponRespVO>> getList(@RequestParam("ids") Collection<Long> ids) {
+        List<CouponDO> list = couponService.getList(ids);
+        return success(CouponConvert.INSTANCE.convertList(list));
+    }
+
+    @GetMapping("/page")
+    @ApiOperation("获得优惠券分页")
+    @PreAuthorize("@ss.hasPermission('coupon::query')")
+    public CommonResult<PageResult<CouponRespVO>> getPage(@Valid CouponPageReqVO pageVO) {
+        PageResult<CouponDO> pageResult = couponService.getPage(pageVO);
+        return success(CouponConvert.INSTANCE.convertPage(pageResult));
+    }
+
+
+}

+ 110 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponBaseVO.java

@@ -0,0 +1,110 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
+
+import lombok.*;
+import java.util.*;
+import java.math.BigDecimal;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+* 优惠券 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class CouponBaseVO {
+
+    @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机", required = true)
+    @NotNull(message = "优惠券类型 reward-满减 discount-折扣 random-随机不能为空")
+    private String type;
+
+    @ApiModelProperty(value = "优惠券名称", required = true)
+    @NotNull(message = "优惠券名称不能为空")
+    private String name;
+
+    @ApiModelProperty(value = "优惠券类型id")
+    private Long couponTypeId;
+
+    @ApiModelProperty(value = "优惠券编码", required = true)
+    @NotNull(message = "优惠券编码不能为空")
+    private String couponCode;
+
+    @ApiModelProperty(value = "领用人", required = true)
+    @NotNull(message = "领用人不能为空")
+    private Long memberId;
+
+    @ApiModelProperty(value = "优惠券使用订单id", required = true)
+    @NotNull(message = "优惠券使用订单id不能为空")
+    private Long useOrderId;
+
+    @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用", required = true)
+    @NotNull(message = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用不能为空")
+    private Boolean goodsType;
+
+    @ApiModelProperty(value = "适用商品id", required = true)
+    @NotNull(message = "适用商品id不能为空")
+    private String goodsIds;
+
+    @ApiModelProperty(value = "最小金额", required = true)
+    @NotNull(message = "最小金额不能为空")
+    private BigDecimal atLeast;
+
+    @ApiModelProperty(value = "面额", required = true)
+    @NotNull(message = "面额不能为空")
+    private BigDecimal money;
+
+    @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加", required = true)
+    @NotNull(message = "1 =< 折扣 <= 9.9 当type为discount时需要添加不能为空")
+    private BigDecimal discount;
+
+    @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加", required = true)
+    @NotNull(message = "最多折扣金额 当type为discount时可选择性添加不能为空")
+    private BigDecimal discountLimit;
+
+    @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用", required = true)
+    @NotNull(message = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用不能为空")
+    private Boolean whetherForbidPreference;
+
+    @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启", required = true)
+    @NotNull(message = "是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ApiModelProperty(value = "过期前N天提醒", required = true)
+    @NotNull(message = "过期前N天提醒不能为空")
+    private Integer expireNoticeFixedTerm;
+
+    @ApiModelProperty(value = "是否已提醒", required = true)
+    @NotNull(message = "是否已提醒不能为空")
+    private Boolean whetherNoticed;
+
+    @ApiModelProperty(value = "优惠券状态 1已领用(未使用) 2已使用 3已过期", required = true)
+    @NotNull(message = "优惠券状态 1已领用(未使用) 2已使用 3已过期不能为空")
+    private Integer state;
+
+    @ApiModelProperty(value = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取", required = true)
+    @NotNull(message = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取不能为空")
+    private Boolean getType;
+
+    @ApiModelProperty(value = "领取时间", required = true)
+    @NotNull(message = "领取时间不能为空")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date fetchTime;
+
+    @ApiModelProperty(value = "使用时间", required = true)
+    @NotNull(message = "使用时间不能为空")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date useTime;
+
+    @ApiModelProperty(value = "可使用的开始时间", required = true)
+    @NotNull(message = "可使用的开始时间不能为空")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date startTime;
+
+    @ApiModelProperty(value = "有效期结束时间", required = true)
+    @NotNull(message = "有效期结束时间不能为空")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date endTime;
+
+}

+ 3 - 3
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateReqVO.java → yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponCreateReqVO.java

@@ -1,14 +1,14 @@
-package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
 
 import lombok.*;
 import java.util.*;
 import io.swagger.annotations.*;
 import javax.validation.constraints.*;
 
-@ApiModel("管理后台 - 商品sku创建 Request VO")
+@ApiModel("管理后台 - 优惠券创建 Request VO")
 @Data
 @EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
-public class ProductSkuCreateReqVO extends ProductSkuBaseVO {
+public class CouponCreateReqVO extends CouponBaseVO {
 
 }

+ 90 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponExcelVO.java

@@ -0,0 +1,90 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
+
+import lombok.*;
+import java.util.*;
+import java.math.BigDecimal;
+import io.swagger.annotations.*;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+
+/**
+ * 优惠券 Excel VO
+ *
+ * @author wxr
+ */
+@Data
+public class CouponExcelVO {
+
+    @ExcelProperty("用户ID")
+    private Long id;
+
+    @ExcelProperty("优惠券类型 reward-满减 discount-折扣 random-随机")
+    private String type;
+
+    @ExcelProperty("优惠券名称")
+    private String name;
+
+    @ExcelProperty("优惠券类型id")
+    private Long couponTypeId;
+
+    @ExcelProperty("优惠券编码")
+    private String couponCode;
+
+    @ExcelProperty("领用人")
+    private Long memberId;
+
+    @ExcelProperty("优惠券使用订单id")
+    private Long useOrderId;
+
+    @ExcelProperty("适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用")
+    private Boolean goodsType;
+
+    @ExcelProperty("适用商品id")
+    private String goodsIds;
+
+    @ExcelProperty("最小金额")
+    private BigDecimal atLeast;
+
+    @ExcelProperty("面额")
+    private BigDecimal money;
+
+    @ExcelProperty("1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    private BigDecimal discount;
+
+    @ExcelProperty("最多折扣金额 当type为discount时可选择性添加")
+    private BigDecimal discountLimit;
+
+    @ExcelProperty("优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用")
+    private Boolean whetherForbidPreference;
+
+    @ExcelProperty("是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ExcelProperty("过期前N天提醒")
+    private Integer expireNoticeFixedTerm;
+
+    @ExcelProperty("是否已提醒")
+    private Boolean whetherNoticed;
+
+    @ExcelProperty("优惠券状态 1已领用(未使用) 2已使用 3已过期")
+    private Integer state;
+
+    @ExcelProperty("获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取")
+    private Boolean getType;
+
+    @ExcelProperty("领取时间")
+    private Date fetchTime;
+
+    @ExcelProperty("使用时间")
+    private Date useTime;
+
+    @ExcelProperty("可使用的开始时间")
+    private Date startTime;
+
+    @ExcelProperty("有效期结束时间")
+    private Date endTime;
+
+    @ExcelProperty("创建时间")
+    private Date createTime;
+
+}

+ 91 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponExportReqVO.java

@@ -0,0 +1,91 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
+
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel(value = "管理后台 - 优惠券 Excel 导出 Request VO", description = "参数和 CouponPageReqVO 是一致的")
+@Data
+public class CouponExportReqVO {
+
+    @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机")
+    private String type;
+
+    @ApiModelProperty(value = "优惠券名称")
+    private String name;
+
+    @ApiModelProperty(value = "优惠券类型id")
+    private Long couponTypeId;
+
+    @ApiModelProperty(value = "优惠券编码")
+    private String couponCode;
+
+    @ApiModelProperty(value = "领用人")
+    private Long memberId;
+
+    @ApiModelProperty(value = "优惠券使用订单id")
+    private Long useOrderId;
+
+    @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用")
+    private Boolean goodsType;
+
+    @ApiModelProperty(value = "适用商品id")
+    private String goodsIds;
+
+    @ApiModelProperty(value = "最小金额")
+    private BigDecimal atLeast;
+
+    @ApiModelProperty(value = "面额")
+    private BigDecimal money;
+
+    @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    private BigDecimal discount;
+
+    @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加")
+    private BigDecimal discountLimit;
+
+    @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用")
+    private Boolean whetherForbidPreference;
+
+    @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ApiModelProperty(value = "过期前N天提醒")
+    private Integer expireNoticeFixedTerm;
+
+    @ApiModelProperty(value = "是否已提醒")
+    private Boolean whetherNoticed;
+
+    @ApiModelProperty(value = "优惠券状态 1已领用(未使用) 2已使用 3已过期")
+    private Integer state;
+
+    @ApiModelProperty(value = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取")
+    private Boolean getType;
+
+    @ApiModelProperty(value = "领取时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] fetchTime;
+
+    @ApiModelProperty(value = "使用时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] useTime;
+
+    @ApiModelProperty(value = "可使用的开始时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] startTime;
+
+    @ApiModelProperty(value = "有效期结束时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] createTime;
+
+}

+ 93 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponPageReqVO.java

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
+
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 优惠券分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponPageReqVO extends PageParam {
+
+    @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机")
+    private String type;
+
+    @ApiModelProperty(value = "优惠券名称")
+    private String name;
+
+    @ApiModelProperty(value = "优惠券类型id")
+    private Long couponTypeId;
+
+    @ApiModelProperty(value = "优惠券编码")
+    private String couponCode;
+
+    @ApiModelProperty(value = "领用人")
+    private Long memberId;
+
+    @ApiModelProperty(value = "优惠券使用订单id")
+    private Long useOrderId;
+
+    @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用")
+    private Boolean goodsType;
+
+    @ApiModelProperty(value = "适用商品id")
+    private String goodsIds;
+
+    @ApiModelProperty(value = "最小金额")
+    private BigDecimal atLeast;
+
+    @ApiModelProperty(value = "面额")
+    private BigDecimal money;
+
+    @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    private BigDecimal discount;
+
+    @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加")
+    private BigDecimal discountLimit;
+
+    @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用")
+    private Boolean whetherForbidPreference;
+
+    @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ApiModelProperty(value = "过期前N天提醒")
+    private Integer expireNoticeFixedTerm;
+
+    @ApiModelProperty(value = "是否已提醒")
+    private Boolean whetherNoticed;
+
+    @ApiModelProperty(value = "优惠券状态 1已领用(未使用) 2已使用 3已过期")
+    private Integer state;
+
+    @ApiModelProperty(value = "获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取")
+    private Boolean getType;
+
+    @ApiModelProperty(value = "领取时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] fetchTime;
+
+    @ApiModelProperty(value = "使用时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] useTime;
+
+    @ApiModelProperty(value = "可使用的开始时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] startTime;
+
+    @ApiModelProperty(value = "有效期结束时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] createTime;
+
+}

+ 4 - 4
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityRespVO.java → yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponRespVO.java

@@ -1,16 +1,16 @@
-package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
 
 import lombok.*;
 import java.util.*;
 import io.swagger.annotations.*;
 
-@ApiModel("管理后台 - 促销活动 Response VO")
+@ApiModel("管理后台 - 优惠券 Response VO")
 @Data
 @EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
-public class ActivityRespVO extends ActivityBaseVO {
+public class CouponRespVO extends CouponBaseVO {
 
-    @ApiModelProperty(value = "活动编号", required = true)
+    @ApiModelProperty(value = "用户ID", required = true)
     private Long id;
 
     @ApiModelProperty(value = "创建时间", required = true)

+ 18 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/coupon/vo/CouponUpdateReqVO.java

@@ -0,0 +1,18 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+@ApiModel("管理后台 - 优惠券更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponUpdateReqVO extends CouponBaseVO {
+
+    @ApiModelProperty(value = "用户ID", required = true)
+    @NotNull(message = "用户ID不能为空")
+    private Long id;
+
+}

+ 81 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/CouponTempleteController.java

@@ -0,0 +1,81 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete;
+
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.*;
+import cn.iocoder.yudao.module.coupon.convert.CouponTemplete.CouponTempleteConvert;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO;
+import cn.iocoder.yudao.module.coupon.service.CouponTemplete.CouponTempleteService;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.annotations.*;
+
+import javax.validation.*;
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 优惠券模板")
+@RestController
+@RequestMapping("/coupon/template")
+@Validated
+public class CouponTempleteController {
+
+    @Resource
+    private CouponTempleteService couponTempleteServiceService;
+
+    @PostMapping("/create")
+    @ApiOperation("创建优惠券模板")
+    @PreAuthorize("@ss.hasPermission('CouponTemplete::create')")
+    public CommonResult<Long> create(@Valid @RequestBody CouponTempleteCreateReqVO createReqVO) {
+        return success(couponTempleteServiceService.create(createReqVO));
+    }
+
+//    @PutMapping("/update")
+//    @ApiOperation("更新优惠券模板")
+//    @PreAuthorize("@ss.hasPermission('CouponTemplete::update')")
+//    public CommonResult<Boolean> update(@Valid @RequestBody CouponTempleteUpdateReqVO updateReqVO) {
+//        couponTempleteServiceService.update(updateReqVO);
+//        return success(true);
+//    }
+//
+//    @DeleteMapping("/delete")
+//    @ApiOperation("删除优惠券模板")
+//    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+//    @PreAuthorize("@ss.hasPermission('CouponTemplete::delete')")
+//    public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
+//        couponTempleteServiceService.delete(id);
+//        return success(true);
+//    }
+//
+//    @GetMapping("/get")
+//    @ApiOperation("获得优惠券模板")
+//    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+//    @PreAuthorize("@ss.hasPermission('CouponTemplete::query')")
+//    public CommonResult<CouponTempleteRespVO> get(@RequestParam("id") Long id) {
+//        CouponTempleteDO couponTempleteDO = couponTempleteServiceService.get(id);
+//        return success(CouponTempleteConvert.INSTANCE.convert(couponTempleteDO));
+//    }
+//
+//    @GetMapping("/list")
+//    @ApiOperation("获得优惠券模板列表")
+//    @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+//    @PreAuthorize("@ss.hasPermission('CouponTemplete::query')")
+//    public CommonResult<List<CouponTempleteRespVO>> getList(@RequestParam("ids") Collection<Long> ids) {
+//        List<CouponTempleteDO> list = couponTempleteServiceService.getList(ids);
+//        return success(CouponTempleteConvert.INSTANCE.convertList(list));
+//    }
+//
+    @GetMapping("/page")
+    @ApiOperation("获得优惠券模板分页")
+    @PreAuthorize("@ss.hasPermission('CouponTemplete::query')")
+    public CommonResult<PageResult<CouponTempleteRespVO>> getPage(@Valid CouponTempletePageReqVO pageVO) {
+        PageResult<CouponTempleteDO> pageResult = couponTempleteServiceService.getPage(pageVO);
+        return success(CouponTempleteConvert.INSTANCE.convertPage(pageResult));
+    }
+
+
+
+}

+ 172 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteBaseVO.java

@@ -0,0 +1,172 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+import java.util.*;
+import java.math.BigDecimal;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+* 优惠券模板 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class CouponTempleteBaseVO {
+
+
+    //基本信息
+
+    @ApiModelProperty(value = "优惠券名称", required = true)
+    @NotNull(message = "优惠券名称不能为空")
+    private String name;
+
+    @ApiModelProperty(value = "名称备注")
+    private String couponNameRemark;
+
+    @ApiModelProperty(value = "优惠券图片")
+    private String image;
+
+    /*  ============判断适用商品——开始=============  */
+
+
+    @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用", required = true)
+    @NotNull(message = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用不能为空")
+    private Integer goodsType;
+
+    @ApiModelProperty(value = "适用商品id")
+    private String productIds;
+
+    @ApiModelProperty(value = "使用门槛0-无门槛 1-有门槛", required = true)
+    @NotNull(message = "使用门槛0-无门槛 1-有门槛不能为空")
+    private Boolean hasUseLimit;
+
+    @ApiModelProperty(value = "满多少元使用 0代表无限制", required = true)
+    @NotNull(message = "满多少元使用 0代表无限制不能为空")
+    private BigDecimal atLeast;
+
+
+    /*  ============折扣类型——开始=============  */
+
+    @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机", required = true)
+    @NotNull(message = "优惠券类型 reward-满减 discount-折扣 random-随机不能为空")
+    private String type;
+
+    @ApiModelProperty(value = "发放面额 当type为reward时需要添加")
+    @NotNull(message = "发放面额 当type为reward时需要添加不能为空")
+    private BigDecimal money;
+
+    @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    @NotNull(message = "1 =< 折扣 <= 9.9 当type为discount时需要添加不能为空")
+    private BigDecimal discount;
+
+    @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加")
+    @NotNull(message = "最多折扣金额 当type为discount时可选择性添加不能为空")
+    private BigDecimal discountLimit;
+
+    @ApiModelProperty(value = "最低金额 当type为radom时需要添加", required = true)
+    @NotNull(message = "最低金额 当type为radom时需要添加不能为空")
+    private BigDecimal minMoney;
+
+    @ApiModelProperty(value = "最大金额 当type为radom时需要添加", required = true)
+    @NotNull(message = "最大金额 当type为radom时需要添加不能为空")
+    private BigDecimal maxMoney;
+
+    /*  ============折扣类型——结束=============  */
+
+
+    /*  ============过期类型——开始=============  */
+
+
+    @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期", required = true)
+    @NotNull(message = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期 不能为空")
+    private Integer validityType;
+
+    @ApiModelProperty(value = "使用开始日期 过期类型1时必填")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date startUseTime;
+
+    @ApiModelProperty(value = "使用结束日期 过期类型1时必填")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date endUseTime;
+
+    @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效")
+    @NotNull(message = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效不能为空")
+    private Integer fixedTerm;
+
+    @ApiModelProperty(value = "有效日期结束时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date endTime;
+
+    /*  ============过期类型——结束=============  */
+
+
+    @ApiModelProperty(value = "领取是否无限制0-否 1是", required = true)
+    @NotNull(message = "是否无限制0-否 1是")
+    private Boolean whetherLimitless;
+
+    @ApiModelProperty(value = "每人最大领取个数", required = true)
+    @NotNull(message = "每人最大领取个数不能为空")
+    private Integer maxFetch;
+
+    @ApiModelProperty(value = "是否开启过期提醒 0-不开启 1-开启", required = true)
+    @NotNull(message = "是否开启过期提醒0-不开启 1-开启不能为空")
+    private Boolean whetherExpireNotice;
+
+    @ApiModelProperty(value = "过期前N天提醒", required = true)
+    @NotNull(message = "过期前N天提醒不能为空")
+    private Integer expireNoticeFixedTerm;
+
+    @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用", required = true)
+    @NotNull(message = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用不能为空")
+    private Boolean whetherForbidPreference;
+
+    @ApiModelProperty(value = "是否显示", required = true)
+    @NotNull(message = "是否显示不能为空")
+    private Integer whetherShow;
+
+    @ApiModelProperty(value = "是否禁止发放0-否 1-是", required = true)
+    @NotNull(message = "是否禁止发放0-否 1-是不能为空")
+    private Boolean whetherForbidden;
+
+    /*  ============汇总计算——开始=============  */
+
+
+
+    @ApiModelProperty(value = "使用优惠券购买的商品数量", required = true)
+    @NotNull(message = "使用优惠券购买的商品数量不能为空")
+    private Integer orderGoodsNum;
+
+    @ApiModelProperty(value = "订单的优惠总金额", required = true)
+    @NotNull(message = "订单的优惠总金额不能为空")
+    private BigDecimal discountOrderMoney;
+
+    @ApiModelProperty(value = "用券总成交额", required = true)
+    @NotNull(message = "用券总成交额不能为空")
+    private BigDecimal orderMoney;
+
+    @ApiModelProperty(value = "发放数量", required = true)
+    @NotNull(message = "发放数量不能为空")
+    private Integer count;
+
+    @ApiModelProperty(value = "已领取数量", required = true)
+    @NotNull(message = "已领取数量不能为空")
+    private Integer leadCount;
+
+    @ApiModelProperty(value = "已使用数量", required = true)
+    @NotNull(message = "已使用数量不能为空")
+    private Integer usedCount;
+
+
+    /*  ============汇总计算——结束=============  */
+
+
+    @ApiModelProperty(value = "状态(1进行中2已结束3已关闭)", required = true)
+    @NotNull(message = "状态(1进行中2已结束-1已关闭)不能为空")
+    private Integer status;
+
+
+
+}

+ 12 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteCreateReqVO.java

@@ -0,0 +1,12 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 优惠券模板创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponTempleteCreateReqVO extends CouponTempleteBaseVO {
+
+}

+ 119 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteExcelVO.java

@@ -0,0 +1,119 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+import java.util.*;
+import java.math.BigDecimal;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+
+/**
+ * 优惠券模板 Excel VO
+ *
+ * @author wxr
+ */
+@Data
+public class CouponTempleteExcelVO {
+
+    @ExcelProperty("用户ID")
+    private Long id;
+
+    @ExcelProperty("优惠券类型 reward-满减 discount-折扣 random-随机")
+    private String type;
+
+    @ExcelProperty("优惠券名称")
+    private String name;
+
+    @ExcelProperty("名称备注")
+    private String couponNameRemark;
+
+    @ExcelProperty("优惠券图片")
+    private String image;
+
+    @ExcelProperty("发放数量")
+    private Integer count;
+
+    @ExcelProperty("已领取数量")
+    private Integer leadCount;
+
+    @ExcelProperty("已使用数量")
+    private Integer usedCount;
+
+    @ExcelProperty("适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用")
+    private Integer goodsType;
+
+    @ExcelProperty("适用商品id")
+    private String productIds;
+
+    @ExcelProperty("使用门槛0-无门槛 1-有门槛")
+    private Boolean hasUseLimit;
+
+    @ExcelProperty("满多少元使用 0代表无限制")
+    private BigDecimal atLeast;
+
+    @ExcelProperty("发放面额 当type为reward时需要添加")
+    private BigDecimal money;
+
+    @ExcelProperty("1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    private BigDecimal discount;
+
+    @ExcelProperty("最多折扣金额 当type为discount时可选择性添加")
+    private BigDecimal discountLimit;
+
+    @ExcelProperty("最低金额 当type为radom时需要添加")
+    private BigDecimal minMoney;
+
+    @ExcelProperty("最大金额 当type为radom时需要添加")
+    private BigDecimal maxMoney;
+
+    @ExcelProperty("过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期")
+    private Integer validityType;
+
+    @ExcelProperty("使用开始日期 过期类型1时必填")
+    private Date startUseTime;
+
+    @ExcelProperty("使用结束日期 过期类型1时必填")
+    private Date endUseTime;
+
+    @ExcelProperty("当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效")
+    private Integer fixedTerm;
+
+    @ExcelProperty("是否无限制0-否 1是")
+    private Boolean whetherLimitless;
+
+    @ExcelProperty("每人最大领取个数")
+    private Integer maxFetch;
+
+    @ExcelProperty("是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ExcelProperty("过期前N天提醒")
+    private Integer expireNoticeFixedTerm;
+
+    @ExcelProperty("优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用")
+    private Boolean whetherForbidPreference;
+
+    @ExcelProperty("是否显示")
+    private Integer whetherShow;
+
+    @ExcelProperty("订单的优惠总金额")
+    private BigDecimal discountOrderMoney;
+
+    @ExcelProperty("用券总成交额")
+    private BigDecimal orderMoney;
+
+    @ExcelProperty("是否禁止发放0-否 1-是")
+    private Boolean whetherForbidden;
+
+    @ExcelProperty("使用优惠券购买的商品数量")
+    private Integer orderGoodsNum;
+
+    @ExcelProperty("状态(1进行中2已结束-1已关闭)")
+    private Integer status;
+
+    @ExcelProperty("有效日期结束时间")
+    private Date endTime;
+
+    @ExcelProperty("创建时间")
+    private Date createTime;
+
+}

+ 119 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteExportReqVO.java

@@ -0,0 +1,119 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.util.*;
+import io.swagger.annotations.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel(value = "管理后台 - 优惠券模板 Excel 导出 Request VO", description = "参数和 CouponTempletePageReqVO 是一致的")
+@Data
+public class CouponTempleteExportReqVO {
+
+    @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机")
+    private String type;
+
+    @ApiModelProperty(value = "优惠券名称")
+    private String name;
+
+    @ApiModelProperty(value = "名称备注")
+    private String couponNameRemark;
+
+    @ApiModelProperty(value = "优惠券图片")
+    private String image;
+
+    @ApiModelProperty(value = "发放数量")
+    private Integer count;
+
+    @ApiModelProperty(value = "已领取数量")
+    private Integer leadCount;
+
+    @ApiModelProperty(value = "已使用数量")
+    private Integer usedCount;
+
+    @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用")
+    private Boolean goodsType;
+
+    @ApiModelProperty(value = "适用商品id")
+    private String productIds;
+
+    @ApiModelProperty(value = "使用门槛0-无门槛 1-有门槛")
+    private Boolean hasUseLimit;
+
+    @ApiModelProperty(value = "满多少元使用 0代表无限制")
+    private BigDecimal atLeast;
+
+    @ApiModelProperty(value = "发放面额 当type为reward时需要添加")
+    private BigDecimal money;
+
+    @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    private BigDecimal discount;
+
+    @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加")
+    private BigDecimal discountLimit;
+
+    @ApiModelProperty(value = "最低金额 当type为radom时需要添加")
+    private BigDecimal minMoney;
+
+    @ApiModelProperty(value = "最大金额 当type为radom时需要添加")
+    private BigDecimal maxMoney;
+
+    @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期")
+    private Boolean validityType;
+
+    @ApiModelProperty(value = "使用开始日期 过期类型1时必填")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] startUseTime;
+
+    @ApiModelProperty(value = "使用结束日期 过期类型1时必填")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] endUseTime;
+
+    @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效")
+    private Integer fixedTerm;
+
+    @ApiModelProperty(value = "是否无限制0-否 1是")
+    private Boolean whetherLimitless;
+
+    @ApiModelProperty(value = "每人最大领取个数")
+    private Integer maxFetch;
+
+    @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ApiModelProperty(value = "过期前N天提醒")
+    private Integer expireNoticeFixedTerm;
+
+    @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用")
+    private Boolean whetherForbidPreference;
+
+    @ApiModelProperty(value = "是否显示")
+    private Integer whetherShow;
+
+    @ApiModelProperty(value = "订单的优惠总金额")
+    private BigDecimal discountOrderMoney;
+
+    @ApiModelProperty(value = "用券总成交额")
+    private BigDecimal orderMoney;
+
+    @ApiModelProperty(value = "是否禁止发放0-否 1-是")
+    private Boolean whetherForbidden;
+
+    @ApiModelProperty(value = "使用优惠券购买的商品数量")
+    private Integer orderGoodsNum;
+
+    @ApiModelProperty(value = "状态(1进行中2已结束-1已关闭)")
+    private Integer status;
+
+    @ApiModelProperty(value = "有效日期结束时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] createTime;
+
+}

+ 122 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempletePageReqVO.java

@@ -0,0 +1,122 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 优惠券模板分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponTempletePageReqVO extends PageParam {
+
+    @ApiModelProperty(value = "优惠券类型 reward-满减 discount-折扣 random-随机")
+    private String type;
+
+    @ApiModelProperty(value = "优惠券名称")
+    private String name;
+
+    @ApiModelProperty(value = "名称备注")
+    private String couponNameRemark;
+
+    @ApiModelProperty(value = "优惠券图片")
+    private String image;
+
+    @ApiModelProperty(value = "发放数量")
+    private Integer count;
+
+    @ApiModelProperty(value = "已领取数量")
+    private Integer leadCount;
+
+    @ApiModelProperty(value = "已使用数量")
+    private Integer usedCount;
+
+    @ApiModelProperty(value = "适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用")
+    private Boolean goodsType;
+
+    @ApiModelProperty(value = "适用商品id")
+    private String productIds;
+
+    @ApiModelProperty(value = "使用门槛0-无门槛 1-有门槛")
+    private Boolean hasUseLimit;
+
+    @ApiModelProperty(value = "满多少元使用 0代表无限制")
+    private BigDecimal atLeast;
+
+    @ApiModelProperty(value = "发放面额 当type为reward时需要添加")
+    private BigDecimal money;
+
+    @ApiModelProperty(value = "1 =< 折扣 <= 9.9 当type为discount时需要添加")
+    private BigDecimal discount;
+
+    @ApiModelProperty(value = "最多折扣金额 当type为discount时可选择性添加")
+    private BigDecimal discountLimit;
+
+    @ApiModelProperty(value = "最低金额 当type为radom时需要添加")
+    private BigDecimal minMoney;
+
+    @ApiModelProperty(value = "最大金额 当type为radom时需要添加")
+    private BigDecimal maxMoney;
+
+    @ApiModelProperty(value = "过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期")
+    private Boolean validityType;
+
+    @ApiModelProperty(value = "使用开始日期 过期类型1时必填")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] startUseTime;
+
+    @ApiModelProperty(value = "使用结束日期 过期类型1时必填")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] endUseTime;
+
+    @ApiModelProperty(value = "当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效")
+    private Integer fixedTerm;
+
+    @ApiModelProperty(value = "是否无限制0-否 1是")
+    private Boolean whetherLimitless;
+
+    @ApiModelProperty(value = "每人最大领取个数")
+    private Integer maxFetch;
+
+    @ApiModelProperty(value = "是否开启过期提醒0-不开启 1-开启")
+    private Boolean whetherExpireNotice;
+
+    @ApiModelProperty(value = "过期前N天提醒")
+    private Integer expireNoticeFixedTerm;
+
+    @ApiModelProperty(value = "优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用")
+    private Boolean whetherForbidPreference;
+
+    @ApiModelProperty(value = "是否显示")
+    private Integer whetherShow;
+
+    @ApiModelProperty(value = "订单的优惠总金额")
+    private BigDecimal discountOrderMoney;
+
+    @ApiModelProperty(value = "用券总成交额")
+    private BigDecimal orderMoney;
+
+    @ApiModelProperty(value = "是否禁止发放0-否 1-是")
+    private Boolean whetherForbidden;
+
+    @ApiModelProperty(value = "使用优惠券购买的商品数量")
+    private Integer orderGoodsNum;
+
+    @ApiModelProperty(value = "状态(1进行中2已结束-1已关闭)")
+    private Integer status;
+
+    @ApiModelProperty(value = "有效日期结束时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private Date[] createTime;
+
+}

+ 19 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteRespVO.java

@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 优惠券模板 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponTempleteRespVO extends CouponTempleteBaseVO {
+
+    @ApiModelProperty(value = "用户ID", required = true)
+    private Long id;
+
+    @ApiModelProperty(value = "创建时间", required = true)
+    private Date createTime;
+
+}

+ 17 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/controller/admin/templete/vo/CouponTempleteUpdateReqVO.java

@@ -0,0 +1,17 @@
+package cn.iocoder.yudao.module.coupon.controller.admin.templete.vo;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+@ApiModel("管理后台 - 优惠券模板更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponTempleteUpdateReqVO extends CouponTempleteBaseVO {
+
+    @ApiModelProperty(value = "用户ID", required = true)
+    @NotNull(message = "用户ID不能为空")
+    private Long id;
+
+}

+ 38 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/convert/CouponTemplete/CouponTempleteConvert.java

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.coupon.convert.CouponTemplete;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteCreateReqVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteExcelVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteRespVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteUpdateReqVO;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+
+/**
+ * 优惠券模板 Convert
+ *
+ * @author wxr
+ */
+@Mapper
+public interface CouponTempleteConvert {
+
+    CouponTempleteConvert INSTANCE = Mappers.getMapper(CouponTempleteConvert.class);
+
+    CouponTempleteDO convert(CouponTempleteCreateReqVO bean);
+
+    CouponTempleteDO convert(CouponTempleteUpdateReqVO bean);
+
+    CouponTempleteRespVO convert(CouponTempleteDO bean);
+
+    List<CouponTempleteRespVO> convertList(List<CouponTempleteDO> list);
+
+    PageResult<CouponTempleteRespVO> convertPage(PageResult<CouponTempleteDO> page);
+
+    List<CouponTempleteExcelVO> convertList02(List<CouponTempleteDO> list);
+
+}

+ 34 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/convert/coupon/CouponConvert.java

@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.coupon.convert.coupon;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO;
+
+/**
+ * 优惠券 Convert
+ *
+ * @author wxr
+ */
+@Mapper
+public interface CouponConvert {
+
+    CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class);
+
+    CouponDO convert(CouponCreateReqVO bean);
+
+    CouponDO convert(CouponUpdateReqVO bean);
+
+    CouponRespVO convert(CouponDO bean);
+
+    List<CouponRespVO> convertList(List<CouponDO> list);
+
+    PageResult<CouponRespVO> convertPage(PageResult<CouponDO> page);
+
+    List<CouponExcelVO> convertList02(List<CouponDO> list);
+
+}

+ 158 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/dataobject/CouponTemplete/CouponTempleteDO.java

@@ -0,0 +1,158 @@
+package cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete;
+
+import lombok.*;
+import java.util.*;
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 优惠券模板 DO
+ *
+ * @author wxr
+ */
+@TableName("coupon_templete")
+@KeySequence("coupon_templete_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class CouponTempleteDO extends BaseDO {
+
+    /**
+     * 用户ID
+     */
+    @TableId
+    private Long id;
+    /**
+     * 优惠券类型 reward-满减 discount-折扣 random-随机
+     */
+    private String type;
+    /**
+     * 优惠券名称
+     */
+    private String name;
+    /**
+     * 名称备注
+     */
+    private String couponNameRemark;
+    /**
+     * 优惠券图片
+     */
+    private String image;
+    /**
+     * 发放数量
+     */
+    private Integer count;
+    /**
+     * 已领取数量
+     */
+    private Integer leadCount;
+    /**
+     * 已使用数量
+     */
+    private Integer usedCount;
+    /**
+     * 适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用
+     */
+    private Integer goodsType;
+    /**
+     * 适用商品id
+     */
+    private String productIds;
+    /**
+     * 使用门槛0-无门槛 1-有门槛
+     */
+    private Boolean hasUseLimit;
+    /**
+     * 满多少元使用 0代表无限制
+     */
+    private BigDecimal atLeast;
+    /**
+     * 发放面额 当type为reward时需要添加
+     */
+    private BigDecimal money;
+    /**
+     * 1 =< 折扣 <= 9.9 当type为discount时需要添加
+     */
+    private BigDecimal discount;
+    /**
+     * 最多折扣金额 当type为discount时可选择性添加
+     */
+    private BigDecimal discountLimit;
+    /**
+     * 最低金额 当type为radom时需要添加
+     */
+    private BigDecimal minMoney;
+    /**
+     * 最大金额 当type为radom时需要添加
+     */
+    private BigDecimal maxMoney;
+    /**
+     * 过期类型1-时间范围过期 2-领取之日固定日期后过期 3-领取次日固定日期后过期
+     */
+    private Integer validityType;
+    /**
+     * 使用开始日期 过期类型1时必填
+     */
+    private Date startUseTime;
+    /**
+     * 使用结束日期 过期类型1时必填
+     */
+    private Date endUseTime;
+    /**
+     * 当validity_type为2或者3时需要添加 领取之日起或者次日N天内有效
+     */
+    private Integer fixedTerm;
+    /**
+     * 是否无限制0-否 1是
+     */
+    private Boolean whetherLimitless;
+    /**
+     * 每人最大领取个数
+     */
+    private Integer maxFetch;
+    /**
+     * 是否开启过期提醒0-不开启 1-开启
+     */
+    private Boolean whetherExpireNotice;
+    /**
+     * 过期前N天提醒
+     */
+    private Integer expireNoticeFixedTerm;
+    /**
+     * 优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用
+     */
+    private Boolean whetherForbidPreference;
+    /**
+     * 是否显示
+     */
+    private Integer whetherShow;
+    /**
+     * 订单的优惠总金额
+     */
+    private BigDecimal discountOrderMoney;
+    /**
+     * 用券总成交额
+     */
+    private BigDecimal orderMoney;
+    /**
+     * 是否禁止发放0-否 1-是
+     */
+    private Boolean whetherForbidden;
+    /**
+     * 使用优惠券购买的商品数量
+     */
+    private Integer orderGoodsNum;
+    /**
+     * 状态(1进行中2已结束-1已关闭)
+     */
+    private Integer status;
+    /**
+     * 有效日期结束时间
+     */
+    private Date endTime;
+
+}

+ 118 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/dataobject/coupon/CouponDO.java

@@ -0,0 +1,118 @@
+package cn.iocoder.yudao.module.coupon.dal.dataobject.coupon;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import lombok.*;
+import java.util.*;
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.*;
+
+/**
+ * 优惠券 DO
+ *
+ * @author wxr
+ */
+@TableName("coupon")
+@KeySequence("coupon_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class CouponDO extends BaseDO {
+
+    /**
+     * 用户ID
+     */
+    @TableId
+    private Long id;
+    /**
+     * 优惠券类型 reward-满减 discount-折扣 random-随机
+     */
+    private String type;
+    /**
+     * 优惠券名称
+     */
+    private String name;
+    /**
+     * 优惠券类型id
+     */
+    private Long couponTypeId;
+    /**
+     * 优惠券编码
+     */
+    private String couponCode;
+    /**
+     * 领用人
+     */
+    private Long memberId;
+    /**
+     * 优惠券使用订单id
+     */
+    private Long useOrderId;
+    /**
+     * 适用商品类型1-全部商品可用;2-指定商品可用;3-指定商品不可用
+     */
+    private Boolean goodsType;
+    /**
+     * 适用商品id
+     */
+    private String goodsIds;
+    /**
+     * 最小金额
+     */
+    private BigDecimal atLeast;
+    /**
+     * 面额
+     */
+    private BigDecimal money;
+    /**
+     * 1 =< 折扣 <= 9.9 当type为discount时需要添加
+     */
+    private BigDecimal discount;
+    /**
+     * 最多折扣金额 当type为discount时可选择性添加
+     */
+    private BigDecimal discountLimit;
+    /**
+     * 优惠叠加 0-不限制 1- 优惠券仅原价购买商品时可用
+     */
+    private Boolean whetherForbidPreference;
+    /**
+     * 是否开启过期提醒0-不开启 1-开启
+     */
+    private Boolean whetherExpireNotice;
+    /**
+     * 过期前N天提醒
+     */
+    private Integer expireNoticeFixedTerm;
+    /**
+     * 是否已提醒
+     */
+    private Boolean whetherNoticed;
+    /**
+     * 优惠券状态 1已领用(未使用) 2已使用 3已过期
+     */
+    private Integer state;
+    /**
+     * 获取方式1订单2.直接领取3.活动领取 4转赠 5分享获取
+     */
+    private Boolean getType;
+    /**
+     * 领取时间
+     */
+    private Date fetchTime;
+    /**
+     * 使用时间
+     */
+    private Date useTime;
+    /**
+     * 可使用的开始时间
+     */
+    private Date startTime;
+    /**
+     * 有效期结束时间
+     */
+    private Date endTime;
+
+}

+ 98 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/mysql/CouponTemplete/CouponTempleteMapper.java

@@ -0,0 +1,98 @@
+package cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteExportReqVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempletePageReqVO;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO;
+import org.apache.ibatis.annotations.Mapper;
+
+
+/**
+ * 优惠券模板 Mapper
+ *
+ * @author wxr
+ */
+@Mapper
+public interface CouponTempleteMapper extends BaseMapperX<CouponTempleteDO> {
+
+    default PageResult<CouponTempleteDO> selectPage(CouponTempletePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<CouponTempleteDO>()
+                .eqIfPresent(CouponTempleteDO::getType, reqVO.getType())
+                .likeIfPresent(CouponTempleteDO::getName, reqVO.getName())
+                .eqIfPresent(CouponTempleteDO::getCouponNameRemark, reqVO.getCouponNameRemark())
+                .eqIfPresent(CouponTempleteDO::getImage, reqVO.getImage())
+                .eqIfPresent(CouponTempleteDO::getCount, reqVO.getCount())
+                .eqIfPresent(CouponTempleteDO::getLeadCount, reqVO.getLeadCount())
+                .eqIfPresent(CouponTempleteDO::getUsedCount, reqVO.getUsedCount())
+                .eqIfPresent(CouponTempleteDO::getGoodsType, reqVO.getGoodsType())
+                .eqIfPresent(CouponTempleteDO::getProductIds, reqVO.getProductIds())
+                .eqIfPresent(CouponTempleteDO::getHasUseLimit, reqVO.getHasUseLimit())
+                .eqIfPresent(CouponTempleteDO::getAtLeast, reqVO.getAtLeast())
+                .eqIfPresent(CouponTempleteDO::getMoney, reqVO.getMoney())
+                .eqIfPresent(CouponTempleteDO::getDiscount, reqVO.getDiscount())
+                .eqIfPresent(CouponTempleteDO::getDiscountLimit, reqVO.getDiscountLimit())
+                .eqIfPresent(CouponTempleteDO::getMinMoney, reqVO.getMinMoney())
+                .eqIfPresent(CouponTempleteDO::getMaxMoney, reqVO.getMaxMoney())
+                .eqIfPresent(CouponTempleteDO::getValidityType, reqVO.getValidityType())
+                .betweenIfPresent(CouponTempleteDO::getStartUseTime, reqVO.getStartUseTime())
+                .betweenIfPresent(CouponTempleteDO::getEndUseTime, reqVO.getEndUseTime())
+                .eqIfPresent(CouponTempleteDO::getFixedTerm, reqVO.getFixedTerm())
+                .eqIfPresent(CouponTempleteDO::getWhetherLimitless, reqVO.getWhetherLimitless())
+                .eqIfPresent(CouponTempleteDO::getMaxFetch, reqVO.getMaxFetch())
+                .eqIfPresent(CouponTempleteDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice())
+                .eqIfPresent(CouponTempleteDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm())
+                .eqIfPresent(CouponTempleteDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference())
+                .eqIfPresent(CouponTempleteDO::getWhetherShow, reqVO.getWhetherShow())
+                .eqIfPresent(CouponTempleteDO::getDiscountOrderMoney, reqVO.getDiscountOrderMoney())
+                .eqIfPresent(CouponTempleteDO::getOrderMoney, reqVO.getOrderMoney())
+                .eqIfPresent(CouponTempleteDO::getWhetherForbidden, reqVO.getWhetherForbidden())
+                .eqIfPresent(CouponTempleteDO::getOrderGoodsNum, reqVO.getOrderGoodsNum())
+                .eqIfPresent(CouponTempleteDO::getStatus, reqVO.getStatus())
+                .betweenIfPresent(CouponTempleteDO::getEndTime, reqVO.getEndTime())
+                .betweenIfPresent(CouponTempleteDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(CouponTempleteDO::getId));
+    }
+
+    default List<CouponTempleteDO> selectList(CouponTempleteExportReqVO reqVO) {
+        return selectList(new LambdaQueryWrapperX<CouponTempleteDO>()
+                .eqIfPresent(CouponTempleteDO::getType, reqVO.getType())
+                .likeIfPresent(CouponTempleteDO::getName, reqVO.getName())
+                .eqIfPresent(CouponTempleteDO::getCouponNameRemark, reqVO.getCouponNameRemark())
+                .eqIfPresent(CouponTempleteDO::getImage, reqVO.getImage())
+                .eqIfPresent(CouponTempleteDO::getCount, reqVO.getCount())
+                .eqIfPresent(CouponTempleteDO::getLeadCount, reqVO.getLeadCount())
+                .eqIfPresent(CouponTempleteDO::getUsedCount, reqVO.getUsedCount())
+                .eqIfPresent(CouponTempleteDO::getGoodsType, reqVO.getGoodsType())
+                .eqIfPresent(CouponTempleteDO::getProductIds, reqVO.getProductIds())
+                .eqIfPresent(CouponTempleteDO::getHasUseLimit, reqVO.getHasUseLimit())
+                .eqIfPresent(CouponTempleteDO::getAtLeast, reqVO.getAtLeast())
+                .eqIfPresent(CouponTempleteDO::getMoney, reqVO.getMoney())
+                .eqIfPresent(CouponTempleteDO::getDiscount, reqVO.getDiscount())
+                .eqIfPresent(CouponTempleteDO::getDiscountLimit, reqVO.getDiscountLimit())
+                .eqIfPresent(CouponTempleteDO::getMinMoney, reqVO.getMinMoney())
+                .eqIfPresent(CouponTempleteDO::getMaxMoney, reqVO.getMaxMoney())
+                .eqIfPresent(CouponTempleteDO::getValidityType, reqVO.getValidityType())
+                .betweenIfPresent(CouponTempleteDO::getStartUseTime, reqVO.getStartUseTime())
+                .betweenIfPresent(CouponTempleteDO::getEndUseTime, reqVO.getEndUseTime())
+                .eqIfPresent(CouponTempleteDO::getFixedTerm, reqVO.getFixedTerm())
+                .eqIfPresent(CouponTempleteDO::getWhetherLimitless, reqVO.getWhetherLimitless())
+                .eqIfPresent(CouponTempleteDO::getMaxFetch, reqVO.getMaxFetch())
+                .eqIfPresent(CouponTempleteDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice())
+                .eqIfPresent(CouponTempleteDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm())
+                .eqIfPresent(CouponTempleteDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference())
+                .eqIfPresent(CouponTempleteDO::getWhetherShow, reqVO.getWhetherShow())
+                .eqIfPresent(CouponTempleteDO::getDiscountOrderMoney, reqVO.getDiscountOrderMoney())
+                .eqIfPresent(CouponTempleteDO::getOrderMoney, reqVO.getOrderMoney())
+                .eqIfPresent(CouponTempleteDO::getWhetherForbidden, reqVO.getWhetherForbidden())
+                .eqIfPresent(CouponTempleteDO::getOrderGoodsNum, reqVO.getOrderGoodsNum())
+                .eqIfPresent(CouponTempleteDO::getStatus, reqVO.getStatus())
+                .betweenIfPresent(CouponTempleteDO::getEndTime, reqVO.getEndTime())
+                .betweenIfPresent(CouponTempleteDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(CouponTempleteDO::getId));
+    }
+
+}

+ 76 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/dal/mysql/coupon/CouponMapper.java

@@ -0,0 +1,76 @@
+package cn.iocoder.yudao.module.coupon.dal.mysql.coupon;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*;
+
+/**
+ * 优惠券 Mapper
+ *
+ * @author wxr
+ */
+@Mapper
+public interface CouponMapper extends BaseMapperX<CouponDO> {
+
+    default PageResult<CouponDO> selectPage(CouponPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<CouponDO>()
+                .eqIfPresent(CouponDO::getType, reqVO.getType())
+                .likeIfPresent(CouponDO::getName, reqVO.getName())
+                .eqIfPresent(CouponDO::getCouponTypeId, reqVO.getCouponTypeId())
+                .eqIfPresent(CouponDO::getCouponCode, reqVO.getCouponCode())
+                .eqIfPresent(CouponDO::getMemberId, reqVO.getMemberId())
+                .eqIfPresent(CouponDO::getUseOrderId, reqVO.getUseOrderId())
+                .eqIfPresent(CouponDO::getGoodsType, reqVO.getGoodsType())
+                .eqIfPresent(CouponDO::getGoodsIds, reqVO.getGoodsIds())
+                .eqIfPresent(CouponDO::getAtLeast, reqVO.getAtLeast())
+                .eqIfPresent(CouponDO::getMoney, reqVO.getMoney())
+                .eqIfPresent(CouponDO::getDiscount, reqVO.getDiscount())
+                .eqIfPresent(CouponDO::getDiscountLimit, reqVO.getDiscountLimit())
+                .eqIfPresent(CouponDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference())
+                .eqIfPresent(CouponDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice())
+                .eqIfPresent(CouponDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm())
+                .eqIfPresent(CouponDO::getWhetherNoticed, reqVO.getWhetherNoticed())
+                .eqIfPresent(CouponDO::getState, reqVO.getState())
+                .eqIfPresent(CouponDO::getGetType, reqVO.getGetType())
+                .betweenIfPresent(CouponDO::getFetchTime, reqVO.getFetchTime())
+                .betweenIfPresent(CouponDO::getUseTime, reqVO.getUseTime())
+                .betweenIfPresent(CouponDO::getStartTime, reqVO.getStartTime())
+                .betweenIfPresent(CouponDO::getEndTime, reqVO.getEndTime())
+                .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(CouponDO::getId));
+    }
+
+    default List<CouponDO> selectList(CouponExportReqVO reqVO) {
+        return selectList(new LambdaQueryWrapperX<CouponDO>()
+                .eqIfPresent(CouponDO::getType, reqVO.getType())
+                .likeIfPresent(CouponDO::getName, reqVO.getName())
+                .eqIfPresent(CouponDO::getCouponTypeId, reqVO.getCouponTypeId())
+                .eqIfPresent(CouponDO::getCouponCode, reqVO.getCouponCode())
+                .eqIfPresent(CouponDO::getMemberId, reqVO.getMemberId())
+                .eqIfPresent(CouponDO::getUseOrderId, reqVO.getUseOrderId())
+                .eqIfPresent(CouponDO::getGoodsType, reqVO.getGoodsType())
+                .eqIfPresent(CouponDO::getGoodsIds, reqVO.getGoodsIds())
+                .eqIfPresent(CouponDO::getAtLeast, reqVO.getAtLeast())
+                .eqIfPresent(CouponDO::getMoney, reqVO.getMoney())
+                .eqIfPresent(CouponDO::getDiscount, reqVO.getDiscount())
+                .eqIfPresent(CouponDO::getDiscountLimit, reqVO.getDiscountLimit())
+                .eqIfPresent(CouponDO::getWhetherForbidPreference, reqVO.getWhetherForbidPreference())
+                .eqIfPresent(CouponDO::getWhetherExpireNotice, reqVO.getWhetherExpireNotice())
+                .eqIfPresent(CouponDO::getExpireNoticeFixedTerm, reqVO.getExpireNoticeFixedTerm())
+                .eqIfPresent(CouponDO::getWhetherNoticed, reqVO.getWhetherNoticed())
+                .eqIfPresent(CouponDO::getState, reqVO.getState())
+                .eqIfPresent(CouponDO::getGetType, reqVO.getGetType())
+                .betweenIfPresent(CouponDO::getFetchTime, reqVO.getFetchTime())
+                .betweenIfPresent(CouponDO::getUseTime, reqVO.getUseTime())
+                .betweenIfPresent(CouponDO::getStartTime, reqVO.getStartTime())
+                .betweenIfPresent(CouponDO::getEndTime, reqVO.getEndTime())
+                .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(CouponDO::getId));
+    }
+
+}

+ 6 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/package-info.java

@@ -0,0 +1,6 @@
+/**
+ * coupon模块,主要负责麦一些优惠券的额增删
+ *
+ * 1. Controller URL:以 /coumon/ 开头,避免和其它 Module 冲突
+ */
+package cn.iocoder.yudao.module.coupon;

+ 70 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteService.java

@@ -0,0 +1,70 @@
+package cn.iocoder.yudao.module.coupon.service.CouponTemplete;
+
+import java.util.*;
+import javax.validation.*;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO;
+
+/**
+ * 优惠券模板 Service 接口
+ *
+ * @author wxr
+ */
+public interface CouponTempleteService {
+
+    /**
+     * 创建优惠券模板
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long create(@Valid CouponTempleteCreateReqVO createReqVO);
+
+    /**
+     * 更新优惠券模板
+     *
+     * @param updateReqVO 更新信息
+     */
+    void update(@Valid CouponTempleteUpdateReqVO updateReqVO);
+
+    /**
+     * 删除优惠券模板
+     *
+     * @param id 编号
+     */
+    void delete(Long id);
+
+    /**
+     * 获得优惠券模板
+     *
+     * @param id 编号
+     * @return 优惠券模板
+     */
+    CouponTempleteDO get(Long id);
+
+    /**
+     * 获得优惠券模板列表
+     *
+     * @param ids 编号
+     * @return 优惠券模板列表
+     */
+    List<CouponTempleteDO> getList(Collection<Long> ids);
+
+    /**
+     * 获得优惠券模板分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 优惠券模板分页
+     */
+    PageResult<CouponTempleteDO> getPage(CouponTempletePageReqVO pageReqVO);
+
+    /**
+     * 获得优惠券模板列表, 用于 Excel 导出
+     *
+     * @param exportReqVO 查询条件
+     * @return 优惠券模板列表
+     */
+    List<CouponTempleteDO> getList(CouponTempleteExportReqVO exportReqVO);
+
+}

+ 134 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/CouponTemplete/CouponTempleteServiceImpl.java

@@ -0,0 +1,134 @@
+package cn.iocoder.yudao.module.coupon.service.CouponTemplete;
+
+import cn.iocoder.yudao.module.CouponTemplete.enums.CouponTypeEnum;
+import cn.iocoder.yudao.module.CouponTemplete.enums.CouponValidityTypeEnum;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteCreateReqVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteExportReqVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempletePageReqVO;
+import cn.iocoder.yudao.module.coupon.controller.admin.templete.vo.CouponTempleteUpdateReqVO;
+import cn.iocoder.yudao.module.coupon.convert.CouponTemplete.CouponTempleteConvert;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO;
+import cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import java.util.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.CouponTemplete.enums.ErrorCodeConstants.*;
+
+/**
+ * 优惠券模板 Service 实现类
+ *
+ * @author wxr
+ */
+@Service
+@Validated
+public class CouponTempleteServiceImpl implements CouponTempleteService {
+
+    @Resource
+    private CouponTempleteMapper couponTempleteMapper;
+
+    @Override
+    public Long create(CouponTempleteCreateReqVO createReqVO) {
+        // 插入
+        CouponTempleteDO couponTempleteDO = CouponTempleteConvert.INSTANCE.convert(createReqVO);
+        /* 验证类型、判断必填*/
+        checkCouponType(createReqVO);
+
+        /*验证过期类型、判断必填*/
+        checkValidityType(createReqVO);
+
+
+
+        couponTempleteMapper.insert(couponTempleteDO);
+        // 返回
+        return couponTempleteDO.getId();
+    }
+
+    /*确认优惠券类型*/
+    private void checkValidityType(CouponTempleteCreateReqVO createReqVO) {
+        Integer validtyType = createReqVO.getValidityType();
+
+        if(CouponValidityTypeEnum.TIME_RANGE_EXPIRTED.getStatus().equals(validtyType)){
+            if(createReqVO.getStartUseTime() == null||createReqVO.getEndUseTime() == null){
+                throw exception(START_END_TIME_NOT_NULL);
+            }
+        }else{
+            if(createReqVO.getFixedTerm() == null){
+                throw exception(FIXED_TERM_NOT_NULL);
+            }
+        }
+    }
+
+    private void checkCouponType(CouponTempleteCreateReqVO createReqVO) {
+
+        String couponType = createReqVO.getType();
+        //当type=reward时候,需要添加
+        if(couponType.equals(CouponTypeEnum.REWARD.getName())){
+            if(createReqVO.getMoney()==null){
+                throw exception(MONEY_NOT_NULL);
+            }
+        }else if(couponType.equals(CouponTypeEnum.DISCOUNT.getName())){
+            if(createReqVO.getDiscount()==null){
+                throw exception(DISCOUNT_NOT_NULL);
+            }
+            if(createReqVO.getDiscountLimit()==null){
+                throw exception(DISCOUNT_LIMIT_NOT_NULL);
+            }
+        }else if (couponType.equals(CouponTypeEnum.RANDOW.getName())){
+            //当type为radom时需要添加不能为空
+            if(createReqVO.getMinMoney()==null||createReqVO.getMaxMoney()==null){
+                throw exception(MIN_MAX_NOT_NULL);
+            }
+        }
+    }
+
+    @Override
+    public void update(CouponTempleteUpdateReqVO updateReqVO) {
+        // 校验存在
+        this.validateExists(updateReqVO.getId());
+        // 更新
+        CouponTempleteDO updateObj = CouponTempleteConvert.INSTANCE.convert(updateReqVO);
+        couponTempleteMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void delete(Long id) {
+        // 校验存在
+        this.validateExists(id);
+        // 删除
+        couponTempleteMapper.deleteById(id);
+    }
+
+    private void validateExists(Long id) {
+        if (couponTempleteMapper.selectById(id) == null) {
+            throw exception(COUPON_TEMPLETE_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public CouponTempleteDO get(Long id) {
+        return couponTempleteMapper.selectById(id);
+    }
+
+    @Override
+    public List<CouponTempleteDO> getList(Collection<Long> ids) {
+        return couponTempleteMapper.selectBatchIds(ids);
+    }
+
+    @Override
+    public PageResult<CouponTempleteDO> getPage(CouponTempletePageReqVO pageReqVO) {
+        return couponTempleteMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public List<CouponTempleteDO> getList(CouponTempleteExportReqVO exportReqVO) {
+        return couponTempleteMapper.selectList(exportReqVO);
+    }
+
+}

+ 70 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponService.java

@@ -0,0 +1,70 @@
+package cn.iocoder.yudao.module.coupon.service.coupon;
+
+import java.util.*;
+import javax.validation.*;
+import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+/**
+ * 优惠券 Service 接口
+ *
+ * @author wxr
+ */
+public interface CouponService {
+
+    /**
+     * 创建优惠券
+     *
+     * @param templateId 优惠券模板id
+     * @return 编号
+     */
+    Long create(Long templateId);
+
+    /**
+     * 更新优惠券
+     *
+     * @param updateReqVO 更新信息
+     */
+    void update(@Valid CouponUpdateReqVO updateReqVO);
+
+    /**
+     * 删除优惠券
+     *
+     * @param id 编号
+     */
+    void delete(Long id);
+
+    /**
+     * 获得优惠券
+     *
+     * @param id 编号
+     * @return 优惠券
+     */
+    CouponDO get(Long id);
+
+    /**
+     * 获得优惠券列表
+     *
+     * @param ids 编号
+     * @return 优惠券列表
+     */
+    List<CouponDO> getList(Collection<Long> ids);
+
+    /**
+     * 获得优惠券分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 优惠券分页
+     */
+    PageResult<CouponDO> getPage(CouponPageReqVO pageReqVO);
+
+    /**
+     * 获得优惠券列表, 用于 Excel 导出
+     *
+     * @param exportReqVO 查询条件
+     * @return 优惠券列表
+     */
+    List<CouponDO> getList(CouponExportReqVO exportReqVO);
+
+}

+ 107 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/java/cn/iocoder/yudao/module/coupon/service/coupon/CouponServiceImpl.java

@@ -0,0 +1,107 @@
+package cn.iocoder.yudao.module.coupon.service.coupon;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.CouponTemplete.CouponTempleteDO;
+import cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper;
+import io.micrometer.core.instrument.Counter;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import java.util.*;
+import cn.iocoder.yudao.module.coupon.controller.admin.coupon.vo.*;
+import cn.iocoder.yudao.module.coupon.dal.dataobject.coupon.CouponDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import cn.iocoder.yudao.module.coupon.convert.coupon.CouponConvert;
+import cn.iocoder.yudao.module.coupon.dal.mysql.coupon.CouponMapper;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.CouponTemplete.enums.ErrorCodeConstants.COUPON_NOT_EXISTS;
+
+/**
+ * 优惠券 Service 实现类
+ *
+ * @author wxr
+ */
+@Service
+@Validated
+public class CouponServiceImpl implements CouponService {
+
+    @Resource
+    private CouponMapper couponMapper;
+
+    @Resource
+    private CouponTempleteMapper couponTempleteMapper;
+
+    public Long create(CouponCreateReqVO createReqVO) {
+        // 插入
+        CouponDO couponDO = CouponConvert.INSTANCE.convert(createReqVO);
+        couponMapper.insert(couponDO);
+        // 返回
+        return couponDO.getId();
+    }
+
+
+    /**
+     *todo 获取用户id收获优惠券
+     *@author:wxr
+     *@date:2022-08-13 3:11
+     *@Description
+     */
+    @Override
+    public Long create(Long templateId) {
+        Long userid = SecurityFrameworkUtils.getLoginUserId();
+        CouponDO couponDO = CouponDO.builder().memberId(userid).build();
+        CouponTempleteDO couponTempleteDO = couponTempleteMapper.selectById(templateId);
+        //todo 缺少判空
+        BeanUtil.copyProperties(couponTempleteDO,couponTempleteDO);
+        couponMapper.insert(couponDO);
+        return couponDO.getId();
+    }
+
+    @Override
+    public void update(CouponUpdateReqVO updateReqVO) {
+        // 校验存在
+        this.validateExists(updateReqVO.getId());
+        // 更新
+        CouponDO updateObj = CouponConvert.INSTANCE.convert(updateReqVO);
+        couponMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void delete(Long id) {
+        // 校验存在
+        this.validateExists(id);
+        // 删除
+        couponMapper.deleteById(id);
+    }
+
+    private void validateExists(Long id) {
+        if (couponMapper.selectById(id) == null) {
+            throw exception(COUPON_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public CouponDO get(Long id) {
+        return couponMapper.selectById(id);
+    }
+
+    @Override
+    public List<CouponDO> getList(Collection<Long> ids) {
+        return couponMapper.selectBatchIds(ids);
+    }
+
+    @Override
+    public PageResult<CouponDO> getPage(CouponPageReqVO pageReqVO) {
+        return couponMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public List<CouponDO> getList(CouponExportReqVO exportReqVO) {
+        return couponMapper.selectList(exportReqVO);
+    }
+
+}

+ 12 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/resources/mapper/CouponTemplete/CouponTempleteMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.iocoder.yudao.module.coupon.dal.mysql.CouponTemplete.CouponTempleteMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 12 - 0
yudao-module-mall/yudao-module-coupon-biz/src/main/resources/mapper/coupon/CouponMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.iocoder.yudao.module.coupon.dal.mysql.coupon.CouponMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 7 - 0
yudao-module-mall/yudao-module-market-api/pom.xml

@@ -21,6 +21,13 @@
             <groupId>cn.iocoder.boot</groupId>
             <artifactId>yudao-common</artifactId>
         </dependency>
+
+        <!-- 参数校验 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+            <optional>true</optional>
+        </dependency>
     </dependencies>
 
 </project>

+ 21 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/PriceApi.java

@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.market.api.price;
+
+import cn.iocoder.yudao.module.market.api.price.dto.PriceCalculateReqDTO;
+import cn.iocoder.yudao.module.market.api.price.dto.PriceCalculateRespDTO;
+
+/**
+ * 价格 API 接口
+ *
+ * @author 芋道源码
+ */
+public interface PriceApi {
+
+    /**
+     * 计算商品的价格
+     *
+     * @param calculateReqDTO 价格请求
+     * @return 价格相应
+     */
+    PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO);
+
+}

+ 56 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/dto/PriceCalculateReqDTO.java

@@ -0,0 +1,56 @@
+package cn.iocoder.yudao.module.market.api.price.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * 价格计算 Request DTO
+ *
+ * @author 芋道源码
+ */
+@Data
+public class PriceCalculateReqDTO {
+
+    /**
+     * 用户编号
+     *
+     * 对应 MemberUserDO 的 id 编号
+     */
+    private Long userId;
+
+    /**
+     * 优惠劵编号
+     */
+    private Long couponId;
+
+    /**
+     * 商品 SKU 数组
+     */
+    @NotNull(message = "商品数组不能为空")
+    private List<Item> items;
+
+    /**
+     * 商品 SKU
+     */
+    @Data
+    public static class Item {
+
+        /**
+         * SKU 编号
+         */
+        @NotNull(message = "商品 SKU 编号不能为空")
+        private Long skuId;
+
+        /**
+         * SKU 数量
+         */
+        @NotNull(message = "商品 SKU 数量不能为空")
+        @Min(value = 0L, message = "商品 SKU 数量必须大于等于 0") // 可传递 0 数量,用于购物车未选中的情况
+        private Integer count;
+
+    }
+
+}

+ 202 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/dto/PriceCalculateRespDTO.java

@@ -0,0 +1,202 @@
+package cn.iocoder.yudao.module.market.api.price.dto;
+
+import cn.iocoder.yudao.module.market.enums.common.PromotionLevelEnum;
+import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 价格计算 Response DTO
+ *
+ * @author 芋道源码
+ */
+@Data
+public class PriceCalculateRespDTO {
+
+    /**
+     * 订单
+     */
+    private Order order;
+
+    /**
+     * 商品 SKU 数组
+     */
+    private List<Item> items;
+
+    /**
+     * 营销活动数组
+     *
+     * 只对应 {@link #items} 商品匹配的活动
+     */
+    private List<Promotion> promotions;
+
+    /**
+     * 订单
+     */
+    @Data
+    public static class Order {
+
+        /**
+         * 商品原价(总),单位:分
+         *
+         * 基于 {@link Item#getTotalOriginalPrice()} 求和
+         */
+        private Integer skuOriginalPrice;
+        /**
+         * 商品优惠(总),单位:分
+         *
+         * 基于 {@link Item#getTotalPromotionPrice()} 求和
+         */
+        private Integer skuPromotionPrice;
+        /**
+         * 订单优惠(总),单位:分
+         *
+         * 例如说:满减折扣;不包括优惠劵、商品优惠
+         */
+        private Integer orderPromotionPrice;
+        /**
+         * 运费金额,单位:分
+         */
+        private Integer deliveryPrice;
+        /**
+         * 应付金额(总),单位:分
+         *
+         * = {@link #skuOriginalPrice}
+         * + {@link #deliveryPrice}
+         * - {@link #skuPromotionPrice}
+         * - {@link #orderPromotionPrice}
+         */
+        //         * - {@link #couponPrice}  // TODO 芋艿:靠营销表记录
+        private Integer payPrice;
+
+        // ========== 营销基本信息 ==========
+        /**
+         * 优惠劵编号
+         */
+        private Long couponId;
+//        /**
+//         * 优惠劵减免金额,单位:分
+//         *
+//         *   // TODO 芋艿:靠营销表记录
+//         */
+//        private Integer couponPrice;
+
+    }
+
+    /**
+     * 商品 SKU
+     */
+    @Data
+    public static class Item extends PriceCalculateReqDTO.Item {
+
+        /**
+         * 商品原价(单),单位:分
+         *
+         * 对应 ProductSkuDO 的 price 字段
+         */
+        private Integer originalPrice;
+        /**
+         * 商品原价(总),单位:分
+         *
+         * = {@link #originalPrice} * {@link #getCount()}
+         */
+        private Integer totalOriginalPrice;
+        /**
+         * 商品级优惠(总),单位:分
+         *
+         * 例如说“限时折扣”:商品原价的 8 折;商品原价的减 50 元
+         */
+        private Integer totalPromotionPrice;
+        /**
+         * 最终购买金额(总),单位:分。
+         *
+         * = {@link #totalOriginalPrice}
+         * - {@link #totalPromotionPrice}
+         */
+        private Integer totalPresentPrice;
+        /**
+         * 最终购买金额(单),单位:分。
+         *
+         * = {@link #totalPresentPrice} / {@link #getCount()}
+         */
+        private Integer presentPrice;
+        /**
+         * 应付金额(总),单位:分
+         */
+        private Integer totalPayPrice;
+
+    }
+
+    /**
+     * 营销活动
+     */
+    @Data
+    public static class Promotion {
+
+        /**
+         * 营销编号
+         *
+         * 例如说:营销活动的编号、优惠劵的编号
+         */
+        private Long id;
+        /**
+         * 营销类型
+         *
+         * 枚举 {@link PromotionTypeEnum}
+         */
+        private Integer type;
+        /**
+         * 营销级别
+         *
+         * 枚举 {@link PromotionLevelEnum}
+         */
+        private Integer level;
+        /**
+         * 匹配的商品 SKU 数组
+         */
+        private List<Item> items;
+        /**
+         * 计算时的原价(总),单位:分
+         */
+        private Integer totalOriginalPrice;
+        /**
+         * 计算时的优惠(总),单位:分
+         */
+        private Integer totalPromotionPrice;
+        /**
+         * 是否满足优惠条件
+         */
+        private Boolean meet;
+        /**
+         * 满足条件的提示
+         *
+         * 如果 {@link #meet} = true 满足,则提示“圣诞价:省 150.00 元”
+         * 如果 {@link #meet} = false 不满足,则提示“购满 85 元,可减 40 元”
+         */
+        private String meetTip;
+
+        /**
+         * 匹配的商品 SKU
+         */
+        @Data
+        public static class Item {
+
+            /**
+             * 商品 SKU 编号
+             */
+            private Long skuId;
+            /**
+             * 计算时的原价(总),单位:分
+             */
+            private Integer totalOriginalPrice;
+            /**
+             * 计算时的优惠(总),单位:分
+             */
+            private Integer totalPromotionPrice;
+
+        }
+
+    }
+
+}

+ 0 - 51
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/activity/MarketActivityStatusEnum.java

@@ -1,51 +0,0 @@
-package cn.iocoder.yudao.module.market.enums.activity;
-
-import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
-
-import java.util.Arrays;
-
-/**
- * 促销活动状态枚举
- */
-public enum MarketActivityStatusEnum implements IntArrayValuable {
-
-    WAIT(10, "未开始"),
-    RUN(20, "进行中"),
-    END(30, "已结束"),
-    /**
-     * 1. WAIT、RUN、END 可以转换成 INVALID 状态。
-     * 2. INVALID 只可以转换成 DELETED 状态。
-     */
-    INVALID(40, "已撤销"),
-    DELETED(50, "已删除"),
-    ;
-
-    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MarketActivityStatusEnum::getValue).toArray();
-
-    /**
-     * 状态值
-     */
-    private final Integer value;
-    /**
-     * 状态名
-     */
-    private final String name;
-
-    MarketActivityStatusEnum(Integer value, String name) {
-        this.value = value;
-        this.name = name;
-    }
-
-    public Integer getValue() {
-        return value;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public int[] array() {
-        return ARRAYS;
-    }
-}

+ 0 - 44
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/activity/MarketActivityTypeEnum.java

@@ -1,44 +0,0 @@
-package cn.iocoder.yudao.module.market.enums.activity;
-
-import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
-
-import java.util.Arrays;
-
-/**
- * 促销活动类型枚举
- */
-public enum MarketActivityTypeEnum implements IntArrayValuable {
-
-    TIME_LIMITED_DISCOUNT(1, "限时折扣"),
-    FULL_PRIVILEGE(2, "满减送"),
-    ;
-
-    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MarketActivityTypeEnum::getValue).toArray();
-
-    /**
-     * 类型值
-     */
-    private final Integer value;
-    /**
-     * 类型名
-     */
-    private final String name;
-
-    MarketActivityTypeEnum(Integer value, String name) {
-        this.value = value;
-        this.name = name;
-    }
-
-    public Integer getValue() {
-        return value;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public int[] array() {
-        return ARRAYS;
-    }
-}

+ 39 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionActivityStatusEnum.java

@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.module.market.enums.common;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 促销活动的状态枚举
+ *
+ * @author 芋道源码
+ */
+@AllArgsConstructor
+@Getter
+public enum PromotionActivityStatusEnum implements IntArrayValuable {
+
+    WAIT(10, "未开始"),
+    RUN(20, "进行中"),
+    END(30, "已结束"),
+    CLOSE(40, "已关闭");
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray();
+
+    /**
+     * 状态值
+     */
+    private final Integer status;
+    /**
+     * 状态名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 37 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionConditionTypeEnum.java

@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.market.enums.common;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 营销的条件类型枚举
+ *
+ * @author 芋道源码
+ */
+@AllArgsConstructor
+@Getter
+public enum PromotionConditionTypeEnum implements IntArrayValuable {
+
+    PRICE(10, "满 N 元"),
+    COUNT(20, "满 N 件");
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray();
+
+    /**
+     * 类型值
+     */
+    private final Integer type;
+    /**
+     * 类型名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 37 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionLevelEnum.java

@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.market.enums.common;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 营销的级别枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum PromotionLevelEnum implements IntArrayValuable {
+
+    ORDER(1, "订单级"),
+    SKU(2, "商品级"),
+    ;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionLevelEnum::getLevel).toArray();
+
+    /**
+     * 级别值
+     */
+    private final Integer level;
+    /**
+     * 类型名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+}

+ 38 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionProductScopeEnum.java

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.market.enums.common;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 营销的商品范围枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum PromotionProductScopeEnum implements IntArrayValuable {
+
+    ALL(1, "全部商品参与"),
+    SPU(2, "指定商品参与"),
+    ;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray();
+
+    /**
+     * 范围值
+     */
+    private final Integer scope;
+    /**
+     * 范围名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 37 - 0
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionTypeEnum.java

@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.market.enums.common;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 营销类型枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum PromotionTypeEnum implements IntArrayValuable {
+
+    DISCOUNT(1, "限时折扣"),
+    REWARD(2, "满减送"),
+    ;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray();
+
+    /**
+     * 类型值
+     */
+    private final Integer type;
+    /**
+     * 类型名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+}

+ 0 - 25
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/MarketTestController.java

@@ -1,25 +0,0 @@
-package cn.iocoder.yudao.module.market.controller.admin;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-@Api(tags = "管理后台 - 营销")
-@RestController
-@RequestMapping("/market/test")
-@Validated
-public class MarketTestController {
-
-    @GetMapping("/get")
-    @ApiOperation("获取 market 信息")
-    public CommonResult<String> get() {
-        return success("true");
-    }
-
-}

+ 0 - 77
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/ActivityController.java

@@ -1,77 +0,0 @@
-package cn.iocoder.yudao.module.market.controller.admin.activity;
-
-import org.springframework.web.bind.annotation.*;
-import javax.annotation.Resource;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.security.access.prepost.PreAuthorize;
-import io.swagger.annotations.*;
-import javax.validation.*;
-import java.util.*;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
-import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
-import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert;
-import cn.iocoder.yudao.module.market.service.activity.ActivityService;
-
-@Api(tags = "管理后台 - 促销活动")
-@RestController
-@RequestMapping("/market/activity")
-@Validated
-public class ActivityController {
-
-    @Resource
-    private ActivityService activityService;
-
-    @PostMapping("/create")
-    @ApiOperation("创建促销活动")
-    @PreAuthorize("@ss.hasPermission('market:activity:create')")
-    public CommonResult<Long> createActivity(@Valid @RequestBody ActivityCreateReqVO createReqVO) {
-        return success(activityService.createActivity(createReqVO));
-    }
-
-    @PutMapping("/update")
-    @ApiOperation("更新促销活动")
-    @PreAuthorize("@ss.hasPermission('market:activity:update')")
-    public CommonResult<Boolean> updateActivity(@Valid @RequestBody ActivityUpdateReqVO updateReqVO) {
-        activityService.updateActivity(updateReqVO);
-        return success(true);
-    }
-
-    @DeleteMapping("/delete")
-    @ApiOperation("删除促销活动")
-    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
-    @PreAuthorize("@ss.hasPermission('market:activity:delete')")
-    public CommonResult<Boolean> deleteActivity(@RequestParam("id") Long id) {
-        activityService.deleteActivity(id);
-        return success(true);
-    }
-
-    @GetMapping("/get")
-    @ApiOperation("获得促销活动")
-    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
-    @PreAuthorize("@ss.hasPermission('market:activity:query')")
-    public CommonResult<ActivityRespVO> getActivity(@RequestParam("id") Long id) {
-        ActivityDO activity = activityService.getActivity(id);
-        return success(ActivityConvert.INSTANCE.convert(activity));
-    }
-
-    @GetMapping("/list")
-    @ApiOperation("获得促销活动列表")
-    @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
-    @PreAuthorize("@ss.hasPermission('market:activity:query')")
-    public CommonResult<List<ActivityRespVO>> getActivityList(@RequestParam("ids") Collection<Long> ids) {
-        List<ActivityDO> list = activityService.getActivityList(ids);
-        return success(ActivityConvert.INSTANCE.convertList(list));
-    }
-
-    @GetMapping("/page")
-    @ApiOperation("获得促销活动分页")
-    @PreAuthorize("@ss.hasPermission('market:activity:query')")
-    public CommonResult<PageResult<ActivityRespVO>> getActivityPage(@Valid ActivityPageReqVO pageVO) {
-        PageResult<ActivityDO> pageResult = activityService.getActivityPage(pageVO);
-        return success(ActivityConvert.INSTANCE.convertPage(pageResult));
-    }
-
-}

+ 0 - 59
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityBaseVO.java

@@ -1,59 +0,0 @@
-package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum;
-import cn.iocoder.yudao.module.market.enums.activity.MarketActivityTypeEnum;
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-/**
-* 促销活动 Base VO,提供给添加、修改、详细的子 VO 使用
-* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
-*/
-@Data
-public class ActivityBaseVO {
-
-    @ApiModelProperty(value = "活动标题", required = true)
-    @NotNull(message = "活动标题不能为空")
-    private String title;
-
-    @ApiModelProperty(value = "活动类型", required = true)
-    @NotNull(message = "活动类型不能为空")
-    @InEnum(MarketActivityTypeEnum.class)
-    private Integer activityType;
-
-    @ApiModelProperty(value = "活动状态", required = true)
-    @NotNull(message = "活动状态不能为空")
-    @InEnum(MarketActivityStatusEnum.class)
-    private Integer status;
-
-    @ApiModelProperty(value = "开始时间", required = true)
-    @NotNull(message = "开始时间不能为空")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private Date startTime;
-
-    @ApiModelProperty(value = "结束时间", required = true)
-    @NotNull(message = "结束时间不能为空")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private Date endTime;
-
-    @ApiModelProperty(value = "失效时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private Date invalidTime;
-
-    @ApiModelProperty(value = "删除时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private Date deleteTime;
-
-    @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
-    private String timeLimitedDiscount;
-
-    @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
-    private String fullPrivilege;
-
-}

+ 0 - 17
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityCreateReqVO.java

@@ -1,17 +0,0 @@
-package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
-
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
-
-/**
- * @author xia
- */
-@ApiModel("管理后台 - 促销活动创建 Request VO")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-public class ActivityCreateReqVO extends ActivityBaseVO {
-
-}

+ 0 - 57
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityPageReqVO.java

@@ -1,57 +0,0 @@
-package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum;
-import cn.iocoder.yudao.module.market.enums.activity.MarketActivityTypeEnum;
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-@ApiModel("管理后台 - 促销活动分页 Request VO")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-public class ActivityPageReqVO extends PageParam {
-
-    @ApiModelProperty(value = "活动标题")
-    private String title;
-
-    @ApiModelProperty(value = "活动类型")
-    @InEnum(MarketActivityTypeEnum.class)
-    private Integer activityType;
-
-    @ApiModelProperty(value = "活动状态")
-    @InEnum(MarketActivityStatusEnum.class)
-    private Integer status;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "开始时间")
-    private Date[] startTime;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "结束时间")
-    private Date[] endTime;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "失效时间")
-    private Date[] invalidTime;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "删除时间")
-    private Date[] deleteTime;
-
-    @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
-    private String timeLimitedDiscount;
-
-    @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
-    private String fullPrivilege;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "创建时间")
-    private Date[] createTime;
-
-}

+ 0 - 18
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityUpdateReqVO.java

@@ -1,18 +0,0 @@
-package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
-
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
-
-@ApiModel("管理后台 - 促销活动更新 Request VO")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-public class ActivityUpdateReqVO extends ActivityBaseVO {
-
-    @ApiModelProperty(value = "活动编号", required = true)
-    @NotNull(message = "活动编号不能为空")
-    private Long id;
-
-}

+ 4 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/discount/package-info.java

@@ -0,0 +1,4 @@
+/**
+ * TODO 占位
+ */
+package cn.iocoder.yudao.module.market.controller.admin.discount;

+ 0 - 32
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/activity/ActivityConvert.java

@@ -1,32 +0,0 @@
-package cn.iocoder.yudao.module.market.convert.activity;
-
-import java.util.*;
-
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
-import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
-
-/**
- * 促销活动 Convert
- *
- * @author 芋道源码
- */
-@Mapper
-public interface ActivityConvert {
-
-    ActivityConvert INSTANCE = Mappers.getMapper(ActivityConvert.class);
-
-    ActivityDO convert(ActivityCreateReqVO bean);
-
-    ActivityDO convert(ActivityUpdateReqVO bean);
-
-    ActivityRespVO convert(ActivityDO bean);
-
-    List<ActivityRespVO> convertList(List<ActivityDO> list);
-
-    PageResult<ActivityRespVO> convertPage(PageResult<ActivityDO> page);
-
-}

+ 4 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/discount/package-info.java

@@ -0,0 +1,4 @@
+/**
+ * TODO 占位
+ */
+package cn.iocoder.yudao.module.market.convert.discount;

+ 0 - 64
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/activity/ActivityDO.java

@@ -1,64 +0,0 @@
-package cn.iocoder.yudao.module.market.dal.dataobject.activity;
-
-import lombok.*;
-import java.util.*;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 促销活动 DO
- *
- * @author 芋道源码
- */
-@TableName("market_activity")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class ActivityDO extends BaseDO {
-
-    /**
-     * 活动编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 活动标题
-     */
-    private String title;
-    /**
-     * 活动类型MarketActivityTypeEnum
-     */
-    private Integer activityType;
-    /**
-     * 活动状态MarketActivityStatusEnum
-     */
-    private Integer status;
-    /**
-     * 开始时间
-     */
-    private Date startTime;
-    /**
-     * 结束时间
-     */
-    private Date endTime;
-    /**
-     * 失效时间
-     */
-    private Date invalidTime;
-    /**
-     * 删除时间
-     */
-    private Date deleteTime;
-    /**
-     * 限制折扣字符串,使用 JSON 序列化成字符串存储
-     */
-    private String timeLimitedDiscount;
-    /**
-     * 限制折扣字符串,使用 JSON 序列化成字符串存储
-     */
-    private String fullPrivilege;
-
-}

+ 55 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/discount/DiscountActivityDO.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.market.dal.dataobject.discount;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.module.market.enums.common.PromotionActivityStatusEnum;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 限时折扣活动 DO
+ *
+ * 一个活动下,可以有 {@link DiscountProductDO} 商品;
+ * 一个商品,在指定时间段内,只能属于一个活动;
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "promotion_discount_activity", autoResultMap = true)
+@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DiscountActivityDO extends BaseDO {
+
+    /**
+     * 活动编号,主键自增
+     */
+    @TableId
+    private Long id;
+    /**
+     * 活动标题
+     */
+    private String name;
+    /**
+     * 状态
+     *
+     * 枚举 {@link PromotionActivityStatusEnum}
+     */
+    private Integer status;
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 65 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/discount/DiscountProductDO.java

@@ -0,0 +1,65 @@
+package cn.iocoder.yudao.module.market.dal.dataobject.discount;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 限时折扣商品 DO
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "promotion_discount_product", autoResultMap = true)
+@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DiscountProductDO extends BaseDO {
+
+    /**
+     * 编号,主键自增
+     */
+    @TableId
+    private Long id;
+    /**
+     * 限时折扣活动的编号
+     *
+     * 关联 {@link DiscountActivityDO#getId()}
+     */
+    private Long activityId;
+    /**
+     * 商品 SPU 编号
+     *
+     * 关联 ProductSpuDO 的 id 编号
+     */
+    private Long spuId;
+    /**
+     * 商品 SKU 编号
+     *
+     * 关联 ProductSkuDO 的 id 编号
+     */
+    private Long skuId;
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+    /**
+     * 销售价格,单位:分
+     *
+     * 冗余 ProductSkuDO 的 price 字段
+     */
+    private Integer originalPrice;
+    /**
+     * 优惠价格,单位:分
+     */
+    private Integer promotionPrice;
+
+}

+ 116 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/reward/RewardActivityDO.java

@@ -0,0 +1,116 @@
+package cn.iocoder.yudao.module.market.dal.dataobject.reward;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.module.market.enums.common.PromotionActivityStatusEnum;
+import cn.iocoder.yudao.module.market.enums.common.PromotionConditionTypeEnum;
+import cn.iocoder.yudao.module.market.enums.common.PromotionProductScopeEnum;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 满减送活动 DO
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "promotion_reward_activity", autoResultMap = true)
+@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class RewardActivityDO extends BaseDO {
+
+    /**
+     * 活动编号,主键自增
+     */
+    @TableId
+    private Long id;
+    /**
+     * 活动标题
+     */
+    private String name;
+    /**
+     * 状态
+     *
+     * 枚举 {@link PromotionActivityStatusEnum}
+     */
+    private Integer status;
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 条件类型
+     *
+     * 枚举 {@link PromotionConditionTypeEnum}
+     */
+    private Integer conditionType;
+    /**
+     * 商品范围
+     *
+     * 枚举 {@link PromotionProductScopeEnum}
+     */
+    private Integer productScope;
+    /**
+     * 商品 SPU 编号的数组
+     */
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private List<Long> spuIds;
+    /**
+     * 优惠规则的数组
+     */
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private List<Rule> rules;
+
+    /**
+     * 优惠规则
+     */
+    @Data
+    public static class Rule {
+
+        /**
+         * 优惠门槛
+         *
+         * 1. 满 N 元,单位:分
+         * 2. 满 N 件
+         */
+        private Integer limit;
+        /**
+         * 优惠价格,单位:分
+         */
+        private Integer promotionPrice;
+        /**
+         * 是否包邮
+         */
+        private Boolean freeDelivery;
+        /**
+         * 赠送的积分
+         */
+        private Integer integral;
+        /**
+         * 赠送的优惠劵编号的数组
+         */
+        private List<Long> couponIds;
+        /**
+         * 赠送的优惠卷数量的数组
+         */
+        private List<Integer> couponCounts;
+
+    }
+
+
+}

+ 0 - 35
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/activity/ActivityMapper.java

@@ -1,35 +0,0 @@
-package cn.iocoder.yudao.module.market.dal.mysql.activity;
-
-import java.util.*;
-
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
-import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
-import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
-import org.apache.ibatis.annotations.Mapper;
-import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
-
-/**
- * 促销活动 Mapper
- *
- * @author 芋道源码
- */
-@Mapper
-public interface ActivityMapper extends BaseMapperX<ActivityDO> {
-
-    default PageResult<ActivityDO> selectPage(ActivityPageReqVO reqVO) {
-        return selectPage(reqVO, new LambdaQueryWrapperX<ActivityDO>()
-                .eqIfPresent(ActivityDO::getTitle, reqVO.getTitle())
-                .eqIfPresent(ActivityDO::getActivityType, reqVO.getActivityType())
-                .eqIfPresent(ActivityDO::getStatus, reqVO.getStatus())
-                .betweenIfPresent(ActivityDO::getStartTime, reqVO.getStartTime())
-                .betweenIfPresent(ActivityDO::getEndTime, reqVO.getEndTime())
-                .betweenIfPresent(ActivityDO::getInvalidTime, reqVO.getInvalidTime())
-                .betweenIfPresent(ActivityDO::getDeleteTime, reqVO.getDeleteTime())
-                .eqIfPresent(ActivityDO::getTimeLimitedDiscount, reqVO.getTimeLimitedDiscount())
-                .eqIfPresent(ActivityDO::getFullPrivilege, reqVO.getFullPrivilege())
-                .betweenIfPresent(ActivityDO::getCreateTime, reqVO.getCreateTime())
-                .orderByDesc(ActivityDO::getId));
-    }
-
-}

+ 4 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/discount/package-info.java

@@ -0,0 +1,4 @@
+/**
+ * TODO 占位
+ */
+package cn.iocoder.yudao.module.market.dal.mysql.discount;

+ 3 - 3
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/package-info.java

@@ -1,8 +1,8 @@
 /**
- * market 模块,我们放营销业务。
+ * promotion 模块,我们放营销业务。
  * 例如说:营销活动、banner、优惠券等等
  *
- * 1. Controller URL:以 /market/ 开头,避免和其它 Module 冲突
- * 2. DataObject 表名:以 market_ 开头,方便在数据库中区分
+ * 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突
+ * 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分
  */
 package cn.iocoder.yudao.module.market;

+ 0 - 62
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/activity/ActivityService.java

@@ -1,62 +0,0 @@
-package cn.iocoder.yudao.module.market.service.activity;
-
-import java.util.*;
-import javax.validation.*;
-import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
-import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-
-/**
- * 促销活动 Service 接口
- *
- * @author 芋道源码
- */
-public interface ActivityService {
-
-    /**
-     * 创建促销活动
-     *
-     * @param createReqVO 创建信息
-     * @return 编号
-     */
-    Long createActivity(@Valid ActivityCreateReqVO createReqVO);
-
-    /**
-     * 更新促销活动
-     *
-     * @param updateReqVO 更新信息
-     */
-    void updateActivity(@Valid ActivityUpdateReqVO updateReqVO);
-
-    /**
-     * 删除促销活动
-     *
-     * @param id 编号
-     */
-    void deleteActivity(Long id);
-
-    /**
-     * 获得促销活动
-     *
-     * @param id 编号
-     * @return 促销活动
-     */
-    ActivityDO getActivity(Long id);
-
-    /**
-     * 获得促销活动列表
-     *
-     * @param ids 编号
-     * @return 促销活动列表
-     */
-    List<ActivityDO> getActivityList(Collection<Long> ids);
-
-    /**
-     * 获得促销活动分页
-     *
-     * @param pageReqVO 分页查询
-     * @return 促销活动分页
-     */
-    PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO);
-
-}

+ 0 - 77
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/activity/ActivityServiceImpl.java

@@ -1,77 +0,0 @@
-package cn.iocoder.yudao.module.market.service.activity;
-
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import org.springframework.validation.annotation.Validated;
-
-import java.util.*;
-import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
-import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-
-import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert;
-import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper;
-
-import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*;
-
-/**
- * 促销活动 Service 实现类
- *
- * @author 芋道源码
- */
-@Service
-@Validated
-public class ActivityServiceImpl implements ActivityService {
-
-    @Resource
-    private ActivityMapper activityMapper;
-
-    @Override
-    public Long createActivity(ActivityCreateReqVO createReqVO) {
-        // 插入
-        ActivityDO activity = ActivityConvert.INSTANCE.convert(createReqVO);
-        activityMapper.insert(activity);
-        // 返回
-        return activity.getId();
-    }
-
-    @Override
-    public void updateActivity(ActivityUpdateReqVO updateReqVO) {
-        // 校验存在
-        this.validateActivityExists(updateReqVO.getId());
-        // 更新
-        ActivityDO updateObj = ActivityConvert.INSTANCE.convert(updateReqVO);
-        activityMapper.updateById(updateObj);
-    }
-
-    @Override
-    public void deleteActivity(Long id) {
-        // 校验存在
-        this.validateActivityExists(id);
-        // 删除
-        activityMapper.deleteById(id);
-    }
-
-    private void validateActivityExists(Long id) {
-        if (activityMapper.selectById(id) == null) {
-            throw exception(ACTIVITY_NOT_EXISTS);
-        }
-    }
-
-    @Override
-    public ActivityDO getActivity(Long id) {
-        return activityMapper.selectById(id);
-    }
-
-    @Override
-    public List<ActivityDO> getActivityList(Collection<Long> ids) {
-        return activityMapper.selectBatchIds(ids);
-    }
-
-    @Override
-    public PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO) {
-        return activityMapper.selectPage(pageReqVO);
-    }
-
-}

+ 4 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/discount/package-info.java

@@ -0,0 +1,4 @@
+/**
+ * TODO 占位
+ */
+package cn.iocoder.yudao.module.market.service.discount;

+ 24 - 0
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/price/PriceApiImpl.java

@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.market.service.price;
+
+import cn.iocoder.yudao.module.market.api.price.PriceApi;
+import cn.iocoder.yudao.module.market.api.price.dto.PriceCalculateReqDTO;
+import cn.iocoder.yudao.module.market.api.price.dto.PriceCalculateRespDTO;
+import org.springframework.stereotype.Service;
+
+/**
+ * 价格 API 实现类
+ *
+ * TODO 完善注释
+ *
+ * @author TODO
+ */
+@Service
+public class PriceApiImpl implements PriceApi {
+
+    @Override
+    public PriceCalculateRespDTO calculatePrice(PriceCalculateReqDTO calculateReqDTO) {
+        // TODO fixme:实现逻辑
+        return new PriceCalculateRespDTO();
+    }
+
+}

+ 0 - 197
yudao-module-mall/yudao-module-market-biz/src/test/java/cn/iocoder/yudao/module/market/service/activity/ActivityServiceImplTest.java

@@ -1,197 +0,0 @@
-package cn.iocoder.yudao.module.market.service.activity;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import javax.annotation.Resource;
-
-import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
-
-import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
-import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
-import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-
-import org.springframework.context.annotation.Import;
-
-import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*;
-import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
-import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
-import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
-* {@link ActivityServiceImpl} 的单元测试类
-*
-* @author 芋道源码
-*/
-@Import(ActivityServiceImpl.class)
-public class ActivityServiceImplTest extends BaseDbUnitTest {
-
-    @Resource
-    private ActivityServiceImpl activityService;
-
-    @Resource
-    private ActivityMapper activityMapper;
-
-    @Test
-    public void testCreateActivity_success() {
-        // 准备参数
-        ActivityCreateReqVO reqVO = randomPojo(ActivityCreateReqVO.class);
-
-        // 调用
-        Long activityId = activityService.createActivity(reqVO);
-        // 断言
-        assertNotNull(activityId);
-        // 校验记录的属性是否正确
-        ActivityDO activity = activityMapper.selectById(activityId);
-        assertPojoEquals(reqVO, activity);
-    }
-
-    @Test
-    public void testUpdateActivity_success() {
-        // mock 数据
-        ActivityDO dbActivity = randomPojo(ActivityDO.class);
-        activityMapper.insert(dbActivity);// @Sql: 先插入出一条存在的数据
-        // 准备参数
-        ActivityUpdateReqVO reqVO = randomPojo(ActivityUpdateReqVO.class, o -> {
-            o.setId(dbActivity.getId()); // 设置更新的 ID
-        });
-
-        // 调用
-        activityService.updateActivity(reqVO);
-        // 校验是否更新正确
-        ActivityDO activity = activityMapper.selectById(reqVO.getId()); // 获取最新的
-        assertPojoEquals(reqVO, activity);
-    }
-
-    @Test
-    public void testUpdateActivity_notExists() {
-        // 准备参数
-        ActivityUpdateReqVO reqVO = randomPojo(ActivityUpdateReqVO.class);
-
-        // 调用, 并断言异常
-        assertServiceException(() -> activityService.updateActivity(reqVO), ACTIVITY_NOT_EXISTS);
-    }
-
-    @Test
-    public void testDeleteActivity_success() {
-        // mock 数据
-        ActivityDO dbActivity = randomPojo(ActivityDO.class);
-        activityMapper.insert(dbActivity);// @Sql: 先插入出一条存在的数据
-        // 准备参数
-        Long id = dbActivity.getId();
-
-        // 调用
-        activityService.deleteActivity(id);
-       // 校验数据不存在了
-       assertNull(activityMapper.selectById(id));
-    }
-
-    @Test
-    public void testDeleteActivity_notExists() {
-        // 准备参数
-        Long id = randomLongId();
-
-        // 调用, 并断言异常
-        assertServiceException(() -> activityService.deleteActivity(id), ACTIVITY_NOT_EXISTS);
-    }
-
-    @Test
-    @Disabled  // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
-    public void testGetActivityPage() {
-       // mock 数据
-       ActivityDO dbActivity = randomPojo(ActivityDO.class, o -> { // 等会查询到
-           o.setTitle(null);
-           o.setActivityType(null);
-           o.setStatus(null);
-           o.setStartTime(null);
-           o.setEndTime(null);
-           o.setInvalidTime(null);
-           o.setDeleteTime(null);
-           o.setTimeLimitedDiscount(null);
-           o.setFullPrivilege(null);
-           o.setCreateTime(null);
-       });
-       activityMapper.insert(dbActivity);
-       // 测试 title 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTitle(null)));
-       // 测试 activityType 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setActivityType(null)));
-       // 测试 status 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStatus(null)));
-       // 测试 startTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStartTime(null)));
-       // 测试 endTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setEndTime(null)));
-       // 测试 invalidTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setInvalidTime(null)));
-       // 测试 deleteTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setDeleteTime(null)));
-       // 测试 timeLimitedDiscount 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTimeLimitedDiscount(null)));
-       // 测试 fullPrivilege 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setFullPrivilege(null)));
-       // 测试 createTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setCreateTime(null)));
-       // 准备参数
-       ActivityPageReqVO reqVO = new ActivityPageReqVO();
-       reqVO.setTitle(null);
-       reqVO.setActivityType(null);
-       reqVO.setStatus(null);
-       reqVO.setStartTime(null);
-       reqVO.setEndTime(null);
-       reqVO.setInvalidTime(null);
-       reqVO.setDeleteTime(null);
-       reqVO.setTimeLimitedDiscount(null);
-       reqVO.setFullPrivilege(null);
-       reqVO.setCreateTime(null);
-
-       // 调用
-       PageResult<ActivityDO> pageResult = activityService.getActivityPage(reqVO);
-       // 断言
-       assertEquals(1, pageResult.getTotal());
-       assertEquals(1, pageResult.getList().size());
-       assertPojoEquals(dbActivity, pageResult.getList().get(0));
-    }
-
-    @Test
-    @Disabled  // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
-    public void testGetActivityList() {
-       // mock 数据
-       ActivityDO dbActivity = randomPojo(ActivityDO.class, o -> { // 等会查询到
-           o.setTitle(null);
-           o.setActivityType(null);
-           o.setStatus(null);
-           o.setStartTime(null);
-           o.setEndTime(null);
-           o.setInvalidTime(null);
-           o.setDeleteTime(null);
-           o.setTimeLimitedDiscount(null);
-           o.setFullPrivilege(null);
-           o.setCreateTime(null);
-       });
-       activityMapper.insert(dbActivity);
-       // 测试 title 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTitle(null)));
-       // 测试 activityType 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setActivityType(null)));
-       // 测试 status 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStatus(null)));
-       // 测试 startTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStartTime(null)));
-       // 测试 endTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setEndTime(null)));
-       // 测试 invalidTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setInvalidTime(null)));
-       // 测试 deleteTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setDeleteTime(null)));
-       // 测试 timeLimitedDiscount 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTimeLimitedDiscount(null)));
-       // 测试 fullPrivilege 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setFullPrivilege(null)));
-       // 测试 createTime 不匹配
-       activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setCreateTime(null)));
-    }
-
-}

+ 30 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java

@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.product.api.sku;
+
+import cn.iocoder.yudao.module.product.api.sku.dto.SkuDecrementStockBatchReqDTO;
+import cn.iocoder.yudao.module.product.api.sku.dto.SkuInfoRespDTO;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author LeeYan9
+ * @since 2022-08-26
+ */
+public interface ProductSkuApi {
+
+
+    /**
+     * 根据skuId列表 查询sku信息
+     *
+     * @param skuIds sku ID列表
+     * @return sku信息列表
+     */
+    List<SkuInfoRespDTO> getSkusByIds(Collection<Long> skuIds);
+
+    /**
+     * 批量扣减sku库存
+     *
+     * @param batchReqDTO sku库存信息列表
+     */
+    void decrementStockBatch(SkuDecrementStockBatchReqDTO batchReqDTO);
+}

+ 45 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuDecrementStockBatchReqDTO.java

@@ -0,0 +1,45 @@
+package cn.iocoder.yudao.module.product.api.sku.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @author LeeYan9
+ * @since 2022-08-26
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SkuDecrementStockBatchReqDTO {
+
+
+    private List<Item> items;
+
+    @Data
+    public static class Item {
+
+        /**
+         * 商品 SPU 编号,自增
+         */
+        private Long productId;
+
+        /**
+         * 商品 SKU 编号,自增
+         */
+        private Long skuId;
+
+        /**
+         * 数量
+         */
+        private Integer count;
+
+    }
+
+    public static SkuDecrementStockBatchReqDTO of(List<Item> items) {
+        return new SkuDecrementStockBatchReqDTO(items);
+    }
+
+}

+ 93 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/SkuInfoRespDTO.java

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.product.api.sku.dto;
+
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author LeeYan9
+ * @since 2022-08-26
+ */
+@Data
+public class SkuInfoRespDTO {
+
+    /**
+     * 商品 SKU 编号,自增
+     */
+    private Long id;
+    /**
+     * 商品 SKU 名字
+     */
+    private String name;
+    /**
+     * SPU 编号
+     */
+    private Long spuId;
+
+    /**
+     * 规格值数组,JSON 格式
+     */
+    private List<Property> properties;
+    /**
+     * 销售价格,单位:分
+     */
+    private Integer price;
+    /**
+     * 市场价,单位:分
+     */
+    private Integer marketPrice;
+    /**
+     * 成本价,单位:分
+     */
+    private Integer costPrice;
+    /**
+     * SKU 的条形码
+     */
+    private String barCode;
+    /**
+     * 图片地址
+     */
+    private String picUrl;
+    /**
+     * SKU 状态
+     * <p>
+     * 枚举 {@link CommonStatusEnum}
+     */
+    private Integer status;
+    /**
+     * 库存
+     */
+    private Integer stock;
+    /**
+     * 预警预存
+     */
+    private Integer warnStock;
+    /**
+     * 商品重量,单位:kg 千克
+     */
+    private Double weight;
+    /**
+     * 商品体积,单位:m^3 平米
+     */
+    private Double volume;
+
+    /**
+     * 商品属性
+     */
+    @Data
+    public static class Property {
+
+        /**
+         * 属性编号
+         */
+        private Long propertyId;
+        /**
+         * 属性值编号
+         */
+        private Long valueId;
+
+    }
+
+
+}

+ 23 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java

@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.product.api.spu;
+
+import cn.iocoder.yudao.module.product.api.sku.dto.SkuInfoRespDTO;
+import cn.iocoder.yudao.module.product.api.spu.dto.SpuInfoRespDTO;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author LeeYan9
+ * @since 2022-08-26
+ */
+public interface ProductSpuApi {
+
+
+    /**
+     * 根据spuId列表 查询spu信息
+     *
+     * @param spuIds spu ID列表
+     * @return spu信息列表
+     */
+    List<SpuInfoRespDTO> getSpusByIds(Collection<Long> spuIds);
+}

+ 124 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/SpuInfoRespDTO.java

@@ -0,0 +1,124 @@
+package cn.iocoder.yudao.module.product.api.spu.dto;
+
+import cn.iocoder.yudao.module.product.api.sku.dto.SkuInfoRespDTO;
+import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum;
+import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author LeeYan9
+ * @since 2022-08-26
+ */
+@Data
+public class SpuInfoRespDTO {
+
+    /**
+     * 商品 SPU 编号,自增
+     */
+    private Long id;
+
+    // ========== 基本信息 =========
+
+    /**
+     * 商品名称
+     */
+    private String name;
+    /**
+     * 商品编码
+     */
+    private String code;
+    /**
+     * 商品卖点
+     */
+    private String sellPoint;
+    /**
+     * 商品详情
+     */
+    private String description;
+    /**
+     * 商品分类编号
+     */
+    private Long categoryId;
+    /**
+     * 商品品牌编号
+     */
+    private Long brandId;
+    /**
+     * 商品图片的数组
+     * <p>
+     * 1. 第一张图片将作为商品主图,支持同时上传多张图;
+     * 2. 建议使用尺寸 800x800 像素以上、大小不超过 1M 的正方形图片;
+     * 3. 至少 1 张,最多上传 10 张
+     */
+    private List<String> picUrls;
+    /**
+     * 商品视频
+     */
+    private String videoUrl;
+
+    /**
+     * 排序字段
+     */
+    private Integer sort;
+    /**
+     * 商品状态
+     * <p>
+     * 枚举 {@link ProductSpuStatusEnum}
+     */
+    private Integer status;
+
+    // ========== SKU 相关字段 =========
+
+    /**
+     * 规格类型
+     * <p>
+     * 枚举 {@link ProductSpuSpecTypeEnum}
+     */
+    private Integer specType;
+    /**
+     * 最小价格,单位使用:分
+     * <p>
+     * 基于其对应的 {@link SkuInfoRespDTO#getPrice()} 最小值
+     */
+    private Integer minPrice;
+    /**
+     * 最大价格,单位使用:分
+     * <p>
+     * 基于其对应的 {@link SkuInfoRespDTO#getPrice()} 最大值
+     */
+    private Integer maxPrice;
+    /**
+     * 市场价,单位使用:分
+     * <p>
+     * 基于其对应的 {@link SkuInfoRespDTO#getMarketPrice()} 最大值
+     */
+    private Integer marketPrice;
+    /**
+     * 总库存
+     * <p>
+     * 基于其对应的 {@link SkuInfoRespDTO#getStock()} 求和
+     */
+    private Integer totalStock;
+    /**
+     * 是否展示库存
+     */
+    private Boolean showStock;
+
+    // ========== 统计相关字段 =========
+
+    /**
+     * 商品销量
+     */
+    private Integer salesCount;
+    /**
+     * 虚拟销量
+     */
+    private Integer virtualSalesCount;
+    /**
+     * 商品点击量
+     */
+    private Integer clickCount;
+
+}

+ 19 - 11
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java

@@ -3,30 +3,38 @@ package cn.iocoder.yudao.module.product.enums;
 import cn.iocoder.yudao.framework.common.exception.ErrorCode;
 
 /**
- * product 错误码枚举类
- * <p>
+ * Product 错误码枚举类
+ *
  * product 系统,使用 1-008-000-000 段
  */
 public interface ErrorCodeConstants {
 
-    // ========== 商品分类相关  1008001000============
+    // ========== 商品分类相关 1008001000 ============
     ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1008001000, "商品分类不存在");
     ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1008001001, "父分类不存在");
-    ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1008001002, "存在子分类,无法删除");
+    ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1008001002, "父分类不能是二级分类");
+    ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1008001003, "存在子分类,无法删除");
+    ErrorCode CATEGORY_DISABLED = new ErrorCode(1008001004, "商品分类({})已禁用,无法使用");
+    ErrorCode CATEGORY_LEVEL_ERROR = new ErrorCode(1008001005, "商品分类不正确,原因:必须使用第三级的商品分类下");
 
-    // ========== 品牌相关编号 1008002000 ==========
+    // ========== 商品品牌相关编号 1008002000 ==========
     ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1008002000, "品牌不存在");
+    ErrorCode BRAND_DISABLED = new ErrorCode(1008002001, "品牌不存在");
+    ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1008002002, "品牌名称已存在");
 
-    // ========== 规格名称 1008003000 ==========
+    // ========== 商品规格名称 1008003000 ==========
     ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1008003000, "规格名称不存在");
 
     // ========== 规格值 1008004000 ==========
     ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1008004000, "规格值不存在");
 
-    // ========== 商品spu 1008005000 ==========
-    ErrorCode SPU_NOT_EXISTS = new ErrorCode(1008005000, "商品spu不存在");
+    // ========== 商品 SPU 1008005000 ==========
+    ErrorCode SPU_NOT_EXISTS = new ErrorCode(1008005000, "商品 SPU 不存在");
+
+    // ========== 商品 SKU 1008006000 ==========
+    ErrorCode SKU_NOT_EXISTS = new ErrorCode(1008006000, "商品 SKU 不存在");
+    ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1008006001, "商品 SKU 的属性组合存在重复");
+    ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1008006002, "一个 SPU 下的每个 SKU,其规格数必须一致");
+    ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1008006003, "一个 SPU 下的每个 SKU,必须不重复");
 
-    // ========== 商品sku 1008006000 ==========
-    ErrorCode SKU_NOT_EXISTS = new ErrorCode(1008006000, "商品sku不存在");
-    ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1008006001, "商品sku的属性组合存在重复");
 }

+ 38 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.product.enums.comment;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 商品评论的审批状态枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum ProductCommentAuditStatusEnum implements IntArrayValuable {
+
+    NONE(1, "待审核"),
+    APPROVE(2, "审批通过"),
+    REJECT(2, "审批不通过"),;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray();
+
+    /**
+     * 审批状态
+     */
+    private final Integer status;
+    /**
+     * 状态名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 38 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/delivery/DeliveryTypeEnum.java

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.product.enums.delivery;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 配送方式枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum DeliveryTypeEnum implements IntArrayValuable {
+
+    // TODO 芋艿:英文单词,需要再想下;
+    EXPRESS(1, "快递发货"),
+    USER(2, "用户自提"),;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getMode).toArray();
+
+    /**
+     * 配送方式
+     */
+    private final Integer mode;
+    /**
+     * 状态名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 38 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/group/ProductGroupStyleEnum.java

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.product.enums.group;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 商品分组的样式枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum ProductGroupStyleEnum implements IntArrayValuable {
+
+    ONE(1, "每列一个"),
+    TWO(2, "每列两个"),
+    THREE(2, "每列三个"),;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductGroupStyleEnum::getStyle).toArray();
+
+    /**
+     * 列表样式
+     */
+    private final Integer style;
+    /**
+     * 状态名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 37 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuSpecTypeEnum.java

@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.product.enums.spu;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 商品 SPU 规格类型
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum ProductSpuSpecTypeEnum implements IntArrayValuable {
+
+    RECYCLE(1, "统一规格"),
+    DISABLE(2, "多规格");
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuSpecTypeEnum::getType).toArray();
+
+    /**
+     * 规格
+     */
+    private final Integer type;
+    /**
+     * 规格名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 38 - 0
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.product.enums.spu;
+
+import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 商品 SPU 状态
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum ProductSpuStatusEnum implements IntArrayValuable {
+
+    RECYCLE(-1, "回收站"),
+    DISABLE(0, "下架"),
+    ENABLE(1, "上架"),;
+
+    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStyle).toArray();
+
+    /**
+     * 状态
+     */
+    private final Integer style;
+    /**
+     * 状态名
+     */
+    private final String name;
+
+    @Override
+    public int[] array() {
+        return ARRAYS;
+    }
+
+}

+ 2 - 8
yudao-module-mall/yudao-module-product-biz/pom.xml

@@ -2,13 +2,12 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>cn.iocoder.boot</groupId>
         <artifactId>yudao-module-mall</artifactId>
         <version>${revision}</version>
     </parent>
-
+    <modelVersion>4.0.0</modelVersion>
     <artifactId>yudao-module-product-biz</artifactId>
     <packaging>jar</packaging>
 
@@ -18,7 +17,6 @@
         例如:品牌、商品分类、spu、sku等功能。
     </description>
 
-
     <dependencies>
         <dependency>
             <groupId>cn.iocoder.boot</groupId>
@@ -31,10 +29,6 @@
             <groupId>cn.iocoder.boot</groupId>
             <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
         </dependency>
-        <dependency>
-            <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-spring-boot-starter-biz-weixin</artifactId>
-        </dependency>
         <dependency>
             <groupId>cn.iocoder.boot</groupId>
             <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
@@ -64,4 +58,4 @@
 
     </dependencies>
 
-</project>
+</project>

+ 1 - 0
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java

@@ -0,0 +1 @@
+package cn.iocoder.yudao.module.product.api;

+ 26 - 0
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java

@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.product.api.sku;
+
+import cn.iocoder.yudao.module.product.api.sku.dto.SkuDecrementStockBatchReqDTO;
+import cn.iocoder.yudao.module.product.api.sku.dto.SkuInfoRespDTO;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * todo 注释
+ */
+@Service
+public class ProductSkuApiImpl implements ProductSkuApi {
+
+    @Override
+    public List<SkuInfoRespDTO> getSkusByIds(Collection<Long> skuIds) {
+        return null;
+    }
+
+    @Override
+    public void decrementStockBatch(SkuDecrementStockBatchReqDTO batchReqDTO) {
+
+    }
+
+}

+ 20 - 0
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java

@@ -0,0 +1,20 @@
+package cn.iocoder.yudao.module.product.api.spu;
+
+import cn.iocoder.yudao.module.product.api.spu.dto.SpuInfoRespDTO;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * todo 注释
+ */
+@Service
+public class ProductSpuApiImpl implements ProductSpuApi {
+
+    @Override
+    public List<SpuInfoRespDTO> getSpusByIds(Collection<Long> spuIds) {
+        return null;
+    }
+
+}

+ 22 - 29
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/BrandController.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java

@@ -2,12 +2,10 @@ package cn.iocoder.yudao.module.product.controller.admin.brand;
 
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
-import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
 import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*;
-import cn.iocoder.yudao.module.product.convert.brand.BrandConvert;
-import cn.iocoder.yudao.module.product.dal.dataobject.brand.BrandDO;
-import cn.iocoder.yudao.module.product.service.brand.BrandService;
+import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert;
+import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
+import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
@@ -16,34 +14,32 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
-import java.io.IOException;
+import java.util.Comparator;
 import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
 
-@Api(tags = "管理后台 - 品牌")
+@Api(tags = "管理后台 - 商品品牌")
 @RestController
 @RequestMapping("/product/brand")
 @Validated
-public class BrandController {
+public class ProductBrandController {
 
     @Resource
-    private BrandService brandService;
+    private ProductBrandService brandService;
 
     @PostMapping("/create")
     @ApiOperation("创建品牌")
     @PreAuthorize("@ss.hasPermission('product:brand:create')")
-    public CommonResult<Long> createBrand(@Valid @RequestBody BrandCreateReqVO createReqVO) {
+    public CommonResult<Long> createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) {
         return success(brandService.createBrand(createReqVO));
     }
 
     @PutMapping("/update")
     @ApiOperation("更新品牌")
     @PreAuthorize("@ss.hasPermission('product:brand:update')")
-    public CommonResult<Boolean> updateBrand(@Valid @RequestBody BrandUpdateReqVO updateReqVO) {
+    public CommonResult<Boolean> updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) {
         brandService.updateBrand(updateReqVO);
         return success(true);
     }
@@ -61,29 +57,26 @@ public class BrandController {
     @ApiOperation("获得品牌")
     @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
     @PreAuthorize("@ss.hasPermission('product:brand:query')")
-    public CommonResult<BrandRespVO> getBrand(@RequestParam("id") Long id) {
-        BrandDO brand = brandService.getBrand(id);
-        return success(BrandConvert.INSTANCE.convert(brand));
+    public CommonResult<ProductBrandRespVO> getBrand(@RequestParam("id") Long id) {
+        ProductBrandDO brand = brandService.getBrand(id);
+        return success(ProductBrandConvert.INSTANCE.convert(brand));
     }
 
     @GetMapping("/page")
     @ApiOperation("获得品牌分页")
     @PreAuthorize("@ss.hasPermission('product:brand:query')")
-    public CommonResult<PageResult<BrandRespVO>> getBrandPage(@Valid BrandPageReqVO pageVO) {
-        PageResult<BrandDO> pageResult = brandService.getBrandPage(pageVO);
-        return success(BrandConvert.INSTANCE.convertPage(pageResult));
+    public CommonResult<PageResult<ProductBrandRespVO>> getBrandPage(@Valid ProductBrandPageReqVO pageVO) {
+        PageResult<ProductBrandDO> pageResult = brandService.getBrandPage(pageVO);
+        return success(ProductBrandConvert.INSTANCE.convertPage(pageResult));
     }
 
-    @GetMapping("/export-excel")
-    @ApiOperation("导出品牌 Excel")
-    @PreAuthorize("@ss.hasPermission('product:brand:export')")
-    @OperateLog(type = EXPORT)
-    public void exportBrandExcel(@Valid BrandExportReqVO exportReqVO,
-              HttpServletResponse response) throws IOException {
-        List<BrandDO> list = brandService.getBrandList(exportReqVO);
-        // 导出 Excel
-        List<BrandExcelVO> datas = BrandConvert.INSTANCE.convertList02(list);
-        ExcelUtils.write(response, "品牌.xls", "数据", BrandExcelVO.class, datas);
+    @GetMapping("/list")
+    @ApiOperation("获得品牌列表")
+    @PreAuthorize("@ss.hasPermission('product:brand:query')")
+    public CommonResult<List<ProductBrandRespVO>> getBrandList(@Valid ProductBrandListReqVO listVO) {
+        List<ProductBrandDO> list = brandService.getBrandList(listVO);
+        list.sort(Comparator.comparing(ProductBrandDO::getSort));
+        return success(ProductBrandConvert.INSTANCE.convertList(list));
     }
 
 }

+ 0 - 45
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/BrandExcelVO.java

@@ -1,45 +0,0 @@
-package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-
-import com.alibaba.excel.annotation.ExcelProperty;
-import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
-import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
-
-
-/**
- * 品牌 Excel VO
- *
- * @author 芋道源码
- */
-@Data
-public class BrandExcelVO {
-
-    @ExcelProperty("品牌编号")
-    private Long id;
-
-    @ExcelProperty("分类编号")
-    private Long categoryId;
-
-    @ExcelProperty("品牌名称")
-    private String name;
-
-    @ExcelProperty("品牌图片")
-    private String bannerUrl;
-
-    @ExcelProperty("品牌排序")
-    private Integer sort;
-
-    @ExcelProperty("品牌描述")
-    private String description;
-
-    @ExcelProperty(value = "状态", converter = DictConvert.class)
-    @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
-    private Integer status;
-
-    @ExcelProperty("创建时间")
-    private Date createTime;
-
-}

+ 0 - 28
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/BrandExportReqVO.java

@@ -1,28 +0,0 @@
-package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-@ApiModel(value = "管理后台 - 品牌 Excel 导出 Request VO", description = "参数和 BrandPageReqVO 是一致的")
-@Data
-public class BrandExportReqVO {
-
-    @ApiModelProperty(value = "分类编号", example = "1")
-    private Long categoryId;
-
-    @ApiModelProperty(value = "品牌名称", example = "芋道")
-    private String name;
-
-    @ApiModelProperty(value = "状态", example = "0")
-    private Integer status;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "创建时间")
-    private Date[] createTime;
-
-}

+ 0 - 30
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/BrandPageReqVO.java

@@ -1,30 +0,0 @@
-package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-@ApiModel("管理后台 - 品牌分页 Request VO")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-public class BrandPageReqVO extends PageParam {
-
-    @ApiModelProperty(value = "分类编号", example = "1")
-    private Long categoryId;
-
-    @ApiModelProperty(value = "品牌名称", example = "芋道")
-    private String name;
-
-    @ApiModelProperty(value = "状态", example = "0")
-    private Integer status;
-
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @ApiModelProperty(value = "创建时间")
-    private Date[] createTime;
-
-}

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است