Browse Source

复用商品详情admin/goodinfo接口

wufeng 2 years ago
parent
commit
89797f0e15
3 changed files with 125 additions and 2 deletions
  1. 122 0
      app/abutment/controller/Good.php
  2. 2 2
      app/abutment/controller/Order.php
  3. 1 0
      app/abutment/route/app.php

+ 122 - 0
app/abutment/controller/Good.php

@@ -1716,5 +1716,127 @@ class Good extends BaseController
 
     }
 
+    //商品详情
+    public function info(){
+
+        $this->post = $this->request->filter('trim')->post();
+        $skucode=isset($this->post['skuCode'])&&$this->post['skuCode']!=""?trim($this->post['skuCode']):"";
+        if($skucode==""){
+            return json_show(1005,"参数skuCode不能为空");
+        }
+        $good_platform = Db::name("good_platform")->where(['skuCode'=>$skucode,"is_del"=>0])->find();
+        if($good_platform==false){
+            return json_show(1004,"未找到商品数据");
+        }
+        $data = Db::name("good")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->find();
+        if($data==false){
+            return json_show(1004,"未找到商品数据");
+        }
+        $plat =Db::name("platform")->where(["id"=>$good_platform['platform_code']])->find();
+        $data['skuCode']=$good_platform['skuCode'];
+        $data['platform_code']=$good_platform['id'];
+        $data['platform_code_en']=isset($plat['platform_code'])?$plat['platform_code']:"";
+        $data['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:"";
+        $data['online_reason']=$good_platform['online_reason'];
+        $data['online_time']=$good_platform['online_time'];
+        $data['online_remark']=$good_platform['online_remark'];
+        $data['exam_status']=$good_platform['exam_status'];
+        $data['is_online']=$good_platform['is_online'];
+        $data['plat_code']=$good_platform['plat_code'];
+        $data['exclusive']=makeExcluse($data['is_exclusive']);
+        $unit =Db::name("unit")->where(["id"=>$data['good_unit']])->find();
+        $data['unit'] = isset($unit['unit'])?$unit['unit']:'';
+        $data['cat_info'] = made($data['cat_id'],[]);
+        $spec = Db::name("good_spec")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->select()->toArray();
+        $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
+        $data['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
+        $data['noble_name']=isset($data['noble_metal'])&&$data['noble_metal']!=0?$this->noble[$data['noble_metal']] :"";
+        $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
+        $data['company'] = isset($company['company'])?$company['company']:"";
+        if($data['brand_id']!=0){
+            $brand=Db::name("brand")->where(["id"=>$data['brand_id']])->find();
+            $data["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
+        }else{
+            $data["brand_name"]="";
+            $data["brand_id"]="";
+        }
+        $data['origin_place_cn']="";
+        $data['delivery_place_cn']="";
+        if($data['delivery_place']!==""){
+            $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
+            list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$data['delivery_place']);
+            $data['delivery_place_cn']=GetAddr(json_encode($place));
+        }
+        if($data['origin_place']!==""){
+            $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
+            list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$data['origin_place']);
+            $data['origin_place_cn']=GetAddr(json_encode($place));
+        }
+        $excluse = makeExcluse($data['is_exclusive']);
+        $data['exclusive']=$excluse;
+        $data["good_info_img"]=$data['good_info_img']!=""? $data['good_info_img']:[];
+        $data["good_img"]=$data['good_img']!=""? $data['good_img']:[];
+        $speclist=[];
+        if(!empty($spec)){
+            foreach ($spec as $value){
+                $temp=[];
+                $temp['id']=$value['id'];
+                $temp['spuCode']=$value['spuCode'];
+                $temp['spec_id']=$value['spec_id'];
+                $temp['spec_value_id']=$value['spec_value_id'];
+                $temp['is_del']=$value['is_del'];
+                $sp = Db::name("specs")->where(["id"=>$value['spec_id']])->find();
+                $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
+                $spv = Db::name("spec_value")->where(["id"=>$value['spec_value_id']])->find();
+                $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
+                $speclist[]=$temp;
+            }
+        }
+        $data["speclist"]=empty($speclist)?[]:$speclist;
+        $ladder = Db::name("good_ladder")->where(['skuCode'=>$skucode,"is_del"=>0])->select()->toArray();
+        $data["ladderlist"]=!empty($ladder)?$ladder:[];
+        $nakelist = Db::name("good_nake")->where(['spuCode'=>$good_platform['spuCode'],"is_del"=>0])->select()->toArray();
+//        $catinfo = Db::name("cat")->where(["id"=>$data['cat_id']])->find();
+
+        $cat_top_list = $data['cat_info'];
+        $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
+        // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
+        $gold_price=0;
+        if ($data['is_gold_price']==1 && $cat_top_id==6) {
+            $gold_price = Db::name("gold_price1")->where(["type" => $data['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->value('price', 0);
+        }
+        $data['gold_price'] =$gold_price;
+        $nakearry=[];
+        if(!empty($nakelist)){
+
+            //实时金价
+            foreach ($nakelist as $value){
+                $value['sale_price'] =$value['nake_total'];
+
+                //计算最终售价
+                if ($data['is_gold_price']==1 && $cat_top_id==6) {
+                    //普通商品:直接用财务提交的售价字段;
+                    //贵金属( 商品重量* 最新金价 + 工艺费(财务定价提交的)* 商品重量+包装费+加标费+证书费+产品裸价+其他费用)=商品库商品直接下单的售价
+                    $value['sale_price'] = ($data['weight'] * $gold_price + $value['cost_fee'] * $data['weight'] + $value['package_fee'] + $value['mark_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['other_fee']);
+                }
+                $nakearry[] = $value;
+            }
+        }
+        $proof =Db::name("good_proof")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
+        $data['proof'] = isset($proof)&&$proof!=false? $proof:[];
+        $data["nakelist"]=$nakearry;
+
+        //补充采购员字段
+        //成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
+        $temp_basic_info = Db::name('good_basic')
+            ->field('id,createrid purchase_id,creater purchase')
+            ->where(['spuCode'=>$data['spuCode'],'is_del'=>0])
+            ->find();
+        $data['purchase_id'] = $temp_basic_info['purchase_id'];
+        $data['purchase'] = $temp_basic_info['purchase'];
+
+        return json_show(0,"获取成功",$data);
+    }
+
 
 }

+ 2 - 2
app/abutment/controller/Order.php

@@ -415,7 +415,7 @@ class Order extends BaseController
     public function add()
     {
 
-        $param = $this->request->filter('trim')->post('cgdNo');
+        $param = $this->request->filter('trim')->only(['cgdNo'], 'post');
 
         $val = Validate::rule(['cgdNo|订单编号' => 'require|array|max:100']);
 
@@ -546,7 +546,7 @@ class Order extends BaseController
 
                 if ($win) {
                     $sto = ["order_code" => $wsm_in_code, "status" => $status, "action_remark" => '', "action_type" => "edit"];
-                    ActionLog::logAdd(['id' => $this->request->user['uid'], 'nickname' => $this->request->user['nickname']], $sto, "RKD", $status, $this->post);
+                    ActionLog::logAdd(['id' => $this->request->user['uid'], 'nickname' => $this->request->user['nickname']], $sto, "RKD", $status, $this->request->filter('trim')->post());
                     $process = ["order_code" => $wsm_in_code, "order_id" => $win, "order_status" => $status, "order_type" => 'RKD', "before_status" => $status];
                     ProcessOrder::AddProcess(['id' => $this->request->user['uid'], 'nickname' => $this->request->user['nickname']], $process);
 //                    $order = ["order_code" => $cgdNo, "status" => $cgdinfo['status'], "action_remark" => '', "action_type" => "edit"];

+ 1 - 0
app/abutment/route/app.php

@@ -38,6 +38,7 @@ route::rule('catList', 'abutment/Good/wlist');//分类列表
 route::rule('catListTitle', 'abutment/Good/title');//分类列表-全部
 route::rule('checkIsUpdate', 'abutment/Good/checkIsUpdate');//判断是否允许修改成本信息和基础信息
 route::rule('goodCopy', 'abutment/Good/copy');//上线商品复制
+route::rule('goodInfo', 'abutment/Good/info');//商品详情
 
 //销售订单(采销的采购单)
 route::rule('getOrderList', 'abutment/Order/getList');//列表