xxxrrrdddd 3 年之前
父節點
當前提交
af5f95f05e

+ 5 - 5
application/admin/controller/PetSpec.php

@@ -11,7 +11,7 @@ use app\common\controller\Backend;
  */
 class PetSpec extends Backend
 {
-    
+
     /**
      * PetSpec模型对象
      * @var \app\admin\model\PetSpec
@@ -35,7 +35,7 @@ class PetSpec extends Backend
      * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
-    
+
 
     /**
      * 查看
@@ -54,14 +54,14 @@ class PetSpec extends Backend
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
             $list = $this->model
-                    
+
                     ->where($where)
                     ->order($sort, $order)
                     ->paginate($limit);
 
             foreach ($list as $row) {
-                $row->visible(['id','name','weight','amount']);
-                
+                $row->visible(['id','name','weight','amount','per']);
+
             }
 
             $result = array("total" => $list->total(), "rows" => $list->items());

+ 6 - 0
application/admin/view/pet_spec/add.html

@@ -18,6 +18,12 @@
             <input id="c-amount" class="form-control" name="row[amount]" type="text" data-rule="required;integer">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('计价百分比')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-per" class="form-control" name="row[per]" type="text" data-rule="required;integer">
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 6 - 0
application/admin/view/pet_spec/edit.html

@@ -18,6 +18,12 @@
             <input id="c-amount" class="form-control" name="row[amount]" type="text" data-rule="required;integer" value="{$row.amount|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('计价百分比')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-per" class="form-control" name="row[per]" type="text" data-rule="required;integer" value="{$row.per}">
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 12 - 0
application/admin/view/process/fast.html

@@ -14,6 +14,12 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">多只出港费比例:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input type="text" name="air[out_one_per]" class="short" value="{$price.air.out_one_per|default=''}"/>%
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">上门接送:</label>
         <div class="col-xs-12 col-sm-4">
             起步价<input type="text" name="air[pickup][start_distance]" class="short" value="{$price.air.pickup.start_distance}"/>公里
@@ -52,6 +58,12 @@
             <input type="text" name="fast[start_amount]" class="short" value="{$price.fast.start_amount}"/>元
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">多只价格比例:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input type="text" name="fast[out_one_per]" class="short" value="{$price.fast.out_one_per|default=''}"/>%
+        </div>
+    </div>
     {for start="0" end='5' name='a'}
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:$a==0?'快车详细设置':''}</label>

+ 5 - 5
application/extra/process.php

@@ -1,7 +1,6 @@
 <?php
 return [
-    'air' =>
-        [
+    'air' =>[
             'start_amount' => '',
             'pickup' =>
                 [
@@ -20,13 +19,13 @@ return [
                     'base_weight' => '',
                     'out_amount' => '',
                 ],
+            'out_one_per'=>50,
         ],
     'fast' =>
         [
             'start_kilo' => '',
             'start_amount' => '',
-            'detail' =>
-                [
+            'detail' => [
                     0 =>
                         [
                             'start_kilo' => '',
@@ -58,6 +57,7 @@ return [
                             'amount' => '',
                         ],
                 ],
+            'out_one_per'=>50,
         ],
     'special' =>
         [
@@ -65,4 +65,4 @@ return [
             'start_amount' => '',
             'out_amount' => '',
         ],
-];
+];

+ 21 - 6
application/service/UserOrderService.php

@@ -189,15 +189,17 @@ class UserOrderService{
         #用户折扣
         $level_amount=bcmul($this->user->level_discount,$total_amount);
         $this->order['level_amount']=$level_amount;
+
         #优惠总金额
         $this->order['discount_amount']=bcadd($this->order['coupon_amount'],$this->order['level_amount']);
 
         $this->order['total_amount']=$total_amount;
         $this->order['freights']=$items;
+
+        #先减去用户折扣的
+        $this->order['real_amount']=bcsub($this->order['real_amount'],$level_amount);
         #实付的减去优惠券的
         $this->order['real_amount']=bcsub($this->order['total_amount'],$this->order['coupon_amount']);
-        #实付再减去折扣的
-        $this->order['real_amount']=bcsub($this->order['real_amount'],$level_amount);
 
         #可用的优惠券
         $coupon=[];
@@ -228,11 +230,24 @@ class UserOrderService{
             }
             $distance_price=$out_price;
         }
-        #宠具
+        #笼子百分比算出运费
+        $cage_float=$this->cage_spec['per']/100;
+        $cage_float_price=bcmul($distance_price,$cage_float);
+
+        #宠具+运费
         $cage_price=$this->cage();
-        $total = bcadd($distance_price,$cage_price);
+        $total = bcadd($cage_float_price,$cage_price);
+
+        #件数
+        $num=$this->order['num'];
+        $per=$this->config['fast']['out_one_per'];
+        $out_float=$per/100;
+        $num_price=bcmul(bcmul($out_float,$cage_float_price),$num-1);
+        $total=bcadd($total,$num_price);
 
-        $this->recordLog("专车-起步距离:{$start_kilo},起步价:{$start_amount},距离总价:{$distance_price},宠具价格:{$cage_price},".
+        $this->recordLog("专车-起步距离:{$start_kilo},起步价:{$start_amount},距离总价:{$distance_price},宠具百分比:{$cage_float}," .
+            "笼子百分比算出的运费:{$cage_float_price},宠具价格:{$cage_price},".
+            "只数:{$num},超出百分比:{$this->config['fast']['out_one_per']},超出一只总价:{$num_price}".
             "总价:{$total}"
         );
 
@@ -372,4 +387,4 @@ class UserOrderService{
     {
         $this->log && $this->log->write();
     }
-}
+}

+ 4 - 1
public/assets/js/backend/pet_spec.js

@@ -29,6 +29,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'name', title: __('Name')},
                         {field: 'weight', title: __('Weight')},
                         {field: 'amount', title: __('计价标准')},
+                        {field: 'per', title: __('计价百分比'),formatter(a){
+                            return `${a}%`
+                            }},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
@@ -50,4 +53,4 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         }
     };
     return Controller;
-});
+});