Bläddra i källkod

创建订单-创建订单奖励,修改PV的获取比例

sunxbiao 5 månader sedan
förälder
incheckning
94252bc072

+ 24 - 0
app/common/dao/shared/SharedProsperityRecommendConfigDao.php

@@ -79,4 +79,28 @@ class SharedProsperityRecommendConfigDao extends BaseDao
79 79
         }
80 80
         return $entityList;
81 81
     }
82
+
83
+    /**
84
+     * 获取 配置实体 根据 最大的 直推奖比例
85
+     * @return SharedProsperityRecommendConfigEntity
86
+     */
87
+    public function getSharedProsperityRecommendConfigEntityByMaxRewardRatio(): SharedProsperityRecommendConfigEntity
88
+    {
89
+        $entity = SharedProsperityRecommendConfigEntity::newInstance();
90
+        try {
91
+            /** @var SharedProsperityRecommendConfig $model */
92
+            $model = $this->getModel();
93
+            $dataRes = $model::getDB()
94
+                ->order('reward_ratio', 'desc')
95
+                ->limit(1)
96
+                ->select()
97
+                ->toArray();
98
+            if (!empty($dataRes)) {
99
+                $entity = SharedProsperityRecommendConfigEntity::newInstance($dataRes[0]);
100
+            }
101
+        } catch (\Exception $e) {
102
+
103
+        }
104
+        return $entity;
105
+    }
82 106
 }

+ 0 - 3
app/common/enum/CommonEnum.php

@@ -262,9 +262,6 @@ class CommonEnum
262 262
                 'YangLaoJin' => [
263 263
                     'Ratio' => ['code' => 0.05, 'name' => '将订单消费金额的5%,当做养老金分配给下单人']
264 264
                 ],
265
-                'Pv' => [
266
-                    'Ratio' => ['code' => 1, 'name' => '将利润的100%,作为PV值分配给下单人']
267
-                ],
268 265
                 'ConsumerStocks' => [
269 266
                     'Ratio' => ['code' => 0.5, 'name' => '在共富区消费者获得购买商品赠送商品额50%的消费股']
270 267
                 ],

+ 10 - 0
app/common/repositories/shared/SharedProsperityRecommendConfigRepository.php

@@ -98,4 +98,14 @@ class SharedProsperityRecommendConfigRepository extends BaseRepository
98 98
     {
99 99
         return $this->dao->getSharedProsperityRecommendConfigEntityListByLevelList($levelList);
100 100
     }
101
+
102
+
103
+    /**
104
+     * 获取 最大 推荐奖励占比
105
+     * @return SharedProsperityRecommendConfigEntity
106
+     */
107
+    public function getSharedProsperityRecommendConfigEntityByMaxRewardRatio(): SharedProsperityRecommendConfigEntity
108
+    {
109
+        return $this->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
110
+    }
101 111
 }

+ 7 - 1
app/common/repositories/store/order/StoreOrderRepository.php

@@ -11616,7 +11616,13 @@ class StoreOrderRepository extends BaseRepository
11616 11616
             );
11617 11617
 
11618 11618
             // 发放共富区PV
11619
-            $pv = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['Pv']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11619
+            /** @var SharedProsperityRecommendConfigRepository $sharedProsperityRecommendConfigRepository */
11620
+            $sharedProsperityRecommendConfigRepository = app()->make(SharedProsperityRecommendConfigRepository::class);
11621
+            $sharedProsperityRecommendConfigEntityByMaxRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
11622
+            // 利润 减去 顶格的直推奖,剩下的是PV值
11623
+            $pvProportion = bcsub('1', bcdiv($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(), '100', 4), 2);
11624
+
11625
+            $pv = bcmul($storeOrderEntity->getConPri(), $pvProportion, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11620 11626
             /** @var SharedProsperityRewardRecordRepository $sharedProsperityRewardRecordRepository */
11621 11627
             $sharedProsperityRewardRecordRepository = app()->make(SharedProsperityRewardRecordRepository::class);
11622 11628
             $sharedProsperityRewardRecordRepository->addSharedProsperityRewardRecord(