Browse Source

Merge branch 'dev/2024/0611/update-admin-Y' of Harper/feifan-backend-zx-admin into master

合并生产环境的代码
Yangzw 9 months ago
parent
commit
03e15b9e1e
100 changed files with 1619 additions and 3599 deletions
  1. 21 16
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/CaclEnum.java
  2. 1 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ErrorCodeConstants.java
  3. 2 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserRespVO.java
  4. 18 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogPageReqVO.java
  5. 22 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogRespVO.java
  6. 15 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogSaveReqVO.java
  7. 94 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/PtProfitLogDetailsController.java
  8. 27 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsPageReqVO.java
  9. 29 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsRespVO.java
  10. 25 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsSaveReqVO.java
  11. 4 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/UserSignSocialLogRespVO.java
  12. 23 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlog/PtProfitLogDO.java
  13. 36 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlogdetails/PtProfitLogDetailsDO.java
  14. 34 7
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlog/PtProfitLogMapper.java
  15. 27 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlogdetails/PtProfitLogDetailsMapper.java
  16. 2 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/socialstatuschangelog/SocialStatusChangeLogMapper.java
  17. 5 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/message/order/DistriOrderMessage.java
  18. 5 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/message/order/OrderItemMessage.java
  19. 12 4
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserServiceImpl.java
  20. 159 64
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcServiceImpl.java
  21. 121 43
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/partitioncrash/PartitionCrashServiceImpl.java
  22. 2 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java
  23. 9 2
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java
  24. 59 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsService.java
  25. 77 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsServiceImpl.java
  26. 1 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java
  27. 7 2
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatuschangelog/SocialStatusChangeLogServiceImpl.java
  28. 12 0
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofitlogdetails/PtProfitLogDetailsMapper.xml
  29. 0 38
      feifan-module-infra/feifan-module-infra-biz/src/main/java/cn/newfeifan/mall/module/infra/controller/app/file/AppFileController.java
  30. 0 4
      feifan-module-infra/feifan-module-infra-biz/src/main/java/cn/newfeifan/mall/module/infra/controller/app/package-info.java
  31. 11 1
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/ProductSpuController.java
  32. 4 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSkuRespVO.java
  33. 4 1
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java
  34. 7 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java
  35. 15 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuRespVO.java
  36. 13 1
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java
  37. 11 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java
  38. 0 54
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/category/AppCategoryController.java
  39. 0 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/comment/AppCommentController.http
  40. 0 50
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/comment/AppProductCommentController.java
  41. 0 88
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/favorite/AppFavoriteController.java
  42. 0 77
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/history/AppProductBrowseHistoryController.java
  43. 0 4
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/property/package-info.java
  44. 0 18
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/spu/AppProductSpuController.http
  45. 0 152
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/spu/AppProductSpuController.java
  46. 7 1
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/sku/ProductSkuDO.java
  47. 14 11
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/spu/ProductSpuDO.java
  48. 5 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/mysql/spu/ProductSpuMapper.java
  49. 15 11
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java
  50. 0 5
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/activity/AppActivityController.http
  51. 0 172
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/activity/AppActivityController.java
  52. 0 39
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/article/AppArticleCategoryController.java
  53. 0 75
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/article/AppArticleController.java
  54. 0 44
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/banner/AppBannerController.java
  55. 0 107
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainActivityController.java
  56. 0 9
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainHelpController.http
  57. 0 62
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainHelpController.java
  58. 0 9
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainRecordController.http
  59. 0 162
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainRecordController.java
  60. 0 112
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/combination/AppCombinationActivityController.java
  61. 0 142
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/combination/AppCombinationRecordController.java
  62. 0 92
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/coupon/AppCouponController.java
  63. 0 141
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/coupon/AppCouponTemplateController.java
  64. 0 38
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/diy/AppDiyPageController.java
  65. 0 65
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/diy/AppDiyTemplateController.java
  66. 0 38
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/reward/AppRewardActivityController.java
  67. 0 152
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/seckill/AppSeckillActivityController.java
  68. 0 36
      feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/seckill/AppSeckillConfigController.java
  69. 0 4
      feifan-module-mall/feifan-module-statistics-biz/src/main/java/cn/newfeifan/mall/module/statistics/controller/app/package-info.java
  70. 2 0
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/ErrorCodeConstants.java
  71. 3 1
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/delivery/DeliveryTypeEnum.java
  72. 6 1
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/wxmessage/WcChatMessageTemplateIdEnum.java
  73. 11 4
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java
  74. 3 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java
  75. 4 1
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java
  76. 5 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java
  77. 23 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java
  78. 0 71
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/aftersale/AppAfterSaleController.java
  79. 0 42
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/aftersale/AppAfterSaleLogController.java
  80. 0 4
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/base/package-info.java
  81. 0 52
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/brokerage/AppBrokerageRecordController.java
  82. 0 141
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/brokerage/AppBrokerageUserController.java
  83. 0 50
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java
  84. 0 42
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/cart/AppCartController.http
  85. 0 87
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/cart/AppCartController.java
  86. 0 44
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/config/AppTradeConfigController.java
  87. 0 27
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/delivery/AppDeliverConfigController.java
  88. 0 39
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/delivery/AppDeliverExpressController.java
  89. 0 55
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java
  90. 0 64
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/AppTradeOrderController.http
  91. 0 182
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/AppTradeOrderController.java
  92. 3 2
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java
  93. 25 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderDO.java
  94. 5 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderItemDO.java
  95. 3 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java
  96. 5 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/job/order/TradeOrderAutoCalcJob.java
  97. 1 1
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java
  98. 6 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryService.java
  99. 15 7
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java
  100. 544 526
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java

+ 21 - 16
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/CaclEnum.java

@@ -6,22 +6,27 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum CaclEnum {
-    PLATFORM_TOTAL_ADD(0, "平台总收益", "平台总收益"),
-    PLATFORM_SERVICE_FEE(1, "平台服务费", "平台服务费"),
-    PLATFORM_REVENUE(2, "平台收益", "平台收益"),
-    RECOMMENDED_PERSON_QUOTA(3, "推荐人额度", "推荐人额度"),
-    DIRECT_REFERRAL_QUOTA(4, "直推人额度", "直推人额度"),
-    TOGETHER_AWARD(5, "合赢奖", "合赢奖"),
-    HIGH_QUOTA(6, "最高可以获得积分", "最高可以获得积分"),
-    SMALL_QUOTA_CRASH(7, "小区额度分配", "小区额度分配"),
-    AFTER_CRASH_CALC_PT_TOTAL_QUOTA(8, "碰撞后计算平台总收益", "碰撞后计算平台总收益"),
-    ORDER_PAY_INTEGRAL(9, "购物获得积分", "购物获得冻结积分"),
-    ORDER_REFUND_INTEGRAL(10, "订单退款,积分退回", "购物收货7天后,冻结积分变为可用积分"),
-    ORDER_INTEGRAL_UNFREEZE(11, "订单积分到账", "订单积分到账"),
-    AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA(12, "碰撞后计算平台收益", "碰撞后计算平台收益"),
-    FREEZE_CHANGE_INTEGRAL(13, "冻结积分转化成可用积分", "冻结积分变为可用积分"),
-    GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(14, "合赢奖超额", "合赢奖的获取超出最高可获取"),
-    GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(15, "直推奖超额", "直推奖的获取超出最高可获取");
+    PLATFORM_TOTAL_ADD(0, "平台总收益","平台总收益"),
+    PLATFORM_SERVICE_FEE(1, "平台服务费","平台服务费"),
+    PLATFORM_REVENUE(2, "平台收益","平台收益"),
+    RECOMMENDED_PERSON_QUOTA(3, "直推奖获得","直推奖获得"),           //直推奖获得可用积分
+    DIRECT_REFERRAL_QUOTA(4, "购物获得","购物获得可用积分"),       //购物用户自得额度
+    TOGETHER_AWARD(5, "合赢奖","合赢奖"),
+    HIGH_QUOTA(6, "最高可以获得积分","最高可以获得积分"),
+    SMALL_QUOTA_CRASH(7, "合赢奖获得","小区额度分配"),
+    AFTER_CRASH_CALC_PT_TOTAL_QUOTA(8, "碰撞后计算平台总收益","碰撞后计算平台总收益"),
+    ORDER_PAY_INTEGRAL(9, "购物支付","购物使用积分进行支付"),      //购物使用积分进行支付
+    ORDER_REFUND_INTEGRAL(10, "退回退款返回","退回退款订单项,消费者支付的积分"),
+    AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA(12, "碰撞后计算平台收益","碰撞后计算平台收益"),
+    GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(14, "合赢奖超额","合赢奖超额"),
+    GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(15, "直推奖超额","直推奖超额"),
+    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(16,"手动取消支付返回","取消订单,退回积分"),
+    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(17,"支付超时返回","订单超时未支付,退回积分"),
+    ORDER_PAY_INTEGRAL_ANCESTER(18, "直推奖获得","直推人购物,推荐人获得冻结积分"),//购物 上级直推人 获得积分
+    ORDER_REFUND_INTEGRAL_CONSUMER(19,"订单退款","订单退款,收回消费者获得的冻结积分"),
+    ORDER_REFUND_INTEGRAL_ANCESTER(20,"订单退款","订单退款,收回消费者的推荐人,获得的冻结积分"),
+    ORDER_PAY_INTEGRAL_CONSUMER(21, "购物获得","消费者购物,获得冻结积分"),//购物者本人 获得积分
+    ;
 
     /**
      * 来源

+ 1 - 0
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ErrorCodeConstants.java

@@ -28,5 +28,6 @@ public interface ErrorCodeConstants {
     ErrorCode SOCIAL_STATUS_CHANGE_LOG_NOT_EXISTS = new ErrorCode(1_002_030_021, "查询日志记录不存在");
     ErrorCode GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT = new ErrorCode(1_002_030_022, "合赢奖不能超过最大限制");
     ErrorCode USER_SIGN_IN_LOG_NOT_EXISTS = new ErrorCode(1_002_030_023, "签到日志不存在");
+    ErrorCode PT_PROFIT_LOG_DETAILS_NOT_EXISTS = new ErrorCode(1_002_030_024, "平台利润记录详情不存在");
 
 }

+ 2 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserRespVO.java

@@ -76,4 +76,6 @@ public class DuserRespVO {
     @Schema(description = "用户头像")
     private String avatar;
 
+    @Schema(description = "用户积分")
+    private Long integral;
 }

+ 18 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogPageReqVO.java

@@ -39,4 +39,22 @@ public class PtProfitLogPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    @Schema(description = "变动的冻结积分值(可为负数)")
+    private Long freezeAmount;
+
+    @Schema(description = "变动后冻结积分钱包的余额")
+    private Long afterFreezeAmount;
+
+    @Schema(description = "最大可用积分变化值")
+    private Long maxAvailablePointsAmount;
+
+    @Schema(description = "最大可用积分额度")
+    private Long afterMaxAvailablePointsAmount;
+
+    @Schema(description = "合赢奖超出额度")
+    private Long accumulatedQuotaAmount;
+
+    @Schema(description = "直推奖超出额度")
+    private Long ancestorQuotaAmount;
+
 }

+ 22 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogRespVO.java

@@ -48,4 +48,26 @@ public class PtProfitLogRespVO {
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;
+
+    @Schema(description = "变动的冻结积分值(可为负数)")
+    private Long freezeAmount;
+
+    @Schema(description = "变动后冻结积分钱包的余额")
+    private Long afterFreezeAmount;
+
+    @Schema(description = "最大可用积分变化值")
+    @ExcelProperty("最大可用积分变化值")
+    private Long maxAvailablePointsAmount;
+
+    @Schema(description = "最大可用积分额度")
+    @ExcelProperty("最大可用积分额度")
+    private Long afterMaxAvailablePointsAmount;
+
+    @Schema(description = "合赢奖超出额度")
+    @ExcelProperty("合赢奖超出额度")
+    private Long accumulatedQuotaAmount;
+
+    @Schema(description = "直推奖超出额度")
+    @ExcelProperty("直推奖超出额度")
+    private Long ancestorQuotaAmount;
 }

+ 15 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogSaveReqVO.java

@@ -41,4 +41,19 @@ public class PtProfitLogSaveReqVO {
     @Schema(description = "变动后冻结积分钱包的余额")
     private Long afterFreezeAmount;
 
+    @Schema(description = "最大可用积分变化值")
+    private Long maxAvailablePointsAmount;
+
+    @Schema(description = "最大可用积分额度")
+    private Long afterMaxAvailablePointsAmount;
+
+    @Schema(description = "合赢奖超出额度")
+    private Long accumulatedQuotaAmount;
+
+    @Schema(description = "直推奖超出额度")
+    private Long ancestorQuotaAmount;
+
+    @Schema(description = "产生积分的用户ID,例如:下订单的用户ID", example = "31502")
+    private Long generateUserId;
+
 }

+ 94 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/PtProfitLogDetailsController.java

@@ -0,0 +1,94 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails;
+
+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.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.*;
+import javax.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.CommonResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
+
+import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
+
+import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
+import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.*;
+
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+import cn.newfeifan.mall.module.distri.service.ptprofitlogdetails.PtProfitLogDetailsService;
+
+@Tag(name = "管理后台 - 平台利润记录详情")
+@RestController
+@RequestMapping("/distri/pt-profit-log-details")
+@Validated
+public class PtProfitLogDetailsController {
+
+    @Resource
+    private PtProfitLogDetailsService ptProfitLogDetailsService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建平台利润记录详情")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:create')")
+    public CommonResult<Long> createPtProfitLogDetails(@Valid @RequestBody PtProfitLogDetailsSaveReqVO createReqVO) {
+        return success(ptProfitLogDetailsService.createPtProfitLogDetails(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新平台利润记录详情")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:update')")
+    public CommonResult<Boolean> updatePtProfitLogDetails(@Valid @RequestBody PtProfitLogDetailsSaveReqVO updateReqVO) {
+        ptProfitLogDetailsService.updatePtProfitLogDetails(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除平台利润记录详情")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:delete')")
+    public CommonResult<Boolean> deletePtProfitLogDetails(@RequestParam("id") Long id) {
+        ptProfitLogDetailsService.deletePtProfitLogDetails(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得平台利润记录详情")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:query')")
+    public CommonResult<PtProfitLogDetailsRespVO> getPtProfitLogDetails(@RequestParam("id") Long id) {
+        PtProfitLogDetailsDO ptProfitLogDetails = ptProfitLogDetailsService.getPtProfitLogDetails(id);
+        return success(BeanUtils.toBean(ptProfitLogDetails, PtProfitLogDetailsRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得平台利润记录详情分页")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:query')")
+    public CommonResult<PageResult<PtProfitLogDetailsRespVO>> getPtProfitLogDetailsPage(@Valid PtProfitLogDetailsPageReqVO pageReqVO) {
+        PageResult<PtProfitLogDetailsDO> pageResult = ptProfitLogDetailsService.getPtProfitLogDetailsPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, PtProfitLogDetailsRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出平台利润记录详情 Excel")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:export')")
+    @OperateLog(type = EXPORT)
+    public void exportPtProfitLogDetailsExcel(@Valid PtProfitLogDetailsPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<PtProfitLogDetailsDO> list = ptProfitLogDetailsService.getPtProfitLogDetailsPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "平台利润记录详情.xls", "数据", PtProfitLogDetailsRespVO.class,
+                        BeanUtils.toBean(list, PtProfitLogDetailsRespVO.class));
+    }
+
+}

+ 27 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsPageReqVO.java

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo;
+
+import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 平台利润记录详情分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class PtProfitLogDetailsPageReqVO extends PageParam {
+
+    @Schema(description = "平台利润记录编号", example = "19955")
+    private Long distriPtProfitLogId;
+
+    @Schema(description = "订单项编号", example = "9530")
+    private Long orderItemId;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 29 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsRespVO.java

@@ -0,0 +1,29 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 平台利润记录详情 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class PtProfitLogDetailsRespVO {
+
+    @Schema(description = "详情编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32357")
+    @ExcelProperty("详情编号")
+    private Long id;
+
+    @Schema(description = "平台利润记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19955")
+    @ExcelProperty("平台利润记录编号")
+    private Long distriPtProfitLogId;
+
+    @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9530")
+    @ExcelProperty("订单项编号")
+    private Long orderItemId;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 25 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsSaveReqVO.java

@@ -0,0 +1,25 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import javax.validation.constraints.*;
+
+@Schema(description = "管理后台 - 平台利润记录详情新增/修改 Request VO")
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class PtProfitLogDetailsSaveReqVO {
+
+    @Schema(description = "详情编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32357")
+    private Long id;
+
+    @Schema(description = "平台利润记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19955")
+    @NotNull(message = "平台利润记录编号不能为空")
+    private Long distriPtProfitLogId;
+
+    @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9530")
+    @NotNull(message = "订单项编号不能为空")
+    private Long orderItemId;
+
+}

+ 4 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/UserSignSocialLogRespVO.java

@@ -19,5 +19,8 @@ public class UserSignSocialLogRespVO {
 
     @Schema(description = "操作时间")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] createTime;
+    private LocalDateTime createTime;
+
+    @Schema(description = "排序", example = "1")
+    private Integer sort;
 }

+ 23 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlog/PtProfitLogDO.java

@@ -61,5 +61,28 @@ public class PtProfitLogDO extends BaseDO {
      */
     private Long afterFreezeAmount;
 
+    /**
+     * 最大可用积分变化值
+     */
+    private Long maxAvailablePointsAmount;
+    /**
+     * 最大可用积分额度
+     */
+    private Long afterMaxAvailablePointsAmount;
+    /**
+     * 合赢奖超出额度
+     */
+    private Long accumulatedQuotaAmount;
+    /**
+     * 直推奖超出额度
+     */
+    private Long ancestorQuotaAmount;
+
+
+    /**
+     * 产生积分的用户ID,例如:下订单的用户ID
+     */
+    private Long generateUserId;
+
 
 }

+ 36 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlogdetails/PtProfitLogDetailsDO.java

@@ -0,0 +1,36 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails;
+
+import lombok.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 平台利润记录详情 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_pt_profit_log_details")
+@KeySequence("distri_pt_profit_log_details_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class PtProfitLogDetailsDO extends BaseDO {
+
+    /**
+     * 详情编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 平台利润记录编号
+     */
+    private Long distriPtProfitLogId;
+    /**
+     * 订单项编号
+     */
+    private Long orderItemId;
+
+}

+ 34 - 7
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlog/PtProfitLogMapper.java

@@ -8,6 +8,12 @@ import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog.PtProfitLogDO;
 import org.apache.ibatis.annotations.Mapper;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.*;
 
+import java.util.Arrays;
+import java.util.List;
+
+import static cn.newfeifan.mall.module.distri.constant.DistriConstants.PT_ID;
+import static cn.newfeifan.mall.module.distri.enums.CaclEnum.*;
+
 /**
  * 平台利润记录 Mapper
  *
@@ -17,15 +23,36 @@ import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.*;
 public interface PtProfitLogMapper extends BaseMapperX<PtProfitLogDO> {
 
     default PageResult<PtProfitLogDO> selectPage(PtProfitLogPageReqVO reqVO) {
+        //用户只能查看这些类型
+        List<Integer> profitStatus = Arrays.asList(
+                RECOMMENDED_PERSON_QUOTA.getType(),
+                DIRECT_REFERRAL_QUOTA.getType(),
+                SMALL_QUOTA_CRASH.getType(),
+                ORDER_PAY_INTEGRAL.getType(),
+                ORDER_REFUND_INTEGRAL.getType(),
+                ORDER_CANCEL_BY_USER_REFUND_INTEGRAL.getType(),
+                ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL.getType(),
+                ORDER_PAY_INTEGRAL_ANCESTER.getType(),
+                ORDER_REFUND_INTEGRAL_CONSUMER.getType(),
+                ORDER_REFUND_INTEGRAL_ANCESTER.getType(),
+                ORDER_PAY_INTEGRAL_CONSUMER.getType());
+
+        if(reqVO.getUserId().equals(PT_ID)){
+            profitStatus = Arrays.asList(
+                    PLATFORM_TOTAL_ADD.getType(),
+                    PLATFORM_SERVICE_FEE.getType(),
+                    PLATFORM_REVENUE.getType(),
+                    AFTER_CRASH_CALC_PT_TOTAL_QUOTA.getType(),
+                    AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA.getType(),
+                    GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT.getType(),
+                    GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT.getType()
+            );
+            reqVO.setUserId(null);
+        }
+
         return selectPage(reqVO, new LambdaQueryWrapperX<PtProfitLogDO>()
-                .eqIfPresent(PtProfitLogDO::getAmount, reqVO.getAmount())
-                .eqIfPresent(PtProfitLogDO::getAfterAmount, reqVO.getAfterAmount())
-                .eqIfPresent(PtProfitLogDO::getPercentTemplate, reqVO.getPercentTemplate())
-                .betweenIfPresent(PtProfitLogDO::getCreateTime, reqVO.getCreateTime())
-                .eqIfPresent(PtProfitLogDO::getProfitStatus, reqVO.getProfitStatus())
                 .eqIfPresent(PtProfitLogDO::getUserId, reqVO.getUserId())
-                .eqIfPresent(PtProfitLogDO::getOrderId, reqVO.getOrderId())
-                .eqIfPresent(PtProfitLogDO::getOrderNo, reqVO.getOrderNo())
+                .in(PtProfitLogDO::getProfitStatus, profitStatus)
                 .orderByDesc(PtProfitLogDO::getCreateTime)
         );
     }

+ 27 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlogdetails/PtProfitLogDetailsMapper.java

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlogdetails;
+
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.*;
+
+/**
+ * 平台利润记录详情 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface PtProfitLogDetailsMapper extends BaseMapperX<PtProfitLogDetailsDO> {
+
+    default PageResult<PtProfitLogDetailsDO> selectPage(PtProfitLogDetailsPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<PtProfitLogDetailsDO>()
+                .eqIfPresent(PtProfitLogDetailsDO::getDistriPtProfitLogId, reqVO.getDistriPtProfitLogId())
+                .eqIfPresent(PtProfitLogDetailsDO::getOrderItemId, reqVO.getOrderItemId())
+                .betweenIfPresent(PtProfitLogDetailsDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(PtProfitLogDetailsDO::getId));
+    }
+
+}

+ 2 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/socialstatuschangelog/SocialStatusChangeLogMapper.java

@@ -36,6 +36,7 @@ public interface SocialStatusChangeLogMapper extends BaseMapperX<SocialStatusCha
         return selectPage(pageReqVO ,new LambdaQueryWrapperX<SocialStatusChangeLogDO>()
                 .eq(SocialStatusChangeLogDO::getUserId, pageReqVO.getUserId())
                 .eq(SocialStatusChangeLogDO::getSocialStatusChangeCategoryId, SocialStatusEnum.SIGN_IN_SOCIAL.getStatus())
+                .orderByDesc(SocialStatusChangeLogDO::getCreateTime)
         );
      }
-}
+}

+ 5 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/message/order/DistriOrderMessage.java

@@ -79,6 +79,11 @@ public class DistriOrderMessage {
      */
     private Long increaseIntegral;
 
+    /**
+     * 推荐用户获得积分
+     */
+    private Long ancestorIncreaseIntegral;
+
 
     @Override
     public boolean equals(Object o) {

+ 5 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/message/order/OrderItemMessage.java

@@ -43,6 +43,11 @@ public class OrderItemMessage {
      */
     private Long increaseIntegral;
 
+    /**
+     * 推荐用户获得积分
+     */
+    private Long ancestorIncreaseIntegral;
+
     /**
      * 订单项ID
      */

+ 12 - 4
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserServiceImpl.java

@@ -72,6 +72,8 @@ public class DuserServiceImpl implements DuserService {
     @Resource
     private SocialStatusChangeLogService socialStatusChangeLogService;
 
+
+
     @Override
     public Long createDuser(DuserSaveReqVO createReqVO) {
         // 插入
@@ -171,7 +173,7 @@ public class DuserServiceImpl implements DuserService {
             DuserDO duser = getDuserByUser(memberUserRespVO.getId());
             if(duser == null) continue;
             SocialStatusDO socialStatus = socialStatusService.getSocialStatus(duser.getSocialStatusId());
-//            if(socialStatus == null) continue;
+            if(socialStatus == null) continue;
             memberUserRespVO.setCurrentMemberWorthLevelName(socialStatus.getName());
             memberUserRespVO.setCurrentMemberWorthLevel(socialStatus.getLevel());
             //获取钱包
@@ -303,9 +305,15 @@ public class DuserServiceImpl implements DuserService {
             duserRespVO.setAvatar(memberUserService.getUser(duserRespVO.getUserId()).getAvatar());
 
             SocialStatusDO socialStatus = socialStatusService.getSocialStatus(duserRespVO.getSocialStatusId());
-            if(socialStatus == null) continue;
-            duserRespVO.setSocialStatusLevel(socialStatus.getLevel());
-            duserRespVO.setSocialStatusLevelName(socialStatus.getName());
+            if(socialStatus != null) {
+                duserRespVO.setSocialStatusLevel(socialStatus.getLevel());
+                duserRespVO.setSocialStatusLevelName(socialStatus.getName());
+            }
+
+            IntegralDO integral = integralService.getIntegral(duserRespVO.getUserId());
+            if(integral != null){
+                duserRespVO.setIntegral(integral.getCurrentQuota());
+            }
         }
     }
 }

+ 159 - 64
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcServiceImpl.java

@@ -6,6 +6,7 @@ import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.PtProfitLogDetailsSaveReqVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
@@ -21,6 +22,7 @@ import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageSe
 import cn.newfeifan.mall.module.distri.service.partitioncrash.PartitionCrashService;
 import cn.newfeifan.mall.module.distri.service.ptprofit.PtProfitService;
 import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
+import cn.newfeifan.mall.module.distri.service.ptprofitlogdetails.PtProfitLogDetailsService;
 import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -83,6 +85,9 @@ public class OrderCalcServiceImpl implements OrderCalcService {
     @Resource
     private PartitionCrashService partitionCrashService;
 
+    @Resource
+    private PtProfitLogDetailsService ptProfitLogDetailsService;
+
     @Override
     public Long createOrderCalc(OrderCalcSaveReqVO createReqVO) {
         // 插入
@@ -197,10 +202,14 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             BigDecimal price = new BigDecimal(priceStream);
             BigDecimal costPrice = new BigDecimal(longStream);
 
+            // 添加平台利润记录详情
+            List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS = new ArrayList<>();
+
 
             // 计算
             // 计算利润: (价格 - 成本价格) * 产品数量
-            final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0")};      //用户自得不用要计算,从orderItem里面获取
+            //用户自得和直推奖不用计算,从orderItem里面获取
+            final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0"), new BigDecimal("0")};
             k.getOrderItemMessages().forEach(j -> {
                 BigDecimal onePrice = new BigDecimal(j.getPrice());
                 BigDecimal oneCostPrice = new BigDecimal(j.getCostPrice());
@@ -208,12 +217,18 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                 BigDecimal oneGrossProfit = onePrice.subtract(oneCostPrice).multiply(productCount);
                 profit[0] = profit[0].add(oneGrossProfit);  // 注意这里的改动
                 profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral()));     //自得积分
+                profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral()));     //自得积分
 
+                // 遍历订单项拿到订单项编号
                 updateOrderItem(j.getOrderItemId());
+                PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO = PtProfitLogDetailsSaveReqVO.builder()
+                        .orderItemId(j.getOrderItemId())
+                        .build();
+                ptProfitLogDetailsSaveReqVOS.add(ptProfitLogDetailsSaveReqVO);
             });
 
 
-            // 计算毛利: 利润 * 0.38
+            // 计算毛利: 利润 * 1
             BigDecimal grossProfit = profit[0].multiply(new BigDecimal(orderPercentageDO.getGrossProfitPerc())).setScale(4, RoundingMode.DOWN);
 
             // 计算平台收益
@@ -226,22 +241,22 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             // 用户所得: 毛利 * 0.35
             BigDecimal descendantQuota = profit[1];
 
-            // 直推奖: 毛利 * 0.35 (上一级)
-            BigDecimal ancestorQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitAncestorQuotaPerc())).setScale(4, RoundingMode.DOWN);
+            // 直推奖: 毛利 * 0.3 (上一级)
+            BigDecimal ancestorQuota = profit[2];
 
-            // 合赢将: 毛利 * 0.08
+            // 合赢将: 毛利 * 0.12
             BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
-            // 平台服务费: 毛利 * 0.22
+            // 平台服务费: 毛利 * 0.05
             BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
 
-            // 计算当前下单人的毛利的
-            BigDecimal highQuota = grossProfit.multiply(new BigDecimal("3")).setScale(4, RoundingMode.DOWN);
+            // 计算当前下单人的毛利的
+            BigDecimal highQuota = grossProfit.multiply(new BigDecimal("10")).setScale(4, RoundingMode.DOWN);
 
             // 乘以 10000 并转换为整数
             Long grossProfitInt = grossProfit.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
-            Long ancestorQuotaInt = ancestorQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
+            Long ancestorQuotaInt = ancestorQuota.longValue();
             Long descendantQuotaInt = descendantQuota.longValue();
             Long bonusQuotaInt = bonusQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
             Long highQuotaInt = highQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
@@ -252,20 +267,20 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             // 获取当前下单人关系
             SharePathDO sharePath = getSharePath(k.getUserId());
             // 如果sharePath为空, 则说明没有直推人关系
-            IntegralDO integralDOAncestor = integralService.selectByUser(sharePath.getAncestor());
-            IntegralDO integralDO = integralService.selectByUser(sharePath.getDescendant());
-            IntegralDO ptIntegral = integralService.selectByUser(1L);
+            IntegralDO integralDOAncestor = integralService.selectByUser(sharePath.getAncestor());      //父级
+            IntegralDO integralDO = integralService.selectByUser(sharePath.getDescendant());            //自己
+            IntegralDO ptIntegral = integralService.selectByUser(1L);                         //pt
 
 
             // ========== 身价计算 ==============
             //推荐人身价计算
             double orderAncestorSocialStatus = Double.parseDouble(orderPercentageDO.getOrderAncestorSocialStatus());
-            double ancestorSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderAncestorSocialStatus;
+            double ancestorSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderAncestorSocialStatus / 100;
             duserService.updateDuserSocial(integralDOAncestor.getUserId(), (long) ancestorSocial, SocialStatusEnum.SHOPPING_ANCESTOR_SOCIAL.getStatus());
 
             //自得身价计算
             double orderUserSocialStatus = Double.parseDouble(orderPercentageDO.getOrderUserSocialStatus());
-            double descendantSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderUserSocialStatus;
+            double descendantSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderUserSocialStatus / 100;
             duserService.updateDuserSocial(integralDO.getUserId(), (long) descendantSocial, SocialStatusEnum.SHOPPING_SOCIAL.getStatus());
 
 
@@ -286,15 +301,32 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .percentTemplate(percentTemplate).build();
             saveList.add(orderCalcSaveReqVO);
             // ========== 修改用户钱包 =================
+
             //直推奖也要限制额度
             Long ancestorHighQuota = integralDOAncestor.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();//加上基础的最大额度值
-            if (ancestorHighQuota < ancestorQuotaInt) {
-                changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, 0L,
-                        descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
-            } else {
-                changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, ancestorQuotaInt,
-                        descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
+
+            //amount用于记录本次添加的值
+            Long amount = 0L;
+            //平台需要补回的收益
+            Long ptReplenish = ancestorQuotaInt;
+
+            //如果直推人的可获取额度大于0,则能够获取
+            if (ancestorHighQuota.compareTo(0L) > 0) {
+                if (ancestorHighQuota.compareTo(ancestorQuotaInt) > 0) {
+                    //如果最大额度 > 直推人可获取额度,则直接获取
+                    amount = ancestorQuotaInt;
+                    //平台没有需要补回的收益
+                    ptReplenish = 0L;
+                } else {
+                    //如果最大额度 < 直推人可获取额度,则获取自己的最大额度
+                    amount = ancestorHighQuota;
+                    //用户本次没有拿到的直推奖
+                    ptReplenish = ancestorQuotaInt - ancestorHighQuota;
+                }
             }
+            changeUserWallet(integralSaveReqVOS, integralDO, integralDOAncestor, ptIntegral, amount,
+                    descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt);
+
             // ========== 修改平台信息 =================
             // 每个订单计算的过程
             // 增加平台收益
@@ -305,9 +337,12 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                             .ptGrossAdd(grossProfitAfterBonusInt)
                             .ptTotalAdd(platformQuotaInt + grossProfitAfterBonusInt).build();
 
+
             // 当直推人获取的积分额度不足时,平台收益要加回来,并生成log
-            calcIntegral(ptProfitSaveReqVOS, ptProfitSaveReqVO, ancestorHighQuota, ancestorQuotaInt,
-                    k.getOrderId(), k.getNo(), integralDOAncestor.getUserId());
+            if (ptReplenish.compareTo(0L) > 0) {
+                calcIntegral(ptProfitSaveReqVOS, ptProfitSaveReqVO, ptReplenish,
+                        k.getOrderId(), k.getNo());
+            }
 
             ptProfitSaveReqVOS.add(ptProfitSaveReqVO);
             // ========== 增加日志记录 =================
@@ -315,51 +350,97 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             // 平台记录
             // 平台总收益
             // 平台总收益
-            PtProfitLogSaveReqVO ptTotal = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId())
-                    .profitStatus(CaclEnum.PLATFORM_TOTAL_ADD.getType()).orderNo(k.getNo())
-                    .amount(platformQuotaInt + grossProfitAfterBonusInt).afterAmount(ptProfitDO.getPtTotalAdd() + platformQuotaInt + grossProfitAfterBonusInt).percentTemplate(percentTemplate).build();
+            PtProfitLogSaveReqVO ptTotal = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.PLATFORM_TOTAL_ADD.getType())
+                    .orderNo(k.getNo())
+                    .amount(platformQuotaInt + grossProfitAfterBonusInt)
+                    .afterAmount(ptProfitDO.getPtTotalAdd() + platformQuotaInt + grossProfitAfterBonusInt)
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
             // 平台收益
-            PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId())
-                    .profitStatus(CaclEnum.PLATFORM_REVENUE.getType()).orderNo(k.getNo())
-                    .amount(grossProfitAfterBonusInt).afterAmount(ptProfitDO.getPtGrossAdd() + ptProfitSaveReqVO.getPtGrossAdd()).percentTemplate(percentTemplate).build();
+            PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.PLATFORM_REVENUE.getType())
+                    .orderNo(k.getNo())
+                    .amount(grossProfitAfterBonusInt)
+                    .afterAmount(ptProfitDO.getPtGrossAdd() + ptProfitSaveReqVO.getPtGrossAdd())
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
 
             // 平台服务费
-            PtProfitLogSaveReqVO ptAddLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId())
-                    .profitStatus(CaclEnum.PLATFORM_SERVICE_FEE.getType()).orderNo(k.getNo())
-                    .amount(platformQuotaInt).afterAmount(ptProfitDO.getPtAdd() + ptProfitSaveReqVO.getPtAdd()).percentTemplate(percentTemplate).build();
-
+            PtProfitLogSaveReqVO ptAddLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.PLATFORM_SERVICE_FEE.getType())
+                    .orderNo(k.getNo())
+                    .amount(platformQuotaInt)
+                    .afterAmount(ptProfitDO.getPtAdd() + ptProfitSaveReqVO.getPtAdd())
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
 
-            // 推荐人记录
-            PtProfitLogSaveReqVO tjrLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId()).profitStatus(CaclEnum.RECOMMENDED_PERSON_QUOTA.getType()).orderNo(k.getNo()).userId(sharePath.getAncestor()).amount(ancestorQuotaInt).afterAmount(integralDOAncestor.getCurrentQuota() + ancestorQuotaInt).percentTemplate(percentTemplate).build();
 
+            // 直推奖记录
+            PtProfitLogSaveReqVO tjrLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.RECOMMENDED_PERSON_QUOTA.getType())
+                    .orderNo(k.getNo())
+                    .userId(sharePath.getAncestor())
+                    .amount(amount)
+                    .afterAmount(integralDOAncestor.getCurrentQuota())
+                    .freezeAmount(-amount)
+                    .afterFreezeAmount(integralDOAncestor.getFreezeQuota())
+                    .ancestorQuotaAmount(ptReplenish)
+                    .maxAvailablePointsAmount(-amount)
+                    .afterMaxAvailablePointsAmount(ancestorHighQuota - amount)
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
 
-            // 直推人记录
-            PtProfitLogSaveReqVO ztrLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId()).profitStatus(CaclEnum.DIRECT_REFERRAL_QUOTA.getType()).orderNo(k.getNo()).userId(sharePath.getDescendant()).amount(descendantQuotaInt).afterAmount(integralDO.getCurrentQuota() + descendantQuotaInt).percentTemplate(percentTemplate).build();
-            // 直推人冻结积分转化成可用记录
-            PtProfitLogSaveReqVO freezeLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId()).profitStatus(CaclEnum.FREEZE_CHANGE_INTEGRAL.getType()).orderNo(k.getNo()).userId(sharePath.getDescendant()).freezeAmount(descendantQuotaInt).afterFreezeAmount(integralDO.getCurrentQuota() - descendantQuotaInt).percentTemplate(percentTemplate).build();
 
-            PtProfitLogSaveReqVO highQuotaLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId()).profitStatus(CaclEnum.HIGH_QUOTA.getType()).orderNo(k.getNo()).userId(sharePath.getDescendant()).amount(highQuotaInt).afterAmount(integralDO.getHighQuota() + highQuotaInt).percentTemplate(percentTemplate).build();
+            // 用户自得记录 + 户冻结积分转化成可用 + 扣减最高可用额度记录
+            PtProfitLogSaveReqVO ztrLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.DIRECT_REFERRAL_QUOTA.getType())
+                    .orderNo(k.getNo())
+                    .userId(sharePath.getDescendant())
+                    .amount(descendantQuotaInt)
+                    .afterAmount(integralDO.getCurrentQuota())
+                    .freezeAmount(-descendantQuotaInt)
+                    .afterFreezeAmount(integralDO.getFreezeQuota())
+                    .maxAvailablePointsAmount(highQuotaInt)
+                    .afterMaxAvailablePointsAmount(integralDO.getHighQuota())
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
 
             // 合赢奖记录
-            PtProfitLogSaveReqVO hyjLog = PtProfitLogSaveReqVO.builder().orderId(k.getOrderId()).profitStatus(CaclEnum.TOGETHER_AWARD.getType()).orderNo(k.getNo()).amount(bonusQuotaInt).afterAmount(0L).percentTemplate(percentTemplate).build();
-
+            PtProfitLogSaveReqVO hyjLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.TOGETHER_AWARD.getType())
+                    .orderNo(k.getNo())
+                    .amount(bonusQuotaInt)
+                    .afterAmount(0L)
+                    .generateUserId(integralDO.getUserId())
+                    .percentTemplate(percentTemplate).build();
+            // 添加获得合赢奖的记录
+            hyjLog.setId(ptProfitLogService.createPtProfitLog(hyjLog));
+            for (PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO : ptProfitLogDetailsSaveReqVOS) {
+                ptProfitLogDetailsSaveReqVO.setDistriPtProfitLogId(hyjLog.getId());
+            }
+            ptProfitLogDetailsService.saveBatch(ptProfitLogDetailsSaveReqVOS);
 
             ptProfitLogSaveReqVOS.add(ptTotal);
             ptProfitLogSaveReqVOS.add(ptGrossAddLog);
             ptProfitLogSaveReqVOS.add(ptAddLog);
             ptProfitLogSaveReqVOS.add(tjrLog);
             ptProfitLogSaveReqVOS.add(ztrLog);
-            ptProfitLogSaveReqVOS.add(freezeLog);
-            ptProfitLogSaveReqVOS.add(hyjLog);
-            ptProfitLogSaveReqVOS.add(highQuotaLog);
-
 
         });
 
         // 信息整合
-        // 计算平台收益
-//        ptProfitDO = calcPtProfit(ptProfitDO, ptProfitSaveReqVOS);
-
         // 将信息存储到数据库中
         orderCalcMapper.insertBatch(BeanUtils.toBean(saveList, OrderCalcDO.class));
 
@@ -382,22 +463,22 @@ public class OrderCalcServiceImpl implements OrderCalcService {
 
     }
 
-    private void calcIntegral(List<PtProfitSaveReqVO> ptProfitSaveReqVOS, PtProfitSaveReqVO ptProfitSaveReqVO,
-                              Long highQuotaInt, Long ancestorQuotaInt, Long orderId, String orderNo, Long userId) {
-        if (highQuotaInt < ancestorQuotaInt) {
-            ptProfitSaveReqVO.setPtGrossAdd(ptProfitSaveReqVO.getPtGrossAdd() + ancestorQuotaInt);
-            ptProfitSaveReqVO.setPtTotalAdd(ptProfitSaveReqVO.getPtGrossAdd() + ptProfitSaveReqVO.getPtAdd());
-
-            PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
-                    .orderId(orderId)
-                    .profitStatus(CaclEnum.GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT.getType())
-                    .orderNo(orderNo)
-                    .userId(userId)
-                    .amount(ancestorQuotaInt)
-                    .afterAmount(ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum() + ancestorQuotaInt)
-                    .build();
-            ptProfitLogService.createPtProfitLog(ptProfitLog);
-        }
+    /**
+     * 在用户获取直推奖的时候溢出的需要加入到平台,并记录log
+     */
+    private void calcIntegral(List<PtProfitSaveReqVO> ptProfitSaveReqVOS, PtProfitSaveReqVO ptProfitSaveReqVO
+            , Long ancestorQuotaInt, Long orderId, String orderNo) {
+        ptProfitSaveReqVO.setPtGrossAdd(ptProfitSaveReqVO.getPtGrossAdd() + ancestorQuotaInt);
+        ptProfitSaveReqVO.setPtTotalAdd(ptProfitSaveReqVO.getPtGrossAdd() + ptProfitSaveReqVO.getPtAdd());
+
+        PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
+                .orderId(orderId)
+                .profitStatus(CaclEnum.GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT.getType())
+                .orderNo(orderNo)
+                .amount(ancestorQuotaInt)
+                .afterAmount(ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum() + ancestorQuotaInt)
+                .build();
+        ptProfitLogService.createPtProfitLog(ptProfitLog);
     }
 
     private PtProfitDO calcPtProfit(PtProfitDO ptProfitDO, List<PtProfitSaveReqVO> ptProfitSaveReqVOS) {
@@ -432,6 +513,19 @@ public class OrderCalcServiceImpl implements OrderCalcService {
         saveList.add(orderCalcSaveReqVO);
     }
 
+    /**
+     * 修改用户钱包
+     *
+     * @param integralSaveReqVOS
+     * @param integralDO
+     * @param integralDOAncestor
+     * @param pt
+     * @param ancestorQuota
+     * @param descendantQuota
+     * @param highQuota
+     * @param ptA
+     * @param ptB
+     */
     private void changeUserWallet(List<IntegralSaveReqVO> integralSaveReqVOS, IntegralDO integralDO, IntegralDO integralDOAncestor, IntegralDO pt,
                                   Long ancestorQuota, Long descendantQuota, Long highQuota, Long ptA, Long ptB) {
         // 修改用户钱包
@@ -446,6 +540,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
         // 减少推荐人的可获取额度
         integralDOAncestor.setHighQuota(integralDOAncestor.getHighQuota() - ancestorQuota);
         integralDOAncestor.setAncestorQuota(integralDOAncestor.getAncestorQuota() + ancestorQuota);
+        integralDOAncestor.setFreezeQuota(integralDOAncestor.getFreezeQuota() - ancestorQuota);
         integralService.updateIntegral(BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));
 
         // 增加平台额度

+ 121 - 43
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/partitioncrash/PartitionCrashServiceImpl.java

@@ -142,11 +142,14 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
     @Override
     public void calcCrash(List<Long> userId) {
 
+        Map<Long, Long> userHighQuotaMap = new HashMap<>();
+
         // 获取所有的营销用户
         List<DuserDO> duserDOS = duserService.selectAllUser();
         if (duserDOS.isEmpty()) {
             return;
         }
+        //记录所有用户的id和积分
         List<HashMap<Long, Long>> afterCrashMap = new ArrayList<>();
         // 获取当前合赢奖百分比
         OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
@@ -197,6 +200,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
 
 
                 crashSaveReqVOBuilder.partNo(todayNo);
+                crashSaveReqVOBuilder.userId(k.getUserId());
                 crashSaveReqVOBuilder.nickName(k.getNickName());
                 crashSaveReqVOBuilder.userName(k.getName());
 
@@ -264,38 +268,77 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
 
                 BigDecimal smallBigDecimal = new BigDecimal(String.valueOf(smallQuota));
                 BigDecimal multiply = smallBigDecimal.divide(new BigDecimal("2.0"), 4, RoundingMode.DOWN);
-                if (compare(highQuota, multiply) && multiply.longValue() != 0) {
-                    integralDO.setCurrentQuota(integralDO.getCurrentQuota() + multiply.intValue());
-//                    integralDO.setHighQuota(integralDO.getHighQuota() - multiply.intValue());
-                    integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + multiply.intValue());
+                //直推人的本次添加积分
+                Long amount = 0L;
+                //平台需要补回的收益(也可以理解为用户溢出)
+                Long ptReplenish = multiply.longValue();
+
+                //直推人
+                if (multiply.longValue() != 0) {
+                    if (highQuota.compareTo(0L) > 0) {
+
+                        if (highQuota.compareTo(multiply.longValue()) > 0) {
+                            amount = multiply.longValue();
+                            ptReplenish = 0L;
+                        } else {
+                            amount = highQuota;
+                            ptReplenish = multiply.longValue() - highQuota;
+                        }
+                        addHighQuota(userHighQuotaMap, integralDO.getUserId(), amount);
+                    }
+                    integralDO.setCurrentQuota(integralDO.getCurrentQuota() + amount);
+                    integralDO.setHighQuota(integralDO.getHighQuota() - amount);
+
+
+                    integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + amount);
                     // 碰撞后的额度添加到日志中 增加日志模块
                     integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
-                    ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
+                    ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, amount,
+                            integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO), ptReplenish, -amount, highQuota - amount);
                 }
-                if (compare(parentHighQuota, multiply) && multiply.longValue() != 0) {
+
+                //直推人的上级的本次添加积分
+                Long parentAmount = 0L;
+                //平台需要补回的收益(也可以理解为用户溢出)
+                Long parentPtReplenish = multiply.longValue();
+                //直推人的父级
+                if (multiply.longValue() != 0) {
+                    if (parentHighQuota.compareTo(0L) > 0) {
+                        if (parentHighQuota.compareTo(multiply.longValue()) > 0) {
+                            parentAmount = multiply.longValue();
+                            parentPtReplenish = 0L;
+                        } else {
+                            parentAmount = highQuota;
+                            parentPtReplenish = multiply.longValue() - highQuota;
+                        }
+                        addHighQuota(userHighQuotaMap, parentIntegralDo.getUserId(), parentAmount);
+                    }
                     // 减去最高额度
-                    parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + multiply.intValue());
-//                    parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - multiply.intValue());
-                    parentIntegralDo.setAccumulatedQuota(parentIntegralDo.getAccumulatedQuota() + multiply.intValue());
+                    parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - parentAmount);
+                    parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + parentAmount);
+
+                    parentIntegralDo.setAccumulatedQuota(parentIntegralDo.getAccumulatedQuota() + parentAmount);
                     // 碰撞后的额度添加到日志中 增加日志模块
                     integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class));
-                    ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, Long.parseLong(String.valueOf(multiply.intValue())), parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO));
+                    ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, parentAmount,
+                            parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO), parentPtReplenish, -parentAmount, parentHighQuota - parentAmount);
                 }
-                if(highQuota < multiply.longValue() && multiply.longValue() != 0L){
-                    calcIntegral(multiply.longValue(), integralDO.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
+
+                if (!ptReplenish.equals(0L)) {
+                    calcIntegral(ptReplenish, integralDO.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
                 }
-                if(parentHighQuota < multiply.longValue() && multiply.longValue() != 0L){
-                    calcIntegral(multiply.longValue(), parentIntegralDo.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
+                if (!parentPtReplenish.equals(0L)) {
+                    calcIntegral(parentPtReplenish, parentIntegralDo.getUserId(), JsonUtils.toJsonString(orderPercentageDO));
                 }
 
                 // 获取计算后积分, Long为userId, Integer为碰撞后额度
                 HashMap<Long, Long> map = new HashMap<>();
                 // 如果为当前用户为平台,则不需要存入这个地方
                 if (!k.getUserId().equals(PT_ID)) {
-                    map.put(k.getUserId(), multiply.longValue());
+                    map.put(k.getUserId(), amount);
                 }
                 if (!parentIntegralDo.getUserId().equals(PT_ID)) {
-                    map.put(parentIntegralDo.getUserId(), multiply.longValue());
+                    map.put(parentIntegralDo.getUserId(), parentAmount);
                 }
                 afterCrashMap.add(map);
 
@@ -326,8 +369,6 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
 //                if (ptProfit.getPtGrossAdd() <= 0) {
 //                    break;
 //                }
-                // 当前平台总积分
-//                Integer ptTotalAdd = ptProfit.getPtTotalAdd();
 
                 if (entry.getValue() == 0) {
                     continue;
@@ -336,32 +377,52 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
                 // 获取当前用户的钱包
                 IntegralDO integralDO = integralDOMap.get(entry.getKey());
                 // 获取当前父亲的钱包
-                Long parent = sonAndParent.get(entry.getKey());
-                IntegralDO parentIntegralDo = integralDOMap.get(parent);
                 Long highQuota = integralDO.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();       //加上基础的最大额度值
-                Long parentHighQuota = parentIntegralDo.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();
-                if(highQuota  < entry.getValue()){
-                    continue;
-                }
-                if(parentHighQuota < entry.getValue()){
-                    continue;
+
+                for (Long key : userHighQuotaMap.keySet()) {
+                    if (key.equals(entry.getKey())) {
+                        if (userHighQuotaMap.get(key) > 0L) {
+                            highQuota = highQuota + entry.getValue();
+                            userHighQuotaMap.put(key, userHighQuotaMap.get(key) - entry.getValue());
+                            break;
+                        }
+                    }
                 }
 
-                integralDO.setHighQuota(integralDO.getHighQuota() - entry.getValue());
-                parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - entry.getValue());
-                integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
-                integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class));
-
-                // 扣除平台收益
-                log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + entry.getValue());
-                ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - entry.getValue());
-                // 平台扣除积分
-                ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - entry.getValue());
-                // 碰撞后的额度添加到日志中 增加日志模块
-                ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA
-                        , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO));
-                ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA
-                        , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO));
+
+                //amount用于记录本次添加的值
+                Long amount = 0L;
+                //平台需要补回的收益
+                Long ptReplenish = entry.getValue();
+
+                //如果直推人的可获取额度大于0,则能够获取
+                if (highQuota.compareTo(0L) > 0) {
+                    if (highQuota.compareTo(entry.getValue()) > 0) {
+                        //如果最大额度 > 直推人可获取额度,则直接获取
+                        amount = entry.getValue();
+                        //平台没有需要补回的收益
+                        ptReplenish = 0L;
+                    } else {
+                        //如果最大额度 < 直推人可获取额度,则获取自己的最大额度
+                        amount = highQuota;
+                        //用户本次没有拿到的直推奖
+                        ptReplenish = entry.getValue() - highQuota;
+                    }
+
+                    integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
+
+
+                    // 扣除平台收益
+                    log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + amount);
+                    ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - amount);
+                    // 平台扣除积分
+                    ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - amount);
+                    // 碰撞后的额度添加到日志中 增加日志模块
+                    ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_QUOTA
+                            , -entry.getValue(), ptProfit.getPtTotalAdd(), JsonUtils.toJsonString(orderPercentageDO), null, null, null);
+                    ptProfitLogService.addMessage(entry.getKey(), CaclEnum.AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA
+                            , -entry.getValue(), ptProfit.getPtGrossAdd(), JsonUtils.toJsonString(orderPercentageDO), null, null, null);
+                }
             }
         }
         ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId())
@@ -382,10 +443,21 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
         createPtProfitDailyStatisticsLog(sum);
     }
 
+    //向集合中放用户获取的积分
+    private void addHighQuota(Map<Long, Long> map, Long userId, Long value) {
+        for (Long key : map.keySet()) {
+            if (key.equals(userId)) {
+                map.put(key, map.get(key) + value);
+                break;
+            }
+        }
+        map.put(userId, value);
+    }
+
     private void calcIntegral(Long multiply, Long userId, String jsonString) {
         PtProfitDO ptProfit = ptProfitService.getPtProfit();
         ptProfitLogService.addMessage(userId, CaclEnum.GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT, multiply,
-                ptProfit.getPtTotalAdd(), jsonString);
+                ptProfit.getPtTotalAdd(), jsonString, null, null, null);
     }
 
     private void createPtProfitDailyStatisticsLog(Long sum) {
@@ -393,7 +465,9 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
 
         //确保每天只有一条记录
         PtProfitDailyStatisticsLogDO ptLog = ptProfitDailyStatisticsLogMapper.selectByEveryday(now);
+        Long totalCollisionAmount = 0L;
         if (ptLog != null) {
+            totalCollisionAmount = ptLog.getTotalCollisionAmount();
             ptProfitDailyStatisticsLogMapper.deleteById(ptLog.getId());
         }
         //获取平台总收益
@@ -401,7 +475,11 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
 
         ptLog = new PtProfitDailyStatisticsLogDO();
         ptLog.setEveryday(now);
-        ptLog.setTotalCollisionAmount(sum);
+        if (!totalCollisionAmount.equals(0L)) {
+            ptLog.setTotalCollisionAmount(sum + totalCollisionAmount);
+        } else {
+            ptLog.setTotalCollisionAmount(sum);
+        }
         ptLog.setTotalRemainingAmount(ptProfitDO.getPtGrossAdd());
 
         ptProfitDailyStatisticsLogMapper.insert(ptLog);

+ 2 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java

@@ -63,8 +63,9 @@ public interface PtProfitLogService {
      * @param amount      增加额度
      * @param afterAmount 增加之后的额度
      * @param jsonString  百分比计算模板
+     * @param accumulatedQuotAmount  合赢奖溢出
      */
-    void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String jsonString);
+    void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String jsonString,Long accumulatedQuotAmount, Long maxAvailablePointsAmount ,Long afterMaxAvailablePointsAmount);
     void addMessage(Long userId, CaclEnum caclEnum, Integer amount, Integer afterAmount);
 
     /**

+ 9 - 2
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java

@@ -19,6 +19,7 @@ import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
 import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlog.PtProfitLogMapper;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.CaclEnum.*;
 import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
 
 /**
@@ -89,14 +90,20 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
     }
 
     @Override
-    public void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String percentTemplate) {
+    public void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String percentTemplate,Long accumulatedQuotAmount, Long maxAvailablePointsAmount ,Long afterMaxAvailablePointsAmount) {
         PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
                 .afterAmount(afterAmount)
                 .amount(amount)
                 .percentTemplate(percentTemplate)
-                .userId(userId)
                 .profitStatus(caclEnum.getType())
+                .accumulatedQuotaAmount(accumulatedQuotAmount)
+                .maxAvailablePointsAmount(maxAvailablePointsAmount)
+                .afterMaxAvailablePointsAmount(afterMaxAvailablePointsAmount)
+                .generateUserId(userId)
                 .build();
+        if(caclEnum.getType().equals(SMALL_QUOTA_CRASH.getType())){
+            ptProfitLog.setUserId(userId);
+        }
         ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
         // todo 发送通知
         // todo 发短信

+ 59 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsService.java

@@ -0,0 +1,59 @@
+package cn.newfeifan.mall.module.distri.service.ptprofitlogdetails;
+
+import java.util.*;
+import javax.validation.*;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+
+/**
+ * 平台利润记录详情 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface PtProfitLogDetailsService {
+
+    /**
+     * 创建平台利润记录详情
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createPtProfitLogDetails(@Valid PtProfitLogDetailsSaveReqVO createReqVO);
+
+    /**
+     * 更新平台利润记录详情
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updatePtProfitLogDetails(@Valid PtProfitLogDetailsSaveReqVO updateReqVO);
+
+    /**
+     * 删除平台利润记录详情
+     *
+     * @param id 编号
+     */
+    void deletePtProfitLogDetails(Long id);
+
+    /**
+     * 获得平台利润记录详情
+     *
+     * @param id 编号
+     * @return 平台利润记录详情
+     */
+    PtProfitLogDetailsDO getPtProfitLogDetails(Long id);
+
+    /**
+     * 获得平台利润记录详情分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 平台利润记录详情分页
+     */
+    PageResult<PtProfitLogDetailsDO> getPtProfitLogDetailsPage(PtProfitLogDetailsPageReqVO pageReqVO);
+
+    /**
+     * 批量创建
+     * @param ptProfitLogDetailsSaveReqVOS 对象集
+     */
+    void saveBatch(List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS);
+}

+ 77 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsServiceImpl.java

@@ -0,0 +1,77 @@
+package cn.newfeifan.mall.module.distri.service.ptprofitlogdetails;
+
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import java.util.*;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+
+import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlogdetails.PtProfitLogDetailsMapper;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
+
+/**
+ * 平台利润记录详情 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class PtProfitLogDetailsServiceImpl implements PtProfitLogDetailsService {
+
+    @Resource
+    private PtProfitLogDetailsMapper ptProfitLogDetailsMapper;
+
+    @Override
+    public Long createPtProfitLogDetails(PtProfitLogDetailsSaveReqVO createReqVO) {
+        // 插入
+        PtProfitLogDetailsDO ptProfitLogDetails = BeanUtils.toBean(createReqVO, PtProfitLogDetailsDO.class);
+        ptProfitLogDetailsMapper.insert(ptProfitLogDetails);
+        // 返回
+        return ptProfitLogDetails.getId();
+    }
+
+    @Override
+    public void updatePtProfitLogDetails(PtProfitLogDetailsSaveReqVO updateReqVO) {
+        // 校验存在
+        validatePtProfitLogDetailsExists(updateReqVO.getId());
+        // 更新
+        PtProfitLogDetailsDO updateObj = BeanUtils.toBean(updateReqVO, PtProfitLogDetailsDO.class);
+        ptProfitLogDetailsMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deletePtProfitLogDetails(Long id) {
+        // 校验存在
+        validatePtProfitLogDetailsExists(id);
+        // 删除
+        ptProfitLogDetailsMapper.deleteById(id);
+    }
+
+    private void validatePtProfitLogDetailsExists(Long id) {
+        if (ptProfitLogDetailsMapper.selectById(id) == null) {
+            throw exception(PT_PROFIT_LOG_DETAILS_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public PtProfitLogDetailsDO getPtProfitLogDetails(Long id) {
+        return ptProfitLogDetailsMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<PtProfitLogDetailsDO> getPtProfitLogDetailsPage(PtProfitLogDetailsPageReqVO pageReqVO) {
+        return ptProfitLogDetailsMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public void saveBatch(List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS) {
+        List<PtProfitLogDetailsDO> ptProfitLogDetailsDOList = BeanUtils.toBean(ptProfitLogDetailsSaveReqVOS, PtProfitLogDetailsDO.class);
+        ptProfitLogDetailsMapper.insertBatch(ptProfitLogDetailsDOList);
+    }
+
+}

+ 1 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java

@@ -250,6 +250,7 @@ public class SharePathServiceImpl implements SharePathService {
         if (integral != null) memberUserRespVO.setCurrentQuota(integral.getCurrentQuota());
 
         SocialStatusDO socialStatus = socialStatusService.getSocialStatus(duser.getSocialStatusId());
+        if(socialStatus == null) return memberUserRespVO;
         memberUserRespVO.setCurrentMemberWorthLevelName(socialStatus.getName());
         memberUserRespVO.setCurrentMemberWorthLevel(socialStatus.getLevel());
 

+ 7 - 2
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatuschangelog/SocialStatusChangeLogServiceImpl.java

@@ -90,7 +90,12 @@ public class SocialStatusChangeLogServiceImpl implements SocialStatusChangeLogSe
     @Override
     public PageResult<UserSignSocialLogRespVO> getUserSignLog(SocialStatusChangeLogPageReqVO pageReqVO) {
         PageResult<SocialStatusChangeLogDO> userSignLog = socialStatusChangeLogMapper.getUserSignLog(pageReqVO);
-        return BeanUtils.toBean(userSignLog, UserSignSocialLogRespVO.class);
+
+        PageResult<UserSignSocialLogRespVO> bean = BeanUtils.toBean(userSignLog, UserSignSocialLogRespVO.class);
+        for (int i = 0; i < bean.getList().size(); i++) {
+            bean.getList().get(i).setSort( (i + 1) + (pageReqVO.getPageNo() -1) *pageReqVO.getPageSize());
+        }
+        return bean;
     }
 
-}
+}

+ 12 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofitlogdetails/PtProfitLogDetailsMapper.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.newfeifan.mall.module.distri.dal.mysql.ptprofitlogdetails.PtProfitLogDetailsMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.zhongxing.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 0 - 38
feifan-module-infra/feifan-module-infra-biz/src/main/java/cn/newfeifan/mall/module/infra/controller/app/file/AppFileController.java

@@ -1,38 +0,0 @@
-package cn.newfeifan.mall.module.infra.controller.app.file;
-
-import cn.hutool.core.io.IoUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.infra.controller.app.file.vo.AppFileUploadReqVO;
-import cn.newfeifan.mall.module.infra.service.file.FileService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.annotation.Resource;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 文件存储")
-@RestController
-@RequestMapping("/infra/file")
-@Validated
-@Slf4j
-public class AppFileController {
-
-    @Resource
-    private FileService fileService;
-
-    @PostMapping("/upload")
-    @Operation(summary = "上传文件")
-    public CommonResult<String> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
-        MultipartFile file = uploadReqVO.getFile();
-        String path = uploadReqVO.getPath();
-        return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
-    }
-
-}

+ 0 - 4
feifan-module-infra/feifan-module-infra-biz/src/main/java/cn/newfeifan/mall/module/infra/controller/app/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 占位
- */
-package cn.newfeifan.mall.module.infra.controller.app;

+ 11 - 1
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/ProductSpuController.java

@@ -9,6 +9,7 @@ import cn.newfeifan.mall.module.product.controller.admin.spu.vo.*;
 import cn.newfeifan.mall.module.product.convert.spu.ProductSpuConvert;
 import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
 import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
+import cn.newfeifan.mall.module.product.dal.mysql.spu.ProductSpuMapper;
 import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
 import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
 import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
@@ -43,6 +44,10 @@ public class ProductSpuController {
     @Resource
     private ProductSkuService productSkuService;
 
+    //add by Ben
+    @Resource
+    private ProductSpuMapper productSpuMapper;
+
     @PostMapping("/create")
     @Operation(summary = "创建商品 SPU")
     @PreAuthorize("@ss.hasPermission('product:spu:create')")
@@ -87,7 +92,12 @@ public class ProductSpuController {
         }
         // 查询商品 SKU
         List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
-        return success(ProductSpuConvert.INSTANCE.convert(spu, skus));
+
+        String shopName = productSpuMapper.selectShopNameById(spu.getShopId());
+        CommonResult<ProductSpuRespVO> success = success(ProductSpuConvert.INSTANCE.convert(spu, skus));
+        success.getData().setShopName(shopName);
+
+        return success;
     }
 
     @GetMapping("/list-all-simple")

+ 4 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSkuRespVO.java

@@ -3,6 +3,7 @@ package cn.newfeifan.mall.module.product.controller.admin.spu.vo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Schema(description = "管理后台 - 商品 SKU Response VO")
@@ -61,4 +62,7 @@ public class ProductSkuRespVO {
     @Schema(description = "商户id", example = "8240")
     private Long merchantId;
 
+        @Schema(description = "高精度价格", example = "9255")
+        private BigDecimal highPrecisionPrice;
+
 }

+ 4 - 1
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java

@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
 import java.util.List;
 
 @Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO")
@@ -18,7 +19,6 @@ public class ProductSkuSaveReqVO {
     private String name;
 
     @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
-    @NotNull(message = "销售价格,单位:分不能为空")
     private Integer price;
 
     @Schema(description = "市场价", example = "2999")
@@ -85,4 +85,7 @@ public class ProductSkuSaveReqVO {
 
     @Schema(description = "商户id", example = "8240")
     private Long merchantId;
+
+    @Schema(description = "高精度价格", example = "9255")
+    private BigDecimal highPrecisionPrice;
 }

+ 7 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java

@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -82,4 +83,10 @@ public class ProductSpuPageReqVO extends PageParam {
 
     @Schema(description = "店铺编号集")
     private List<Long> shopIds;
+
+    @Schema(description = "高精度价格", example = "9255")
+    private BigDecimal highPrecisionPrice;
+
+    @Schema(description = "高精度", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Boolean highPrecision;
 }

+ 15 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuRespVO.java

@@ -9,6 +9,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -17,6 +18,8 @@ import java.util.List;
 @ExcelIgnoreUnannotated
 public class ProductSpuRespVO {
 
+
+
     @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
     @ExcelProperty("商品编号")
     private Long id;
@@ -132,7 +135,19 @@ public class ProductSpuRespVO {
     @Schema(description = "店铺id", example = "20588")
     private Long shopId;
 
+    @Schema(description = "店铺名称", example = "中星温暖")
+    private String shopName;
 
     @Schema(description = "商户id", example = "8240")
     private Long merchantId;
+    @Schema(description = "商品支付类别")
+    private Integer spuPayType;
+
+    @Schema(description = "高精度", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("高精度")
+    private Boolean highPrecision;
+
+    @Schema(description = "高精度价格", example = "9255")
+    @ExcelProperty("高精度价格")
+    private BigDecimal highPrecisionPrice;
 }

+ 13 - 1
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import javax.validation.Valid;
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
 import java.util.List;
 
 @Schema(description = "管理后台 - 商品 SPU 新增/更新 Request VO")
@@ -36,7 +37,6 @@ public class ProductSpuSaveReqVO {
     private Long categoryId;
 
     @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
-    @NotNull(message = "商品品牌不能为空")
     private Long brandId;
 
     @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.zhongxing.cn/xx.png")
@@ -105,4 +105,16 @@ public class ProductSpuSaveReqVO {
 
     @Schema(description = "商户id", example = "8240")
     private Long merchantId;
+
+    @Schema(description = "商品支付类别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @NotNull(message = "商品支付类别不能为空")
+    private Integer spuPayType;
+
+    @Schema(description = "高精度价格", example = "9255")
+    private BigDecimal highPrecisionPrice;
+
+    @Schema(description = "高精度", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "高精度不能为空")
+    private Boolean highPrecision;
+
 }

+ 11 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java

@@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.ToString;
 
+import java.math.BigDecimal;
+
 @Schema(description = "管理后台 - 商品 SPU 精简 Response VO")
 @Data
 @ToString(callSuper = true)
@@ -42,4 +44,13 @@ public class ProductSpuSimpleRespVO {
     private Long shopId;
     @Schema(description = "商户id", example = "8240")
     private Long merchantId;
+
+    @Schema(description = "商品支付类别", example = "2")
+    private Integer spuPayType;
+
+    @Schema(description = "高精度")
+    private Boolean highPrecision;
+
+    @Schema(description = "高精度价格", example = "9255")
+    private BigDecimal highPrecisionPrice;
 }

+ 0 - 54
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/category/AppCategoryController.java

@@ -1,54 +0,0 @@
-package cn.newfeifan.mall.module.product.controller.app.category;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.product.controller.app.category.vo.AppCategoryRespVO;
-import cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryDO;
-import cn.newfeifan.mall.module.product.service.category.ProductCategoryService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 APP - 商品分类")
-@RestController
-@RequestMapping("/product/category")
-@Validated
-public class AppCategoryController {
-
-    @Resource
-    private ProductCategoryService categoryService;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得商品分类列表")
-    public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() {
-        List<ProductCategoryDO> list = categoryService.getEnableCategoryList();
-        list.sort(Comparator.comparing(ProductCategoryDO::getSort));
-        return success(BeanUtils.toBean(list, AppCategoryRespVO.class));
-    }
-
-    @GetMapping("/list-by-ids")
-    @Operation(summary = "获得商品分类列表,指定编号")
-    @Parameter(name = "ids", description = "商品分类编号数组", required = true)
-    public CommonResult<List<AppCategoryRespVO>> getProductCategoryList(@RequestParam("ids") List<Long> ids) {
-        if (CollUtil.isEmpty(ids)) {
-            return success(Collections.emptyList());
-        }
-        List<ProductCategoryDO> list = categoryService.getEnableCategoryList(ids);
-        list.sort(Comparator.comparing(ProductCategoryDO::getSort));
-        return success(BeanUtils.toBean(list, AppCategoryRespVO.class));
-    }
-
-}

+ 0 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/comment/AppCommentController.http


+ 0 - 50
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/comment/AppProductCommentController.java

@@ -1,50 +0,0 @@
-package cn.newfeifan.mall.module.product.controller.app.comment;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.product.controller.app.comment.vo.AppCommentPageReqVO;
-import cn.newfeifan.mall.module.product.controller.app.comment.vo.AppProductCommentRespVO;
-import cn.newfeifan.mall.module.product.dal.dataobject.comment.ProductCommentDO;
-import cn.newfeifan.mall.module.product.service.comment.ProductCommentService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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 javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 APP - 商品评价")
-@RestController
-@RequestMapping("/product/comment")
-@Validated
-public class AppProductCommentController {
-
-    @Resource
-    private ProductCommentService productCommentService;
-
-    @GetMapping("/page")
-    @Operation(summary = "获得商品评价分页")
-    public CommonResult<PageResult<AppProductCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) {
-        // 查询评论分页
-        PageResult<ProductCommentDO> pageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(PageResult.empty(pageResult.getTotal()));
-        }
-
-        // 拼接返回
-        pageResult.getList().forEach(item -> {
-            if (Boolean.TRUE.equals(item.getAnonymous())) {
-                item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS);
-            }
-        });
-        return success(BeanUtils.toBean(pageResult, AppProductCommentRespVO.class));
-    }
-
-}

+ 0 - 88
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/favorite/AppFavoriteController.java

@@ -1,88 +0,0 @@
-package cn.newfeifan.mall.module.product.controller.app.favorite;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.product.controller.app.favorite.vo.AppFavoriteBatchReqVO;
-import cn.newfeifan.mall.module.product.controller.app.favorite.vo.AppFavoritePageReqVO;
-import cn.newfeifan.mall.module.product.controller.app.favorite.vo.AppFavoriteReqVO;
-import cn.newfeifan.mall.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
-import cn.newfeifan.mall.module.product.convert.favorite.ProductFavoriteConvert;
-import cn.newfeifan.mall.module.product.dal.dataobject.favorite.ProductFavoriteDO;
-import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
-import cn.newfeifan.mall.module.product.service.favorite.ProductFavoriteService;
-import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertList;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 APP - 商品收藏")
-@RestController
-@RequestMapping("/product/favorite")
-public class AppFavoriteController {
-
-    @Resource
-    private ProductFavoriteService productFavoriteService;
-    @Resource
-    private ProductSpuService productSpuService;
-
-    @PostMapping(value = "/create")
-    @Operation(summary = "添加商品收藏")
-    @PreAuthenticated
-    public CommonResult<Long> createFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
-        return success(productFavoriteService.createFavorite(getLoginUserId(), reqVO.getSpuId()));
-    }
-
-    @DeleteMapping(value = "/delete")
-    @Operation(summary = "取消单个商品收藏")
-    @PreAuthenticated
-    public CommonResult<Boolean> deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
-        productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId());
-        return success(Boolean.TRUE);
-    }
-
-    @GetMapping(value = "/page")
-    @Operation(summary = "获得商品收藏分页")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppFavoriteRespVO>> getFavoritePage(AppFavoritePageReqVO reqVO) {
-        PageResult<ProductFavoriteDO> favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO);
-        if (CollUtil.isEmpty(favoritePage.getList())) {
-            return success(PageResult.empty());
-        }
-
-        // 得到商品 spu 信息
-        List<ProductFavoriteDO> favorites = favoritePage.getList();
-        List<Long> spuIds = convertList(favorites, ProductFavoriteDO::getSpuId);
-        List<ProductSpuDO> spus = productSpuService.getSpuList(spuIds);
-
-        // 转换 VO 结果
-        PageResult<AppFavoriteRespVO> pageResult = new PageResult<>(favoritePage.getTotal());
-        pageResult.setList(ProductFavoriteConvert.INSTANCE.convertList(favorites, spus));
-        return success(pageResult);
-    }
-
-    @GetMapping(value = "/exits")
-    @Operation(summary = "检查是否收藏过商品")
-    @PreAuthenticated
-    public CommonResult<Boolean> isFavoriteExists(AppFavoriteReqVO reqVO) {
-        ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
-        return success(favorite != null);
-    }
-
-    @GetMapping(value = "/get-count")
-    @Operation(summary = "获得商品收藏数量")
-    @PreAuthenticated
-    public CommonResult<Long> getFavoriteCount() {
-        return success(productFavoriteService.getFavoriteCount(getLoginUserId()));
-    }
-
-}

+ 0 - 77
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/history/AppProductBrowseHistoryController.java

@@ -1,77 +0,0 @@
-package cn.newfeifan.mall.module.product.controller.app.history;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO;
-import cn.newfeifan.mall.module.product.controller.app.history.vo.AppProductBrowseHistoryDeleteReqVO;
-import cn.newfeifan.mall.module.product.controller.app.history.vo.AppProductBrowseHistoryPageReqVO;
-import cn.newfeifan.mall.module.product.controller.app.history.vo.AppProductBrowseHistoryRespVO;
-import cn.newfeifan.mall.module.product.dal.dataobject.history.ProductBrowseHistoryDO;
-import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
-import cn.newfeifan.mall.module.product.service.history.ProductBrowseHistoryService;
-import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertMap;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 APP - 商品浏览记录")
-@RestController
-@RequestMapping("/product/browse-history")
-public class AppProductBrowseHistoryController {
-
-    @Resource
-    private ProductBrowseHistoryService productBrowseHistoryService;
-    @Resource
-    private ProductSpuService productSpuService;
-
-    @DeleteMapping(value = "/delete")
-    @Operation(summary = "删除商品浏览记录")
-    @PreAuthenticated
-    public CommonResult<Boolean> deleteBrowseHistory(@RequestBody @Valid AppProductBrowseHistoryDeleteReqVO reqVO) {
-        productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), reqVO.getSpuIds());
-        return success(Boolean.TRUE);
-    }
-
-    @DeleteMapping(value = "/clean")
-    @Operation(summary = "清空商品浏览记录")
-    @PreAuthenticated
-    public CommonResult<Boolean> deleteBrowseHistory() {
-        productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), null);
-        return success(Boolean.TRUE);
-    }
-
-    @GetMapping(value = "/page")
-    @Operation(summary = "获得商品浏览记录分页")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppProductBrowseHistoryRespVO>> getBrowseHistoryPage(AppProductBrowseHistoryPageReqVO reqVO) {
-        ProductBrowseHistoryPageReqVO pageReqVO = BeanUtils.toBean(reqVO, ProductBrowseHistoryPageReqVO.class)
-                .setUserId(getLoginUserId())
-                .setUserDeleted(false); // 排除用户已删除的(隐藏的)
-        PageResult<ProductBrowseHistoryDO> pageResult = productBrowseHistoryService.getBrowseHistoryPage(pageReqVO);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(PageResult.empty());
-        }
-
-        // 得到商品 spu 信息
-        Set<Long> spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId);
-        Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId);
-        return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class,
-                vo -> Optional.ofNullable(spuMap.get(vo.getSpuId()))
-                        .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()))));
-    }
-
-}

+ 0 - 4
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/property/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 占位符,无时间作用,避免 package 缩进
- */
-package cn.newfeifan.mall.module.product.controller.app.property;

+ 0 - 18
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/spu/AppProductSpuController.http

@@ -1,18 +0,0 @@
-### 获得订单交易的分页(默认)
-GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### 获得订单交易的分页(价格)
-GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=price&sortAsc=true
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### 获得订单交易的分页(销售)
-GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=salesCount&sortAsc=true
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### 获得商品 SPU 明细
-GET {{appApi}}/product/spu/get-detail?id=102
-tenant-id: {{appTenentId}}

+ 0 - 152
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/app/spu/AppProductSpuController.java

@@ -1,152 +0,0 @@
-package cn.newfeifan.mall.module.product.controller.app.spu;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.member.api.level.MemberLevelApi;
-import cn.newfeifan.mall.module.member.api.level.dto.MemberLevelRespDTO;
-import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
-import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
-import cn.newfeifan.mall.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
-import cn.newfeifan.mall.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
-import cn.newfeifan.mall.module.product.controller.app.spu.vo.AppProductSpuRespVO;
-import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
-import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
-import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
-import cn.newfeifan.mall.module.product.service.history.ProductBrowseHistoryService;
-import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
-import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-import static cn.newfeifan.mall.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE;
-import static cn.newfeifan.mall.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
-
-@Tag(name = "用户 APP - 商品 SPU")
-@RestController
-@RequestMapping("/product/spu")
-@Validated
-public class AppProductSpuController {
-
-    @Resource
-    private ProductSpuService productSpuService;
-    @Resource
-    private ProductSkuService productSkuService;
-    @Resource
-    private ProductBrowseHistoryService productBrowseHistoryService;
-
-    @Resource
-    private MemberLevelApi memberLevelApi;
-    @Resource
-    private MemberUserApi memberUserApi;
-
-    @GetMapping("/list-by-ids")
-    @Operation(summary = "获得商品 SPU 列表")
-    @Parameter(name = "ids", description = "编号列表", required = true)
-    public CommonResult<List<AppProductSpuRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) {
-        List<ProductSpuDO> list = productSpuService.getSpuList(ids);
-        if (CollUtil.isEmpty(list)) {
-            return success(Collections.emptyList());
-        }
-
-        // 拼接返回
-        list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
-        List<AppProductSpuRespVO> voList = BeanUtils.toBean(list, AppProductSpuRespVO.class);
-        // 处理 vip 价格
-        MemberLevelRespDTO memberLevel = getMemberLevel();
-        voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
-        return success(voList);
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得商品 SPU 分页")
-    public CommonResult<PageResult<AppProductSpuRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
-        PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(PageResult.empty(pageResult.getTotal()));
-        }
-
-        // 拼接返回
-        pageResult.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
-        PageResult<AppProductSpuRespVO> voPageResult = BeanUtils.toBean(pageResult, AppProductSpuRespVO.class);
-        // 处理 vip 价格
-        MemberLevelRespDTO memberLevel = getMemberLevel();
-        voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
-        return success(voPageResult);
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得商品 SPU 明细")
-    @Parameter(name = "id", description = "编号", required = true)
-    public CommonResult<AppProductSpuDetailRespVO> getSpuDetail(@RequestParam("id") Long id) {
-        // 获得商品 SPU
-        ProductSpuDO spu = productSpuService.getSpu(id);
-        if (spu == null) {
-            throw exception(SPU_NOT_EXISTS);
-        }
-        if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) {
-            throw exception(SPU_NOT_ENABLE);
-        }
-        // 获得商品 SKU
-        List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
-
-        // 增加浏览量
-        productSpuService.updateBrowseCount(id, 1);
-        // 保存浏览记录
-        productBrowseHistoryService.createBrowseHistory(getLoginUserId(), id);
-
-        // 拼接返回
-        spu.setBrowseCount(spu.getBrowseCount() + spu.getVirtualSalesCount());
-        AppProductSpuDetailRespVO spuVO = BeanUtils.toBean(spu, AppProductSpuDetailRespVO.class)
-                .setSkus(BeanUtils.toBean(skus, AppProductSpuDetailRespVO.Sku.class));
-        // 处理 vip 价格
-        MemberLevelRespDTO memberLevel = getMemberLevel();
-        spuVO.setVipPrice(calculateVipPrice(spuVO.getPrice(), memberLevel));
-        return success(spuVO);
-    }
-
-    private MemberLevelRespDTO getMemberLevel() {
-        Long userId = getLoginUserId();
-        if (userId == null) {
-            return null;
-        }
-        MemberUserRespDTO user = memberUserApi.getUser(userId);
-        if (user.getLevelId() == null || user.getLevelId() <= 0) {
-            return null;
-        }
-        return memberLevelApi.getMemberLevel(user.getLevelId());
-    }
-
-    /**
-     * 计算会员 VIP 优惠价格
-     *
-     * @param price 原价
-     * @param memberLevel 会员等级
-     * @return 优惠价格
-     */
-    public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) {
-        if (memberLevel == null || memberLevel.getDiscountPercent() == null) {
-            return 0;
-        }
-        Integer newPrice = price * memberLevel.getDiscountPercent() / 100;
-        return price - newPrice;
-    }
-
-    // TODO 非繁人:商品的浏览记录;
-}

+ 7 - 1
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/sku/ProductSkuDO.java

@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
 import lombok.*;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -36,7 +37,6 @@ public class ProductSkuDO extends BaseDO {
     private Long id;
     /**
      * SPU 编号
-     *
      * 关联 {@link ProductSpuDO#getId()}
      */
     private Long spuId;
@@ -49,6 +49,7 @@ public class ProductSkuDO extends BaseDO {
      * 商品价格,单位:分
      */
     private Integer price;
+
     /**
      * 市场价,单位:分
      */
@@ -108,6 +109,11 @@ public class ProductSkuDO extends BaseDO {
 
 
     private Long merchantId;
+
+    /**
+     * 高精度价格
+     */
+    private BigDecimal highPrecisionPrice;
     /**
      * 商品属性
      */

+ 14 - 11
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/spu/ProductSpuDO.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import lombok.*;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -57,13 +58,11 @@ public class ProductSpuDO extends BaseDO {
 
     /**
      * 商品分类编号
-     *
      * 关联 {@link ProductCategoryDO#getId()}
      */
     private Long categoryId;
     /**
      * 商品品牌编号
-     *
      * 关联 {@link ProductBrandDO#getId()}
      */
     private Long brandId;
@@ -83,7 +82,6 @@ public class ProductSpuDO extends BaseDO {
     private Integer sort;
     /**
      * 商品状态
-     *
      * 枚举 {@link ProductSpuStatusEnum}
      */
     private Integer status;
@@ -92,32 +90,27 @@ public class ProductSpuDO extends BaseDO {
 
     /**
      * 规格类型
-     *
      * false - 单规格
      * true - 多规格
      */
     private Boolean specType;
     /**
      * 商品价格,单位使用:分
-     *
      * 基于其对应的 {@link ProductSkuDO#getPrice()} sku单价最低的商品的
      */
     private Integer price;
     /**
      * 市场价,单位使用:分
-     *
      * 基于其对应的 {@link ProductSkuDO#getMarketPrice()} sku单价最低的商品的
      */
     private Integer marketPrice;
     /**
      * 成本价,单位使用:分
-     *
      * 基于其对应的 {@link ProductSkuDO#getCostPrice()} sku单价最低的商品的
      */
     private Integer costPrice;
     /**
      * 库存
-     *
      * 基于其对应的 {@link ProductSkuDO#getStock()} 求和
      */
     private Integer stock;
@@ -126,14 +119,12 @@ public class ProductSpuDO extends BaseDO {
 
     /**
      * 配送方式数组
-     *
      * 对应 DeliveryTypeEnum 枚举
      */
     @TableField(typeHandler = IntegerListTypeHandler.class)
     private List<Integer> deliveryTypes;
     /**
      * 物流配置模板编号
-     *
      * 对应 TradeDeliveryExpressTemplateDO 的 id 编号
      */
     private Long deliveryTemplateId;
@@ -148,7 +139,6 @@ public class ProductSpuDO extends BaseDO {
     // TODO @puhui999:字段估计要改成 brokerageType
     /**
      * 分销类型
-     *
      * false - 默认
      * true - 自行设置
      */
@@ -187,5 +177,18 @@ public class ProductSpuDO extends BaseDO {
      */
     private Long merchantId;
 
+    /**
+     * 商品支付类别
+     */
+    private Integer spuPayType;
+
+    /**
+     * 高精度
+     */
+    private Boolean highPrecision;
+    /**
+     * 高精度价格
+     */
+    private BigDecimal highPrecisionPrice;
 
 }

+ 5 - 0
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/mysql/spu/ProductSpuMapper.java

@@ -12,6 +12,7 @@ import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 import java.util.Objects;
@@ -20,6 +21,10 @@ import java.util.Set;
 @Mapper
 public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
 
+    //add by Ben
+    @Select("select name from sale_shop where id=#{id}")
+    String selectShopNameById(Long id);
+
     /**
      * 获取商品 SPU 分页列表数据
      *

+ 15 - 11
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java

@@ -13,7 +13,6 @@ import cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryD
 import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
 import cn.newfeifan.mall.module.product.dal.mysql.spu.ProductSpuMapper;
 import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
-import cn.newfeifan.mall.module.product.service.brand.ProductBrandService;
 import cn.newfeifan.mall.module.product.service.category.ProductCategoryService;
 import cn.newfeifan.mall.module.product.service.favorite.ProductFavoriteService;
 import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
@@ -49,8 +48,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
     @Lazy // 循环依赖,避免报错
     private ProductSkuService productSkuService;
     @Resource
-    private ProductBrandService brandService;
-    @Resource
     private ProductCategoryService categoryService;
 
     @Resource
@@ -61,7 +58,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
     public Long createSpu(ProductSpuSaveReqVO createReqVO) {
         // 校验分类、品牌
         validateCategory(createReqVO.getCategoryId());
-        brandService.validateProductBrand(createReqVO.getBrandId());
+//        brandService.validateProductBrand(createReqVO.getBrandId());
 
         // 根据商户ID查询对应的店铺ID
         // todo 后续如果存在多店铺的情况下
@@ -92,7 +89,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
         validateSpuExists(updateReqVO.getId());
         // 校验分类、品牌
         validateCategory(updateReqVO.getCategoryId());
-        brandService.validateProductBrand(updateReqVO.getBrandId());
+//        brandService.validateProductBrand(updateReqVO.getBrandId());
         // 校验SKU
         List<ProductSkuSaveReqVO> skuSaveReqList = updateReqVO.getSkus();
         productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
@@ -113,12 +110,19 @@ public class ProductSpuServiceImpl implements ProductSpuService {
      * @param skus 商品 SKU 数组
      */
     private void initSpuFromSkus(ProductSpuDO spu, List<ProductSkuSaveReqVO> skus) {
-        // sku 单价最低的商品的价格
-        spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice));
-        // sku 单价最低的商品的市场价格
-        spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice));
-        // sku 单价最低的商品的成本价格
-        spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice));
+        //是否是高精度商品
+        if(!spu.getHighPrecision()){
+            // sku 单价最低的商品的价格
+            spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice));
+            // sku 单价最低的商品的市场价格
+            spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice));
+            // sku 单价最低的商品的成本价格
+            spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice));
+        }else{
+            // sku 单价最低的商品的价格
+            spu.setHighPrecisionPrice(getMinValue(skus, ProductSkuSaveReqVO::getHighPrecisionPrice));
+        }
+
         // skus 库存总数
         spu.setStock(getSumValue(skus, ProductSkuSaveReqVO::getStock, Integer::sum));
         // 若是 spu 已有状态则不处理

+ 0 - 5
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/activity/AppActivityController.http

@@ -1,5 +0,0 @@
-### /promotion/activity/list-by-spu-ids 获得多个商品,近期参与的每个活动
-GET {{appApi}}/promotion/activity/list-by-spu-ids?spuIds=222&spuIds=633
-Authorization: Bearer {{appToken}}
-Content-Type: application/json
-tenant-id: {{appTenentId}}

+ 0 - 172
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/activity/AppActivityController.java

@@ -1,172 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.activity;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.map.MapUtil;
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.promotion.controller.app.activity.vo.AppActivityRespVO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.bargain.BargainActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.combination.CombinationActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.discount.DiscountActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.discount.DiscountProductDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.reward.RewardActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
-import cn.newfeifan.mall.module.promotion.enums.common.PromotionActivityStatusEnum;
-import cn.newfeifan.mall.module.promotion.enums.common.PromotionTypeEnum;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainActivityService;
-import cn.newfeifan.mall.module.promotion.service.combination.CombinationActivityService;
-import cn.newfeifan.mall.module.promotion.service.discount.DiscountActivityService;
-import cn.newfeifan.mall.module.promotion.service.reward.RewardActivityService;
-import cn.newfeifan.mall.module.promotion.service.seckill.SeckillActivityService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.*;
-
-@Tag(name = "用户 APP - 营销活动") // 用于提供跨多个活动的 HTTP 接口
-@RestController
-@RequestMapping("/promotion/activity")
-@Validated
-public class AppActivityController {
-
-    @Resource
-    private CombinationActivityService combinationActivityService;
-    @Resource
-    private SeckillActivityService seckillActivityService;
-    @Resource
-    private BargainActivityService bargainActivityService;
-    @Resource
-    private DiscountActivityService discountActivityService;
-    @Resource
-    private RewardActivityService rewardActivityService;
-
-    @GetMapping("/list-by-spu-id")
-    @Operation(summary = "获得单个商品,近期参与的每个活动")
-    @Parameter(name = "spuId", description = "商品编号", required = true)
-    public CommonResult<List<AppActivityRespVO>> getActivityListBySpuId(@RequestParam("spuId") Long spuId) {
-        // 每种活动,只返回一个
-        return success(getAppActivityList(Collections.singletonList(spuId)));
-    }
-
-    @GetMapping("/list-by-spu-ids")
-    @Operation(summary = "获得多个商品,近期参与的每个活动")
-    @Parameter(name = "spuIds", description = "商品编号数组", required = true)
-    public CommonResult<Map<Long, List<AppActivityRespVO>>> getActivityListBySpuIds(@RequestParam("spuIds") List<Long> spuIds) {
-        if (CollUtil.isEmpty(spuIds)) {
-            return success(MapUtil.empty());
-        }
-        // 每种活动,只返回一个;key 为 SPU 编号
-        return success(convertMultiMap(getAppActivityList(spuIds), AppActivityRespVO::getSpuId));
-    }
-
-    private List<AppActivityRespVO> getAppActivityList(Collection<Long> spuIds) {
-        if (CollUtil.isEmpty(spuIds)) {
-            return new ArrayList<>();
-        }
-        // 获取开启的且开始的且没有结束的活动
-        List<AppActivityRespVO> activityList = new ArrayList<>();
-        LocalDateTime now = LocalDateTime.now();
-        // 1. 拼团活动
-        getCombinationActivities(spuIds, now, activityList);
-        // 2. 秒杀活动
-        getSeckillActivities(spuIds, now, activityList);
-        // 3. 砍价活动
-        getBargainActivities(spuIds, now, activityList);
-        // 4. 限时折扣活动
-        getDiscountActivities(spuIds, now, activityList);
-        // 5. 满减送活动
-        getRewardActivities(spuIds, now, activityList);
-        return activityList;
-    }
-
-    private void getCombinationActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
-        List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(
-                spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
-        if (CollUtil.isEmpty(combinationActivities)) {
-            return;
-        }
-
-        combinationActivities.forEach(item -> {
-            activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(),
-                    item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime()));
-        });
-    }
-
-    private void getSeckillActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
-        List<SeckillActivityDO> seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(
-                spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
-        if (CollUtil.isEmpty(seckillActivities)) {
-            return;
-        }
-
-        seckillActivities.forEach(item -> {
-            activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(),
-                    item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime()));
-        });
-    }
-
-    private void getBargainActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
-        List<BargainActivityDO> bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatusAndDateTimeLt(
-                spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
-        if (CollUtil.isNotEmpty(bargainActivities)) {
-            return;
-        }
-
-        bargainActivities.forEach(item -> {
-            activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(),
-                    item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime()));
-        });
-    }
-
-    private void getDiscountActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
-        List<DiscountActivityDO> discountActivities = discountActivityService.getDiscountActivityBySpuIdsAndStatusAndDateTimeLt(
-                spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
-        if (CollUtil.isEmpty(discountActivities)) {
-            return;
-        }
-
-        List<DiscountProductDO> products = discountActivityService.getDiscountProductsByActivityId(
-                convertSet(discountActivities, DiscountActivityDO::getId));
-        Map<Long, Long> productMap = convertMap(products, DiscountProductDO::getActivityId, DiscountProductDO::getSpuId);
-        discountActivities.forEach(item -> activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(),
-                item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
-    }
-
-    private void getRewardActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
-        // TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部
-        List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt(
-                spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now);
-        if (CollUtil.isEmpty(rewardActivityList)) {
-            return;
-        }
-
-        Map<Long, Optional<RewardActivityDO>> spuIdAndActivityMap = spuIds.stream()
-                .collect(Collectors.toMap(
-                        spuId -> spuId,
-                        spuId -> rewardActivityList.stream()
-                                .filter(activity -> activity.getProductSpuIds().contains(spuId))
-                                .max(Comparator.comparing(RewardActivityDO::getCreateTime))));
-        for (Long supId : spuIdAndActivityMap.keySet()) {
-            if (!spuIdAndActivityMap.get(supId).isPresent()) {
-                continue;
-            }
-
-            RewardActivityDO rewardActivityDO = spuIdAndActivityMap.get(supId).get();
-            activityList.add(new AppActivityRespVO(rewardActivityDO.getId(), PromotionTypeEnum.REWARD_ACTIVITY.getType(),
-                    rewardActivityDO.getName(), supId, rewardActivityDO.getStartTime(), rewardActivityDO.getEndTime()));
-        }
-    }
-
-}

+ 0 - 39
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/article/AppArticleCategoryController.java

@@ -1,39 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.article;
-
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO;
-import cn.newfeifan.mall.module.promotion.convert.article.ArticleCategoryConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.article.ArticleCategoryDO;
-import cn.newfeifan.mall.module.promotion.service.article.ArticleCategoryService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.Comparator;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 APP - 文章分类")
-@RestController
-@RequestMapping("/promotion/article-category")
-@Validated
-public class AppArticleCategoryController {
-
-    @Resource
-    private ArticleCategoryService articleCategoryService;
-
-    @RequestMapping("/list")
-    @Operation(summary = "获得文章分类列表")
-    public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() {
-        List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus(
-                CommonStatusEnum.ENABLE.getStatus());
-        categoryList.sort(Comparator.comparing(ArticleCategoryDO::getSort)); // 按 sort 降序排列
-        return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList));
-    }
-
-}

+ 0 - 75
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/article/AppArticleController.java

@@ -1,75 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.article;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
-import cn.newfeifan.mall.module.promotion.controller.app.article.vo.article.AppArticleRespVO;
-import cn.newfeifan.mall.module.promotion.convert.article.ArticleConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.article.ArticleDO;
-import cn.newfeifan.mall.module.promotion.service.article.ArticleService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.Parameters;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 APP - 文章")
-@RestController
-@RequestMapping("/promotion/article")
-@Validated
-public class AppArticleController {
-
-    @Resource
-    private ArticleService articleService;
-
-    @RequestMapping("/list")
-    @Operation(summary = "获得文章详情列表")
-    @Parameters({
-            @Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章
-            @Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章
-    })
-    public CommonResult<List<AppArticleRespVO>> getArticleList(
-            @RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
-            @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
-        return success(ArticleConvert.INSTANCE.convertList03(
-                articleService.getArticleCategoryListByRecommend(recommendHot, recommendBanner)));
-    }
-
-    @RequestMapping("/page")
-    @Operation(summary = "获得文章详情分页")
-    public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) {
-        return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO)));
-    }
-
-    @RequestMapping("/get")
-    @Operation(summary = "获得文章详情")
-    @Parameters({
-            @Parameter(name = "id", description = "文章编号", example = "1024"),
-            @Parameter(name = "title", description = "文章标题", example = "1024"),
-    })
-    public CommonResult<AppArticleRespVO> getArticle(@RequestParam(value = "id", required = false) Long id,
-                                                     @RequestParam(value = "title", required = false) String title) {
-        ArticleDO article = id != null ? articleService.getArticle(id)
-                : articleService.getLastArticleByTitle(title);
-        return success(BeanUtils.toBean(article, AppArticleRespVO.class));
-    }
-
-    @PutMapping("/add-browse-count")
-    @Operation(summary = "增加文章浏览量")
-    @Parameter(name = "id", description = "文章编号", example = "1024")
-    public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
-        articleService.addArticleBrowseCount(id);
-        return success(true);
-    }
-
-}

+ 0 - 44
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/banner/AppBannerController.java

@@ -1,44 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.banner;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.promotion.controller.app.banner.vo.AppBannerRespVO;
-import cn.newfeifan.mall.module.promotion.convert.banner.BannerConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.banner.BannerDO;
-import cn.newfeifan.mall.module.promotion.service.banner.BannerService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@RestController
-@RequestMapping("/promotion/banner")
-@Tag(name = "用户 APP - 首页 Banner")
-@Validated
-public class AppBannerController {
-
-    @Resource
-    private BannerService bannerService;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得 banner 列表")
-    @Parameter(name = "position", description = "Banner position", example = "1")
-    public CommonResult<List<AppBannerRespVO>> getBannerList(@RequestParam("position") Integer position) {
-        List<BannerDO> bannerList = bannerService.getBannerListByPosition(position);
-        return success(BannerConvert.INSTANCE.convertList01(bannerList));
-    }
-
-    @PutMapping("/add-browse-count")
-    @Operation(summary = "增加 Banner 点击量")
-    @Parameter(name = "id", description = "Banner 编号", example = "1024")
-    public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
-        bannerService.addBannerBrowseCount(id);
-        return success(true);
-    }
-
-}

+ 0 - 107
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainActivityController.java

@@ -1,107 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.bargain;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageParam;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.module.product.api.spu.ProductSpuApi;
-import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
-import cn.newfeifan.mall.module.promotion.convert.bargain.BargainActivityConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.bargain.BargainActivityDO;
-import cn.newfeifan.mall.module.promotion.enums.bargain.BargainRecordStatusEnum;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainActivityService;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainRecordService;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertList;
-
-@Tag(name = "用户 App - 砍价活动")
-@RestController
-@RequestMapping("/promotion/bargain-activity")
-@Validated
-public class AppBargainActivityController {
-
-    /**
-     * {@link AppBargainActivityRespVO} 缓存,通过它异步刷新 {@link #getBargainActivityList0(Integer)} 所要的首页数据
-     */
-    private final LoadingCache<Integer, List<AppBargainActivityRespVO>> bargainActivityListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
-            new CacheLoader<Integer, List<AppBargainActivityRespVO>>() {
-
-                @Override
-                public List<AppBargainActivityRespVO> load(Integer count) {
-                    return getBargainActivityList0(count);
-                }
-
-            });
-
-    @Resource
-    private BargainActivityService bargainActivityService;
-    @Resource
-    private BargainRecordService bargainRecordService;
-
-    @Resource
-    private ProductSpuApi spuApi;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得砍价活动列表", description = "用于小程序首页")
-    @Parameter(name = "count", description = "需要展示的数量", example = "6")
-    public CommonResult<List<AppBargainActivityRespVO>> getBargainActivityList(
-            @RequestParam(name = "count", defaultValue = "6") Integer count) {
-        return success(bargainActivityListCache.getUnchecked(count));
-    }
-
-    private List<AppBargainActivityRespVO>getBargainActivityList0(Integer count) {
-        List<BargainActivityDO> list = bargainActivityService.getBargainActivityListByCount(count);
-        if (CollUtil.isEmpty(list)) {
-            return Collections.emptyList();
-        }
-        // 拼接数据
-        List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId));
-        return BargainActivityConvert.INSTANCE.convertAppList(list, spuList);
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得砍价活动分页")
-    public CommonResult<PageResult<AppBargainActivityRespVO>> getBargainActivityPage(PageParam pageReqVO) {
-        PageResult<BargainActivityDO> result = bargainActivityService.getBargainActivityPage(pageReqVO);
-        if (CollUtil.isEmpty(result.getList())) {
-            return success(PageResult.empty(result.getTotal()));
-        }
-        // 拼接数据
-        List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(result.getList(), BargainActivityDO::getSpuId));
-        return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList));
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得砍价活动详情")
-    @Parameter(name = "id", description = "活动编号", example = "1")
-    public CommonResult<AppBargainActivityDetailRespVO> getBargainActivityDetail(@RequestParam("id") Long id) {
-        BargainActivityDO activity = bargainActivityService.getBargainActivity(id);
-        if (activity == null) {
-            return success(null);
-        }
-        // 拼接数据
-        Integer successUserCount = bargainRecordService.getBargainRecordUserCount(id, BargainRecordStatusEnum.SUCCESS.getStatus());
-        ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId());
-        return success(BargainActivityConvert.INSTANCE.convert(activity, successUserCount, spu));
-    }
-
-}

+ 0 - 9
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainHelpController.http

@@ -1,9 +0,0 @@
-### /promotion/bargain-record/create 创建砍价助力
-POST {{appApi}}/promotion/bargain-help/create
-Authorization: Bearer test248
-Content-Type: application/json
-tenant-id: {{appTenentId}}
-
-{
-  "recordId": 26
-}

+ 0 - 62
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainHelpController.java

@@ -1,62 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.bargain;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
-import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO;
-import cn.newfeifan.mall.module.promotion.convert.bargain.BargainHelpConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.bargain.BargainHelpDO;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainHelpService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 App - 砍价助力")
-@RestController
-@RequestMapping("/promotion/bargain-help")
-@Validated
-public class AppBargainHelpController {
-
-    @Resource
-    private BargainHelpService bargainHelpService;
-
-    @Resource
-    private MemberUserApi memberUserApi;
-
-    @PostMapping("/create")
-    @Operation(summary = "创建砍价助力", description = "给拼团记录砍一刀") // 返回结果为砍价金额,单位:分
-    public CommonResult<Integer> createBargainHelp(@RequestBody AppBargainHelpCreateReqVO reqVO) {
-        BargainHelpDO help = bargainHelpService.createBargainHelp(getLoginUserId(), reqVO);
-        return success(help.getReducePrice());
-    }
-
-    @GetMapping("/list")
-    @Operation(summary = "获得砍价助力列表")
-    @Parameter(name = "recordId", description = "砍价记录编号", required = true, example = "111")
-    public CommonResult<List<AppBargainHelpRespVO>> getBargainHelpList(@RequestParam("recordId") Long recordId) {
-        List<BargainHelpDO> helps = bargainHelpService.getBargainHelpListByRecordId(recordId);
-        if (CollUtil.isEmpty(helps)) {
-            return success(Collections.emptyList());
-        }
-        helps.sort((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())); // 倒序展示
-
-        // 拼接数据
-        Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(
-                convertSet(helps, BargainHelpDO::getUserId));
-        return success(BargainHelpConvert.INSTANCE.convertList(helps, userMap));
-    }
-
-}

+ 0 - 9
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainRecordController.http

@@ -1,9 +0,0 @@
-### /promotion/bargain-record/create 创建砍价记录
-POST {{appApi}}/promotion/bargain-record/create
-Authorization: Bearer {{appToken}}
-Content-Type: application/json
-tenant-id: {{appTenentId}}
-
-{
-  "activityId": 1
-}

+ 0 - 162
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/bargain/AppBargainRecordController.java

@@ -1,162 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.bargain;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.lang.Assert;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageParam;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
-import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
-import cn.newfeifan.mall.module.product.api.spu.ProductSpuApi;
-import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO;
-import cn.newfeifan.mall.module.promotion.convert.bargain.BargainRecordConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.bargain.BargainActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.bargain.BargainRecordDO;
-import cn.newfeifan.mall.module.promotion.enums.bargain.BargainRecordStatusEnum;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainActivityService;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainHelpService;
-import cn.newfeifan.mall.module.promotion.service.bargain.BargainRecordService;
-import cn.newfeifan.mall.module.trade.api.order.TradeOrderApi;
-import cn.newfeifan.mall.module.trade.api.order.dto.TradeOrderRespDTO;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.Parameters;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 App - 砍价记录")
-@RestController
-@RequestMapping("/promotion/bargain-record")
-@Validated
-public class AppBargainRecordController {
-
-    @Resource
-    private BargainHelpService bargainHelpService;
-    @Resource
-    private BargainRecordService bargainRecordService;
-    @Resource
-    private BargainActivityService bargainActivityService;
-
-    @Resource
-    private TradeOrderApi tradeOrderApi;
-    @Resource
-    private MemberUserApi memberUserApi;
-    @Resource
-    private ProductSpuApi productSpuApi;
-
-    @GetMapping("/get-summary")
-    @Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页")
-    public CommonResult<AppBargainRecordSummaryRespVO> getBargainRecordSummary() {
-        // 砍价成功的用户数量
-        Integer successUserCount = bargainRecordService.getBargainRecordUserCount(
-                BargainRecordStatusEnum.SUCCESS.getStatus());
-        if (successUserCount == 0) {
-            return success(new AppBargainRecordSummaryRespVO().setSuccessUserCount(0)
-                    .setSuccessList(Collections.emptyList()));
-        }
-        // 砍价成功的用户列表
-        List<BargainRecordDO> successList = bargainRecordService.getBargainRecordList(
-                BargainRecordStatusEnum.SUCCESS.getStatus(), 7);
-        List<BargainActivityDO> activityList = bargainActivityService.getBargainActivityList(
-                convertSet(successList, BargainRecordDO::getActivityId));
-        Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(
-                convertSet(successList, BargainRecordDO::getUserId));
-        // 拼接返回
-        return success(BargainRecordConvert.INSTANCE.convert(successUserCount, successList, activityList, userMap));
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得砍价记录的明细")
-    @Parameters({
-            @Parameter(name = "id", description = "砍价记录编号", example = "111"), // 场景一:查看指定的砍价记录
-            @Parameter(name = "activityId", description = "砍价活动编号", example = "222") // 场景二:查看指定的砍价活动
-    })
-    public CommonResult<AppBargainRecordDetailRespVO> getBargainRecordDetail(
-            @RequestParam(value = "id", required = false) Long id,
-            @RequestParam(value = "activityId", required = false) Long activityId) {
-        // 1. 查询砍价记录 + 砍价活动
-        Assert.isTrue(id != null || activityId != null, "砍价记录编号和活动编号不能同时为空");
-        BargainRecordDO record = id != null ? bargainRecordService.getBargainRecord(id)
-                : bargainRecordService.getLastBargainRecord(getLoginUserId(), activityId);
-        if (activityId == null || record != null) {
-            activityId = record.getActivityId();
-        }
-        // 2. 查询助力记录
-        Long userId = getLoginUserId();
-        Integer helpAction = getHelpAction(userId, record, activityId);
-        // 3. 如果是自己的订单,则查询订单信息
-        TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId())
-                ? tradeOrderApi.getOrder(record.getOrderId()) : null;
-        // TODO 继续查询别的字段
-
-        // 拼接返回
-        return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction, order));
-    }
-
-    private Integer getHelpAction(Long userId, BargainRecordDO record, Long activityId) {
-        // 0.1 如果没有活动,无法帮砍
-        if (activityId == null) {
-            return null;
-        }
-        // 0.2 如果是自己的砍价记录,无法帮砍
-        if (record != null && record.getUserId().equals(userId)) {
-            return null;
-        }
-
-        // 1. 判断是否已经助力
-        if (record != null
-            && bargainHelpService.getBargainHelp(record.getId(), userId) != null) {
-            return AppBargainRecordDetailRespVO.HELP_ACTION_SUCCESS;
-        }
-        // 2. 判断是否满助力
-        BargainActivityDO activity = bargainActivityService.getBargainActivity(activityId);
-        if (activity != null
-            && bargainHelpService.getBargainHelpCountByActivity(activityId, userId) >= activity.getBargainCount()) {
-            return AppBargainRecordDetailRespVO.HELP_ACTION_FULL;
-        }
-        // 3. 允许助力
-        return AppBargainRecordDetailRespVO.HELP_ACTION_NONE;
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得砍价记录的分页")
-    public CommonResult<PageResult<AppBargainRecordRespVO>> getBargainRecordPage(PageParam pageParam) {
-        PageResult<BargainRecordDO> pageResult = bargainRecordService.getBargainRecordPage(getLoginUserId(), pageParam);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(PageResult.empty(pageResult.getTotal()));
-        }
-
-        // 拼接数据
-        List<BargainActivityDO> activityList = bargainActivityService.getBargainActivityList(
-                convertSet(pageResult.getList(), BargainRecordDO::getActivityId));
-        List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(
-                convertSet(pageResult.getList(), BargainRecordDO::getSpuId));
-        List<TradeOrderRespDTO> orderList = tradeOrderApi.getOrderList(
-                convertSet(pageResult.getList(), BargainRecordDO::getOrderId));
-        return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList));
-    }
-
-    @PostMapping("/create")
-    @Operation(summary = "创建砍价记录", description = "参与砍价活动")
-    @PreAuthenticated
-    public CommonResult<Long> createBargainRecord(@RequestBody AppBargainRecordCreateReqVO reqVO) {
-        Long recordId = bargainRecordService.createBargainRecord(getLoginUserId(), reqVO);
-        return success(recordId);
-    }
-
-}

+ 0 - 112
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/combination/AppCombinationActivityController.java

@@ -1,112 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.combination;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageParam;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.module.product.api.spu.ProductSpuApi;
-import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
-import cn.newfeifan.mall.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
-import cn.newfeifan.mall.module.promotion.convert.combination.CombinationActivityConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.combination.CombinationActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.combination.CombinationProductDO;
-import cn.newfeifan.mall.module.promotion.service.combination.CombinationActivityService;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertList;
-
-@Tag(name = "用户 APP - 拼团活动")
-@RestController
-@RequestMapping("/promotion/combination-activity")
-@Validated
-public class AppCombinationActivityController {
-
-    /**
-     * {@link AppCombinationActivityRespVO} 缓存,通过它异步刷新 {@link #getCombinationActivityList0(Integer)} 所要的首页数据
-     */
-    private final LoadingCache<Integer, List<AppCombinationActivityRespVO>> combinationActivityListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
-            new CacheLoader<Integer, List<AppCombinationActivityRespVO>>() {
-
-                @Override
-                public List<AppCombinationActivityRespVO> load(Integer count) {
-                    return getCombinationActivityList0(count);
-                }
-
-            });
-
-    @Resource
-    private CombinationActivityService activityService;
-
-    @Resource
-    private ProductSpuApi spuApi;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得拼团活动列表", description = "用于小程序首页")
-    @Parameter(name = "count", description = "需要展示的数量", example = "6")
-    public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityList(
-            @RequestParam(name = "count", defaultValue = "6") Integer count) {
-        return success(combinationActivityListCache.getUnchecked(count));
-    }
-
-    private List<AppCombinationActivityRespVO> getCombinationActivityList0(Integer count) {
-        List<CombinationActivityDO> activityList = activityService.getCombinationActivityListByCount(count);
-        if (CollUtil.isEmpty(activityList)) {
-            return Collections.emptyList();
-        }
-        // 拼接返回
-        List<CombinationProductDO> productList = activityService.getCombinationProductListByActivityIds(
-                convertList(activityList, CombinationActivityDO::getId));
-        List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId));
-        return CombinationActivityConvert.INSTANCE.convertAppList(activityList, productList, spuList);
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得拼团活动分页")
-    public CommonResult<PageResult<AppCombinationActivityRespVO>> getCombinationActivityPage(PageParam pageParam) {
-        PageResult<CombinationActivityDO> pageResult = activityService.getCombinationActivityPage(pageParam);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(PageResult.empty(pageResult.getTotal()));
-        }
-        // 拼接返回
-        List<CombinationProductDO> productList = activityService.getCombinationProductListByActivityIds(
-                convertList(pageResult.getList(), CombinationActivityDO::getId));
-        List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), CombinationActivityDO::getSpuId));
-        return success(CombinationActivityConvert.INSTANCE.convertAppPage(pageResult, productList, spuList));
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得拼团活动明细")
-    @Parameter(name = "id", description = "活动编号", required = true, example = "1024")
-    public CommonResult<AppCombinationActivityDetailRespVO> getCombinationActivityDetail(@RequestParam("id") Long id) {
-        // 1. 获取活动
-        CombinationActivityDO activity = activityService.getCombinationActivity(id);
-        if (activity == null
-                || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
-            return success(null);
-        }
-
-        // 2. 获取活动商品
-        List<CombinationProductDO> products = activityService.getCombinationProductsByActivityId(activity.getId());
-        return success(CombinationActivityConvert.INSTANCE.convert3(activity, products));
-    }
-
-}

+ 0 - 142
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/combination/AppCombinationRecordController.java

@@ -1,142 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.combination;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO;
-import cn.newfeifan.mall.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO;
-import cn.newfeifan.mall.module.promotion.convert.combination.CombinationActivityConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.combination.CombinationRecordDO;
-import cn.newfeifan.mall.module.promotion.enums.combination.CombinationRecordStatusEnum;
-import cn.newfeifan.mall.module.promotion.service.combination.CombinationRecordService;
-import cn.newfeifan.mall.module.trade.api.order.TradeOrderApi;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.Parameters;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.context.annotation.Lazy;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import javax.validation.constraints.Max;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertList;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 APP - 拼团活动")
-@RestController
-@RequestMapping("/promotion/combination-record")
-@Validated
-public class AppCombinationRecordController {
-
-    @Resource
-    private CombinationRecordService combinationRecordService;
-    @Resource
-    @Lazy
-    private TradeOrderApi tradeOrderApi;
-
-    @GetMapping("/get-summary")
-    @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页")
-    public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
-        AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
-        // 1. 获得拼团参与用户数量
-        Long userCount = combinationRecordService.getCombinationUserCount();
-        if (userCount == 0) {
-            summary.setAvatars(Collections.emptyList());
-            summary.setUserCount(userCount);
-            return success(summary);
-        }
-        summary.setUserCount(userCount);
-
-        // 2. 获得拼团记录头像
-        List<CombinationRecordDO> records = combinationRecordService.getLatestCombinationRecordList(
-                AppCombinationRecordSummaryRespVO.AVATAR_COUNT);
-        summary.setAvatars(convertList(records, CombinationRecordDO::getAvatar));
-        return success(summary);
-    }
-
-    @GetMapping("/get-head-list")
-    @Operation(summary = "获得最近 n 条拼团记录(团长发起的)")
-    @Parameters({
-            @Parameter(name = "activityId", description = "拼团活动编号"),
-            @Parameter(name = "status", description = "拼团状态"), // 对应 CombinationRecordStatusEnum 枚举
-            @Parameter(name = "count", description = "数量")
-    })
-    public CommonResult<List<AppCombinationRecordRespVO>> getHeadCombinationRecordList(
-            @RequestParam(value = "activityId", required = false) Long activityId,
-            @RequestParam("status") Integer status,
-            @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
-        List<CombinationRecordDO> list = combinationRecordService.getHeadCombinationRecordList(activityId, status, count);
-        return success(BeanUtils.toBean(list, AppCombinationRecordRespVO.class));
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得我的拼团记录分页")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppCombinationRecordRespVO>> getCombinationRecordPage(
-            @Valid AppCombinationRecordPageReqVO pageReqVO) {
-        PageResult<CombinationRecordDO> pageResult = combinationRecordService.getCombinationRecordPage(
-                getLoginUserId(), pageReqVO);
-        return success(BeanUtils.toBean(pageResult, AppCombinationRecordRespVO.class));
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得拼团记录明细")
-    @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
-    public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
-        // 1. 查找这条拼团记录
-        CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
-        if (record == null) {
-            return success(null);
-        }
-
-        // 2. 查找该拼团的参团记录
-        CombinationRecordDO headRecord;
-        List<CombinationRecordDO> memberRecords;
-        if (Objects.equals(record.getHeadId(), CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长
-            headRecord = record;
-            memberRecords = combinationRecordService.getCombinationRecordListByHeadId(record.getId());
-        } else { // 情况二:团员
-            headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId());
-            memberRecords = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId());
-        }
-
-        // 3. 拼接数据
-        return success(CombinationActivityConvert.INSTANCE.convert(getLoginUserId(), headRecord, memberRecords));
-    }
-
-    @GetMapping("/cancel")
-    @Operation(summary = "取消拼团")
-    @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
-    public CommonResult<Boolean> cancelCombinationRecord(@RequestParam("id") Long id) {
-        Long userId = getLoginUserId();
-        // 1、查找这条拼团记录
-        CombinationRecordDO record = combinationRecordService.getCombinationRecordByIdAndUser(userId, id);
-        if (record == null) {
-            return success(Boolean.FALSE);
-        }
-        // 1.1、需要先校验拼团记录未完成;
-        if (!CombinationRecordStatusEnum.isInProgress(record.getStatus())) {
-            return success(Boolean.FALSE);
-        }
-
-        // 2. 取消已支付的订单
-        tradeOrderApi.cancelPaidOrder(userId, record.getOrderId());
-        // 3. 取消拼团记录
-        combinationRecordService.cancelCombinationRecord(userId, record.getId(), record.getHeadId());
-        return success(Boolean.TRUE);
-    }
-
-}

+ 0 - 92
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/coupon/AppCouponController.java

@@ -1,92 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.coupon;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.promotion.controller.app.coupon.vo.coupon.*;
-import cn.newfeifan.mall.module.promotion.convert.coupon.CouponConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.coupon.CouponDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
-import cn.newfeifan.mall.module.promotion.enums.coupon.CouponTakeTypeEnum;
-import cn.newfeifan.mall.module.promotion.service.coupon.CouponService;
-import cn.newfeifan.mall.module.promotion.service.coupon.CouponTemplateService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.Collections;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 App - 优惠劵")
-@RestController
-@RequestMapping("/promotion/coupon")
-@Validated
-public class AppCouponController {
-
-    @Resource
-    private CouponService couponService;
-    @Resource
-    private CouponTemplateService couponTemplateService;
-
-    @PostMapping("/take")
-    @Operation(summary = "领取优惠劵")
-    @Parameter(name = "templateId", description = "优惠券模板编号", required = true, example = "1024")
-    @PreAuthenticated
-    public CommonResult<Boolean> takeCoupon(@Valid @RequestBody AppCouponTakeReqVO reqVO) {
-        // 1. 领取优惠劵
-        Long userId = getLoginUserId();
-        couponService.takeCoupon(reqVO.getTemplateId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER);
-
-        // 2. 检查是否可以继续领取
-        CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(reqVO.getTemplateId());
-        boolean canTakeAgain = true;
-        if (couponTemplate.getTakeLimitCount() != null && couponTemplate.getTakeLimitCount() > 0) {
-            Integer takeCount = couponService.getTakeCount(reqVO.getTemplateId(), userId);
-            canTakeAgain = takeCount < couponTemplate.getTakeLimitCount();
-        }
-        return success(canTakeAgain);
-    }
-
-    @GetMapping("/match-list")
-    @Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表")
-    public CommonResult<List<AppCouponMatchRespVO>> getMatchCouponList(AppCouponMatchReqVO matchReqVO) {
-        // todo: 优化:优惠金额倒序
-        List<CouponDO> list = couponService.getMatchCouponList(getLoginUserId(), matchReqVO);
-        return success(BeanUtils.toBean(list, AppCouponMatchRespVO.class));
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "我的优惠劵列表")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppCouponRespVO>> getCouponPage(AppCouponPageReqVO pageReqVO) {
-        PageResult<CouponDO> pageResult = couponService.getCouponPage(
-                CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId())));
-        return success(BeanUtils.toBean(pageResult, AppCouponRespVO.class));
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获得优惠劵")
-    @Parameter(name = "id", description = "优惠劵编号", required = true, example = "1024")
-    @PreAuthenticated
-    public CommonResult<AppCouponRespVO> getCoupon(@RequestParam("id") Long id) {
-        CouponDO coupon = couponService.getCoupon(getLoginUserId(), id);
-        return success(BeanUtils.toBean(coupon, AppCouponRespVO.class));
-    }
-
-    @GetMapping(value = "/get-unused-count")
-    @Operation(summary = "获得未使用的优惠劵数量")
-    @PreAuthenticated
-    public CommonResult<Long> getUnusedCouponCount() {
-        return success(couponService.getUnusedCouponCount(getLoginUserId()));
-    }
-
-}

+ 0 - 141
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/coupon/AppCouponTemplateController.java

@@ -1,141 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.coupon;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.framework.common.util.object.ObjectUtils;
-import cn.newfeifan.mall.module.product.api.spu.ProductSpuApi;
-import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
-import cn.newfeifan.mall.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
-import cn.newfeifan.mall.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO;
-import cn.newfeifan.mall.module.promotion.convert.coupon.CouponTemplateConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
-import cn.newfeifan.mall.module.promotion.enums.common.PromotionProductScopeEnum;
-import cn.newfeifan.mall.module.promotion.enums.coupon.CouponTakeTypeEnum;
-import cn.newfeifan.mall.module.promotion.service.coupon.CouponService;
-import cn.newfeifan.mall.module.promotion.service.coupon.CouponTemplateService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.Parameters;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.*;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
-import static java.util.Collections.singletonList;
-
-@Tag(name = "用户 App - 优惠劵模板")
-@RestController
-@RequestMapping("/promotion/coupon-template")
-@Validated
-public class AppCouponTemplateController {
-
-    @Resource
-    private CouponTemplateService couponTemplateService;
-    @Resource
-    private CouponService couponService;
-
-    @Resource
-    private ProductSpuApi productSpuApi;
-
-    @GetMapping("/get")
-    @Operation(summary = "获得优惠劵模版")
-    @Parameter(name = "id", description = "优惠券模板编号", required = true, example = "1024")
-    public CommonResult<AppCouponTemplateRespVO> getCouponTemplate(Long id) {
-        CouponTemplateDO template = couponTemplateService.getCouponTemplate(id);
-        if (template == null) {
-            return success(null);
-        }
-        // 处理是否可领取
-        Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), singletonList(template));
-        return success(BeanUtils.toBean(template, AppCouponTemplateRespVO.class)
-                .setCanTake(canCanTakeMap.get(template.getId())));
-    }
-
-    @GetMapping("/list")
-    @Operation(summary = "获得优惠劵模版列表")
-    @Parameters({
-            @Parameter(name = "spuId", description = "商品 SPU 编号"), // 目前主要给商品详情使用
-            @Parameter(name = "productScope", description = "使用类型"),
-            @Parameter(name = "count", description = "数量", required = true)
-    })
-    public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(
-            @RequestParam(value = "spuId", required = false) Long spuId,
-            @RequestParam(value = "productScope", required = false) Integer productScope,
-            @RequestParam(value = "count", required = false, defaultValue = "10") Integer count) {
-        // 1.1 处理查询条件:商品范围编号
-        Long productScopeValue = getProductScopeValue(productScope, spuId);
-        // 1.2 处理查询条件:领取方式 = 直接领取
-        List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue());
-
-        // 2. 查询
-        List<CouponTemplateDO> list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope,
-                productScopeValue, count);
-
-        // 3.1 领取数量
-        Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list);
-        // 3.2 拼接返回
-        return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap));
-    }
-
-    @GetMapping("/list-by-ids")
-    @Operation(summary = "获得优惠劵模版列表")
-    @Parameter(name = "ids", description = "优惠券模板编号列表")
-    public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(
-            @RequestParam(value = "ids", required = false) Set<Long> ids) {
-        // 1. 查询
-        List<CouponTemplateDO> list = couponTemplateService.getCouponTemplateList(ids);
-
-        // 2.1 领取数量
-        Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list);
-        // 2.2 拼接返回
-        return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap));
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得优惠劵模版分页")
-    public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) {
-        // 1.1 处理查询条件:商品范围编号
-        Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId());
-        // 1.2 处理查询条件:领取方式 = 直接领取
-        List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue());
-
-        // 2. 分页查询
-        PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCouponTemplatePage(
-                CouponTemplateConvert.INSTANCE.convert(pageReqVO, canTakeTypes, pageReqVO.getProductScope(), productScopeValue));
-
-        // 3.1 领取数量
-        Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), pageResult.getList());
-        // 3.2 拼接返回
-        return success(CouponTemplateConvert.INSTANCE.convertAppPage(pageResult, canCanTakeMap));
-    }
-
-    /**
-     * 获得商品的使用范围编号
-     *
-     * @param productScope 商品范围
-     * @param spuId        商品 SPU 编号
-     * @return 商品范围编号
-     */
-    private Long getProductScopeValue(Integer productScope, Long spuId) {
-        // 通用券:没有商品范围
-        if (ObjectUtils.equalsAny(productScope, PromotionProductScopeEnum.ALL.getScope(), null)) {
-            return null;
-        }
-        // 品类券:查询商品的品类编号
-        if (Objects.equals(productScope, PromotionProductScopeEnum.CATEGORY.getScope()) && spuId != null) {
-            ProductSpuRespDTO spu = productSpuApi.getSpu(spuId);
-            return spu != null ? spu.getCategoryId() : null;
-        }
-        // 商品卷:直接返回
-        return spuId;
-    }
-
-}

+ 0 - 38
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/diy/AppDiyPageController.java

@@ -1,38 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.diy;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.promotion.controller.app.diy.vo.AppDiyPagePropertyRespVO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.diy.DiyPageDO;
-import cn.newfeifan.mall.module.promotion.service.diy.DiyPageService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 APP - 装修页面")
-@RestController
-@RequestMapping("/promotion/diy-page")
-@Validated
-public class AppDiyPageController {
-
-    @Resource
-    private DiyPageService diyPageService;
-
-    @GetMapping("/get")
-    @Operation(summary = "获得装修页面")
-    @Parameter(name = "id", description = "编号", required = true, example = "1024")
-    public CommonResult<AppDiyPagePropertyRespVO> getDiyPage(@RequestParam("id") Long id) {
-        DiyPageDO diyPage = diyPageService.getDiyPage(id);
-        return success(BeanUtils.toBean(diyPage, AppDiyPagePropertyRespVO.class));
-    }
-
-}

+ 0 - 65
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/diy/AppDiyTemplateController.java

@@ -1,65 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.diy;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO;
-import cn.newfeifan.mall.module.promotion.convert.diy.DiyTemplateConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.diy.DiyPageDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.diy.DiyTemplateDO;
-import cn.newfeifan.mall.module.promotion.enums.diy.DiyPageEnum;
-import cn.newfeifan.mall.module.promotion.service.diy.DiyPageService;
-import cn.newfeifan.mall.module.promotion.service.diy.DiyTemplateService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.findFirst;
-
-@Tag(name = "用户 APP - 装修模板")
-@RestController
-@RequestMapping("/promotion/diy-template")
-@Validated
-public class AppDiyTemplateController {
-
-    @Resource
-    private DiyTemplateService diyTemplateService;
-    @Resource
-    private DiyPageService diyPageService;
-
-    // TODO @疯狂:要不要把 used 和 get 接口合并哈;不传递 id,直接拿默认;
-    @GetMapping("/used")
-    @Operation(summary = "使用中的装修模板")
-    public CommonResult<AppDiyTemplatePropertyRespVO> getUsedDiyTemplate() {
-        DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate();
-        return success(buildVo(diyTemplate));
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获得装修模板")
-    @Parameter(name = "id", description = "编号", required = true, example = "1024")
-    public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplate(@RequestParam("id") Long id) {
-        DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id);
-        return success(buildVo(diyTemplate));
-    }
-
-    private AppDiyTemplatePropertyRespVO buildVo(DiyTemplateDO diyTemplate) {
-        if (diyTemplate == null) {
-            return null;
-        }
-        // 查询模板下的页面
-        List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
-        String home = findFirst(pages, page -> DiyPageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
-        String user = findFirst(pages, page -> DiyPageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
-        // 拼接返回
-        return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
-    }
-
-}

+ 0 - 38
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/reward/AppRewardActivityController.java

@@ -1,38 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.reward;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.promotion.controller.app.reward.vo.AppRewardActivityRespVO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.reward.RewardActivityDO;
-import cn.newfeifan.mall.module.promotion.service.reward.RewardActivityService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 满减送活动")
-@RestController
-@RequestMapping("/promotion/reward-activity")
-@Validated
-public class AppRewardActivityController {
-
-    @Resource
-    private RewardActivityService rewardActivityService;
-
-    @GetMapping("/get")
-    @Operation(summary = "获得满减送活动")
-    @Parameter(name = "id", description = "编号", required = true, example = "1024")
-    public CommonResult<AppRewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
-        RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
-        return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class));
-    }
-
-}

+ 0 - 152
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/seckill/AppSeckillActivityController.java

@@ -1,152 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.seckill;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils;
-import cn.newfeifan.mall.module.product.api.spu.ProductSpuApi;
-import cn.newfeifan.mall.module.product.api.spu.dto.ProductSpuRespDTO;
-import cn.newfeifan.mall.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO;
-import cn.newfeifan.mall.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO;
-import cn.newfeifan.mall.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO;
-import cn.newfeifan.mall.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.seckill.SeckillProductDO;
-import cn.newfeifan.mall.module.promotion.service.seckill.SeckillActivityService;
-import cn.newfeifan.mall.module.promotion.service.seckill.SeckillConfigService;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.context.annotation.Lazy;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.time.Duration;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertList;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.findFirst;
-import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.isBetween;
-
-@Tag(name = "用户 App - 秒杀活动")
-@RestController
-@RequestMapping("/promotion/seckill-activity")
-@Validated
-public class AppSeckillActivityController {
-
-    /**
-     * {@link AppSeckillActivityNowRespVO} 缓存,通过它异步刷新 {@link #getNowSeckillActivity()} 所要的首页数据
-     */
-    private final LoadingCache<String, AppSeckillActivityNowRespVO> nowSeckillActivityCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
-            new CacheLoader<String, AppSeckillActivityNowRespVO>() {
-
-                @Override
-                public AppSeckillActivityNowRespVO load(String key) {
-                     return getNowSeckillActivity0();
-                }
-
-            });
-
-    @Resource
-    private SeckillActivityService activityService;
-    @Resource
-    @Lazy
-    private SeckillConfigService configService;
-
-    @Resource
-    private ProductSpuApi spuApi;
-
-    @GetMapping("/get-now")
-    @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用")
-    public CommonResult<AppSeckillActivityNowRespVO> getNowSeckillActivity() {
-        return success(nowSeckillActivityCache.getUnchecked("")); // 缓存
-    }
-
-    private AppSeckillActivityNowRespVO getNowSeckillActivity0() {
-        // 1. 获取当前时间处在哪个秒杀阶段
-        SeckillConfigDO config = configService.getCurrentSeckillConfig();
-        if (config == null) { // 时段不存在直接返回 null
-            return new AppSeckillActivityNowRespVO();
-        }
-
-        // 2.1 查询满足当前阶段的活动
-        List<SeckillActivityDO> activityList = activityService.getSeckillActivityListByConfigIdAndStatus(config.getId(), CommonStatusEnum.ENABLE.getStatus());
-        List<SeckillProductDO> productList = activityService.getSeckillProductListByActivityId(
-                convertList(activityList, SeckillActivityDO::getId));
-        // 2.2 获取 spu 信息
-        List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(activityList, SeckillActivityDO::getSpuId));
-        return SeckillActivityConvert.INSTANCE.convert(config, activityList, productList, spuList);
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得秒杀活动分页")
-    public CommonResult<PageResult<AppSeckillActivityRespVO>> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) {
-        // 1. 查询满足当前阶段的活动
-        PageResult<SeckillActivityDO> pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(PageResult.empty(pageResult.getTotal()));
-        }
-        List<SeckillProductDO> productList = activityService.getSeckillProductListByActivityId(
-                convertList(pageResult.getList(), SeckillActivityDO::getId));
-
-        // 2. 拼接数据
-        List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId));
-        return success(SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList));
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得秒杀活动明细")
-    @Parameter(name = "id", description = "活动编号", required = true, example = "1024")
-    public CommonResult<AppSeckillActivityDetailRespVO> getSeckillActivity(@RequestParam("id") Long id) {
-        // 1. 获取活动
-        SeckillActivityDO activity = activityService.getSeckillActivity(id);
-        if (activity == null
-                || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
-            return success(null);
-        }
-
-        // 2. 获取时间段
-        List<SeckillConfigDO> configs = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus());
-        configs.removeIf(config -> !CollUtil.contains(activity.getConfigIds(), config.getId()));
-        // 2.1 优先使用当前时间段
-        SeckillConfigDO config = findFirst(configs, config0 -> isBetween(config0.getStartTime(), config0.getEndTime()));
-        // 2.2 如果没有,则获取最后一个,因为倾向优先展示“未开始” > “已结束”
-        if (config == null) {
-            config = CollUtil.getLast(configs);
-        }
-        if (config == null) {
-            return null;
-        }
-        // 3. 计算开始时间、结束时间
-        LocalDate nowDate;
-        // 3.1 如果在活动日期范围内,则以今天为 nowDate
-        if (LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) {
-            nowDate = LocalDate.now();
-        } else {
-            // 3.2 如果不在活动时间范围内,则直接以活动的 endTime 作为 nowDate,因为还是倾向优先展示“未开始” > “已结束”
-            nowDate = activity.getEndTime().toLocalDate();
-        }
-        LocalDateTime startTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getStartTime()));
-        LocalDateTime endTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getEndTime()));
-
-        // 4. 拼接数据
-        List<SeckillProductDO> productList = activityService.getSeckillProductListByActivityId(activity.getId());
-        return success(SeckillActivityConvert.INSTANCE.convert3(activity, productList, startTime, endTime));
-    }
-
-}

+ 0 - 36
feifan-module-mall/feifan-module-promotion-biz/src/main/java/cn/newfeifan/mall/module/promotion/controller/app/seckill/AppSeckillConfigController.java

@@ -1,36 +0,0 @@
-package cn.newfeifan.mall.module.promotion.controller.app.seckill;
-
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO;
-import cn.newfeifan.mall.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert;
-import cn.newfeifan.mall.module.promotion.dal.dataobject.seckill.SeckillConfigDO;
-import cn.newfeifan.mall.module.promotion.service.seckill.SeckillConfigService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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 javax.annotation.Resource;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 秒杀时间段")
-@RestController
-@RequestMapping("/promotion/seckill-config")
-@Validated
-public class AppSeckillConfigController {
-    @Resource
-    private SeckillConfigService configService;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得秒杀时间段列表")
-    public CommonResult<List<AppSeckillConfigRespVO>> getSeckillConfigList() {
-        List<SeckillConfigDO> list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus());
-        return success(SeckillConfigConvert.INSTANCE.convertList2(list));
-    }
-
-}

+ 0 - 4
feifan-module-mall/feifan-module-statistics-biz/src/main/java/cn/newfeifan/mall/module/statistics/controller/app/package-info.java

@@ -1,4 +0,0 @@
-/**
- * TODO 非繁人:占位
- */
-package cn.newfeifan.mall.module.statistics.controller.app;

+ 2 - 0
feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/ErrorCodeConstants.java

@@ -35,6 +35,8 @@ public interface ErrorCodeConstants {
     ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
     ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态");
     ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单");
+    ErrorCode ORDER_DELIVERY_DETAILS_IS_NULL = new ErrorCode(1_011_000_033, "交易订单发货失败,请填写完整信息");
+
 
     // ========== After Sale 模块 1-011-000-100 ==========
     ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");

+ 3 - 1
feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/delivery/DeliveryTypeEnum.java

@@ -17,7 +17,9 @@ import java.util.HashMap;
 public enum DeliveryTypeEnum implements IntArrayValuable {
 
     EXPRESS(1, "快递发货"),
-    PICK_UP(2, "用户自提"),;
+    PICK_UP(2, "用户自提"),
+    VIRTUAL_PRODUCT(3,"虚拟商品收货")
+    ;
 
     public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getType).toArray();
 

+ 6 - 1
feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/wxmessage/WcChatMessageTemplateIdEnum.java

@@ -13,7 +13,12 @@ public enum WcChatMessageTemplateIdEnum {
     ORDER_DELIVERY("1","订单发货通知"),
     AFTER_SALE_CHECK("2","售后订单审核通知"),
     AFTER_SALE_NO_CHECK("3","售后订单待审核通知"),
-    ORDER_NO_DELIVERY("4","订单待发货通知");
+    ORDER_NO_DELIVERY("4","订单待发货通知"),
+    //下面是常来此购的
+    ORDER_DELIVERY2("5","订单发货通知"),
+    AFTER_SALE_CHECK2("6","售后订单审核通知"),
+    AFTER_SALE_NO_CHECK2("7","售后订单待审核通知"),
+    ORDER_NO_DELIVERY2("8","订单出货提醒");
 
     private final String templateId;
     private final String name;

+ 11 - 4
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java

@@ -105,7 +105,11 @@ public class TradeOrderController {
         List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(
                 convertSet(pageResult.getList(), TradeOrderDO::getId));
         // 最终组合
-        return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, userMap));
+        PageResult<TradeOrderPageItemRespVO> data = TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, userMap);
+        for (TradeOrderPageItemRespVO tradeOrderPageItemRespVO : data.getList()) {
+            tradeOrderPageItemRespVO.setSpuType(tradeOrderQueryService.getSpuType(orderItems));
+        }
+        return success(data);
     }
 
     @GetMapping("/summary")
@@ -142,7 +146,9 @@ public class TradeOrderController {
         MemberUserRespDTO brokerageUser = order.getBrokerageUserId() != null ?
                 memberUserApi.getUser(order.getBrokerageUserId()) : null;
         List<TradeOrderLogDO> orderLogs = tradeOrderLogService.getOrderLogListByOrderId(id);
-        return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs, user, brokerageUser));
+        TradeOrderDetailRespVO convert = TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs, user, brokerageUser);
+        convert.setSpuType(tradeOrderQueryService.getSpuType(orderItems));
+        return success(convert);
     }
 
     @GetMapping("/get-express-track-list")
@@ -316,8 +322,8 @@ public class TradeOrderController {
     @GetMapping("/startCalc")
     @Operation(summary = "计算启动")
     public CommonResult<String> startCalc(@RequestParam("orderIds") List<Long> orderIds) {
-//        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder();
-        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder(orderIds);
+        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder();
+//        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder(orderIds);
 
 
         Map<Long, List<OrderItemMessage>> orderItemMessageGroupBy = appTradeOrderDetailRespVos.stream()
@@ -328,6 +334,7 @@ public class TradeOrderController {
                         .count(k.getCount())
                         .orderItemId(k.getOrderItemId())
                         .increaseIntegral(k.getIncreaseIntegral())
+                        .ancestorIncreaseIntegral(k.getAncestorIncreaseIntegral())
                         .totalPrice(k.getTotalPrice()).build())
                 .collect(Collectors.groupingBy(OrderItemMessage::getOrderId));
 

+ 3 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java

@@ -150,4 +150,7 @@ public class TradeOrderBaseVO {
 
     @Schema(description = "店铺id", example = "20588")
     private Long shopId;
+
+    @Schema(description = "商品类型,只有购买的商品是虚拟商品的时候才会有返回")
+    private Integer spuType;
 }

+ 4 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java

@@ -16,12 +16,15 @@ public class TradeOrderDeliveryReqVO {
     private Long id;
 
     @Schema(description = "发货物流公司编号", example = "1")
-    @NotNull(message = "发货物流公司不能为空")
     private Long logisticsId;
 
     @Schema(description = "发货物流单号", example = "SF123456789")
     private String logisticsNo;
 
 
+    @Schema(description = "发货备注", example = "备注")
+    private String deliveryRemark;
 
+    @Schema(description = "发货信息附件", requiredMode = Schema.RequiredMode.REQUIRED)
+    private String attachment;
 }

+ 5 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java

@@ -104,5 +104,10 @@ public class TradeOrderDetailRespVO extends TradeOrderBaseVO {
 
     }
 
+    @Schema(description = "发货备注", example = "备注")
+    private String deliveryRemark;
+
+    @Schema(description = "发货信息附件")
+    private String attachment;
 
 }

+ 23 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java

@@ -73,5 +73,28 @@ public class TradeOrderPageReqVO extends PageParam {
 
     @Schema(description = "店铺编号集")
     private List<Long> shopIds;
+    @Schema(description = "支付积分")
+    private Long payIntegral;
+
+    @Schema(description = "用户获得积分")
+    private Long increaseIntegral;
+
+    @Schema(description = "退还的使用的积分")
+    private Long refundIntegral;
+
+    @Schema(description = "实付人民币,单位:分")
+    private Integer payRmb;
+
+    @Schema(description = "订阅物流信息,未订阅是0,已订阅是1", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Integer subscriptionLogisticsInfo;
+
+    @Schema(description = "物流签收时间")
+    private LocalDateTime receivingTime;
+
+    @Schema(description = "发货备注", example = "你猜")
+    private String deliveryRemark;
+
+    @Schema(description = "发货信息附件")
+    private String attachment;
 
 }

+ 0 - 71
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/aftersale/AppAfterSaleController.java

@@ -1,71 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.aftersale;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageParam;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO;
-import cn.newfeifan.mall.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO;
-import cn.newfeifan.mall.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
-import cn.newfeifan.mall.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO;
-import cn.newfeifan.mall.module.trade.convert.aftersale.AfterSaleConvert;
-import cn.newfeifan.mall.module.trade.service.aftersale.AfterSaleService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 App - 交易售后")
-@RestController
-@RequestMapping("/trade/after-sale")
-@Validated
-@Slf4j
-public class AppAfterSaleController {
-
-    @Resource
-    private AfterSaleService afterSaleService;
-
-    @GetMapping(value = "/page")
-    @Operation(summary = "获得售后分页")
-    public CommonResult<PageResult<AppAfterSaleRespVO>> getAfterSalePage(PageParam pageParam) {
-        return success(AfterSaleConvert.INSTANCE.convertPage02(
-                afterSaleService.getAfterSalePage(getLoginUserId(), pageParam)));
-    }
-
-    @GetMapping(value = "/get")
-    @Operation(summary = "获得售后订单")
-    @Parameter(name = "id", description = "售后编号", required = true, example = "1")
-    public CommonResult<AppAfterSaleRespVO> getAfterSale(@RequestParam("id") Long id) {
-        return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
-    }
-
-    @PostMapping(value = "/create")
-    @Operation(summary = "申请售后")
-    public CommonResult<Long> createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) {
-        return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
-    }
-
-    @PutMapping(value = "/delivery")
-    @Operation(summary = "退回货物")
-    public CommonResult<Boolean> deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) {
-        afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO);
-        return success(true);
-    }
-
-    @DeleteMapping(value = "/cancel")
-    @Operation(summary = "取消售后")
-    @Parameter(name = "id", description = "售后编号", required = true, example = "1")
-    public CommonResult<Boolean> cancelAfterSale(@RequestParam("id") Long id) {
-        afterSaleService.cancelAfterSale(getLoginUserId(), id);
-        return success(true);
-    }
-
-}

+ 0 - 42
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/aftersale/AppAfterSaleLogController.java

@@ -1,42 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.aftersale;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.module.trade.controller.app.aftersale.vo.log.AppAfterSaleLogRespVO;
-import cn.newfeifan.mall.module.trade.dal.dataobject.aftersale.AfterSaleLogDO;
-import cn.newfeifan.mall.module.trade.service.aftersale.AfterSaleLogService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "管理后台 - 售后日志")
-@RestController
-@RequestMapping("/trade/after-sale-log")
-@Validated
-@Slf4j
-public class AppAfterSaleLogController {
-
-    @Resource
-    private AfterSaleLogService afterSaleLogService;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得售后日志列表")
-    @Parameter(name = "afterSaleId", description = "售后编号", required = true, example = "1")
-    public CommonResult<List<AppAfterSaleLogRespVO>> getAfterSaleLogList(
-            @RequestParam("afterSaleId") Long afterSaleId) {
-        List<AfterSaleLogDO> logs = afterSaleLogService.getAfterSaleLogList(afterSaleId);
-        return success(BeanUtils.toBean(logs, AppAfterSaleLogRespVO.class));
-    }
-
-}

+ 0 - 4
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/base/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 基础包,放一些通用的 VO 类
- */
-package cn.newfeifan.mall.module.trade.controller.app.base;

+ 0 - 52
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/brokerage/AppBrokerageRecordController.java

@@ -1,52 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.brokerage;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
-import cn.newfeifan.mall.module.trade.convert.brokerage.BrokerageRecordConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
-import cn.newfeifan.mall.module.trade.service.brokerage.BrokerageRecordService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 APP - 分销用户")
-@RestController
-@RequestMapping("/trade/brokerage-record")
-@Validated
-@Slf4j
-public class AppBrokerageRecordController {
-    @Resource
-    private BrokerageRecordService brokerageRecordService;
-
-    @GetMapping("/page")
-    @Operation(summary = "获得分销记录分页")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppBrokerageRecordRespVO>> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) {
-        PageResult<BrokerageRecordDO> pageResult = brokerageRecordService.getBrokerageRecordPage(
-                BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
-        return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class));
-    }
-
-    @GetMapping("/get-product-brokerage-price")
-    @Operation(summary = "获得商品的分销金额")
-    public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
-        return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId));
-    }
-
-}

+ 0 - 141
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/brokerage/AppBrokerageUserController.java

@@ -1,141 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.brokerage;
-
-import cn.hutool.core.date.LocalDateTimeUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
-import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.user.*;
-import cn.newfeifan.mall.module.trade.convert.brokerage.BrokerageRecordConvert;
-import cn.newfeifan.mall.module.trade.convert.brokerage.BrokerageUserConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
-import cn.newfeifan.mall.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
-import cn.newfeifan.mall.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
-import cn.newfeifan.mall.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
-import cn.newfeifan.mall.module.trade.service.brokerage.BrokerageRecordService;
-import cn.newfeifan.mall.module.trade.service.brokerage.BrokerageUserService;
-import cn.newfeifan.mall.module.trade.service.brokerage.BrokerageWithdrawService;
-import cn.newfeifan.mall.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.time.LocalDateTime;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Optional;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
-import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 APP - 分销用户")
-@RestController
-@RequestMapping("/trade/brokerage-user")
-@Validated
-@Slf4j
-public class AppBrokerageUserController {
-
-    @Resource
-    private BrokerageUserService brokerageUserService;
-    @Resource
-    private BrokerageRecordService brokerageRecordService;
-    @Resource
-    private BrokerageWithdrawService brokerageWithdrawService;
-
-    @Resource
-    private MemberUserApi memberUserApi;
-
-    @GetMapping("/get")
-    @Operation(summary = "获得个人分销信息")
-    @PreAuthenticated
-    public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() {
-        Optional<BrokerageUserDO> user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId()));
-        // 返回数据
-        AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO()
-                .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false))
-                .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0))
-                .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0));
-        return success(respVO);
-    }
-
-    @PutMapping("/bind")
-    @Operation(summary = "绑定推广员")
-    @PreAuthenticated
-    public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
-        return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId()));
-    }
-
-    @GetMapping("/get-summary")
-    @Operation(summary = "获得个人分销统计")
-    @PreAuthenticated
-    public CommonResult<AppBrokerageUserMySummaryRespVO> getBrokerageUserSummary() {
-        // 查询当前登录用户信息
-        BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(getLoginUserId());
-        // 统计用户昨日的佣金
-        LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
-        LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
-        LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
-        Integer yesterdayPrice = brokerageRecordService.getSummaryPriceByUserId(brokerageUser.getId(),
-                BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime);
-        // 统计用户提现的佣金
-        Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(brokerageUser.getId()),
-                        BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream()
-                .findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0);
-        // 统计分销用户数量(一级)
-        Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1);
-        // 统计分销用户数量(二级)
-        Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2);
-
-        // 拼接返回
-        return success(BrokerageUserConvert.INSTANCE.convert(yesterdayPrice, withdrawPrice, firstBrokerageUserCount, secondBrokerageUserCount, brokerageUser));
-    }
-
-    @GetMapping("/rank-page-by-user-count")
-    @Operation(summary = "获得分销用户排行分页(基于用户量)")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppBrokerageUserRankByUserCountRespVO>> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) {
-        // 分页查询
-        PageResult<AppBrokerageUserRankByUserCountRespVO> pageResult = brokerageUserService.getBrokerageUserRankPageByUserCount(pageReqVO);
-        // 拼接数据
-        Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByUserCountRespVO::getId));
-        return success(BrokerageUserConvert.INSTANCE.convertPage03(pageResult, userMap));
-    }
-
-    @GetMapping("/rank-page-by-price")
-    @Operation(summary = "获得分销用户排行分页(基于佣金)")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppBrokerageUserRankByPriceRespVO>> getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) {
-        // 分页查询
-        PageResult<AppBrokerageUserRankByPriceRespVO> pageResult = brokerageRecordService.getBrokerageUserChildSummaryPageByPrice(pageReqVO);
-        // 拼接数据
-        Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByPriceRespVO::getId));
-        return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap));
-    }
-
-    @GetMapping("/child-summary-page")
-    @Operation(summary = "获得下级分销统计分页")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppBrokerageUserChildSummaryRespVO>> getBrokerageUserChildSummaryPage(
-            AppBrokerageUserChildSummaryPageReqVO pageReqVO) {
-        PageResult<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId());
-        return success(pageResult);
-    }
-
-    @GetMapping("/get-rank-by-price")
-    @Operation(summary = "获得分销用户排行(基于佣金)")
-    @Parameter(name = "times", description = "时间段", required = true)
-    public CommonResult<Integer> getRankByPrice(
-            @RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) {
-        return success(brokerageRecordService.getUserRankByPrice(getLoginUserId(), times));
-    }
-
-}

+ 0 - 50
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java

@@ -1,50 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.brokerage;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO;
-import cn.newfeifan.mall.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
-import cn.newfeifan.mall.module.trade.convert.brokerage.BrokerageWithdrawConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
-import cn.newfeifan.mall.module.trade.service.brokerage.BrokerageWithdrawService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 APP - 分销提现")
-@RestController
-@RequestMapping("/trade/brokerage-withdraw")
-@Validated
-@Slf4j
-public class AppBrokerageWithdrawController {
-
-    @Resource
-    private BrokerageWithdrawService brokerageWithdrawService;
-
-    @GetMapping("/page")
-    @Operation(summary = "获得分销提现分页")
-    @PreAuthenticated
-    public CommonResult<PageResult<AppBrokerageWithdrawRespVO>> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) {
-        PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
-                BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
-        return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult));
-    }
-
-    @PostMapping("/create")
-    @Operation(summary = "创建分销提现")
-    @PreAuthenticated
-    public CommonResult<Long> createBrokerageWithdraw(@RequestBody @Valid AppBrokerageWithdrawCreateReqVO createReqVO) {
-        return success(brokerageWithdrawService.createBrokerageWithdraw(getLoginUserId(), createReqVO));
-    }
-
-}

+ 0 - 42
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/cart/AppCartController.http

@@ -1,42 +0,0 @@
-### 请求 /trade/cart/add 接口 => 成功
-POST {{appApi}}/trade/cart/add
-tenant-id: {{appTenentId}}
-Authorization: Bearer {{appToken}}
-Content-Type: application/json
-
-{
-  "skuId": 1,
-  "count": 10,
-  "addStatus": true
-}
-
-### 请求 /trade/cart/update 接口 => 成功
-PUT {{appApi}}/trade/cart/update
-tenant-id: {{appTenentId}}
-Authorization: Bearer {{appToken}}
-Content-Type: application/json
-
-{
-  "id": 35,
-  "count": 5
-}
-
-### 请求 /trade/cart/delete 接口 => 成功
-DELETE {{appApi}}/trade/cart/delete?ids=1
-tenant-id: {{appTenentId}}
-Authorization: Bearer {{appToken}}
-
-### 请求 /trade/cart/get-count 接口 => 成功
-GET {{appApi}}/trade/cart/get-count
-tenant-id: {{appTenentId}}
-Authorization: Bearer {{appToken}}
-
-### 请求 /trade/cart/get-count-map 接口 => 成功
-GET {{appApi}}/trade/cart/get-count-map
-tenant-id: {{appTenentId}}
-Authorization: Bearer {{appToken}}
-
-### 请求 /trade/cart/list 接口 => 成功
-GET {{appApi}}/trade/cart/list
-tenant-id: {{appTenentId}}
-Authorization: Bearer {{appToken}}

+ 0 - 87
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/cart/AppCartController.java

@@ -1,87 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.cart;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.trade.controller.app.cart.vo.*;
-import cn.newfeifan.mall.module.trade.service.cart.CartService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 App - 购物车")
-@RestController
-@RequestMapping("/trade/cart")
-@RequiredArgsConstructor
-@Validated
-@Slf4j
-public class AppCartController {
-
-    @Resource
-    private CartService cartService;
-
-    @PostMapping("/add")
-    @Operation(summary = "添加购物车商品")
-    @PreAuthenticated
-    public CommonResult<Long> addCart(@Valid @RequestBody AppCartAddReqVO addCountReqVO) {
-        return success(cartService.addCart(getLoginUserId(), addCountReqVO));
-    }
-
-    @PutMapping("/update-count")
-    @Operation(summary = "更新购物车商品数量")
-    @PreAuthenticated
-    public CommonResult<Boolean> updateCartCount(@Valid @RequestBody AppCartUpdateCountReqVO updateReqVO) {
-        cartService.updateCartCount(getLoginUserId(), updateReqVO);
-        return success(true);
-    }
-
-    @PutMapping("/update-selected")
-    @Operation(summary = "更新购物车商品选中")
-    @PreAuthenticated
-    public CommonResult<Boolean> updateCartSelected(@Valid @RequestBody AppCartUpdateSelectedReqVO updateReqVO) {
-        cartService.updateCartSelected(getLoginUserId(), updateReqVO);
-        return success(true);
-    }
-
-    @PutMapping("/reset")
-    @Operation(summary = "重置购物车商品")
-    @PreAuthenticated
-    public CommonResult<Boolean> resetCart(@Valid @RequestBody AppCartResetReqVO updateReqVO) {
-        cartService.resetCart(getLoginUserId(), updateReqVO);
-        return success(true);
-    }
-
-    @DeleteMapping("/delete")
-    @Operation(summary = "删除购物车商品")
-    @Parameter(name = "ids", description = "购物车商品编号", required = true, example = "1024,2048")
-    @PreAuthenticated
-    public CommonResult<Boolean> deleteCart(@RequestParam("ids") List<Long> ids) {
-        cartService.deleteCart(getLoginUserId(), ids);
-        return success(true);
-    }
-
-    @GetMapping("get-count")
-    @Operation(summary = "查询用户在购物车中的商品数量")
-    @PreAuthenticated
-    public CommonResult<Integer> getCartCount() {
-        return success(cartService.getCartCount(getLoginUserId()));
-    }
-
-    @GetMapping("/list")
-    @Operation(summary = "查询用户的购物车列表")
-    @PreAuthenticated
-    public CommonResult<AppCartListRespVO> getCartList() {
-        return success(cartService.getCartList(getLoginUserId()));
-    }
-
-}

+ 0 - 44
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/config/AppTradeConfigController.java

@@ -1,44 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.config;
-
-import cn.hutool.core.util.ObjUtil;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.trade.controller.app.config.vo.AppTradeConfigRespVO;
-import cn.newfeifan.mall.module.trade.convert.config.TradeConfigConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.config.TradeConfigDO;
-import cn.newfeifan.mall.module.trade.service.config.TradeConfigService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-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 javax.annotation.Resource;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 交易配置")
-@RestController
-@RequestMapping("/trade/config")
-@RequiredArgsConstructor
-@Validated
-@Slf4j
-public class AppTradeConfigController {
-
-    @Resource
-    private TradeConfigService tradeConfigService;
-
-    @Value("${feifan.tencent-lbs-key}")
-    private String tencentLbsKey;
-
-    @GetMapping("/get")
-    @Operation(summary = "获得交易配置")
-    public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
-        TradeConfigDO config = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
-        return success(TradeConfigConvert.INSTANCE.convert02(config).setTencentLbsKey(tencentLbsKey));
-    }
-
-}

+ 0 - 27
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/delivery/AppDeliverConfigController.java

@@ -1,27 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.delivery;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.trade.controller.app.delivery.vo.config.AppDeliveryConfigRespVO;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 配送配置")
-@RestController
-@RequestMapping("/trade/delivery/config")
-@Validated
-public class AppDeliverConfigController {
-
-    // TODO @非繁人:这里后面干掉,合并到 AppTradeConfigController 中
-    @GetMapping("/get")
-    @Operation(summary = "获得配送配置")
-    public CommonResult<AppDeliveryConfigRespVO> getDeliveryConfig() {
-        return success(new AppDeliveryConfigRespVO().setPickUpEnable(true).setTencentLbsKey("123456"));
-    }
-
-}

+ 0 - 39
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/delivery/AppDeliverExpressController.java

@@ -1,39 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.delivery;
-
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO;
-import cn.newfeifan.mall.module.trade.convert.delivery.DeliveryExpressConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
-import cn.newfeifan.mall.module.trade.service.delivery.DeliveryExpressService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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 javax.annotation.Resource;
-import java.util.Comparator;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 快递公司")
-@RestController
-@RequestMapping("/trade/delivery/express")
-@Validated
-public class AppDeliverExpressController {
-
-    @Resource
-    private DeliveryExpressService deliveryExpressService;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得快递公司列表")
-    public CommonResult<List<AppDeliveryExpressRespVO>> getDeliveryExpressList() {
-        List<DeliveryExpressDO> list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus());
-        list.sort(Comparator.comparing(DeliveryExpressDO::getSort));
-        return success(DeliveryExpressConvert.INSTANCE.convertList03(list));
-    }
-
-}

+ 0 - 55
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java

@@ -1,55 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.delivery;
-
-import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO;
-import cn.newfeifan.mall.module.trade.convert.delivery.DeliveryPickUpStoreConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
-import cn.newfeifan.mall.module.trade.service.delivery.DeliveryPickUpStoreService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.Parameters;
-import io.swagger.v3.oas.annotations.tags.Tag;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "用户 App - 自提门店")
-@RestController
-@RequestMapping("/trade/delivery/pick-up-store")
-@Validated
-public class AppDeliverPickUpStoreController {
-
-    @Resource
-    private DeliveryPickUpStoreService deliveryPickUpStoreService;
-
-    @GetMapping("/list")
-    @Operation(summary = "获得自提门店列表")
-    @Parameters({
-            @Parameter(name = "latitude", description = "精度", example = "110"),
-            @Parameter(name = "longitude", description = "纬度", example = "120")
-    })
-    public CommonResult<List<AppDeliveryPickUpStoreRespVO>> getDeliveryPickUpStoreList(
-            @RequestParam(value = "latitude", required = false) Double latitude,
-            @RequestParam(value = "longitude", required = false) Double longitude) {
-        List<DeliveryPickUpStoreDO> list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus(
-                CommonStatusEnum.ENABLE.getStatus());
-        return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude));
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获得自提门店")
-    @Parameter(name = "id", description = "门店编号")
-    public CommonResult<AppDeliveryPickUpStoreRespVO> getOrder(@RequestParam("id") Long id) {
-        DeliveryPickUpStoreDO store = deliveryPickUpStoreService.getDeliveryPickUpStore(id);
-        return success(DeliveryPickUpStoreConvert.INSTANCE.convert03(store));
-    }
-
-}

+ 0 - 64
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/AppTradeOrderController.http

@@ -1,64 +0,0 @@
-### /trade-order/settlement 获得订单结算信息(基于商品)
-GET {{appApi}}/trade/order/settlement?type=0&items[0].skuId=1&items[0].count=2&items[1].skuId=2&items[1].count=3&couponId=1
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### /trade-order/settlement 获得订单结算信息(基于购物车)
-GET {{appApi}}/trade/order/settlement?type=0&items[0].cartId=50&couponId=1
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### /trade-order/create 创建订单(基于商品)【快递】
-POST {{appApi}}/trade/order/create
-Content-Type: application/json
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-{
-  "pointStatus": true,
-  "deliveryType": 1,
-  "addressId": 21,
-  "items": [
-    {
-      "skuId": 1,
-      "count": 2
-    }
-  ],
-  "remark": "我是备注"
-}
-
-### /trade-order/create 创建订单(基于商品)【自提】
-POST {{appApi}}/trade/order/create
-Content-Type: application/json
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-{
-  "pointStatus": true,
-  "deliveryType": 2,
-  "pickUpStoreId": 1,
-  "items": [
-    {
-      "skuId": 1,
-      "count": 2
-    }
-  ],
-  "remark": "我是备注",
-  "receiverName": "土豆",
-  "receiverMobile": "15601691300"
-}
-
-### 获得订单交易的分页
-GET {{appApi}}/trade/order/page?pageNo=1&pageSize=10
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### 获得订单交易的详细
-GET {{appApi}}/trade/order/get-detail?id=21
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}
-
-### 获得交易订单的物流轨迹
-GET {{appApi}}/trade/order/get-express-track-list?id=70
-Authorization: Bearer {{appToken}}
-tenant-id: {{appTenentId}}

+ 0 - 182
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/AppTradeOrderController.java

@@ -1,182 +0,0 @@
-package cn.newfeifan.mall.module.trade.controller.app.order;
-
-import cn.newfeifan.mall.framework.common.pojo.CommonResult;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-import cn.newfeifan.mall.framework.security.core.annotations.PreAuthenticated;
-import cn.newfeifan.mall.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
-import cn.newfeifan.mall.module.trade.controller.app.order.vo.*;
-import cn.newfeifan.mall.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
-import cn.newfeifan.mall.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
-import cn.newfeifan.mall.module.trade.convert.order.TradeOrderConvert;
-import cn.newfeifan.mall.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
-import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO;
-import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderItemDO;
-import cn.newfeifan.mall.module.trade.enums.order.TradeOrderStatusEnum;
-import cn.newfeifan.mall.module.trade.framework.order.config.TradeOrderProperties;
-import cn.newfeifan.mall.module.trade.service.aftersale.AfterSaleService;
-import cn.newfeifan.mall.module.trade.service.delivery.DeliveryExpressService;
-import cn.newfeifan.mall.module.trade.service.order.TradeOrderQueryService;
-import cn.newfeifan.mall.module.trade.service.order.TradeOrderUpdateService;
-import com.google.common.collect.Maps;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.List;
-import java.util.Map;
-
-import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
-import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.convertSet;
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-@Tag(name = "用户 App - 交易订单")
-@RestController
-@RequestMapping("/trade/order")
-@Validated
-@Slf4j
-public class AppTradeOrderController {
-
-    @Resource
-    private TradeOrderUpdateService tradeOrderUpdateService;
-    @Resource
-    private TradeOrderQueryService tradeOrderQueryService;
-    @Resource
-    private DeliveryExpressService deliveryExpressService;
-
-    @Resource
-    private AfterSaleService afterSaleService;
-
-    @Resource
-    private TradeOrderProperties tradeOrderProperties;
-
-    @GetMapping("/settlement")
-    @Operation(summary = "获得订单结算信息")
-    @PreAuthenticated
-    public CommonResult<AppTradeOrderSettlementRespVO> settlementOrder(@Valid AppTradeOrderSettlementReqVO settlementReqVO) {
-        return success(tradeOrderUpdateService.settlementOrder(getLoginUserId(), settlementReqVO));
-    }
-
-    @PostMapping("/create")
-    @Operation(summary = "创建订单")
-    @PreAuthenticated
-    public CommonResult<AppTradeOrderCreateRespVO> createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) {
-        TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), createReqVO);
-        return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId()));
-    }
-
-    @PostMapping("/update-paid")
-    @Operation(summary = "更新订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
-    public CommonResult<Boolean> updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) {
-        tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()),
-                notifyReqDTO.getPayOrderId());
-        return success(true);
-    }
-
-    @GetMapping("/get-detail")
-    @Operation(summary = "获得交易订单")
-    @Parameter(name = "id", description = "交易订单编号")
-    public CommonResult<AppTradeOrderDetailRespVO> getOrder(@RequestParam("id") Long id) {
-        // 查询订单
-        TradeOrderDO order = tradeOrderQueryService.getOrder(getLoginUserId(), id);
-        if (order == null) {
-            return success(null);
-        }
-
-        // 查询订单项
-        List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(order.getId());
-        // 查询物流公司
-        DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ?
-                deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null;
-        // 最终组合
-        return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express));
-    }
-
-    @GetMapping("/get-express-track-list")
-    @Operation(summary = "获得交易订单的物流轨迹")
-    @Parameter(name = "id", description = "交易订单编号")
-    public CommonResult<List<AppOrderExpressTrackRespDTO>> getOrderExpressTrackList(@RequestParam("id") Long id) {
-        return success(TradeOrderConvert.INSTANCE.convertList02(
-                tradeOrderQueryService.getExpressTrackList(id, getLoginUserId())));
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得交易订单分页")
-    public CommonResult<PageResult<AppTradeOrderPageItemRespVO>> getOrderPage(AppTradeOrderPageReqVO reqVO) {
-        // 查询订单
-        PageResult<TradeOrderDO> pageResult = tradeOrderQueryService.getOrderPage(getLoginUserId(), reqVO);
-        // 查询订单项
-        List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(
-                convertSet(pageResult.getList(), TradeOrderDO::getId));
-        // 最终组合
-        return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems));
-    }
-
-    @GetMapping("/get-count")
-    @Operation(summary = "获得交易订单数量")
-    public CommonResult<Map<String, Long>> getOrderCount() {
-        Map<String, Long> orderCount = Maps.newLinkedHashMapWithExpectedSize(5);
-        // 全部
-        orderCount.put("allCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), null, null));
-        // 待付款(未支付)
-        orderCount.put("unpaidCount", tradeOrderQueryService.getOrderCount(getLoginUserId(),
-                TradeOrderStatusEnum.UNPAID.getStatus(), null));
-        // 待发货
-        orderCount.put("undeliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(),
-                TradeOrderStatusEnum.UNDELIVERED.getStatus(), null));
-        // 待收货
-        orderCount.put("deliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(),
-                TradeOrderStatusEnum.DELIVERED.getStatus(), null));
-        // 待评价
-        orderCount.put("uncommentedCount", tradeOrderQueryService.getOrderCount(getLoginUserId(),
-                TradeOrderStatusEnum.COMPLETED.getStatus(), false));
-        // 售后数量
-        orderCount.put("afterSaleCount", afterSaleService.getApplyingAfterSaleCount(getLoginUserId()));
-        return success(orderCount);
-    }
-
-    @PutMapping("/receive")
-    @Operation(summary = "确认交易订单收货")
-    @Parameter(name = "id", description = "交易订单编号")
-    public CommonResult<Boolean> receiveOrder(@RequestParam("id") Long id) {
-        tradeOrderUpdateService.receiveOrderByMember(getLoginUserId(), id);
-        return success(true);
-    }
-
-    @DeleteMapping("/cancel")
-    @Operation(summary = "取消交易订单")
-    @Parameter(name = "id", description = "交易订单编号")
-    public CommonResult<Boolean> cancelOrder(@RequestParam("id") Long id) {
-        tradeOrderUpdateService.cancelOrderByMember(getLoginUserId(), id);
-        return success(true);
-    }
-
-    @DeleteMapping("/delete")
-    @Operation(summary = "删除交易订单")
-    @Parameter(name = "id", description = "交易订单编号")
-    public CommonResult<Boolean> deleteOrder(@RequestParam("id") Long id) {
-        tradeOrderUpdateService.deleteOrder(getLoginUserId(), id);
-        return success(true);
-    }
-
-    // ========== 订单项 ==========
-
-    @GetMapping("/item/get")
-    @Operation(summary = "获得交易订单项")
-    @Parameter(name = "id", description = "交易订单项编号")
-    public CommonResult<AppTradeOrderItemRespVO> getOrderItem(@RequestParam("id") Long id) {
-        TradeOrderItemDO item = tradeOrderQueryService.getOrderItem(getLoginUserId(), id);
-        return success(TradeOrderConvert.INSTANCE.convert03(item));
-    }
-
-    @PostMapping("/item/create-comment")
-    @Operation(summary = "创建交易订单项的评价")
-    public CommonResult<Long> createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) {
-        return success(tradeOrderUpdateService.createOrderItemCommentByMember(getLoginUserId(), createReqVO));
-    }
-
-}

+ 3 - 2
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java

@@ -1,12 +1,10 @@
 package cn.newfeifan.mall.module.trade.controller.app.order.vo;
 
 import cn.newfeifan.mall.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
-import cn.newfeifan.mall.module.trade.enums.order.TradeOrderRefundStatusEnum;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.time.LocalDateTime;
-import java.util.Date;
 import java.util.List;
 
 @Schema(description = "用户 App - 订单交易的明细 Response VO")
@@ -146,4 +144,7 @@ public class AppTradeOrderDetailRespVO {
 
     @Schema(description = "店铺id", example = "20588")
     private Long shopId;
+
+    @Schema(description = "支付积分", example = "10000")
+    private Long payIntegral;
 }

+ 25 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderDO.java

@@ -334,6 +334,22 @@ public class TradeOrderDO extends BaseDO {
     private Long shopId;
 
     private Long merchantId;
+    /**
+     * 支付积分
+     */
+    private Long payIntegral;
+    /**
+     * 用户获得积分
+     */
+    private Long increaseIntegral;
+    /**
+     * 退还的使用的积分
+     */
+    private Long refundIntegral;
+    /**
+     * 实付人民币,单位:分
+     */
+    private Integer payRmb;
 
     /**
      * 订阅物流信息,未订阅是0,已订阅是1
@@ -343,4 +359,13 @@ public class TradeOrderDO extends BaseDO {
      * 物流签收时间
      */
     private LocalDateTime receivingTime;
+
+    /**
+     * 发货备注
+     */
+    private String deliveryRemark;
+    /**
+     * 发货信息附件
+     */
+    private String attachment;
 }

+ 5 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderItemDO.java

@@ -158,6 +158,11 @@ public class TradeOrderItemDO extends BaseDO {
      */
     private Boolean distributeBenefit;
 
+    /**
+     * 推荐用户获得积分
+      */
+    private Long ancestorIncreaseIntegral;
+
     /**
      * 商品属性
      */

+ 3 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java

@@ -7,6 +7,7 @@ import cn.newfeifan.mall.framework.mybatis.core.query.MPJLambdaWrapperX;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
 import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
+import cn.newfeifan.mall.module.trade.dal.dataobject.aftersale.AfterSaleDO;
 import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import org.apache.ibatis.annotations.Mapper;
@@ -41,6 +42,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
                 .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal())
                 .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId())
                 .eqIfPresent(TradeOrderDO::getMerchantId, reqVO.getMerchantId())
+                .eqIfPresent(TradeOrderDO::getShopId,reqVO.getShopId())
                 .inIfPresent(TradeOrderDO::getShopId, reqVO.getShopIds())
                 .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds())
                 .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode())
@@ -100,6 +102,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
                 .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal())
                 .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId())
                 .eqIfPresent(TradeOrderDO::getMerchantId, reqVO.getMerchantId())
+                .eqIfPresent(TradeOrderDO::getShopId,reqVO.getShopId())
                 .inIfPresent(TradeOrderDO::getShopId, reqVO.getShopIds())
                 .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds())
                 .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode())

+ 5 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/job/order/TradeOrderAutoCalcJob.java

@@ -8,6 +8,8 @@ import cn.newfeifan.mall.module.distri.mq.message.order.OrderCalcMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.OrderItemMessage;
 import cn.newfeifan.mall.module.trade.mq.producer.order.DistriOrderProducer;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderQueryService;
+import org.quartz.DisallowConcurrentExecution;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -21,6 +23,8 @@ import java.util.stream.Collectors;
  * @author 非繁源码
  */
 @Component
+@DisallowConcurrentExecution
+@Lazy(false)
 public class TradeOrderAutoCalcJob implements JobHandler {
 
     @Resource
@@ -42,6 +46,7 @@ public class TradeOrderAutoCalcJob implements JobHandler {
                         .count(k.getCount())
                         .orderItemId(k.getOrderItemId())
                         .increaseIntegral(k.getIncreaseIntegral())
+                        .ancestorIncreaseIntegral(k.getAncestorIncreaseIntegral())
                         .totalPrice(k.getTotalPrice()).build())
                 .collect(Collectors.groupingBy(OrderItemMessage::getOrderId));
 

+ 1 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java

@@ -403,7 +403,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
         params.add(afterStatus ? "商家确认退款" : "商家拒绝退款");
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         params.add(LocalDateTime.now().format(formatter));
-        wcChatMessageUtils.sendWcChatMessage(afterSale.getUserId(), WcChatMessageTemplateIdEnum.AFTER_SALE_CHECK.getTemplateId(),
+        wcChatMessageUtils.sendWcChatMessage(afterSale.getUserId(), WcChatMessageTemplateIdEnum.AFTER_SALE_CHECK2.getTemplateId(),
                 params, null, afterSale.getUserId(), afterSale.getId());
     }
 

+ 6 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryService.java

@@ -221,4 +221,10 @@ public interface TradeOrderQueryService {
 
     TradeOrderDO getOrderById(Long orderId);
 
+    /**
+     * 用来判断当前的这个订单中的商品是不是虚拟商品
+     * @param orderItems 订单项
+     * @return 0 是虚拟商品
+     */
+    Integer getSpuType(List<TradeOrderItemDO> orderItems);
 }

+ 15 - 7
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java

@@ -11,6 +11,8 @@ import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
 import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
 import cn.newfeifan.mall.module.product.api.sku.ProductSkuApi;
+import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
+import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
 import cn.newfeifan.mall.module.system.dal.dataobject.user.AdminUserDO;
 import cn.newfeifan.mall.module.system.dal.mysql.user.AdminUserMapper;
 import cn.newfeifan.mall.module.trade.controller.admin.delivery.vo.expresstemplate.ShopBO;
@@ -88,6 +90,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
 
     @Resource
     private AdminUserMapper userMapper;
+    @Resource
+    private ProductSpuService productSpuService;
 
     // =================== Order ===================
 
@@ -133,13 +137,6 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
     private Set<Long> buildQueryConditionUserIds(TradeOrderPageReqVO reqVO) {
         // 获得 userId 相关的查询
         Set<Long> userIds = new HashSet<>();
-        if (StrUtil.isNotEmpty(reqVO.getUserMobile())) {
-            MemberUserRespDTO user = memberUserApi.getUserByMobile(reqVO.getUserMobile());
-            if (user == null) { // 没查询到用户,说明肯定也没他的订单
-                return null;
-            }
-            userIds.add(user.getId());
-        }
         if (StrUtil.isNotEmpty(reqVO.getUserNickname())) {
             List<MemberUserRespDTO> users = memberUserApi.getUserListByNickname(reqVO.getUserNickname());
             if (CollUtil.isEmpty(users)) { // 没查询到用户,说明肯定也没他的订单
@@ -289,6 +286,17 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
         );
     }
 
+    @Override
+    public Integer getSpuType(List<TradeOrderItemDO> orderItems) {
+        for (TradeOrderItemDO orderItem : orderItems) {
+            ProductSpuDO spu = productSpuService.getSpu(orderItem.getSpuId());
+            if(spu.getSpuType() == 0){
+                return 0;
+            }
+        }
+        return null;
+    }
+
     public static ShopBO getShopBO(StringRedisTemplate stringRedisTemplate, AdminUserMapper userMapper, Logger log) {
         Long loginUserId = getLoginUserId();
         String s = stringRedisTemplate.opsForValue().get("shop:" + loginUserId);

+ 544 - 526
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java

@@ -221,6 +221,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         } else if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.PICK_UP.getType())) {
             order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile());
             order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码,长度为 8 位
+        } else if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.VIRTUAL_PRODUCT.getType())) {
+            MemberAddressRespDTO address = addressApi.getAddress(createReqVO.getAddressId(), userId);
+            order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile())
+                    .setReceiverDetailAddress(address.getDetailAddress());
         }
         return order;
     }
@@ -356,12 +360,19 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
     @Transactional(rollbackFor = Exception.class)
     @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_DELIVERY)
     public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) {
+        //校验发货信息不能都为空
+        if(deliveryReqVO.getLogisticsNo() == null && deliveryReqVO.getDeliveryRemark() == null){
+            throw exception(ORDER_DELIVERY_DETAILS_IS_NULL);
+        }
+
         // 1.1 校验并获得交易订单(可发货)
         TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
         order.setLogisticsId(deliveryReqVO.getLogisticsId());
         order.setLogisticsNo(deliveryReqVO.getLogisticsNo());
+        order.setAttachment(deliveryReqVO.getAttachment());
+        order.setDeliveryRemark(deliveryReqVO.getDeliveryRemark());
         // 1.2 校验 deliveryType 是否为快递,是快递才可以发货
-        if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) {
+        if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType()) || ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.VIRTUAL_PRODUCT.getType())) {
             throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS);
         }
 
@@ -369,7 +380,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         TradeOrderDO updateOrderObj = new TradeOrderDO();
         // 2.1 快递发货
         DeliveryExpressDO express = null;
-        if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) {
+        if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL) && deliveryReqVO.getLogisticsId() != null) {
             express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
             updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
         } else {
@@ -379,13 +390,20 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
 
         try {
             //发送订单订阅
-            testSubscribe(order);
+            if (deliveryReqVO.getLogisticsId() != null && deliveryReqVO.getLogisticsNo() != null) {
+                testSubscribe(order);
+            }
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
 
         // 执行更新
-        updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
+        if(deliveryReqVO.getDeliveryRemark() != null){
+            //如果是虚拟商品直接完成发货和签收
+            updateOrderObj.setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setDeliveryTime(LocalDateTime.now()).setReceivingTime(LocalDateTime.now());
+        }else{
+            updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
+        }
         int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
         if (updateCount == 0) {
             throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
@@ -408,617 +426,617 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         params.add(LocalDateTime.now().format(formatter));
         params.add(tradeOrderItemMapper.getSupNameByOrderId(order.getId()));
-        wcChatMessageUtils.sendWcChatMessage(order.getUserId(), WcChatMessageTemplateIdEnum.ORDER_DELIVERY.getTemplateId(),
-                params, null,order.getUserId(), order.getId());
+        wcChatMessageUtils.sendWcChatMessage(order.getUserId(), WcChatMessageTemplateIdEnum.ORDER_DELIVERY2.getTemplateId(),
+                params, null, order.getUserId(), order.getId());
     }
 
-/**
- * 订阅物流信息
- *
- * @param order 交易订单对象,包含物流信息和接收人手机号
- * @throws Exception 抛出异常,可能由于外部服务调用失败等原因
- */
-private void testSubscribe(TradeOrderDO order) throws Exception {
-    // 根据物流ID获取配送信息
-    DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(order.getLogisticsId());
-
-    // 设置订阅参数,包括回调URL和手机号
-    SubscribeParameters subscribeParameters = new SubscribeParameters();
-    subscribeParameters.setCallbackurl("http://47.107.28.221:8002/admin-api/trade/order/callBackUrl?orderId=" + order.getId());
-    subscribeParameters.setPhone(order.getReceiverMobile());
-    //添加盐
-    subscribeParameters.setSalt(order.getLogisticsNo());
-
-    // 创建订阅参数实例,并设置相关公司代码、物流单号和密钥
-    SubscribeParam subscribeParam = new SubscribeParam();
-    subscribeParam.setParameters(subscribeParameters);
-    subscribeParam.setCompany(deliveryExpress.getCode());
-    subscribeParam.setNumber(order.getLogisticsNo());
-    subscribeParam.setKey(key);
-
-    // 构建订阅请求对象,设置请求模式和参数
-    SubscribeReq subscribeReq = new SubscribeReq();
-    subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA);
-    subscribeReq.setParam(new Gson().toJson(subscribeParam));
-
-    // 调用订阅服务,并打印执行结果
-    IBaseClient subscribe = new Subscribe();
-    HttpResult execute = subscribe.execute(subscribeReq);
-
-    Gson gson = new Gson();
-    JsonObject jsonObject = gson.fromJson(execute.getBody(), JsonObject.class);
-    boolean result = jsonObject.get("result").getAsBoolean();
-    String returnCode = jsonObject.get("returnCode").getAsString();
-
-    if (result && returnCode.equals("200")) {
-        log.info("订单号:{}:订阅成功", order.getNo());
-
-        order.setSubscriptionLogisticsInfo(TradeOrderSubscribeStatusEnum.SUBSCRIBE.getStatus());
-    } else if (returnCode.equals("600") || returnCode.equals("601")) {
-        throw exception(NOT_SUFFICIENT_FUNDS);
-    } else {
-        log.info("订单号:{}:订阅失败原因:{}",order.getNo(),jsonObject);
-
-        order.setSubscriptionLogisticsInfo(TradeOrderSubscribeStatusEnum.abnormal.getStatus());
-    }
-    tradeOrderMapper.updateById(order);
+    /**
+     * 订阅物流信息
+     *
+     * @param order 交易订单对象,包含物流信息和接收人手机号
+     * @throws Exception 抛出异常,可能由于外部服务调用失败等原因
+     */
+    private void testSubscribe(TradeOrderDO order) throws Exception {
+        // 根据物流ID获取配送信息
+        DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(order.getLogisticsId());
+
+        // 设置订阅参数,包括回调URL和手机号
+        SubscribeParameters subscribeParameters = new SubscribeParameters();
+        subscribeParameters.setCallbackurl("http://47.107.28.221:8002/admin-api/trade/order/callBackUrl?orderId=" + order.getId());
+        subscribeParameters.setPhone(order.getReceiverMobile());
+        //添加盐
+        subscribeParameters.setSalt(order.getLogisticsNo());
+
+        // 创建订阅参数实例,并设置相关公司代码、物流单号和密钥
+        SubscribeParam subscribeParam = new SubscribeParam();
+        subscribeParam.setParameters(subscribeParameters);
+        subscribeParam.setCompany(deliveryExpress.getCode());
+        subscribeParam.setNumber(order.getLogisticsNo());
+        subscribeParam.setKey(key);
+
+        // 构建订阅请求对象,设置请求模式和参数
+        SubscribeReq subscribeReq = new SubscribeReq();
+        subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA);
+        subscribeReq.setParam(new Gson().toJson(subscribeParam));
+
+        // 调用订阅服务,并打印执行结果
+        IBaseClient subscribe = new Subscribe();
+        HttpResult execute = subscribe.execute(subscribeReq);
+
+        Gson gson = new Gson();
+        JsonObject jsonObject = gson.fromJson(execute.getBody(), JsonObject.class);
+        boolean result = jsonObject.get("result").getAsBoolean();
+        String returnCode = jsonObject.get("returnCode").getAsString();
+
+        if (result && returnCode.equals("200")) {
+            log.info("订单号:{}:订阅成功", order.getNo());
+
+            order.setSubscriptionLogisticsInfo(TradeOrderSubscribeStatusEnum.SUBSCRIBE.getStatus());
+        } else if (returnCode.equals("600") || returnCode.equals("601")) {
+            throw exception(NOT_SUFFICIENT_FUNDS);
+        } else {
+            log.info("订单号:{}:订阅失败原因:{}", order.getNo(), jsonObject);
 
-}
+            order.setSubscriptionLogisticsInfo(TradeOrderSubscribeStatusEnum.abnormal.getStatus());
+        }
+        tradeOrderMapper.updateById(order);
 
-/**
- * 校验交易订单满足被发货的条件
- * <p>
- * 1. 交易订单未发货
- *
- * @param id 交易订单编号
- * @return 交易订单
- */
-private TradeOrderDO validateOrderDeliverable(Long id) {
-    TradeOrderDO order = validateOrderExists(id);
-    // 1. 校验订单是否未发货
-    if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
-        throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE);
     }
 
-    // 2. 执行 TradeOrderHandler 前置处理
-    tradeOrderHandlers.forEach(handler -> handler.beforeDeliveryOrder(order));
-    return order;
-}
+    /**
+     * 校验交易订单满足被发货的条件
+     * <p>
+     * 1. 交易订单未发货
+     *
+     * @param id 交易订单编号
+     * @return 交易订单
+     */
+    private TradeOrderDO validateOrderDeliverable(Long id) {
+        TradeOrderDO order = validateOrderExists(id);
+        // 1. 校验订单是否未发货
+        if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) {
+            throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE);
+        }
 
-@NotNull
-private TradeOrderDO validateOrderExists(Long id) {
-    // 校验订单是否存在
-    TradeOrderDO order = tradeOrderMapper.selectById(id);
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
+        // 2. 执行 TradeOrderHandler 前置处理
+        tradeOrderHandlers.forEach(handler -> handler.beforeDeliveryOrder(order));
+        return order;
     }
-    return order;
-}
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_RECEIVE)
-public void receiveOrderByMember(Long userId, Long id) {
-    // 校验并获得交易订单(可收货)
-    TradeOrderDO order = validateOrderReceivable(userId, id);
+    @NotNull
+    private TradeOrderDO validateOrderExists(Long id) {
+        // 校验订单是否存在
+        TradeOrderDO order = tradeOrderMapper.selectById(id);
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
+        }
+        return order;
+    }
 
-    // 收货订单
-    receiveOrder0(order);
-}
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_RECEIVE)
+    public void receiveOrderByMember(Long userId, Long id) {
+        // 校验并获得交易订单(可收货)
+        TradeOrderDO order = validateOrderReceivable(userId, id);
 
-@Override
-public int receiveOrderBySystem() {
-    // 1. 查询过期的待支付订单
-    LocalDateTime expireTime = minusTime(tradeOrderProperties.getReceiveExpireTime());
-    List<TradeOrderDO> orders = tradeOrderMapper.selectListByStatusAndDeliveryTimeLt(
-            TradeOrderStatusEnum.DELIVERED.getStatus(), expireTime);
-    if (CollUtil.isEmpty(orders)) {
-        return 0;
+        // 收货订单
+        receiveOrder0(order);
     }
 
-    // 2. 遍历执行,逐个取消
-    int count = 0;
-    for (TradeOrderDO order : orders) {
-        try {
-            getSelf().receiveOrderBySystem(order);
-            count++;
-        } catch (Throwable e) {
-            log.error("[receiveOrderBySystem][order({}) 自动收货订单异常]", order.getId(), e);
+    @Override
+    public int receiveOrderBySystem() {
+        // 1. 查询过期的待支付订单
+        LocalDateTime expireTime = minusTime(tradeOrderProperties.getReceiveExpireTime());
+        List<TradeOrderDO> orders = tradeOrderMapper.selectListByStatusAndDeliveryTimeLt(
+                TradeOrderStatusEnum.DELIVERED.getStatus(), expireTime);
+        if (CollUtil.isEmpty(orders)) {
+            return 0;
         }
-    }
-    return count;
-}
 
-/**
- * 自动收货单个订单
- *
- * @param order 订单
- */
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_RECEIVE)
-public void receiveOrderBySystem(TradeOrderDO order) {
-    receiveOrder0(order);
-}
+        // 2. 遍历执行,逐个取消
+        int count = 0;
+        for (TradeOrderDO order : orders) {
+            try {
+                getSelf().receiveOrderBySystem(order);
+                count++;
+            } catch (Throwable e) {
+                log.error("[receiveOrderBySystem][order({}) 自动收货订单异常]", order.getId(), e);
+            }
+        }
+        return count;
+    }
 
-/**
- * 收货订单的核心实现
- *
- * @param order 订单
- */
-private void receiveOrder0(TradeOrderDO order) {
-    // 更新 TradeOrderDO 状态为已完成
-    int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(),
-            new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now()));
-    if (updateCount == 0) {
-        throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
+    /**
+     * 自动收货单个订单
+     *
+     * @param order 订单
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_RECEIVE)
+    public void receiveOrderBySystem(TradeOrderDO order) {
+        receiveOrder0(order);
     }
 
-    // 插入订单日志
-    TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus());
-}
+    /**
+     * 收货订单的核心实现
+     *
+     * @param order 订单
+     */
+    private void receiveOrder0(TradeOrderDO order) {
+        // 更新 TradeOrderDO 状态为已完成
+        int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(),
+                new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now()));
+        if (updateCount == 0) {
+            throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
+        }
 
-/**
- * 校验交易订单满足可售货的条件
- * <p>
- * 1. 交易订单待收货
- *
- * @param userId 用户编号
- * @param id     交易订单编号
- * @return 交易订单
- */
-private TradeOrderDO validateOrderReceivable(Long userId, Long id) {
-    // 校验订单是否存在
-    TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId);
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
-    }
-    // 校验订单是否是待收货状态
-    if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) {
-        throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
+        // 插入订单日志
+        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus());
     }
-    return order;
-}
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL)
-public void cancelOrderByMember(Long userId, Long id) {
-    // 1.1 校验存在
-    TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId);
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
-    }
-    // 1.2 校验状态
-    if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) {
-        throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
+    /**
+     * 校验交易订单满足可售货的条件
+     * <p>
+     * 1. 交易订单待收货
+     *
+     * @param userId 用户编号
+     * @param id     交易订单编号
+     * @return 交易订单
+     */
+    private TradeOrderDO validateOrderReceivable(Long userId, Long id) {
+        // 校验订单是否存在
+        TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId);
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
+        }
+        // 校验订单是否是待收货状态
+        if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) {
+            throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED);
+        }
+        return order;
     }
 
-    // 2. 取消订单
-    cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
-}
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL)
+    public void cancelOrderByMember(Long userId, Long id) {
+        // 1.1 校验存在
+        TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId);
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
+        }
+        // 1.2 校验状态
+        if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) {
+            throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
+        }
 
-@Override
-public int cancelOrderBySystem() {
-    // 1. 查询过期的待支付订单
-    LocalDateTime expireTime = minusTime(tradeOrderProperties.getPayExpireTime());
-    List<TradeOrderDO> orders = tradeOrderMapper.selectListByStatusAndCreateTimeLt(
-            TradeOrderStatusEnum.UNPAID.getStatus(), expireTime);
-    if (CollUtil.isEmpty(orders)) {
-        return 0;
+        // 2. 取消订单
+        cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
     }
 
-    // 2. 遍历执行,逐个取消
-    int count = 0;
-    for (TradeOrderDO order : orders) {
-        try {
-            getSelf().cancelOrderBySystem(order);
-            count++;
-        } catch (Throwable e) {
-            log.error("[cancelOrderBySystem][order({}) 过期订单异常]", order.getId(), e);
+    @Override
+    public int cancelOrderBySystem() {
+        // 1. 查询过期的待支付订单
+        LocalDateTime expireTime = minusTime(tradeOrderProperties.getPayExpireTime());
+        List<TradeOrderDO> orders = tradeOrderMapper.selectListByStatusAndCreateTimeLt(
+                TradeOrderStatusEnum.UNPAID.getStatus(), expireTime);
+        if (CollUtil.isEmpty(orders)) {
+            return 0;
         }
-    }
-    return count;
-}
 
-/**
- * 自动取消单个订单
- *
- * @param order 订单
- */
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL)
-public void cancelOrderBySystem(TradeOrderDO order) {
-    cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT);
-}
+        // 2. 遍历执行,逐个取消
+        int count = 0;
+        for (TradeOrderDO order : orders) {
+            try {
+                getSelf().cancelOrderBySystem(order);
+                count++;
+            } catch (Throwable e) {
+                log.error("[cancelOrderBySystem][order({}) 过期订单异常]", order.getId(), e);
+            }
+        }
+        return count;
+    }
 
-/**
- * 取消订单的核心实现
- *
- * @param order      订单
- * @param cancelType 取消类型
- */
-private void cancelOrder0(TradeOrderDO order, TradeOrderCancelTypeEnum cancelType) {
-    // 1. 更新 TradeOrderDO 状态为已取消
-    int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(),
-            new TradeOrderDO().setStatus(TradeOrderStatusEnum.CANCELED.getStatus())
-                    .setCancelType(cancelType.getType()).setCancelTime(LocalDateTime.now()));
-    if (updateCount == 0) {
-        throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
+    /**
+     * 自动取消单个订单
+     *
+     * @param order 订单
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL)
+    public void cancelOrderBySystem(TradeOrderDO order) {
+        cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT);
     }
 
-    // 2. 执行 TradeOrderHandler 的后置处理
-    List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
-    tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems));
+    /**
+     * 取消订单的核心实现
+     *
+     * @param order      订单
+     * @param cancelType 取消类型
+     */
+    private void cancelOrder0(TradeOrderDO order, TradeOrderCancelTypeEnum cancelType) {
+        // 1. 更新 TradeOrderDO 状态为已取消
+        int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(),
+                new TradeOrderDO().setStatus(TradeOrderStatusEnum.CANCELED.getStatus())
+                        .setCancelType(cancelType.getType()).setCancelTime(LocalDateTime.now()));
+        if (updateCount == 0) {
+            throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID);
+        }
 
-    // 3. 增加订单日志
-    TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus());
-}
+        // 2. 执行 TradeOrderHandler 的后置处理
+        List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
+        tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems));
 
-/**
- * 如果金额全部被退款,则取消订单
- * 如果还有未被退款的金额,则无需取消订单
- *
- * @param order       订单
- * @param refundPrice 退款金额
- */
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_CANCEL_AFTER_SALE)
-public void cancelOrderByAfterSale(TradeOrderDO order, Integer refundPrice) {
-    // 1. 更新订单
-    if (refundPrice < order.getPayPrice()) {
-        return;
+        // 3. 增加订单日志
+        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus());
     }
-    tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
-            .setStatus(TradeOrderStatusEnum.CANCELED.getStatus())
-            .setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now()));
 
-    // 2. 执行 TradeOrderHandler 的后置处理
-    List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
-    tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems));
-}
+    /**
+     * 如果金额全部被退款,则取消订单
+     * 如果还有未被退款的金额,则无需取消订单
+     *
+     * @param order       订单
+     * @param refundPrice 退款金额
+     */
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_CANCEL_AFTER_SALE)
+    public void cancelOrderByAfterSale(TradeOrderDO order, Integer refundPrice) {
+        // 1. 更新订单
+        if (refundPrice < order.getPayPrice()) {
+            return;
+        }
+        tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
+                .setStatus(TradeOrderStatusEnum.CANCELED.getStatus())
+                .setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now()));
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_DELETE)
-public void deleteOrder(Long userId, Long id) {
-    // 1.1 校验存在
-    TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId);
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
+        // 2. 执行 TradeOrderHandler 的后置处理
+        List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
+        tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems));
     }
-    // 1.2 校验状态
-    if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus())) {
-        throw exception(ORDER_DELETE_FAIL_STATUS_NOT_CANCEL);
-    }
-    // 2. 删除订单
-    tradeOrderMapper.deleteById(id);
 
-    // 3. 记录日志
-    TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
-}
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_DELETE)
+    public void deleteOrder(Long userId, Long id) {
+        // 1.1 校验存在
+        TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId);
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
+        }
+        // 1.2 校验状态
+        if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus())) {
+            throw exception(ORDER_DELETE_FAIL_STATUS_NOT_CANCEL);
+        }
+        // 2. 删除订单
+        tradeOrderMapper.deleteById(id);
 
-@Override
-public void updateOrderRemark(TradeOrderRemarkReqVO reqVO) {
-    // 校验并获得交易订单
-    validateOrderExists(reqVO.getId());
+        // 3. 记录日志
+        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
+    }
 
-    // 更新
-    TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO);
-    tradeOrderMapper.updateById(order);
-}
+    @Override
+    public void updateOrderRemark(TradeOrderRemarkReqVO reqVO) {
+        // 校验并获得交易订单
+        validateOrderExists(reqVO.getId());
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_PRICE)
-public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) {
-    // 1.1 校验交易订单
-    TradeOrderDO order = validateOrderExists(reqVO.getId());
-    if (order.getPayStatus()) {
-        throw exception(ORDER_UPDATE_PRICE_FAIL_PAID);
-    }
-    // 1.2 校验调价金额是否变化
-    if (order.getAdjustPrice() > 0) {
-        throw exception(ORDER_UPDATE_PRICE_FAIL_ALREADY);
-    }
-    // 1.3 支付价格不能为 0
-    int newPayPrice = order.getPayPrice() + order.getAdjustPrice();
-    if (newPayPrice <= 0) {
-        throw exception(ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR);
+        // 更新
+        TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO);
+        tradeOrderMapper.updateById(order);
     }
 
-    // 2. 更新订单
-    tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
-            .setAdjustPrice(reqVO.getAdjustPrice()).setPayPrice(newPayPrice));
-
-    // 3. 更新 TradeOrderItem,需要做 adjustPrice 的分摊
-    List<TradeOrderItemDO> orderOrderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
-    List<Integer> dividePrices = TradePriceCalculatorHelper.dividePrice2(orderOrderItems, newPayPrice);
-    List<TradeOrderItemDO> updateItems = new ArrayList<>();
-    for (int i = 0; i < orderOrderItems.size(); i++) {
-        TradeOrderItemDO item = orderOrderItems.get(i);
-        updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(dividePrices.get(i))
-                .setPayPrice(item.getPayPrice() + dividePrices.get(i)));
-    }
-    tradeOrderItemMapper.updateBatch(updateItems);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_PRICE)
+    public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) {
+        // 1.1 校验交易订单
+        TradeOrderDO order = validateOrderExists(reqVO.getId());
+        if (order.getPayStatus()) {
+            throw exception(ORDER_UPDATE_PRICE_FAIL_PAID);
+        }
+        // 1.2 校验调价金额是否变化
+        if (order.getAdjustPrice() > 0) {
+            throw exception(ORDER_UPDATE_PRICE_FAIL_ALREADY);
+        }
+        // 1.3 支付价格不能为 0
+        int newPayPrice = order.getPayPrice() + order.getAdjustPrice();
+        if (newPayPrice <= 0) {
+            throw exception(ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR);
+        }
 
-    // 4. 更新支付订单
-    payOrderApi.updatePayOrderPrice(order.getPayOrderId(), newPayPrice);
+        // 2. 更新订单
+        tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
+                .setAdjustPrice(reqVO.getAdjustPrice()).setPayPrice(newPayPrice));
+
+        // 3. 更新 TradeOrderItem,需要做 adjustPrice 的分摊
+        List<TradeOrderItemDO> orderOrderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
+        List<Integer> dividePrices = TradePriceCalculatorHelper.dividePrice2(orderOrderItems, newPayPrice);
+        List<TradeOrderItemDO> updateItems = new ArrayList<>();
+        for (int i = 0; i < orderOrderItems.size(); i++) {
+            TradeOrderItemDO item = orderOrderItems.get(i);
+            updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(dividePrices.get(i))
+                    .setPayPrice(item.getPayPrice() + dividePrices.get(i)));
+        }
+        tradeOrderItemMapper.updateBatch(updateItems);
 
-    // 5. 记录订单日志
-    TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(),
-            MapUtil.<String, Object>builder().put("oldPayPrice", MoneyUtils.fenToYuanStr(order.getPayPrice()))
-                    .put("newPayPrice", MoneyUtils.fenToYuanStr(newPayPrice)).build());
-}
+        // 4. 更新支付订单
+        payOrderApi.updatePayOrderPrice(order.getPayOrderId(), newPayPrice);
 
-@Override
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS)
-public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) {
-    // 校验交易订单
-    TradeOrderDO order = validateOrderExists(reqVO.getId());
-    // 只有待发货状态,才可以修改订单收货地址;
-    if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) {
-        throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED);
+        // 5. 记录订单日志
+        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(),
+                MapUtil.<String, Object>builder().put("oldPayPrice", MoneyUtils.fenToYuanStr(order.getPayPrice()))
+                        .put("newPayPrice", MoneyUtils.fenToYuanStr(newPayPrice)).build());
     }
 
-    // 更新
-    tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO));
+    @Override
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS)
+    public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) {
+        // 校验交易订单
+        TradeOrderDO order = validateOrderExists(reqVO.getId());
+        // 只有待发货状态,才可以修改订单收货地址;
+        if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) {
+            throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED);
+        }
 
-    // 记录订单日志
-    TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
-}
+        // 更新
+        tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO));
 
-@Override
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
-public void pickUpOrderByAdmin(Long id) {
-    getSelf().pickUpOrder(tradeOrderMapper.selectById(id));
-}
+        // 记录订单日志
+        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
+    }
 
-@Override
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
-public void pickUpOrderByAdmin(String pickUpVerifyCode) {
-    getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
-}
+    @Override
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
+    public void pickUpOrderByAdmin(Long id) {
+        getSelf().pickUpOrder(tradeOrderMapper.selectById(id));
+    }
 
-@Override
-public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) {
-    return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode);
-}
+    @Override
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
+    public void pickUpOrderByAdmin(String pickUpVerifyCode) {
+        getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
+    }
 
-@Transactional(rollbackFor = Exception.class)
-public void pickUpOrder(TradeOrderDO order) {
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
+    @Override
+    public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) {
+        return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode);
     }
-    if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) {
-        throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP);
+
+    @Transactional(rollbackFor = Exception.class)
+    public void pickUpOrder(TradeOrderDO order) {
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
+        }
+        if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) {
+            throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP);
+        }
+        receiveOrder0(order);
     }
-    receiveOrder0(order);
-}
 
 // =================== Order Item ===================
 
-@Override
-public void updateOrderItemWhenAfterSaleCreate(Long id, Long afterSaleId) {
-    // 更新订单项
-    updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(),
-            TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), afterSaleId);
-}
-
-@Override
-@Transactional(rollbackFor = Exception.class)
-public void updateOrderItemWhenAfterSaleSuccess(Long id, Integer refundPrice) {
-    // 1.1 更新订单项
-    updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
-            TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), null);
-    // 1.2 执行 TradeOrderHandler 的后置处理
-    TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(id);
-    TradeOrderDO order = tradeOrderMapper.selectById(orderItem.getOrderId());
-    tradeOrderHandlers.forEach(handler -> handler.afterCancelOrderItem(order, orderItem));
-
-    // 2.1 更新订单的退款金额、积分
-    Integer orderRefundPrice = order.getRefundPrice() + refundPrice;
-    Integer orderRefundPoint = order.getRefundPoint() + orderItem.getUsePoint();
-    Integer refundStatus = isAllOrderItemAfterSaleSuccess(order.getId()) ?
-            TradeOrderRefundStatusEnum.ALL.getStatus() // 如果都售后成功,则需要取消订单
-            : TradeOrderRefundStatusEnum.PART.getStatus();
-    tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
-            .setRefundStatus(refundStatus)
-            .setRefundPrice(orderRefundPrice).setRefundPoint(orderRefundPoint));
-    // 2.2 如果全部退款,则进行取消订单
-    getSelf().cancelOrderByAfterSale(order, orderRefundPrice);
-}
-
-@Override
-public void updateOrderItemWhenAfterSaleCancel(Long id) {
-    // 更新订单项
-    updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
-            TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null);
-}
+    @Override
+    public void updateOrderItemWhenAfterSaleCreate(Long id, Long afterSaleId) {
+        // 更新订单项
+        updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(),
+                TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), afterSaleId);
+    }
 
-private void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus,
-                                            Long afterSaleId) {
-    // 更新订单项
-    int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, afterSaleId);
-    if (updateCount <= 0) {
-        throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateOrderItemWhenAfterSaleSuccess(Long id, Integer refundPrice) {
+        // 1.1 更新订单项
+        updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
+                TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), null);
+        // 1.2 执行 TradeOrderHandler 的后置处理
+        TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(id);
+        TradeOrderDO order = tradeOrderMapper.selectById(orderItem.getOrderId());
+        tradeOrderHandlers.forEach(handler -> handler.afterCancelOrderItem(order, orderItem));
+
+        // 2.1 更新订单的退款金额、积分
+        Integer orderRefundPrice = order.getRefundPrice() + refundPrice;
+        Integer orderRefundPoint = order.getRefundPoint() + orderItem.getUsePoint();
+        Integer refundStatus = isAllOrderItemAfterSaleSuccess(order.getId()) ?
+                TradeOrderRefundStatusEnum.ALL.getStatus() // 如果都售后成功,则需要取消订单
+                : TradeOrderRefundStatusEnum.PART.getStatus();
+        tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
+                .setRefundStatus(refundStatus)
+                .setRefundPrice(orderRefundPrice).setRefundPoint(orderRefundPoint));
+        // 2.2 如果全部退款,则进行取消订单
+        getSelf().cancelOrderByAfterSale(order, orderRefundPrice);
     }
 
-}
+    @Override
+    public void updateOrderItemWhenAfterSaleCancel(Long id) {
+        // 更新订单项
+        updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
+                TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null);
+    }
 
-/**
- * 判断指定订单的所有订单项,是不是都售后成功
- *
- * @param id 订单编号
- * @return 是否都售后成功
- */
-private boolean isAllOrderItemAfterSaleSuccess(Long id) {
-    List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(id);
-    return orderItems.stream().allMatch(orderItem -> Objects.equals(orderItem.getAfterSaleStatus(),
-            TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus()));
-}
+    private void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus,
+                                                Long afterSaleId) {
+        // 更新订单项
+        int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, afterSaleId);
+        if (updateCount <= 0) {
+            throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL);
+        }
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_COMMENT)
-public Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO) {
-    // 1.1 先通过订单项 ID,查询订单项是否存在
-    TradeOrderItemDO orderItem = tradeOrderItemMapper.selectByIdAndUserId(createReqVO.getOrderItemId(), userId);
-    if (orderItem == null) {
-        throw exception(ORDER_ITEM_NOT_FOUND);
     }
-    // 1.2 校验订单相关状态
-    TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderItem.getOrderId(), userId);
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
-    }
-    if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) {
-        throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED);
+
+    /**
+     * 判断指定订单的所有订单项,是不是都售后成功
+     *
+     * @param id 订单编号
+     * @return 是否都售后成功
+     */
+    private boolean isAllOrderItemAfterSaleSuccess(Long id) {
+        List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(id);
+        return orderItems.stream().allMatch(orderItem -> Objects.equals(orderItem.getAfterSaleStatus(),
+                TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus()));
     }
-    if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) {
-        throw exception(ORDER_COMMENT_STATUS_NOT_FALSE);
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_COMMENT)
+    public Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO) {
+        // 1.1 先通过订单项 ID,查询订单项是否存在
+        TradeOrderItemDO orderItem = tradeOrderItemMapper.selectByIdAndUserId(createReqVO.getOrderItemId(), userId);
+        if (orderItem == null) {
+            throw exception(ORDER_ITEM_NOT_FOUND);
+        }
+        // 1.2 校验订单相关状态
+        TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderItem.getOrderId(), userId);
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
+        }
+        if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) {
+            throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED);
+        }
+        if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) {
+            throw exception(ORDER_COMMENT_STATUS_NOT_FALSE);
+        }
+
+        // 2. 创建评价
+        Long commentId = createOrderItemComment0(orderItem, createReqVO);
+
+        // 3. 如果订单项都评论了,则更新订单评价状态
+        List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
+        if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) {
+            tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE)
+                    .setFinishTime(LocalDateTime.now()));
+            // 增加订单日志。注意:只有在所有订单项都评价后,才会增加
+            TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
+        }
+        return commentId;
     }
 
-    // 2. 创建评价
-    Long commentId = createOrderItemComment0(orderItem, createReqVO);
+    @Override
+    public int createOrderItemCommentBySystem() {
+        // 1. 查询过期的待支付订单
+        LocalDateTime expireTime = minusTime(tradeOrderProperties.getCommentExpireTime());
+        List<TradeOrderDO> orders = tradeOrderMapper.selectListByStatusAndReceiveTimeLt(
+                TradeOrderStatusEnum.COMPLETED.getStatus(), expireTime, false);
+        if (CollUtil.isEmpty(orders)) {
+            return 0;
+        }
 
-    // 3. 如果订单项都评论了,则更新订单评价状态
-    List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
-    if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) {
-        tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE)
-                .setFinishTime(LocalDateTime.now()));
-        // 增加订单日志。注意:只有在所有订单项都评价后,才会增加
-        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
+        // 2. 遍历执行,逐个取消
+        int count = 0;
+        for (TradeOrderDO order : orders) {
+            try {
+                getSelf().createOrderItemCommentBySystemBySystem(order);
+                count++;
+            } catch (Throwable e) {
+                log.error("[createOrderItemCommentBySystem][order({}) 过期订单异常]", order.getId(), e);
+            }
+        }
+        return count;
     }
-    return commentId;
-}
 
-@Override
-public int createOrderItemCommentBySystem() {
-    // 1. 查询过期的待支付订单
-    LocalDateTime expireTime = minusTime(tradeOrderProperties.getCommentExpireTime());
-    List<TradeOrderDO> orders = tradeOrderMapper.selectListByStatusAndReceiveTimeLt(
-            TradeOrderStatusEnum.COMPLETED.getStatus(), expireTime, false);
-    if (CollUtil.isEmpty(orders)) {
-        return 0;
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) {
+        tradeOrderMapper.updateById(
+                new TradeOrderDO().setId(orderId).setCombinationActivityId(activityId)
+                        .setCombinationRecordId(combinationRecordId).setCombinationHeadId(headId));
     }
 
-    // 2. 遍历执行,逐个取消
-    int count = 0;
-    for (TradeOrderDO order : orders) {
-        try {
-            getSelf().createOrderItemCommentBySystemBySystem(order);
-            count++;
-        } catch (Throwable e) {
-            log.error("[createOrderItemCommentBySystem][order({}) 过期订单异常]", order.getId(), e);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void cancelPaidOrder(Long userId, Long orderId) {
+        // TODO 非繁人:这里实现要优化下;
+        TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
+        if (order == null) {
+            throw exception(ORDER_NOT_FOUND);
         }
+        cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
     }
-    return count;
-}
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) {
-    tradeOrderMapper.updateById(
-            new TradeOrderDO().setId(orderId).setCombinationActivityId(activityId)
-                    .setCombinationRecordId(combinationRecordId).setCombinationHeadId(headId));
-}
+    /**
+     * 保存订单的签收时间
+     *
+     * @param com 快递公司编码
+     * @param nu  单号
+     */
+    public void updateOrder(String com, String nu, LocalDateTime time) {
+        DeliveryExpressDO deliveryExpressDO = deliveryExpressService.selectByCode(com);
+        TradeOrderDO tradeOrderDO = tradeOrderMapper.selectOne(new LambdaQueryWrapper<TradeOrderDO>()
+                .eq(TradeOrderDO::getLogisticsNo, nu)
+                .eq(TradeOrderDO::getLogisticsId, deliveryExpressDO.getId())
+                .isNull(TradeOrderDO::getReceivingTime)
+        );
+        if (tradeOrderDO == null) {
+            return;
+        }
+        tradeOrderDO.setReceivingTime(time);
 
-@Override
-@Transactional(rollbackFor = Exception.class)
-public void cancelPaidOrder(Long userId, Long orderId) {
-    // TODO 非繁人:这里实现要优化下;
-    TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
-    if (order == null) {
-        throw exception(ORDER_NOT_FOUND);
+        tradeOrderMapper.updateById(tradeOrderDO);
     }
-    cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL);
-}
 
-/**
- * 保存订单的签收时间
- *
- * @param com 快递公司编码
- * @param nu  单号
- */
-public void updateOrder(String com, String nu, LocalDateTime time) {
-    DeliveryExpressDO deliveryExpressDO = deliveryExpressService.selectByCode(com);
-    TradeOrderDO tradeOrderDO = tradeOrderMapper.selectOne(new LambdaQueryWrapper<TradeOrderDO>()
-            .eq(TradeOrderDO::getLogisticsNo, nu)
-            .eq(TradeOrderDO::getLogisticsId, deliveryExpressDO.getId())
-            .isNull(TradeOrderDO::getReceivingTime)
-    );
-    if (tradeOrderDO == null) {
-        return;
+    @Override
+    public void updateOrderById(TradeOrderDO order) {
+        tradeOrderMapper.updateById(order);
     }
-    tradeOrderDO.setReceivingTime(time);
 
-    tradeOrderMapper.updateById(tradeOrderDO);
-}
+    /**
+     * 创建单个订单的评论
+     *
+     * @param order 订单
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_COMMENT)
+    public void createOrderItemCommentBySystemBySystem(TradeOrderDO order) {
+        // 1. 查询未评论的订单项
+        List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderIdAndCommentStatus(
+                order.getId(), Boolean.FALSE);
+        if (CollUtil.isEmpty(orderItems)) {
+            return;
+        }
 
-@Override
-public void updateOrderById(TradeOrderDO order) {
-    tradeOrderMapper.updateById(order);
-}
+        // 2. 逐个评论
+        for (TradeOrderItemDO orderItem : orderItems) {
+            // 2.1 创建评价
+            AppTradeOrderItemCommentCreateReqVO commentCreateReqVO = new AppTradeOrderItemCommentCreateReqVO()
+                    .setOrderItemId(orderItem.getId()).setAnonymous(false).setContent("")
+                    .setBenefitScores(5).setDescriptionScores(5);
+            createOrderItemComment0(orderItem, commentCreateReqVO);
 
-/**
- * 创建单个订单的评论
- *
- * @param order 订单
- */
-@Transactional(rollbackFor = Exception.class)
-@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_COMMENT)
-public void createOrderItemCommentBySystemBySystem(TradeOrderDO order) {
-    // 1. 查询未评论的订单项
-    List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderIdAndCommentStatus(
-            order.getId(), Boolean.FALSE);
-    if (CollUtil.isEmpty(orderItems)) {
-        return;
+            // 2.2 更新订单项评价状态
+            tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE));
+        }
+
+        // 3. 所有订单项都评论了,则更新订单评价状态
+        tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE)
+                .setFinishTime(LocalDateTime.now()));
+        // 增加订单日志。注意:只有在所有订单项都评价后,才会增加
+        TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
     }
 
-    // 2. 逐个评论
-    for (TradeOrderItemDO orderItem : orderItems) {
-        // 2.1 创建评价
-        AppTradeOrderItemCommentCreateReqVO commentCreateReqVO = new AppTradeOrderItemCommentCreateReqVO()
-                .setOrderItemId(orderItem.getId()).setAnonymous(false).setContent("")
-                .setBenefitScores(5).setDescriptionScores(5);
-        createOrderItemComment0(orderItem, commentCreateReqVO);
+    /**
+     * 创建订单项的评论的核心实现
+     *
+     * @param orderItem   订单项
+     * @param createReqVO 评论内容
+     * @return 评论编号
+     */
+    private Long createOrderItemComment0(TradeOrderItemDO orderItem, AppTradeOrderItemCommentCreateReqVO createReqVO) {
+        // 1. 创建评价
+        ProductCommentCreateReqDTO productCommentCreateReqDTO = TradeOrderConvert.INSTANCE.convert04(createReqVO, orderItem);
+        Long commentId = productCommentApi.createComment(productCommentCreateReqDTO);
 
-        // 2.2 更新订单项评价状态
+        // 2. 更新订单项评价状态
         tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE));
+        return commentId;
     }
 
-    // 3. 所有订单项都评论了,则更新订单评价状态
-    tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE)
-            .setFinishTime(LocalDateTime.now()));
-    // 增加订单日志。注意:只有在所有订单项都评价后,才会增加
-    TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus());
-}
-
-/**
- * 创建订单项的评论的核心实现
- *
- * @param orderItem   订单项
- * @param createReqVO 评论内容
- * @return 评论编号
- */
-private Long createOrderItemComment0(TradeOrderItemDO orderItem, AppTradeOrderItemCommentCreateReqVO createReqVO) {
-    // 1. 创建评价
-    ProductCommentCreateReqDTO productCommentCreateReqDTO = TradeOrderConvert.INSTANCE.convert04(createReqVO, orderItem);
-    Long commentId = productCommentApi.createComment(productCommentCreateReqDTO);
-
-    // 2. 更新订单项评价状态
-    tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE));
-    return commentId;
-}
-
 // =================== 营销相关的操作 ===================
 
-/**
- * 获得自身的代理对象,解决 AOP 生效问题
- *
- * @return 自己
- */
-private TradeOrderUpdateServiceImpl getSelf() {
-    return SpringUtil.getBean(getClass());
-}
+    /**
+     * 获得自身的代理对象,解决 AOP 生效问题
+     *
+     * @return 自己
+     */
+    private TradeOrderUpdateServiceImpl getSelf() {
+        return SpringUtil.getBean(getClass());
+    }
 
 }

Some files were not shown because too many files changed in this diff