kevin_zhangl 3 лет назад
Родитель
Сommit
e7056fa4c0

+ 0 - 3
.gitignore

@@ -23,6 +23,3 @@ vendor
 frontendApi/web/pdfs/
 #composer.json
 composer.lock
-
-frontendApi/web/index.php
-backendApi/web/index.php

+ 0 - 1
backendApi/web/.gitignore

@@ -3,4 +3,3 @@
 upload
 /upload/excelExport
 /upload/excel_export
-index.php

+ 8 - 1
common/models/forms/ApproachOrderForm.php

@@ -376,9 +376,16 @@ class ApproachOrderForm extends Model
             }
         }
 
+        // 汇率
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
+        // 运费.美元转奈拉
+        $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
+        // 普通商品免运费阈值.美元转奈拉
+        $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
+
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
-        $this->_freight = ($totalAmount>=300) ? 0 : 15;
+        $this->_freight = ($totalAmount >= $freeShipping) ? 0 : $freight;
         if($this->_address['PROVINCE']==1){
             $this->_freight = 0;
         }

+ 9 - 1
common/models/forms/OrderForm.php

@@ -483,9 +483,17 @@ class OrderForm extends Model
                 }
             }
         }
+
+        // 汇率
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
+        // 运费.美元转奈拉
+        $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
+        // 普通商品免运费阈值.美元转奈拉
+        $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
+
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
-        $this->_freight = ($totalAmount>=300) ? 0 : 15;
+        $this->_freight = ($totalAmount >= $freeShipping) ? 0 : $freight;
         if($this->_address['PROVINCE']==1){
             $this->_freight = 0;
         }

+ 10 - 0
frontendApi/modules/v1/controllers/ShopController.php

@@ -9,6 +9,7 @@
 namespace frontendApi\modules\v1\controllers;
 
 use Codeception\PHPUnit\ResultPrinter\HTML;
+use common\helpers\Cache;
 use common\helpers\Date;
 use common\helpers\Form;
 use common\helpers\LoggerTool;
@@ -119,12 +120,21 @@ class ShopController extends BaseController {
             $userBalance['cash'] = $userCashResult['CASH'];
         }
 
+        // 汇率
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
+        // 运费.奈拉
+        $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
+        // 普通商品免运费阈值.奈拉
+        $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
+
         return static::notice(
             [
                 'payList'=>$payList,
                 'allAddress'=>$allAddress,
                 'userBalance'=>$userBalance,
                 'sellType' => ShopGoods::CATEGORY_TYPE,
+                'freight' => $freight,
+                'freeShipping' => $freeShipping,
             ]);
     }
 

+ 0 - 1
frontendApi/web/.gitignore

@@ -1,3 +1,2 @@
 /index-test.php
 /test.php
-index.php

+ 46 - 28
frontendEle/src/views/shop/order.vue

@@ -86,11 +86,19 @@
                   <div class="sum">
                     <div class="sum_box" v-if="category_type === 1">
                         <div>Freight</div><!-- 运费 -->
-                        <div><span v-if="category_type === 1">{{ prefixSign }}</span> {{ payType === "cash" ? freight : pointFreight }} <span v-if="category_type === 1">{{ unit }}</span></div>
+                        <div>
+                            <span v-if="category_type === 1">{{ prefixSign }}</span>
+                              {{ pointFreight }}
+                            <span v-if="category_type === 1">{{ unit }}</span>
+                        </div>
                     </div>
                     <div class="sum_box">
                         <div>Amount paid</div><!-- 实付金额 -->
-                        <div><span v-if="category_type === 1">{{ prefixSign }}</span> {{ payType === "cash" ? cashSum : pointsSum }} <span v-if="category_type === 1">{{ unit }}</span></div>
+                        <div>
+                            <span v-if="category_type === 1">{{ prefixSign }}</span>
+                              {{ payType === "cash" ? cashSum : pointsSum }}
+                            <span v-if="category_type === 1">{{ unit }}</span>
+                        </div>
                     </div>
                   </div>
               </div>
@@ -208,6 +216,7 @@
                 cashSum:'',
                 freight:'',
                 pointFreight:'',
+                freeShipping: '',
                 goodsId:'',
                 goodsNum:'',
                 payPassword:'',
@@ -244,10 +253,10 @@
         components: {
             paystack
         },
-        created(){
+        async created(){
             let option= sessionStorage.getItem('order_goods');
             this.category_type = parseInt(sessionStorage.getItem('category_type'))
-            this.getShowCart();
+            await this.getShowCart();
             if(option){
                 let pageGoodsList=JSON.parse(option);
                 // console.log(pageGoodsList);
@@ -272,7 +281,7 @@
                     })
                 }
 
-                this.getSumMoney();
+                await this.getSumMoney();
             }
         },
         computed: {
@@ -289,10 +298,13 @@
             cancelOrder(){
               history.go(-1)
             },
-            setFreight(){
-              if(this.addressId=='100000000000000000'){//如果地址为自提,则运费为0
-                this.pointFreight = this.freight = 0;
-              }
+            setFreight() {
+                //如果地址为自提,则运费为0
+                if (this.addressId == '100000000000000000') {
+                    this.pointFreight = Number(0)
+                } else {
+                    this.pointFreight = Number(this.freight)
+                }
             },
             getSummaries(param) {
               const { columns, data } = param;
@@ -420,12 +432,13 @@
 
                 // 只有普通商品有运费
                 if (this.category_type === 1) {
-                    if(payAmount>=300){
-                        this.pointFreight = this.freight = 0;
-                    }else{
-                        this.pointFreight = this.freight = 15;
-                    }
+                    // 商品自提,免运费
                     this.setFreight();
+                    // 商品总价大于预定值,免运费
+                    this.pointFreight = (this.pointFreight > 0) ? ((payAmount >= this.freeShipping) ? 0 : this.freight) : 0
+                } else {
+                    // 非普通商品,没有运费
+                    this.pointFreight = 0
                 }
                 // if(payPointAmount>=300){
                 //     this.pointFreight = 0;
@@ -435,32 +448,35 @@
                 //console.log('points_plus_sum',points_plus_sum);
                 //console.log('cash_plus_sum',cash_plus_sum);
                 // this.pointsSum=tool.formatPrice(tool.sum(points_plus_sum) + this.pointFreight);
-              this.pointsSum = this.cashSum = this.form.amount = tool.formatPrice(tool.sum(cash_plus_sum) + this.freight) ;
+              this.pointsSum = this.cashSum = this.form.amount = tool.formatPrice(tool.sum(cash_plus_sum) + this.pointFreight) ;
             },
-            getShowCart(){
-                network.getData('shop/show-cart', { categoryType: this.categoryType })
-                .then(response => {
+            async getShowCart() {
+                await network.getData('shop/show-cart', {categoryType: this.categoryType}).then(response => {
                     this.loading = false
                     // 收货地址
                     this.all_address = response.allAddress;
-                    this.all_address.map((item,index)=>{
-                        if(item.IS_DEFAULT==1){
-                            this.addressId = item.ID
-                        }
+                    this.all_address.map((item, index) => {
+                      if (item.IS_DEFAULT == 1) {
+                        this.addressId = item.ID
+                      }
                     })
                     // 账户
                     this.balance = response.userBalance
 
                     // 支付方式
                     for (let item of response.sellType) {
-                        if (item.id === this.category_type) {
-                            this.payList = item.sell_type
-                            break
-                        }
+                      if (item.id === this.category_type) {
+                        this.payList = item.sell_type
+                        break
+                      }
                     }
 
                     // 支付方式的第一项默认选中
                     this.payType = Object.values(this.payList)[0]['label']
+                    // 免运费阈值
+                    this.freeShipping = response.freeShipping
+                    // 运费
+                    this.freight = response.freight
                 })
             },
             // 切换支付方式
@@ -468,7 +484,9 @@
                 this.payType = type
             },
             choseAddress(addressId){
-              this.getSumMoney()
+                this.addressId = addressId
+                this.setFreight()
+                this.getSumMoney()
             },
             // 关闭支付回调
             handleClose() {
@@ -525,7 +543,7 @@
                     }
                 }, 1000)
             },
-        }
+        },
     }
 </script>
 

+ 7 - 0
sql/upgrade/1741.sql

@@ -0,0 +1,7 @@
+-- 增加运费配置
+INSERT INTO `AR_CONFIG` (`CONFIG_NAME`, `TITLE`, `UNIT`, `INPUT_TYPE`, `OPTIONS`, `VALUE`, `TYPE`, `SORT`, `CREATED_AT`, `UPDATED_AT`) VALUES ('freight', '商品运费', '₦', 1, NULL, '1500', 'other', 49, 1521085263, 1637890704);
+
+-- 增加商品免运费阈值配置
+INSERT INTO `AR_CONFIG` (`CONFIG_NAME`, `TITLE`, `UNIT`, `INPUT_TYPE`, `OPTIONS`, `VALUE`, `TYPE`, `SORT`, `CREATED_AT`, `UPDATED_AT`) VALUES ('freeShipping', '商品免运费阈值', '₦', 1, NULL, '150000', 'other', 49, 1521085263, 1637890704);
+
+