Browse Source

Merge branch 'master' of http://10.0.5.229:10880/Harper/feifan-backend-zx-app into dev/2024/0428/update-app

Yangzw 6 months ago
parent
commit
be8bcaa7a5

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

@@ -411,6 +411,32 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
     @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE)
     public TradeOrderDO createOrder(Long userId, AppTradeOrderCreateReqVO createReqVO) {
 
+        //校验最大值 start  add by Ben
+        //查询订单提成比例
+        QueryWrapper<OrderPercentageDO> queryWrapper = new QueryWrapper<>();
+        OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectOne(queryWrapper);//表中只有一条记录
+        /**
+         * 毛利 = 成本 * 0.38... (推广费用)
+         */
+        String grossProfitPerc = orderPercentageDO.getGrossProfitPerc();
+        float grossProfitPercFloat = Float.parseFloat(grossProfitPerc);
+        if(grossProfitPercFloat>1){
+            throw new RuntimeException("商品毛利值,占利润比例异常,达到"+grossProfitPerc+"!!");
+        }
+
+
+        /**
+         * 购物本人自得 百分比
+         */
+        String grossProfitUserQuotaPerc = orderPercentageDO.getGrossProfitUserQuotaPerc();
+        float grossProfitUserQuotaPercFloat = Float.parseFloat(grossProfitUserQuotaPerc);
+        if(grossProfitUserQuotaPercFloat>0.5){
+            throw new RuntimeException("消费本人获得积分,占毛利比例异常,达到"+grossProfitUserQuotaPerc+"!!");
+        }
+
+        //校验最大值 end
+
+
         // add by Ben 20240314
         // 4. 查询每个sku对应的店铺ID,并传回页面
         List<AppTradeOrderSettlementReqVO.Item> productSkuList = createReqVO.getItems();
@@ -606,70 +632,70 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
             }
         }
 
-        boolean caculateFreezeAmount = false;//增加冻结积分
+//        boolean caculateFreezeAmount = false;//增加冻结积分
 
         //增加冻结积分这分部分,是订单微信支付成功后,才执行的,下面的代码只是为了测试方便写在这,实际永远不会执行。add by Ben
-        if(caculateFreezeAmount){
-
-            //下面这部分,应该是写到订单支付成功的地方的,写在下面这里,只是为了方便测试
-            //查询订单提成比例
-            QueryWrapper<OrderPercentageDO> queryWrapper = new QueryWrapper<>();
-            OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectOne(queryWrapper);//表中只有一条记录
-            /**
-             * 毛利 = 成本 * 0.38... (推广费用)
-             */
-            String grossProfitPerc = orderPercentageDO.getGrossProfitPerc();
-            /**
-             * 推广-推荐人额度 百分比
-             */
-            String grossProfitAncestorQuotaPerc = orderPercentageDO.getGrossProfitAncestorQuotaPerc();
-
-            for(Map<String,Object> m:orderMapList){
-                TradeOrderDO order = (TradeOrderDO)(m.get("order"));
-
-                List<Long> skuList = new ArrayList<>();
-                //汇总各订单项利润
-                List<TradeOrderItemDO> TradeOrderItemList = tradeOrderItemMapper.selectList("order_id", order.getId());
-                for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
-                    Long skuId = tradeOrderItemDO.getSkuId();
-                    skuList.add(skuId);
-                }
-
-                List<ProductSkuDO> productSkuDOS = productSkuMapper.selectBatchIds(skuList);
-                Map<Long,ProductSkuDO> skuDOMap = new HashMap<Long,ProductSkuDO>();
-                for (ProductSkuDO productSkuDO : productSkuDOS) {
-                    skuDOMap.put(productSkuDO.getId(),productSkuDO);
-                }
-
-                Long totalFreezeAmount = 0l;//总冻结积分
-                for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
-                    ProductSkuDO productSkuDO = skuDOMap.get(tradeOrderItemDO.getSkuId());
-                    //这类商品的总推广费
-                    Integer promotionExpenses = (productSkuDO.getPrice()-productSkuDO.getCostPrice())
-                            *tradeOrderItemDO.getCount();
-
-                    //把商品项的推广费,转换为这项商品直推人获得的冻结积分
-                    Long itemFreezeAmount =
-                            promotionExpenses2GrossProfitAncestorQuota(promotionExpenses,
-                                    grossProfitPerc,//毛利 = 成本 * 0.38... (推广费用)
-                                    grossProfitAncestorQuotaPerc//推广-推荐人额度 百分比
-                            );
-
-                    //记录用户在此订单项获得的冻结积分
-                    TradeOrderItemDO toid = new TradeOrderItemDO();
-                    toid.setId(tradeOrderItemDO.getId());
-                    toid.setIncreaseIntegral(itemFreezeAmount);
-                    tradeOrderItemMapper.updateById(toid);
-
-                    totalFreezeAmount+=itemFreezeAmount;
-                }
-
-                Long tradeOrderId = order.getId();
-                String OrderNum =order.getNo();
-                integralService.updateUserIntegral(userId, CaclEnum.ORDER_PAY_INTEGRAL, payPoints*(-1),totalFreezeAmount,tradeOrderId,OrderNum);
-            }
+//        if(caculateFreezeAmount){
+//
+//            //下面这部分,应该是写到订单支付成功的地方的,写在下面这里,只是为了方便测试
+//            //查询订单提成比例
+//            QueryWrapper<OrderPercentageDO> queryWrapper = new QueryWrapper<>();
+//            OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectOne(queryWrapper);//表中只有一条记录
+//            /**
+//             * 毛利 = 成本 * 0.38... (推广费用)
+//             */
+//            String grossProfitPerc = orderPercentageDO.getGrossProfitPerc();
+//            /**
+//             * 推广-推荐人额度 百分比
+//             */
+//            String grossProfitAncestorQuotaPerc = orderPercentageDO.getGrossProfitAncestorQuotaPerc();
+//
+//            for(Map<String,Object> m:orderMapList){
+//                TradeOrderDO order = (TradeOrderDO)(m.get("order"));
+//
+//                List<Long> skuList = new ArrayList<>();
+//                //汇总各订单项利润
+//                List<TradeOrderItemDO> TradeOrderItemList = tradeOrderItemMapper.selectList("order_id", order.getId());
+//                for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
+//                    Long skuId = tradeOrderItemDO.getSkuId();
+//                    skuList.add(skuId);
+//                }
+//
+//                List<ProductSkuDO> productSkuDOS = productSkuMapper.selectBatchIds(skuList);
+//                Map<Long,ProductSkuDO> skuDOMap = new HashMap<Long,ProductSkuDO>();
+//                for (ProductSkuDO productSkuDO : productSkuDOS) {
+//                    skuDOMap.put(productSkuDO.getId(),productSkuDO);
+//                }
+//
+//                Long totalFreezeAmount = 0l;//总冻结积分
+//                for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
+//                    ProductSkuDO productSkuDO = skuDOMap.get(tradeOrderItemDO.getSkuId());
+//                    //这类商品的总推广费
+//                    Integer promotionExpenses = (productSkuDO.getPrice()-productSkuDO.getCostPrice())
+//                            *tradeOrderItemDO.getCount();
+//
+//                    //把商品项的推广费,转换为这项商品直推人获得的冻结积分
+//                    Long itemFreezeAmount =
+//                            promotionExpenses2GrossProfitAncestorQuota(promotionExpenses,
+//                                    grossProfitPerc,//毛利 = 成本 * 0.38... (推广费用)
+//                                    grossProfitAncestorQuotaPerc//推广-推荐人额度 百分比
+//                            );
+//
+//                    //记录用户在此订单项获得的冻结积分
+//                    TradeOrderItemDO toid = new TradeOrderItemDO();
+//                    toid.setId(tradeOrderItemDO.getId());
+//                    toid.setIncreaseIntegral(itemFreezeAmount);
+//                    tradeOrderItemMapper.updateById(toid);
+//
+//                    totalFreezeAmount+=itemFreezeAmount;
+//                }
+//
+//                Long tradeOrderId = order.getId();
+//                String OrderNum =order.getNo();
+//                integralService.updateUserIntegral(userId, CaclEnum.ORDER_PAY_INTEGRAL, payPoints*(-1),totalFreezeAmount,tradeOrderId,OrderNum);
+//            }
 
-        }
+//        }
 
         return virtualOrder;
     }
@@ -836,8 +862,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
          * 毛利 = 成本 * 0.38... (推广费用)
          */
         String grossProfitPerc = orderPercentageDO.getGrossProfitPerc();
+
+
+
         /**
-         * 推广-推荐人额度 百分比
+         * 购物本人自得 百分比
          */
         String grossProfitUserQuotaPerc = orderPercentageDO.getGrossProfitUserQuotaPerc();