wugg 3 år sedan
förälder
incheckning
01dcf79066
2 ändrade filer med 59 tillägg och 0 borttagningar
  1. 45 0
      app/admin/controller/Consult.php
  2. 14 0
      app/common.php

+ 45 - 0
app/admin/controller/Consult.php

@@ -698,6 +698,28 @@ class Consult extends BaseController
             $info["brand_name"]="";
             $info["brand_id"]="";
         }
+        $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
+        $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
+        $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
+        $god=[
+            "metal_id"=>$info['metal_id'],
+            "weight"=>$info["weight"],
+            "demo_fee"=>$info["demo_fee"],
+            "delivery_fee"=>$info["delivery_fee"],
+            "open_fee"=>$info["open_fee"],
+            "packing_fee"=>$info["pakge_fee"],
+            "mark_fee"=>$info["mark_fee"],
+            "nake_fee"=>$info["nake_fee"],
+            "cert_fee"=>$info["cert_fee"],
+            "cost_fee"=>$info["cost_fee"],
+            "num"=>$bidinfo["num"],
+        ];
+        if($info['is_gold_price']==1){
+            $price = GoldPrice($god, $budget/100);
+        }else{
+            $price = GoodPrice($god, $budget/100);
+        }
+        $info['sale_price'] =round($price,2);
         $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
         $info['bargain'] =$bargain;
         return app_show(0,"获取成功",$info);
@@ -852,6 +874,8 @@ class Consult extends BaseController
         $list =Db::name('consult_bids')->where($where)->page($page,$size)->select();
         $data=[];
         foreach ($list as $value){
+            $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
+
             $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
             $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
             $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
@@ -864,6 +888,27 @@ class Consult extends BaseController
                 $value["brand_name"]="";
                 $value["brand_id"]="";
             }
+            $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
+            $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
+                $god=[
+                    "metal_id"=>$value['metal_id'],
+                    "weight"=>$value["weight"],
+                    "demo_fee"=>$value["demo_fee"],
+                    "delivery_fee"=>$value["delivery_fee"],
+                    "open_fee"=>$value["open_fee"],
+                    "packing_fee"=>$value["pakge_fee"],
+                    "mark_fee"=>$value["mark_fee"],
+                    "nake_fee"=>$value["nake_fee"],
+                    "cert_fee"=>$value["cert_fee"],
+                    "cost_fee"=>$value["cost_fee"],
+                    "num"=>$bidinfo["num"],
+                ];
+            if($value['is_gold_price']==1){
+                $price = GoldPrice($god, $budget/100);
+            }else{
+                $price = GoodPrice($god, $budget/100);
+            }
+            $value['sale_price'] =round($price,2);
             $data[]=$value;
         }
         return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);

+ 14 - 0
app/common.php

@@ -654,4 +654,18 @@ function post2($url,$data,$header=[])
     return $output;
 }
 
+function GoldPrice($data,$cost_rate=0){
+    $gold = Db::name("gold_price1")->where(["type"=>$data["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
+        ->find();
+    $rate = $data['open_fee']/$data['num'] + $data['weight']* $gold["price"] + $data['cost_fee']/(1-$cost_rate) *
+        $data['weight']+$data['packing_fee']+$data["mark_fee"]+$data["cert_fee"]+$data['nake_fee'];
+    return $rate;
+}
+
+function GoodPrice($data,$cost_rate=0){
+    $rate = ($data['open_fee']/$data['num']+ $data['cost_fee']+$data['packing_fee']+$data["mark_fee"]+$data["cert_fee"]+$data['nake_fee'])/(1-$cost_rate
+        );
+    return $rate;
+}
+