Kaynağa Gözat

fix(merchant): 修复共富区PV计算逻辑

- 添加获取最大分享奖比例的配置查询
- 修改PV比例计算公式,同时考虑直推奖和分享奖
- 新增变量sharPveRate用于存储直推奖和分享奖的比例总和
- 更新注释以反映新的计算逻辑
shichen 2 ay önce
ebeveyn
işleme
16af9201cd

+ 5 - 1
app/common/repositories/store/product/ProductRepository.php

@@ -1088,9 +1088,13 @@ class ProductRepository extends BaseRepository
1088 1088
             // 计算共富区PV
1089 1089
             /** @var SharedProsperityRecommendConfigRepository $sharedProsperityRecommendConfigRepository */
1090 1090
             $sharedProsperityRecommendConfigRepository = app()->make(SharedProsperityRecommendConfigRepository::class);
1091
+            // 共富配置--获取最大的直推奖比例
1091 1092
             $sharedProsperityRecommendConfigEntityByMaxRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
1093
+            // 共富配置--获取最大的分享奖比例
1094
+            $sharedProsperityRecommendConfigEntityByMaxShareRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxShareRatio();
1092 1095
             // 利润 减去 顶格的直推奖,剩下的是PV值
1093
-            $pvProportion = bcsub('1', bcdiv($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(), '100', 4), 2);
1096
+            $sharPveRate = bcadd($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(),$sharedProsperityRecommendConfigEntityByMaxShareRewardRatio->getShareRatio(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
1097
+            $pvProportion = bcsub('1', bcdiv($sharPveRate, '100', 4), 2);
1094 1098
             // 获取利润
1095 1099
             $productSku = Db::name('store_product_attr_value')->where('product_id', $res['product_id'])->order('price asc')->find();
1096 1100
             // 计算pv

+ 5 - 1
app/common/repositories/system/merchant/MerchantRepository.php

@@ -511,9 +511,13 @@ class MerchantRepository extends BaseRepository
511 511
                 // 计算共富区PV
512 512
                 /** @var SharedProsperityRecommendConfigRepository $sharedProsperityRecommendConfigRepository */
513 513
                 $sharedProsperityRecommendConfigRepository = app()->make(SharedProsperityRecommendConfigRepository::class);
514
+                // 共富配置---获取最大推荐奖
514 515
                 $sharedProsperityRecommendConfigEntityByMaxRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
516
+                // 共富配置--获取最大的分享奖比例
517
+                $sharedProsperityRecommendConfigEntityByMaxShareRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxShareRatio();
515 518
                 // 利润 减去 顶格的直推奖,剩下的是PV值
516
-                $pvProportion = bcsub('1', bcdiv($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(), '100', 4), 2);
519
+                $sharPveRate = bcadd($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(),$sharedProsperityRecommendConfigEntityByMaxShareRewardRatio->getShareRatio(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
520
+                $pvProportion = bcsub('1', bcdiv($sharPveRate, '100', 4), 2);
517 521
                 // 获取利润
518 522
                 $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
519 523
                 // 计算pv