Эх сурвалжийг харах

升级时标准价格为0

theo 3 жил өмнө
parent
commit
0bdc2aaa26

+ 15 - 0
common/models/forms/ApproachDeclarationUpgradeForm.php

@@ -59,6 +59,8 @@ class ApproachDeclarationUpgradeForm extends Model
     private $_decAmount;
     private $_decPv;
     private $_orderGoods;
+    private $_standardAmount;
+    private $_decAmountStandard;
     
     const TYPE_ZC = 'ZC';
     private $_userForm = null;
@@ -151,12 +153,16 @@ class ApproachDeclarationUpgradeForm extends Model
             } else {
                 $ids = $this->goodsId;
                 $totalAmount = 0;
+                $totalAmountStandard = 0;
                 $totalPv = 0;
+                $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
                         $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                         if($goods['STORE_NUMS']>0){
                             $totalAmount += $goods['SELL_PRICE'] * intval($v);
+                            $totalAmountStandard += $goods['SELL_PRICE_STANDARD'] * intval($v);
+                            $realPriceStandard = $goods['SELL_PRICE_STANDARD'];
                             $totalPv += $goods['PRICE_PV'] * intval($v);
                             $this->_orderGoods[] = [
                                 'GOODS_ID' => $goods['ID'],
@@ -169,6 +175,9 @@ class ApproachDeclarationUpgradeForm extends Model
                                 'SKU_CODE' => $goods['GOODS_NO'],
                                 'GOODS_TITLE' => $goods['GOODS_NAME'],
                                 'EMAIL' => Info::getUserEmailByUserId(\Yii::$app->user->id) ?? '',
+                                'STANDARD_PRICE' => $goods['SELL_PRICE_STANDARD'],
+                                'REAL_STANDARD_PRICE' => $realPriceStandard,
+                                'EXCHANGE_RATE' => $exchangeRate,
                                 'TAX_RATE' => $goods['TAX_RATE'],
                             ];
                         }
@@ -189,6 +198,8 @@ class ApproachDeclarationUpgradeForm extends Model
                 }
                 $this->_decAmount = $totalAmount;
                 $this->_decPv = $totalPv;
+                $this->_decAmountStandard = $totalAmountStandard;
+                $this->_standardAmount = $this->_decAmountStandard;
             }
 
             $baseInfo = Info::baseInfoZhByUserName($this->insertUserName);
@@ -252,6 +263,7 @@ class ApproachDeclarationUpgradeForm extends Model
                 throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
             }
 
+            $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
             $orderModel = new ApproachOrder();
             $orderModel->SN = 'OS' . $ord;
             $orderModel->DEC_SN = 'DS' . $ord;
@@ -279,6 +291,9 @@ class ApproachDeclarationUpgradeForm extends Model
             $orderModel->CREATED_AT = Date::nowTime();
             $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
             $orderModel->EMAIL = Info::getUserEmailByUserId(\Yii::$app->user->id) ?? '';
+            $orderModel->ORDER_AMOUNT_STANDARD = $this->_decAmountStandard;
+            $orderModel->PAY_AMOUNT_STANDARD = $this->_standardAmount;
+            $orderModel->EXCHANGE_RATE = $exchangeRate;
             if(!$orderModel->save()){
                 $transaction->rollBack();
                 throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));

+ 15 - 0
common/models/forms/DeclarationUpgradeForm.php

@@ -55,6 +55,8 @@ class DeclarationUpgradeForm extends Model
     private $_decAmount;
     private $_decPv;
     private $_orderGoods;
+    private $_standardAmount;
+    private $_decAmountStandard;
     
     const TYPE_ZC = 'ZC';
     private $_userForm = null;
@@ -149,12 +151,16 @@ class DeclarationUpgradeForm extends Model
             } else {
                 $ids = $this->goodsId;
                 $totalAmount = 0;
+                $totalAmountStandard = 0;
                 $totalPv = 0;
+                $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
                         $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                         if($goods['STORE_NUMS']>0){
                             $totalAmount += $goods['SELL_PRICE'] * intval($v);
+                            $totalAmountStandard += $goods['SELL_PRICE_STANDARD'] * intval($v);
+                            $realPriceStandard = $goods['SELL_PRICE_STANDARD'];
                             $totalPv += $goods['PRICE_PV'] * intval($v);
                             $this->_orderGoods[] = [
                                 'GOODS_ID' => $goods['ID'],
@@ -167,6 +173,9 @@ class DeclarationUpgradeForm extends Model
                                 'SKU_CODE' => $goods['GOODS_NO'],
                                 'GOODS_TITLE' => $goods['GOODS_NAME'],
                                 'EMAIL' => Info::getUserEmailByUserId(\Yii::$app->user->id) ?? '',
+                                'STANDARD_PRICE' => $goods['SELL_PRICE_STANDARD'],
+                                'REAL_STANDARD_PRICE' => $realPriceStandard,
+                                'EXCHANGE_RATE' => $exchangeRate,
                                 'TAX_RATE' => $goods['TAX_RATE'],
                             ];
                         }
@@ -187,6 +196,8 @@ class DeclarationUpgradeForm extends Model
                 }
                 $this->_decAmount = $totalAmount;
                 $this->_decPv = $totalPv;
+                $this->_decAmountStandard = $totalAmountStandard;
+                $this->_standardAmount = $this->_decAmountStandard;
             }
             //看现金余额是否充足
             if (Cash::getAvailableBalance($loginUserId) < $this->_decAmount){
@@ -249,6 +260,7 @@ class DeclarationUpgradeForm extends Model
                 throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
             }
 
+            $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
             $orderModel = new Order();
             $orderModel->SN = 'OS'.$ord;
             $orderModel->DEC_SN = 'DS'.$ord;
@@ -277,6 +289,9 @@ class DeclarationUpgradeForm extends Model
             $orderModel->STATUS = 1;
             $orderModel->CREATED_AT = Date::nowTime();
             $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
+            $orderModel->ORDER_AMOUNT_STANDARD = $this->_decAmountStandard;
+            $orderModel->PAY_AMOUNT_STANDARD = $this->_standardAmount;
+            $orderModel->EXCHANGE_RATE = $exchangeRate;
             if(!$orderModel->save()){
                 $transaction->rollBack();
                 throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));