xxxrrrdddd 2 năm trước cách đây
mục cha
commit
0b5ebee9f2

+ 3 - 3
application/admin/view/process/fast.html

@@ -76,10 +76,10 @@
     {for start="0" end='5' name='a'}
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:$a==0?'快车详细设置':''}</label>
-        <div class="col-xs-12 col-sm-4">
+        <div class="col-xs-24">
             <input type="text" name="fast[detail][{$a}][start_kilo]" class="short" value="{$price.fast.detail[$a]['start_kilo']}"/>公里 -
-            <input type="text" name="fast[detail][{$a}][end_kilo]" class="short" value="{$price.fast.detail[$a]['end_kilo']}"/>公里,每公里
-            <input type="text" name="fast[detail][{$a}][amount]" class="short" value="{$price.fast.detail[$a]['amount']}"/>元
+            <input type="text" name="fast[detail][{$a}][end_kilo]" class="short" value="{$price.fast.detail[$a]['end_kilo']}"/>公里,计算公式
+            <input type="text" name="fast[detail][{$a}][amount]" style="width: 300px;" value="{$price.fast.detail[$a]['amount']}"/><span style="color: red;">请勿中文输入法下输入</span>
         </div>
     </div>
     {/for}

+ 3 - 3
application/index/controller/Index.php

@@ -4,6 +4,7 @@ namespace app\index\controller;
 
 use app\common\controller\Frontend;
 use app\common\model\UserOrder;
+use app\service\UserOrderService;
 use think\helper\Str;
 
 class Index extends Frontend
@@ -17,8 +18,7 @@ class Index extends Frontend
     {
         return $this->view->fetch();
     }
-    public function test(){
-        $order=UserOrder::find();
-        dd($order->sender_order);
+    public function test(UserOrderService $orderService){
+        dd($orderService->fast());
     }
 }

+ 7 - 7
application/service/UserOrderService.php

@@ -224,22 +224,22 @@ class UserOrderService{
         return $this->order;
     }
 
-    protected function fast(){
+    public function fast(){
         #距离
-        $distance=$this->order['distance'];
+        $distance=$this->order['distance']??401;
         $start_kilo=$this->config['fast']['start_kilo'];
         $start_amount=$this->config['fast']['start_amount'];
         if($distance<=$start_kilo){
             $distance_price=$start_amount;
         }else{
-            $out_price=$start_amount;
-            foreach ($this->config['fast']['detail'] as $detail){
-                if($distance>=$detail['start_kilo'] && $distance<$detail['end_kilo']){
-                    $out_price=bcadd($out_price,bcmul($detail['amount'],$distance));
+            $distance_price=0;
+            foreach ($this->config['fast']['detail'] as $k=>$detail){
+                if($distance>$detail['start_kilo'] && $distance<=$detail['end_kilo']){
+                    $calc=str_replace('距离数',$distance,$detail['amount']);
+                    $distance_price=eval("return $calc;");
                     break;
                 }
             }
-            $distance_price=$out_price;
         }
         #笼子百分比算出运费
         $cage_float=$this->cage_spec['per']/100;