Преглед изворни кода

API-下单-如果养老金单独设置开关开启,则养老金采用针对下单的商品规格单独设置的值pension进行分配养老金

sunxbiao пре 5 месеци
родитељ
комит
064a1c66fe

+ 9 - 1
app/common/repositories/store/order/StoreGroupOrderRepository.php

@@ -40,6 +40,7 @@ use app\entity\data\store\StoreProductEntity;
40 40
 use app\entity\data\user\UserAddressEntity;
41 41
 use app\entity\data\user\UserEntity;
42 42
 use app\entity\monomer\store\FzonePayTypeEntity;
43
+use app\entity\monomer\store\StoreOrderPensionJsonEntity;
43 44
 use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
44 45
 use think\db\exception\DbException;
45 46
 use think\exception\ValidateException;
@@ -795,7 +796,14 @@ class StoreGroupOrderRepository extends BaseRepository
795 796
                 ->setDouhuomall(empty($productEntity->getSpuId()) ? StoreOrderEnum::DOHUOMALL['PlatformOrder']['code'] : StoreOrderEnum::DOHUOMALL['SupplyChainOrder']['code'])
796 797
                 ->setDouhuomallStatus(empty($productEntity->getSpuId()) ? null : StoreOrderEnum::DOHUOMALL_STATUS['NotSubmittedToWeiweiBao']['code'])
797 798
                 ->setFzonePaytype($storeOrderCreateRequestEntity->getFzonePayType())
798
-                ->setConPri($serviceMoney);
799
+                ->setConPri($serviceMoney)
800
+                ->setPensionJson(
801
+                    StoreOrderPensionJsonEntity::newInstance()
802
+                        ->setPensionIs($productEntity->getPensionIs())
803
+                        ->setPension($productEntity->getPension())
804
+                        ->setAttrValuePensionNum($productAttrValueEntity->getPensionNum())
805
+                        ->toArray()
806
+                );
799 807
             $storeOrderEntityList[] = $storeOrderEntity;
800 808
         }
801 809
 

+ 15 - 2
app/common/repositories/store/order/StoreOrderRepository.php

@@ -102,6 +102,7 @@ use app\entity\data\user\UserAddressEntity;
102 102
 use app\entity\data\user\UserBillEntity;
103 103
 use app\entity\data\user\UserEntity;
104 104
 use app\entity\monomer\store\FzonePayTypeEntity;
105
+use app\entity\monomer\store\StoreOrderPensionJsonEntity;
105 106
 use app\entity\request\api\store\order\CalculatePostageRequestEntity;
106 107
 use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
107 108
 use app\model\common\JdOrderModel;
@@ -11086,6 +11087,14 @@ class StoreOrderRepository extends BaseRepository
11086 11087
         /** @var StoreOrderRepository $storeOrderRepository */
11087 11088
         $storeOrderRepository = app()->make(StoreOrderRepository::class);
11088 11089
         $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId($orderId);
11090
+        $storeOrderPensionJsonEntity = StoreOrderPensionJsonEntity::newInstance();
11091
+        $yanglaojin = null;
11092
+        if (!empty($storeOrderEntity->getPensionJson()) && is_array($storeOrderEntity->getPensionJson())) {
11093
+            // 当有商品单独设置养老金比例时,下单时,会将该商品 规格内 单独设置的养老金比例 保存下来,该养老金比例 是根据商品售价来计算的
11094
+            $storeOrderPensionJsonEntity = StoreOrderPensionJsonEntity::newInstance($storeOrderEntity->getPensionJson());
11095
+            $pensionProportion = bcdiv((string)$storeOrderPensionJsonEntity->getAttrValuePensionNum(), '100', CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11096
+            $yanglaojin = bcmul((string)$storeOrderEntity->getTotalPrice(), $pensionProportion, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11097
+        }
11089 11098
 
11090 11099
         /** @var UserRepository $userRepository */
11091 11100
         $userRepository = app()->make(UserRepository::class);
@@ -11101,7 +11110,9 @@ class StoreOrderRepository extends BaseRepository
11101 11110
         // 精彩生活区
11102 11111
         if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['WonderfulLiving']['code']) {
11103 11112
             // 为消费者 初始化 添加养老金记录
11104
-            $yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11113
+            if (is_null($yanglaojin)) {
11114
+                $yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11115
+            }
11105 11116
             /** @var UserBillRepository $userBillRepository */
11106 11117
             $userBillRepository = app()->make(UserBillRepository::class);
11107 11118
             $userBillRepository->addUserBill(
@@ -11616,7 +11627,9 @@ class StoreOrderRepository extends BaseRepository
11616 11627
             }
11617 11628
 
11618 11629
             // 为消费者 初始化 添加养老金记录
11619
-            $yanglaojin = bcmul($storeOrderEntity->getTotalPrice(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11630
+            if (is_null($yanglaojin)) {
11631
+                $yanglaojin = bcmul($storeOrderEntity->getTotalPrice(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11632
+            }
11620 11633
             /** @var UserBillRepository $userBillRepository */
11621 11634
             $userBillRepository = app()->make(UserBillRepository::class);
11622 11635
             $userBillRepository->addUserBill(

+ 25 - 0
app/entity/data/store/StoreOrderEntity.php

@@ -99,6 +99,7 @@ class StoreOrderEntity extends DataEntity
99 99
     public $fzonePayOther = null;  // 组合支付other
100 100
     public $fzonePayNote = null;  // 组合支付备注
101 101
     public $fzonePayType = null;
102
+    public $pensionJson = null; // 养老金设置(将当前商品的养老金分配设置保存一份)
102 103
 
103 104
     /**
104 105
      * @return mixed
@@ -1746,6 +1747,30 @@ class StoreOrderEntity extends DataEntity
1746 1747
         return $this;
1747 1748
     }
1748 1749
 
1750
+    /**
1751
+     * @return mixed
1752
+     */
1753
+    public function getPensionJson()
1754
+    {
1755
+        if (is_json($this->pensionJson)) {
1756
+            return json_decode($this->pensionJson, true);
1757
+        }
1758
+        return $this->pensionJson;
1759
+    }
1760
+
1761
+    /**
1762
+     * @param mixed $pensionJson
1763
+     * @return StoreOrderEntity
1764
+     */
1765
+    public function setPensionJson($pensionJson): StoreOrderEntity
1766
+    {
1767
+        if (is_array($pensionJson)) {
1768
+            $pensionJson = json_encode($pensionJson, JSON_UNESCAPED_UNICODE);
1769
+        }
1770
+        $this->pensionJson = $pensionJson;
1771
+        return $this;
1772
+    }
1773
+
1749 1774
     public function deconstructionFzonePaytype()
1750 1775
     {
1751 1776
         if (!empty($this->getFzonePayType()) && is_array(json_decode($this->getFzonePayType(), true))) {

+ 2 - 2
app/entity/monomer/store/FzonePayTypeEntity.php

@@ -2,9 +2,9 @@
2 2
 
3 3
 namespace app\entity\monomer\store;
4 4
 
5
-use app\entity\data\DataEntity;
5
+use app\entity\monomer\MonomerEntity;
6 6
 
7
-class FzonePayTypeEntity extends DataEntity
7
+class FzonePayTypeEntity extends MonomerEntity
8 8
 {
9 9
     public $type = '';
10 10
     public $price = 0.00;

+ 66 - 0
app/entity/monomer/store/StoreOrderPensionJsonEntity.php

@@ -0,0 +1,66 @@
1
+<?php
2
+
3
+namespace app\entity\monomer\store;
4
+
5
+use app\entity\monomer\MonomerEntity;
6
+
7
+class StoreOrderPensionJsonEntity extends MonomerEntity
8
+{
9
+    public $pensionIs = 0; // 是否 单独设置百分比
10
+    public $pension = 0.00; // 商品外部展示的要老金数据
11
+    public $attrValuePensionNum = 0.00; // 针对每个规格设置的 该规格养老金分配比例
12
+
13
+    /**
14
+     * @return int
15
+     */
16
+    public function getPensionIs(): int
17
+    {
18
+        return $this->pensionIs;
19
+    }
20
+
21
+    /**
22
+     * @param mixed $pensionIs
23
+     * @return StoreOrderPensionJsonEntity
24
+     */
25
+    public function setPensionIs($pensionIs): StoreOrderPensionJsonEntity
26
+    {
27
+        $this->pensionIs = (int)$pensionIs;
28
+        return $this;
29
+    }
30
+
31
+    /**
32
+     * @return float
33
+     */
34
+    public function getPension(): float
35
+    {
36
+        return $this->pension;
37
+    }
38
+
39
+    /**
40
+     * @param mixed $pension
41
+     * @return StoreOrderPensionJsonEntity
42
+     */
43
+    public function setPension($pension): StoreOrderPensionJsonEntity
44
+    {
45
+        $this->pension = (float)$pension;
46
+        return $this;
47
+    }
48
+
49
+    /**
50
+     * @return float
51
+     */
52
+    public function getAttrValuePensionNum(): float
53
+    {
54
+        return $this->attrValuePensionNum;
55
+    }
56
+
57
+    /**
58
+     * @param mixed $attrValuePensionNum
59
+     * @return StoreOrderPensionJsonEntity
60
+     */
61
+    public function setAttrValuePensionNum($attrValuePensionNum): StoreOrderPensionJsonEntity
62
+    {
63
+        $this->attrValuePensionNum = (float)$attrValuePensionNum;
64
+        return $this;
65
+    }
66
+}