Browse Source

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

合并生产环境的代码
Yangzw 9 months ago
parent
commit
26a153fca1
54 changed files with 460 additions and 138 deletions
  1. 31 15
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/CaclEnum.java
  2. 6 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogSaveReqVO.java
  3. 0 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/duser/DuserDO.java
  4. 0 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/integral/IntegralDO.java
  5. 0 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofit/PtProfitDO.java
  6. 17 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlog/PtProfitLogDO.java
  7. 1 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/integral/IntegralMapper.java
  8. 1 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/ptprofit/PtProfitMapper.java
  9. 1 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/ptprofitlog/PtProfitLogMapper.java
  10. 2 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralService.java
  11. 4 3
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralServiceImpl.java
  12. 4 2
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java
  13. 5 3
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java
  14. 1 1
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/integral/IntegralMapper.xml
  15. 1 1
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofit/PtProfitMapper.xml
  16. 1 1
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofitlog/PtProfitLogMapper.xml
  17. 4 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSkuRespVO.java
  18. 4 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java
  19. 7 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java
  20. 13 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuRespVO.java
  21. 12 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java
  22. 11 0
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java
  23. 6 1
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/sku/ProductSkuDO.java
  24. 20 11
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/spu/ProductSpuDO.java
  25. 21 5
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spu/ProductSpuServiceImpl.java
  26. 2 0
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/ErrorCodeConstants.java
  27. 1 1
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/aftersale/AfterSaleStatusEnum.java
  28. 3 1
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/delivery/DeliveryTypeEnum.java
  29. 6 1
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/wxmessage/WcChatMessageTemplateIdEnum.java
  30. 8 2
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java
  31. 12 1
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderDetailController.java
  32. 3 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java
  33. 4 2
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java
  34. 4 4
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java
  35. 24 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java
  36. 3 2
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java
  37. 3 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java
  38. 26 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderDO.java
  39. 8 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderItemDO.java
  40. 5 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java
  41. 28 14
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java
  42. 10 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryService.java
  43. 28 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java
  44. 37 13
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java
  45. 3 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java
  46. 27 34
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/utils/wechat/WcChatMessageUtils.java
  47. 4 7
      feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/dal/dataobject/user/MemberUserDO.java
  48. 3 0
      feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/dal/mysql/user/MemberUserMapper.java
  49. 7 0
      feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserService.java
  50. 16 4
      feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserServiceImpl.java
  51. 4 0
      feifan-module-system/feifan-module-system-api/src/main/java/cn/newfeifan/mall/module/system/constant/SystemConstants.java
  52. 2 2
      feifan-module-system/feifan-module-system-biz/src/main/resources/mapper/social/SocialUserMapper.xml
  53. 5 2
      feifan-server/src/main/resources/application-prod.yaml
  54. 1 1
      feifan-server/src/main/resources/application.yaml

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

@@ -6,21 +6,32 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum CaclEnum {
-    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,"订单退款,退回积分"),//订单已支付,用户退款申请通过,则退回商品项使用的积分
-    ORDER_INTEGRAL_UNFREEZE(11,"订单积分到账"),//购物收货7天后,冻结积分变为可用积分
-    ORDER_GET_FREEZE_INTEGRAL(12,"购物返积分"),//购物获得冻结积分
-    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(13,"取消订单,退回积分"),//用户手动取消未支付订单,退回购物使用的积分
-    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(14,"订单超时未支付,退回积分"),//订单超时未支付,退回购物使用的积分
-    ORDER_REFUND_CANCEL_INTEGRAL(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, "购物获得","消费者购物,获得冻结积分"),//购物者本人 获得积分
+    ;
+
+//    ORDER_GET_FREEZE_INTEGRAL(12,"购物返积分"),//购物获得冻结积分
+//    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(13,"取消订单,退回积分"),//用户手动取消未支付订单,退回购物使用的积分
+//    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(14,"订单超时未支付,退回积分"),//订单超时未支付,退回购物使用的积分
+//    ORDER_REFUND_CANCEL_INTEGRAL(15,"订单退款,减少冻结积分"),//订单已支付,用户退款申请通过,则减少之前给用户的冻结积分
     ;
 
     /**
@@ -32,6 +43,11 @@ public enum CaclEnum {
      */
     private final String name;
 
+    /**
+     * 描述
+     */
+    private final String mark;
+
     public static CaclEnum getCaclEnumByValue(int value) {
         for (CaclEnum caclEnum : CaclEnum.values()) {
             if (caclEnum.getType() == value) {

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

@@ -14,6 +14,12 @@ public class PtProfitLogSaveReqVO {
     @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12046")
     private Long id;
 
+    /**
+     * 产生积分的用户ID,例如:下订单的用户ID
+     */
+    @Schema(description = "产生积分的用户ID", example = "6982")
+    private Long generateUserId;
+
     @Schema(description = "增加金额")
     private Long amount;
 

+ 0 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/dataobject/duser/DuserDO.java → feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/duser/DuserDO.java


+ 0 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/dataobject/integral/IntegralDO.java → feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/integral/IntegralDO.java


+ 0 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/dataobject/ptprofit/PtProfitDO.java → feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofit/PtProfitDO.java


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

@@ -1,4 +1,5 @@
 package cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog.PtProfitLogDO;
 
 import lombok.*;
 import com.baomidou.mybatisplus.annotation.*;
@@ -32,6 +33,17 @@ public class PtProfitLogDO extends BaseDO {
      * 增加后金额
      */
     private Long afterAmount;
+
+    /**
+     * 增加冻结金额
+     */
+    private Long freezeAmount;
+    /**
+     * 增加后冻结金额
+     */
+    private Long afterFreezeAmount;
+
+
     /**
      * 收益类型 1:平台服务器费 2:平台收益 3用户下单返回毛利额度 4直推人额度 5合赢奖
      */
@@ -41,6 +53,11 @@ public class PtProfitLogDO extends BaseDO {
      */
     private Long userId;
 
+    /**
+     * 导致积分发生变化的用户ID
+     */
+    private Long generateUserId;
+
     /**
      * 订单Id
      */

+ 1 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/integral/IntegralMapper.java → feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/integral/IntegralMapper.java

@@ -1,4 +1,4 @@
-package cn.newfeifan.mall.module.distri.dal.mysql.integral;
+package cn.newfeifan.mall.module.distri.dal.integral;
 
 import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
 import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;

+ 1 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofit/PtProfitMapper.java → feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/ptprofit/PtProfitMapper.java

@@ -1,4 +1,4 @@
-package cn.newfeifan.mall.module.distri.dal.mysql.ptprofit;
+package cn.newfeifan.mall.module.distri.dal.ptprofit;
 
 import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;

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

@@ -1,4 +1,4 @@
-package cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlog;
+package cn.newfeifan.mall.module.distri.dal.ptprofitlog;
 
 
 import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;

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

@@ -64,7 +64,8 @@ public interface IntegralService {
      * @param freezeAmount 用户冻结积分变化金额,可为负数
      * @return 返回是否执行成功。执行失败,通常是就是用户积分不足,没积分抵扣
      */
-    Boolean updateUserIntegral(Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
+    Boolean updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
+            Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
                                Long tradeOrderId,
                                String orderNum
                                );

+ 4 - 3
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralServiceImpl.java

@@ -1,6 +1,6 @@
 package cn.newfeifan.mall.module.distri.service.integral;
 
-import cn.newfeifan.mall.module.distri.dal.mysql.ptprofit.PtProfitMapper;
+import cn.newfeifan.mall.module.distri.dal.ptprofit.PtProfitMapper;
 import cn.newfeifan.mall.module.distri.enums.CaclEnum;
 import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
 import org.springframework.stereotype.Service;
@@ -88,7 +88,8 @@ public class IntegralServiceImpl implements IntegralService {
      * @return 返回是否执行成功。执行失败,通常是就是用户积分不足,没积分抵扣
      */
     @Override
-    public Boolean updateUserIntegral(Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
+    public Boolean updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
+            Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
                                       Long tradeOrderId,
                                       String OrderNum
                                       ) {
@@ -118,7 +119,7 @@ public class IntegralServiceImpl implements IntegralService {
             }
 
             //记录用户的积分变动日志
-            ptProfitLogService.addMessage(userId, caclEnum, amount, afterAmount,
+            ptProfitLogService.addMessage(generateUserId,userId, caclEnum, amount, afterAmount,
                     freezeAmount, afterFreezeAmount,null,tradeOrderId,OrderNum);
 
         }else if(effectRowNum<1){//如果钱包积分不足,不够抵扣

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

@@ -62,14 +62,16 @@ public interface PtProfitLogService {
     void saveBatch(List<PtProfitLogSaveReqVO> ptProfitLogSaveReqVOS);
 
     //记录用户的积分变动日志
-    void addMessage(Long userId, CaclEnum caclEnum, Integer amount,
+    void addMessage(Long generateUserId,//导致产生积分变动的用户ID
+                    Long userId, CaclEnum caclEnum, Integer amount,
                     Integer afterAmount, Integer freezeAmount,
                     Integer afterFreezeAmount, String percentTemplate,
                     Long tradeOrderId,
                     String OrderNum
                     );
 
-    void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount,
+    void addMessage(Long generateUserId,//导致产生积分变动的用户ID
+            Long userId, CaclEnum caclEnum, Long amount, Long afterAmount,
                     Long freezeAmount, Long afterFreezeAmount,
                     String percentTemplate,
                     Long tradeOrderId,

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

@@ -7,7 +7,7 @@ import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitL
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogRespVO;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog.PtProfitLogDO;
-import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlog.PtProfitLogMapper;
+import cn.newfeifan.mall.module.distri.dal.ptprofitlog.PtProfitLogMapper;
 import cn.newfeifan.mall.module.distri.enums.CaclEnum;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
@@ -87,7 +87,7 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
     }
 
     @Override
-    public void addMessage(Long userId, CaclEnum caclEnum, Integer amount, Integer afterAmount, Integer freezeAmount, Integer afterFreezeAmount, String percentTemplate, Long tradeOrderId, String OrderNum) {
+    public void addMessage(Long generateUserId,Long userId, CaclEnum caclEnum, Integer amount, Integer afterAmount, Integer freezeAmount, Integer afterFreezeAmount, String percentTemplate, Long tradeOrderId, String OrderNum) {
 
     }
 
@@ -104,7 +104,8 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
      * @param OrderNum
      */
     @Override
-    public void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount,
+    public void addMessage(Long generateUserId,//导致产生积分变动的用户ID
+            Long userId, CaclEnum caclEnum, Long amount, Long afterAmount,
                            Long freezeAmount, Long afterFreezeAmount,
                            String percentTemplate,
                            Long tradeOrderId,
@@ -115,6 +116,7 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
                 .amount(amount)
                 .percentTemplate(percentTemplate)
                 .userId(userId)
+                .generateUserId(generateUserId)
                 .profitStatus(caclEnum.getType()).orderId(tradeOrderId).orderNo(OrderNum)
                 .freezeAmount(freezeAmount).afterFreezeAmount(afterFreezeAmount)
                 .build();

+ 1 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/integral/IntegralMapper.xml

@@ -1,6 +1,6 @@
 <?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.integral.IntegralMapper">
+<mapper namespace="cn.newfeifan.mall.module.distri.dal.integral.IntegralMapper">
 
     <!--
         一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。

+ 1 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofit/PtProfitMapper.xml

@@ -1,6 +1,6 @@
 <?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.ptprofit.PtProfitMapper">
+<mapper namespace="cn.newfeifan.mall.module.distri.dal.ptprofit.PtProfitMapper">
 
     <!--
         一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。

+ 1 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofitlog/PtProfitLogMapper.xml

@@ -1,6 +1,6 @@
 <?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.ptprofitlog.PtProfitLogMapper">
+<mapper namespace="cn.newfeifan.mall.module.distri.dal.ptprofitlog.PtProfitLogMapper">
 
     <!--
         一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。

+ 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 - 0
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")
@@ -85,4 +86,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 static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -75,4 +76,10 @@ public class ProductSpuPageReqVO extends PageParam {
 
     @Schema(description = "商户id", example = "8240")
     private Long merchantId;
+
+    @Schema(description = "高精度价格", example = "9255")
+    private BigDecimal highPrecisionPrice;
+
+    @Schema(description = "高精度", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Boolean highPrecision;
 }

+ 13 - 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;
 
@@ -135,4 +136,16 @@ public class ProductSpuRespVO {
 
     @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;
 }

+ 12 - 0
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")
@@ -104,4 +105,15 @@ 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;
 }

+ 6 - 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;
@@ -108,6 +108,11 @@ public class ProductSkuDO extends BaseDO {
 
 
     private Long merchantId;
+
+    /**
+     * 高精度价格
+     */
+    private BigDecimal highPrecisionPrice;
     /**
      * 商品属性
      */

+ 20 - 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;
 
 /**
@@ -38,6 +39,12 @@ public class ProductSpuDO extends BaseDO {
 
     // ========== 基本信息 =========
 
+    /**
+     * 推广费, 单位: 分,值为sku中最大的推广费
+     *
+     */
+    private Integer promotionFee;
+
     /**
      * 商品名称
      */
@@ -57,13 +64,11 @@ public class ProductSpuDO extends BaseDO {
 
     /**
      * 商品分类编号
-     *
      * 关联 {@link ProductCategoryDO#getId()}
      */
     private Long categoryId;
     /**
      * 商品品牌编号
-     *
      * 关联 {@link ProductBrandDO#getId()}
      */
     private Long brandId;
@@ -83,7 +88,6 @@ public class ProductSpuDO extends BaseDO {
     private Integer sort;
     /**
      * 商品状态
-     *
      * 枚举 {@link ProductSpuStatusEnum}
      */
     private Integer status;
@@ -92,32 +96,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 +125,12 @@ public class ProductSpuDO extends BaseDO {
 
     /**
      * 配送方式数组
-     *
      * 对应 DeliveryTypeEnum 枚举
      */
     @TableField(typeHandler = IntegerListTypeHandler.class)
     private List<Integer> deliveryTypes;
     /**
      * 物流配置模板编号
-     *
      * 对应 TradeDeliveryExpressTemplateDO 的 id 编号
      */
     private Long deliveryTemplateId;
@@ -148,7 +145,6 @@ public class ProductSpuDO extends BaseDO {
     // TODO @puhui999:字段估计要改成 brokerageType
     /**
      * 分销类型
-     *
      * false - 默认
      * true - 自行设置
      */
@@ -186,5 +182,18 @@ public class ProductSpuDO extends BaseDO {
      */
     private Long merchantId;
 
+    /**
+     * 商品支付类别
+     */
+    private Integer spuPayType;
+
+    /**
+     * 高精度
+     */
+    private Boolean highPrecision;
+    /**
+     * 高精度价格
+     */
+    private BigDecimal highPrecisionPrice;
 
 }

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

@@ -107,10 +107,19 @@ public class ProductSpuServiceImpl implements ProductSpuService {
         ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class);
         initSpuFromSkus(updateObj, skuSaveReqList);
 
+        //最大推广费, 单位: 分  add by Ben
+        Integer maxPromotionFee = 0;
+
         for (ProductSkuSaveReqVO productSkuSaveReqVO : skuSaveReqList) {
             productSkuSaveReqVO.setShopId(updateReqVO.getShopId());
             productSkuSaveReqVO.setMerchantId(updateReqVO.getMerchantId());
+
+            Integer skuPromotionFee = productSkuSaveReqVO.getPromotionFee();
+            if(skuPromotionFee>maxPromotionFee)
+                maxPromotionFee=skuPromotionFee;
         }
+
+        updateObj.setPromotionFee(maxPromotionFee);
         productSpuMapper.updateById(updateObj);
         // 批量更新 SKU
         productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus());
@@ -125,11 +134,18 @@ public class ProductSpuServiceImpl implements ProductSpuService {
      */
     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 已有状态则不处理

+ 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, "售后单不存在");

+ 1 - 1
feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/aftersale/AfterSaleStatusEnum.java

@@ -27,7 +27,7 @@ public enum AfterSaleStatusEnum implements IntArrayValuable {
     /**
      * 卖家通过售后;【商品待退货】
      */
-    SELLER_AGREE(20, "卖家通过", "商家同意退款"), // 有赞的状态提示:请退货并填写物流信息
+    SELLER_AGREE(20, "卖家通过", "商家等待买家退货"), // 有赞的状态提示:请退货并填写物流信息
     /**
      * 买家已退货,等待卖家收货;【商家待收货】
      */

+ 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;

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

@@ -96,7 +96,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.getSpuTypeByList(tradeOrderPageItemRespVO.getItems()));
+        }
+        return success(data);
     }
 
     @GetMapping("/get-backlog")
@@ -140,7 +144,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")

+ 12 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderDetailController.java

@@ -6,11 +6,14 @@ import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
 //import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
 import cn.newfeifan.mall.module.pay.service.order.PayOrderService;
+import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
+import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
 import cn.newfeifan.mall.module.trade.controller.admin.aftersale.vo.AfterSaleBaseVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.*;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.detailvo.TradeOrderDeliveryVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.detailvo.TradeOrderPayVo;
 import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderDetailRespVO;
+import cn.newfeifan.mall.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
 import cn.newfeifan.mall.module.trade.convert.aftersale.AfterSaleConvert;
 import cn.newfeifan.mall.module.trade.convert.order.TradeOrderConvert;
 import cn.newfeifan.mall.module.trade.dal.dataobject.aftersale.AfterSaleDO;
@@ -63,6 +66,9 @@ public class TradeOrderDetailController {
     @Resource
     private AfterSaleService afterSaleService;
 
+    @Resource
+    private ProductSkuService productSkuService;
+
     @Resource
     private DeliveryExpressService deliveryExpressService;
 
@@ -183,7 +189,12 @@ public class TradeOrderDetailController {
         DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ?
                 deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null;
         // 最终组合
-        return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express));
+        AppTradeOrderDetailRespVO respVO = TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express);
+        for (AppTradeOrderItemRespVO item : respVO.getItems()) {
+            ProductSkuDO sku = productSkuService.getSku(item.getSkuId());
+            item.setHighPrecisionPrice(sku.getHighPrecisionPrice());
+        }
+        return success(respVO);
     }
 
 

+ 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 - 2
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java

@@ -1,7 +1,5 @@
 package cn.newfeifan.mall.module.trade.controller.admin.order.vo;
 
-import cn.newfeifan.mall.framework.common.validation.InEnum;
-import cn.newfeifan.mall.module.trade.enums.delivery.DeliveryTypeEnum;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -22,6 +20,10 @@ public class TradeOrderDeliveryReqVO {
     @Schema(description = "发货物流单号", example = "SF123456789")
     private String logisticsNo;
 
+    @Schema(description = "发货备注", example = "备注")
+    private String deliveryRemark;
 
+    @Schema(description = "发货信息附件", requiredMode = Schema.RequiredMode.REQUIRED)
+    private String attachment;
 
 }

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

@@ -1,15 +1,11 @@
 package cn.newfeifan.mall.module.trade.controller.admin.order.vo;
 
-import cn.newfeifan.mall.module.product.api.comment.dto.ProductCommentCreateReqDTO;
-import cn.newfeifan.mall.module.trade.controller.admin.aftersale.vo.AfterSaleBaseVO;
 import cn.newfeifan.mall.module.trade.controller.admin.base.member.user.MemberUserRespVO;
 import cn.newfeifan.mall.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO;
-import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderDetailRespVO;
 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 = "管理后台 - 交易订单的详情 Response VO")
@@ -104,5 +100,9 @@ public class TradeOrderDetailRespVO extends TradeOrderBaseVO {
 
     }
 
+    @Schema(description = "发货备注", example = "备注")
+    private String deliveryRemark;
 
+    @Schema(description = "发货信息附件")
+    private String attachment;
 }

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

@@ -71,4 +71,28 @@ public class TradeOrderPageReqVO extends PageParam {
     @Schema(description = "商户ID", example = "1")
     private Long  merchantId;
 
+    @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;
+
 }

+ 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;
 }

+ 3 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java

@@ -5,6 +5,7 @@ import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderItemDO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Schema(description = "用户 App - 订单交易项 Response VO")
@@ -59,4 +60,6 @@ public class AppTradeOrderItemRespVO {
     @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
     private Integer afterSaleStatus;
 
+    @Schema(description = "商品精度金额")
+    private BigDecimal highPrecisionPrice;
 }

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

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

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

@@ -43,6 +43,10 @@ public class TradeOrderItemDO extends BaseDO {
      * 用户付款后,获得的冻结积分
      */
     private Long increaseIntegral;
+    /**
+     * 直推人用户付款后,推荐人用户获得积分
+     */
+    private Long ancestorIncreaseIntegral;
     /**
      * 用户编号
      *
@@ -187,6 +191,10 @@ public class TradeOrderItemDO extends BaseDO {
      * 枚举 {@link TradeOrderItemAfterSaleStatusEnum}
      */
     private Integer afterSaleStatus;
+    /**
+     * 是否分配积分、身价权益,已分配是1,未分配为0
+     */
+    private Boolean distributeBenefit;
 
     /**
      * 商品属性

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

@@ -9,6 +9,8 @@ import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderPageR
 import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.time.LocalDateTime;
 import java.util.List;
@@ -17,6 +19,9 @@ import java.util.Set;
 
 @Mapper
 public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
+    //add by Ben 20240604
+    @Select("SELECT ancestor FROM `distri_share_path` where descendant = #{userId} and depth=1")
+    Long selectAncesterByMemberUserId(@Param("userId") Long userId);
 
     default int updateByIdAndStatus(Long id, Integer status, TradeOrderDO update) {
         return update(update, new LambdaUpdateWrapper<TradeOrderDO>()

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

@@ -231,6 +231,9 @@ public class AfterSaleServiceImpl implements AfterSaleService {
         AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus);
 
         // TODO 发送售后消息
+        if(afterSale.getWay().equals(AfterSaleWayEnum.RETURN_AND_REFUND.getWay())){
+            sentWcChatMessage(afterSale,AfterSaleStatusEnum.SELLER_AGREE.getContent());
+        }
     }
 
     @Override
@@ -250,7 +253,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
         AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus);
 
         // 发送给微信用户售后消息
-        sentWcChatMessage(afterSale,false);
+        sentWcChatMessage(afterSale,AfterSaleStatusEnum.SELLER_DISAGREE.getContent());
 
         // 更新交易订单项的售后状态为【未申请】
         tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId());
@@ -351,6 +354,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
                 MapUtil.of("reason", refuseReqVO.getRefuseMemo()));
 
         // TODO 发送售后消息
+        sentWcChatMessage(afterSale,AfterSaleStatusEnum.SELLER_REFUSE.getContent());
 
         // 更新交易订单项的售后状态为【未申请】
         tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId());
@@ -399,17 +403,27 @@ public class AfterSaleServiceImpl implements AfterSaleService {
         Long payIntegral = tradeOrderItemDO.getPayIntegral();//支付积分
 
         //记录退还积分
-        TradeOrderItemDO toid = new TradeOrderItemDO();
-        toid.setId(tradeOrderItemDO.getId());
-        toid.setRefundIntegral(payIntegral);
-        tradeOrderItemMapper.updateById(toid);
-        //返回退款订单项对应的积分
-        integralService.updateUserIntegral(orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL, payIntegral,0l,tradeOrderId,tradeOrderNum);
-
+        if(payIntegral>0) {
+            TradeOrderItemDO toid = new TradeOrderItemDO();
+            toid.setId(tradeOrderItemDO.getId());
+            toid.setRefundIntegral(payIntegral);
+            tradeOrderItemMapper.updateById(toid);
+            //退回退款订单项,购物者支付的积分
+            integralService.updateUserIntegral(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL, payIntegral, 0l, tradeOrderId, tradeOrderNum);
+        }
 
         //2. 减少退货物品对应的冻结积分
-        Long increaseIntegral = tradeOrderItemDO.getIncreaseIntegral();
-        integralService.updateUserIntegral(orderUserId, CaclEnum.ORDER_REFUND_CANCEL_INTEGRAL, 0l,increaseIntegral*(-1),tradeOrderId,tradeOrderNum);
+        Long increaseIntegral = tradeOrderItemDO.getIncreaseIntegral();//消费者自得冻结积分
+        Long ancestorIncreaseIntegral = tradeOrderItemDO.getAncestorIncreaseIntegral();//消费者推荐人得冻结积分
+
+
+        //订单退款,收回消费者获得的冻结积分
+        integralService.updateUserIntegral(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL_CONSUMER, 0l,increaseIntegral*(-1),tradeOrderId,tradeOrderNum);
+
+        //20240604 推荐人(上级用户ID)
+        Long ancesterUserId = tradeOrderMapper.selectAncesterByMemberUserId(orderUserId);
+        //订单退款,收回消费者推荐人获得的冻结积分
+        integralService.updateUserIntegral(orderUserId,ancesterUserId, CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER, 0l,ancestorIncreaseIntegral*(-1),tradeOrderId,tradeOrderNum);
 
         // 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起
         createPayRefund(userIp, afterSale);
@@ -423,7 +437,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
                 AfterSaleStatusEnum.COMPLETE.getStatus());
 
         // 发送给微信用户售后消息
-        sentWcChatMessage(afterSale,true);
+        sentWcChatMessage(afterSale , AfterSaleStatusEnum.COMPLETE.getContent());
 
         // 更新交易订单项的售后状态为【已完成】
         tradeOrderUpdateService.updateOrderItemWhenAfterSaleSuccess(afterSale.getOrderItemId(), afterSale.getRefundPrice());
@@ -434,7 +448,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
      * @param afterSale 售后订单
      * @param afterStatus 是否同意退款
      */
-    private void sentWcChatMessage(AfterSaleDO afterSale,Boolean afterStatus) {
+    private void sentWcChatMessage(AfterSaleDO afterSale,String afterStatus) {
         List<String> params = new ArrayList<>();
         params.add(afterSale.getNo());
         params.add(afterSale.getSpuName());
@@ -443,10 +457,10 @@ public class AfterSaleServiceImpl implements AfterSaleService {
         String formattedPrice = df.format((double) afterSale.getRefundPrice() / 100);
 
         params.add("¥ " + formattedPrice);
-        params.add(afterStatus ? "商家确认退款" : "商家拒绝退款");
+        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());
     }
 

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

@@ -2,6 +2,7 @@ package cn.newfeifan.mall.module.trade.service.order;
 
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
+import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO;
 import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
@@ -206,4 +207,13 @@ public interface TradeOrderQueryService {
      * @return 集合
      */
     Map<String, Long> getBacklog();
+
+    /**
+     * 用来判断当前的这个订单中的商品是不是虚拟商品
+     * @param orderItems 订单项
+     * @return 0 是虚拟商品
+     */
+    Integer getSpuType(List<TradeOrderItemDO> orderItems);
+
+    Integer getSpuTypeByList(List<TradeOrderPageItemRespVO.Item> items);
 }

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

@@ -10,8 +10,11 @@ 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.controller.admin.user.vo.user.UserShopDetailsVO;
 import cn.newfeifan.mall.module.system.service.user.AdminUserService;
+import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO;
 import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
@@ -76,6 +79,9 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
     @Lazy
     private AfterSaleService afterSaleService;
 
+    @Resource
+    private ProductSpuService productSpuService;
+
 
     // =================== Order ===================
 
@@ -234,6 +240,28 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
         return backMap;
     }
 
+    @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;
+    }
+
+    @Override
+    public Integer getSpuTypeByList(List<TradeOrderPageItemRespVO.Item> items) {
+        for (TradeOrderPageItemRespVO.Item orderItem : items) {
+            ProductSpuDO spu = productSpuService.getSpu(orderItem.getSpuId());
+            if(spu.getSpuType() == 0){
+                return 0;
+            }
+        }
+        return null;
+    }
+
     @Override
     public List<ExpressTrackRespDTO> getExpressTrackList(Long id, Long userId) {
         // 查询订单

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

@@ -11,6 +11,7 @@ import cn.newfeifan.mall.framework.common.core.KeyValue;
 import cn.newfeifan.mall.framework.common.enums.UserTypeEnum;
 import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
 import cn.newfeifan.mall.framework.common.util.number.MoneyUtils;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.newfeifan.mall.module.member.api.address.MemberAddressApi;
 import cn.newfeifan.mall.module.member.api.address.dto.MemberAddressRespDTO;
 import cn.newfeifan.mall.module.pay.api.order.PayOrderApi;
@@ -80,7 +81,6 @@ import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.mi
 import static cn.newfeifan.mall.framework.common.util.servlet.ServletUtils.getClientIP;
 import static cn.newfeifan.mall.framework.web.core.util.WebFrameworkUtils.getTerminal;
 import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.*;
-import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.NOT_SUFFICIENT_FUNDS;
 
 /**
  * 交易订单【写】Service 实现类
@@ -353,12 +353,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.getAttachment() == 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);
         }
 
@@ -366,7 +373,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 {
@@ -376,13 +383,25 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
 
         try {
             //发送订单订阅
-            subscribe(order);
+            if (deliveryReqVO.getLogisticsId() != null && deliveryReqVO.getLogisticsNo() != null) {
+                subscribe(order);
+            }
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
 
         // 执行更新
-        updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
+        if (deliveryReqVO.getAttachment() != null) {
+            //如果是虚拟商品直接完成发货和签收
+            updateOrderObj.setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setDeliveryTime(LocalDateTime.now()).setReceivingTime(LocalDateTime.now());
+            TradeOrderItemDO tradeOrderItemDO = tradeOrderItemMapper.selectOne(new LambdaQueryWrapperX<TradeOrderItemDO>()
+                    .eq(TradeOrderItemDO::getOrderId, order.getId())
+            );
+            tradeOrderItemDO.setDistributeBenefit(true);
+            tradeOrderItemMapper.updateById(tradeOrderItemDO);
+        } 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);
@@ -399,13 +418,18 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         //5.发送微信模板消息
         List<String> params = new ArrayList<>();
         params.add(order.getNo());
-        params.add(deliveryExpressService.getDeliveryNameById(order.getLogisticsId()));
-        params.add(order.getLogisticsNo());
+        if (deliveryReqVO.getAttachment() != null) {
+            params.add("无");
+            params.add("-");
+        }else{
+            params.add(deliveryExpressService.getDeliveryNameById(order.getLogisticsId()));
+            params.add(order.getLogisticsNo());
+        }
         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());
     }
 
     /**
@@ -420,7 +444,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
 
         // 设置订阅参数,包括回调URL和手机号
         SubscribeParameters subscribeParameters = new SubscribeParameters();
-        subscribeParameters.setCallbackurl("http://47.107.28.221:8001/admin-api/trade/order/callBackUrl?orderId="+order.getId());
+        subscribeParameters.setCallbackurl("http://47.107.28.221:8001/admin-api/trade/order/callBackUrl?orderId=" + order.getId());
         subscribeParameters.setPhone(order.getReceiverMobile());
         //添加盐
         subscribeParameters.setSalt(order.getLogisticsNo());
@@ -447,13 +471,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         String returnCode = jsonObject.get("returnCode").getAsString();
 
         if (result && returnCode.equals("200")) {
-            log.info("订单号:{}:订阅成功",order.getNo());
+            log.info("订单号:{}:订阅成功", order.getNo());
 
             order.setSubscriptionLogisticsInfo(TradeOrderSubscribeStatusEnum.SUBSCRIBE.getStatus());
-        } else if(returnCode.equals("600") || returnCode.equals("601")) {
+        } else if (returnCode.equals("600") || returnCode.equals("601")) {
             throw exception(NOT_SUFFICIENT_FUNDS);
         } else {
-            log.info("订单号:{}:订阅失败原因:{}",order.getNo(),jsonObject);
+            log.info("订单号:{}:订阅失败原因:{}", order.getNo(), jsonObject);
 
             order.setSubscriptionLogisticsInfo(TradeOrderSubscribeStatusEnum.abnormal.getStatus());
         }

+ 3 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java

@@ -59,6 +59,9 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
             calculateByPickUp(param);
         } else if (DeliveryTypeEnum.EXPRESS.getType().equals(param.getDeliveryType())) {
             calculateExpress(param, result);
+        } else if (DeliveryTypeEnum.VIRTUAL_PRODUCT.getType().equals(param.getDeliveryType())) {
+            // 虚拟商品不需要计算运费
+            calculateByPickUp(param);
         }
     }
 

+ 27 - 34
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/utils/wechat/WcChatMessageUtils.java

@@ -27,9 +27,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.UUID;
 
-import static cn.newfeifan.mall.module.system.constant.SystemConstants.SYSTEM_WX_ACCESS_TOKEN;
-import static cn.newfeifan.mall.module.trade.enums.MessageTemplateConstants.AFTER_SALE_NO_CHECK_List;
-import static cn.newfeifan.mall.module.trade.enums.MessageTemplateConstants.ORDER_NO_DELIVERY_List;
+import static cn.newfeifan.mall.module.system.constant.SystemConstants.WX_TICK_KEY_APPID;
 
 /**
  * 发送微信消息的工具类
@@ -66,7 +64,7 @@ public class WcChatMessageUtils {
      */
     public String getAccessToken() {
 
-        String accessToken = stringRedisTemplate.opsForValue().get(SYSTEM_WX_ACCESS_TOKEN);
+        String accessToken = stringRedisTemplate.opsForValue().get(WX_TICK_KEY_APPID);
 
         if (StrUtil.isEmpty(accessToken)) {
             // 服务号的appid以及秘钥
@@ -82,9 +80,10 @@ public class WcChatMessageUtils {
 
             //微信的accessToken的失效时间是两个小时,这里改为一小时五十五分钟,怕双方的时间误差导致accessToken失效
             long expireTime = 60 * 60 + 55 * 60; // 1小时55分钟转换为秒
-            stringRedisTemplate.opsForValue().set(SYSTEM_WX_ACCESS_TOKEN, accessToken, expireTime, java.util.concurrent.TimeUnit.SECONDS);
+            stringRedisTemplate.opsForValue().set(WX_TICK_KEY_APPID, accessToken, expireTime, java.util.concurrent.TimeUnit.SECONDS);
         }
 
+        log.info("===========Access_token:{}", accessToken);
 
         return accessToken;
     }
@@ -99,9 +98,9 @@ public class WcChatMessageUtils {
     private void sendWxgMessage(Long userId, JsonObject data, String wechatMsgTemplateId, Long systemUserId, Long memberUserId, Long objectId) {
 
         // 组装消息内容
-        String userOpenId = null;
-        if (wechatMsgTemplateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_NO_CHECK.getTemplateId()) ||
-                wechatMsgTemplateId.equals(WcChatMessageTemplateIdEnum.ORDER_NO_DELIVERY.getTemplateId())) {
+        String userOpenId;
+        if (wechatMsgTemplateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_NO_CHECK2.getTemplateId()) ||
+                wechatMsgTemplateId.equals(WcChatMessageTemplateIdEnum.ORDER_NO_DELIVERY2.getTemplateId())) {
             userOpenId = getOpenIdBySysTemUserId(systemUserId);
         } else {
             userOpenId = getOpenId(userId);
@@ -113,7 +112,7 @@ public class WcChatMessageUtils {
         }
 
         String templateId = getTemplateId(wechatMsgTemplateId).getWechatMsgTemplateId(); // 模板id
-        String url = getDoMain(wechatMsgTemplateId, objectId);       // 跳转路径(小程序之外)
+        String url = getDoMain(wechatMsgTemplateId, objectId, memberUserId);       // 跳转路径(小程序之外)
         String client_msg_id = UUID.randomUUID().toString();  // 防重入id
 
 
@@ -124,6 +123,10 @@ public class WcChatMessageUtils {
         message.setClient_msg_id(client_msg_id);
         message.setData(data);
 
+        sendWecChatMessage(userId, wechatMsgTemplateId, systemUserId, memberUserId, objectId, message, userOpenId ,1);
+    }
+
+    private void sendWecChatMessage(Long userId, String wechatMsgTemplateId, Long systemUserId, Long memberUserId, Long objectId, WeChatTemplateMessage message, String userOpenId, int maxRetries) {
         // 发送消息
         String returnMsg = HttpUtil.post(StrUtil.format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={}", getAccessToken()), message.toString());
         cn.hutool.json.JSONObject jsonObject2 = JSONUtil.parseObj(returnMsg);
@@ -148,6 +151,13 @@ public class WcChatMessageUtils {
         }
 
         messageLogService.createMessageLog(messageLogSaveReqVO);
+
+        // 如果微信的accessToken失效,则重新获取,最多重试3次
+        if (jsonObject2.getStr("errcode").equals("40001") && maxRetries <= 3) {
+            maxRetries++;
+            stringRedisTemplate.delete(WX_TICK_KEY_APPID);
+            sendWecChatMessage(userId, wechatMsgTemplateId, systemUserId, memberUserId, objectId, message, userOpenId, maxRetries);
+        }
     }
 
     /**
@@ -200,42 +210,25 @@ public class WcChatMessageUtils {
         sendWxgMessage(userId, templateData, templateId, systemUserId, memberUserId, objectId);
     }
 
-    /**
-     * 判断用户是否有接收者调消息的权限
-     *
-     * @param userId     用户id
-     * @param templateId 自定义的模板id
-     * @return 是否有权限
-     */
-    public Boolean isHavePermission(Long userId, String templateId) {
-        if (templateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_NO_CHECK.getTemplateId())) {
-            // 售后待审核
-            return permissionService.hasAnyPermissions(userId, AFTER_SALE_NO_CHECK_List);
-        } else if (templateId.equals(WcChatMessageTemplateIdEnum.ORDER_NO_DELIVERY.getTemplateId())) {
-            // 订单待发货
-            return permissionService.hasAnyPermissions(userId, ORDER_NO_DELIVERY_List);
-        }
-        return false;
-    }
-
     /**
      * 获取不同端域名(不同的端的代码略有不同)
      *
      * @param templateId 自定义模板id
      * @return 域名加路径
      */
-    public String getDoMain(String templateId, Long objectId) {
+    public String getDoMain(String templateId, Long objectId, Long memberUserId) {
         SystemConfigDO redisConfig = configService.getRedisConfig();
-        if (templateId.equals(WcChatMessageTemplateIdEnum.ORDER_DELIVERY.getTemplateId())) {
+        String username = memberUserService.getUsernameByUserId(memberUserId);
+        if (templateId.equals(WcChatMessageTemplateIdEnum.ORDER_DELIVERY2.getTemplateId())) {
             //订单已发货
-            return redisConfig.getMallDomain() + "/#/pages/order/detail?id=" + objectId;
-        } else if (templateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_CHECK.getTemplateId())) {
+            return redisConfig.getMallDomain() + "/#/pages/order/detail?id=" + objectId + "&username=" + username;
+        } else if (templateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_CHECK2.getTemplateId())) {
             //售后订单审核完成
-            return redisConfig.getMallDomain() + "/#/pages/order/aftersale/detail?id=" + objectId;
-        } else if (templateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_NO_CHECK.getTemplateId())) {
+            return redisConfig.getMallDomain() + "/#/pages/order/aftersale/detail?id=" + objectId + "&username=" + username;
+        } else if (templateId.equals(WcChatMessageTemplateIdEnum.AFTER_SALE_NO_CHECK2.getTemplateId())) {
             //售后订单待审核
             return redisConfig.getMerchantDomain() + "/after-sale";
-        } else if (templateId.equals(WcChatMessageTemplateIdEnum.ORDER_NO_DELIVERY.getTemplateId())) {
+        } else if (templateId.equals(WcChatMessageTemplateIdEnum.ORDER_NO_DELIVERY2.getTemplateId())) {
             //订单待发货
             return redisConfig.getMerchantDomain() + "/order";
         }

+ 4 - 7
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/dal/dataobject/user/MemberUserDO.java

@@ -20,7 +20,6 @@ import java.util.List;
 
 /**
  * 会员用户 DO
- *
  * uk_mobile 索引:基于 {@link #mobile} 字段
  *
  * @author 非繁源码
@@ -47,13 +46,11 @@ public class MemberUserDO extends TenantBaseDO {
     private String mobile;
     /**
      * 加密后的密码
-     *
      * 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐
      */
     private String password;
     /**
      * 帐号状态
-     *
      * 枚举 {@link CommonStatusEnum}
      */
     private Integer status;
@@ -92,7 +89,6 @@ public class MemberUserDO extends TenantBaseDO {
     private String name;
     /**
      * 性别
-     *
      * 枚举 {@link SexEnum}
      */
     private Integer sex;
@@ -102,7 +98,6 @@ public class MemberUserDO extends TenantBaseDO {
     private LocalDateTime birthday;
     /**
      * 所在地
-     *
      * 关联 {@link Area#getId()} 字段
      */
     private Integer areaId;
@@ -127,7 +122,6 @@ public class MemberUserDO extends TenantBaseDO {
 
     /**
      * 会员级别编号
-     *
      * 关联 {@link MemberLevelDO#getId()} 字段
      */
     private Long levelId;
@@ -137,7 +131,6 @@ public class MemberUserDO extends TenantBaseDO {
     private Integer experience;
     /**
      * 用户分组编号
-     *
      * 关联 {@link MemberGroupDO#getId()} 字段
      */
     private Long groupId;
@@ -192,4 +185,8 @@ public class MemberUserDO extends TenantBaseDO {
      * 关联系统用户ID
      */
     private Long systemUsersId;
+    /**
+     * 登录用的用户名
+     */
+    private String username;
 }

+ 3 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/dal/mysql/user/MemberUserMapper.java

@@ -95,4 +95,7 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
         return update(null, lambdaUpdateWrapper);
     }
 
+    default List<MemberUserDO> selectListByMobile(String mobile){
+        return selectList(MemberUserDO::getMobile,mobile);
+    }
 }

+ 7 - 0
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserService.java

@@ -190,4 +190,11 @@ public interface MemberUserService {
     void updateUserByMobile(Long id, String mobile);
 
     Long getUserIdBySystemUserId(Long systemUserId);
+
+    /**
+     * 根据用户ID获取用户名
+     * @param userId 用户ID
+     * @return 用户名
+     */
+    String getUsernameByUserId(Long userId);
 }

+ 16 - 4
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserServiceImpl.java

@@ -316,13 +316,17 @@ public class MemberUserServiceImpl implements MemberUserService {
 
     @Override
     public void updateUserByMobile(Long systemUserId, String mobile) {
-        if(StrUtil.isEmpty(mobile)){
+        if (StrUtil.isEmpty(mobile)) {
             return;
         }
 
-        MemberUserDO memberUserDO = memberUserMapper.selectByMobile(mobile);
-        memberUserDO.setSystemUsersId(systemUserId);
-        memberUserMapper.updateById(memberUserDO);
+        List<MemberUserDO> memberUserDOS = memberUserMapper.selectListByMobile(mobile);
+        if (!memberUserDOS.isEmpty()) {
+            for (MemberUserDO memberUserDO : memberUserDOS) {
+                memberUserDO.setSystemUsersId(systemUserId);
+                memberUserMapper.updateById(memberUserDO);
+            }
+        }
     }
 
     @Override
@@ -331,4 +335,12 @@ public class MemberUserServiceImpl implements MemberUserService {
         return memberUserDO == null ? null : memberUserDO.getId();
     }
 
+    @Override
+    public String getUsernameByUserId(Long userId) {
+        if(userId != null){
+            return memberUserMapper.selectOne(MemberUserDO::getId, userId).getUsername();
+        }
+        return null;
+    }
+
 }

+ 4 - 0
feifan-module-system/feifan-module-system-api/src/main/java/cn/newfeifan/mall/module/system/constant/SystemConstants.java

@@ -1,8 +1,12 @@
 package cn.newfeifan.mall.module.system.constant;
 
 public class SystemConstants {
+    //现在用不上了(非繁科技)
     public static final String SYSTEM_WX_ACCESS_TOKEN = "system:wx:access_token";
 
+    //常来此购的公众
+    public static final String WX_TICK_KEY_APPID = "wechat:access_token";
+
     public static final String SYSTEM_WX_MESSAGE_TEMPLATE = "system:wx:message:template:";
 
     public static final String SYSTEM_CONFIG = "system:config";

+ 2 - 2
feifan-module-system/feifan-module-system-biz/src/main/resources/mapper/social/SocialUserMapper.xml

@@ -5,6 +5,6 @@
     <select id="getOpenIdByUserId" resultType="string" parameterType="long">
         SELECT openid FROM `system_social_user` u
         left join system_social_user_bind b on u.id = b.social_user_id
-        where b.user_id = #{userId}
+        where b.user_id = #{userId} and b.deleted = 0
     </select>
-</mapper>
+</mapper>

+ 5 - 2
feifan-server/src/main/resources/application-prod.yaml

@@ -182,8 +182,11 @@ wx:
   mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
 #    app-id: wx041349c6f39b268b # 测试号(牛希尧提供的)
 #    secret: 5abee519483bc9f8cb37ce280e814bd0
-    app-id: wx917c16ecb85e8fb8 # 测试号(自己的)
-    secret: e6be2d75ba7dc0f3d833469645062b79
+    #    app-id: wx917c16ecb85e8fb8 # 测试号(自己的)
+    #    secret: e6be2d75ba7dc0f3d833469645062b79
+
+    app-id: wxe133514440a8829d # 常来此购(客户的)
+    secret: 4f99fb0f90ebf12807887bf1aa26d8e9
 #    app-id: wxa69ab825b163be19 # 测试号(Kongdy 提供的)
 #    secret: bd4f9fab889591b62aeac0d7b8d8b4a0
     # 存储配置,解决 AccessToken 的跨节点的共享

+ 1 - 1
feifan-server/src/main/resources/application.yaml

@@ -250,7 +250,7 @@ feifan:
     end-code: 9999 # 这里配置 9999 的原因是,测试方便。
   trade:
     order:
-      app-id: 1 # 商户编号
+      app-id: 9 # 商户编号
       pay-expire-time: 2h # 支付的过期时间
       receive-expire-time: 14d # 收货的过期时间
       comment-expire-time: 7d # 评论的过期时间