Просмотр исходного кода

feat(merchant): 添加共富区PV发放功能

- 引入SharedProsperityRecommendConfigRepository依赖
- 实现共富区推荐配置的最大奖励比例获取
- 计算PV比例并从利润中扣除直推奖
- 获取产品SKU信息用于利润计算
- 实现PV值计算并添加到订单数据中
- 为特定商户ID 3447的产品分配PV值
shichen месяцев назад: 5
Родитель
Сommit
1d622f0c8d
1 измененных файлов с 13 добавлено и 0 удалено
  1. 13 0
      app/common/repositories/system/merchant/MerchantRepository.php

+ 13 - 0
app/common/repositories/system/merchant/MerchantRepository.php

@@ -15,6 +15,7 @@ use app\common\dao\system\merchant\MerchantDao;
15 15
 use app\common\enum\CommonEnum;
16 16
 use app\common\model\store\product\ProductReply;
17 17
 use app\common\repositories\BaseRepository;
18
+use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
18 19
 use app\common\repositories\store\product\ProductCopyRepository;
19 20
 use app\common\repositories\store\product\ProductRepository;
20 21
 use app\common\repositories\store\shipping\ShippingTemplateRepository;
@@ -505,6 +506,18 @@ class MerchantRepository extends BaseRepository
505 506
             }else if ($productMerId == 3447) {
506 507
                 $yanglao = bcmul($v['price'], CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], 2);
507 508
                 $v['yanglao'] = $yanglao;
509
+
510
+                // 发放共富区PV
511
+                /** @var SharedProsperityRecommendConfigRepository $sharedProsperityRecommendConfigRepository */
512
+                $sharedProsperityRecommendConfigRepository = app()->make(SharedProsperityRecommendConfigRepository::class);
513
+                $sharedProsperityRecommendConfigEntityByMaxRewardRatio = $sharedProsperityRecommendConfigRepository->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
514
+                // 利润 减去 顶格的直推奖,剩下的是PV值
515
+                $pvProportion = bcsub('1', bcdiv($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(), '100', 4), 2);
516
+                // 获取利润
517
+                $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
518
+                // 计算pv
519
+                $pv = bcmul($productSku['plate_mer_profit'], $pvProportion, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
520
+                $v['pv'] = $pv;
508 521
             }
509 522
 
510 523
 //            $v=($v,$k);