Browse Source

售后优化新生成的采购单的价格

wufeng 2 years ago
parent
commit
bb592ab001

+ 2 - 2
app/admin/controller/After.php

@@ -1329,7 +1329,7 @@ class After extends Base
             "spuCode" => $spuCode,
             "skuCode" => $skuCode,
 //            "good_name" => $ct['good_name'],
-            "sale_price" => $old_cgd['good_price'],
+//            "sale_price" => $old_cgd['good_price'],//采购单价格不为0,取原采购单的价格
             "total_fee" => $old_cgd['good_price'] * $good_num,
 //            "pakge_fee" => isset($origin['package_fee']) ? $origin['package_fee'] : 0,
 //            "cert_fee" => isset($origin['cert_fee']) ? $origin['cert_fee'] : 0,
@@ -1668,7 +1668,7 @@ class After extends Base
             "skuCode" => $skuCode,
             "orderCode" => $orderCode,
 //            "good_name"=>$zxinfo['good_name'],
-            "sale_price" => $old_cgd['good_price'],
+//            "sale_price" => $old_cgd['good_price'],//采购单价格不为0,取原采购单的价格
             "total_fee"=>round($old_cgd['good_price']* $good_num, 2),
 //            "pakge_fee"=>$zxinfo['pakge_fee'],
 //            "cert_fee"=>$zxinfo['cert_fee'],

+ 156 - 0
app/admin/controller/Good.php

@@ -112,6 +112,162 @@ class Good extends Base
         $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
         if ($company_name !== "") $where[] = ["a.createrid", 'in', get_company_item_user_by_name($company_name)];
 
+//        if(!empty($role['platform']) ){
+//            $where[]=["b.platform_code","in",$role['platform']];
+//        }
+        $count = Db::name('good')->alias("a")->leftJoin("good_platform b","a.spuCode=b.spuCode")->where($where)
+            ->count();
+        $total = ceil($count / $size);
+        $page = $page >= $total ? $total : $page;
+        $list = Db::name('good')
+            ->alias("a")
+            ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,a.good_info_img,a.good_thumb_img,b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,b.creater,b.addtime,b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,u.itemid")//成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
+            ->leftJoin("good_platform b","a.spuCode=b.spuCode")
+//            ->leftJoin("good_basic gb","gb.spuCode=a.spuCode")
+            ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
+            ->where($where)
+            ->page($page,$size)
+            ->order("b.addtime desc")
+            ->cursor();
+        $data=[];
+        foreach ($list as $value){
+            $value['cat_info']= made($value['cat_id'],[]);
+            $platform = Db::name("platform")->where(["id"=>$value['platform_code']])->find();
+            $value['platform_name'] = isset($platform['platform_name']) ? $platform['platform_name']:"";
+            $value['platform_code_en'] = isset($platform['platform_code_en']) ? $platform['platform_code_en']:"";
+            $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
+            $value['supplier_name'] = isset($supplier['name']) ? $supplier['name']:"";
+            $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
+            $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
+            $unit = Db::name("unit")->where(["id"=>$value['good_unit']])->find();
+            $value['unit'] =isset($unit['unit'])?$unit['unit']:"";
+            $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find();
+            $value['company'] = isset($company['company'])?$company['company']:"";
+            $value['stock_total'] = Db::name("good_stock")->where(['spuCode'=>$value['spuCode'],"is_del"=>0])->sum("usable_stock");
+            $value['status']=$value['exam_status'];
+            $value['exclusive']=makeExcluse($value['is_exclusive']);
+//            $value['good_info_img']=$value['good_info_img'];
+//            $value['good_img']=$value['good_img'];
+            $spec = Db::name("good_spec")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->select()->toArray();
+            $speclist=[];
+            if(!empty($spec)){
+                foreach ($spec as $val){
+                    $temp=[];
+                    $temp['spec_id']=$val['spec_id'];
+                    $temp['spec_value_id']=$val['spec_value_id'];
+                    $sp = Db::name("specs")->where(["id"=>$val['spec_id']])->find();
+                    $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
+                    $spv = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->find();
+                    $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
+                    $speclist[]=$temp;
+                }
+            }
+            $value['specinfo']=$speclist;
+            $value['noble_name']=isset($value['noble_metal'])&&$value['noble_metal']!=0?$this->noble[$value['noble_metal']] :"";
+            $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
+            $data[]=$value;
+        }
+        return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
+    }
+
+    //获取跟有赞对接的平台所属的商品上线信息
+    public function listByYz(){
+
+        $param = $this->request->only([
+            'page'=>1,
+            'size'=>10,
+            'cat_id'=>'',
+            'good_name'=>'',
+            'skucode'=>'',
+            'spucode'=>'',
+            'start'=>'',
+            'end'=>'',
+            ''=>'',
+            ''=>'',
+        ],'post','trim');
+//        $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
+//        $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
+        $where =[["a.is_del","=",0]];
+//        $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] !=="" ? trim($this->post['cat_id']):"";
+        if($param['cat_id']!=="") $where[]=['a.cat_id',"=",$param['cat_id']];
+
+//        $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
+        if($param['good_name']!=="") $where[]=['a.good_name','like','%'.$param['good_name'].'%'];
+
+//        $skucode = isset($this->post['skucode']) && $this->post['skucode'] !=="" ? trim($this->post['skucode']):"";
+        if($param['skucode']!=='') $where [] = ['b.skucode','like','%'.$param['skucode'].'%'];
+
+//        $spucode = isset($this->post['spucode']) && $this->post['spucode'] !=="" ? trim($this->post['spucode']):"";
+        if($param['spucode']!=='') $where [] = ['b.spucode','like','%'.$param['spucode'].'%'];
+
+//        $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
+        if($param['start']!=='') $where[]=['b.addtime','>=',date('Y-m-d H:i:s',strtotime($param['start']))];
+
+        $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
+        if($end!==""){
+            $where[]=['b.addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
+        }
+        $is_stock = isset($this->post['is_stock']) && $this->post['is_stock'] !=="" ? intval($this->post['is_stock'])
+            :"";
+        if($is_stock!==""){
+            $where[]=['a.is_stock',"=",$is_stock];
+        }
+        $good_type = isset($this->post['good_type']) && $this->post['good_type'] !=="" ? intval($this->post['good_type'])
+            :"";
+        if($good_type!==""){
+            $where[]=['a.good_type',"=",$good_type];
+        }
+        $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !=="" ? trim($this->post['supplierNo'])
+            :"";
+        if($supplierNo!==""){
+            $where[]=['a.supplierNo',"=",$supplierNo];
+        }
+        $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) :"";
+        if($companyNo!==""){
+            $where[]=['a.companyNo',"like","%$companyNo%"];
+        }
+        $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
+        if($creater!==""){
+            $where[]=['a.creater',"like","%$creater%"];
+        }
+        $createrid = isset($this->post['createrid']) && $this->post['createrid'] !=="" ? intval($this->post['createrid']):"";
+        if($createrid!==""){
+            $where[]=['a.createrid',"=",$createrid];
+        }
+        $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status'])
+            :"";
+        if($status!==""){
+            $where[]=['a.status',"=",$status];
+        }
+        $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code'])
+            :"";
+        if($platform_code!==""){
+            //$platform = Db::name("good_platform")->where(["platform_code"=>$platform_code,"is_del"=>0])->column
+            //("spuCode");
+            $where[]=["platform_code","=",$platform_code];
+        }
+        $plat_code = isset($this->post['plat_code']) && $this->post['plat_code'] !=="" ? trim($this->post['plat_code'])
+            :"";
+        if($plat_code!==""){
+            $where[]=["b.plat_code","like","%$plat_code%"];
+        }
+        $exam_status = isset($this->post['exam_status']) && $this->post['exam_status'] !=="" ? intval($this->post['exam_status'])
+            :"";
+        if($exam_status!==""){
+            $where[]=['b.exam_status',"=",$exam_status];
+        }
+        $brand_id = isset($this->post['brand_id']) && $this->post['brand_id'] !=="" ? intval($this->post['brand_id'])
+            :"";
+        if($brand_id!==""){
+            $where[]=['a.brand_id',"=",$brand_id];
+        }
+        $role=$this->checkRole();
+        if(!empty($role['write']) ){
+            $where[]=["a.createrid","in",$role['write']];
+        }
+        $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
+        if ($company_name !== "") $where[] = ["a.createrid", 'in', get_company_item_user_by_name($company_name)];
+
 //        if(!empty($role['platform']) ){
 //            $where[]=["b.platform_code","in",$role['platform']];
 //        }

+ 2 - 2
app/admin/controller/Report.php

@@ -91,7 +91,7 @@ class Report extends Base
         $where_ladder = [['gl.is_del', '=', 0]];
         $where_good = [['g.is_del', '=', 0]];
         if (!empty($param['start_date']) && !empty($param['end_date'])) {
-            $where_ladder[] = ['gp.online_time', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
+            $where_ladder[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
             $where_good[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
         }
         if (!empty($param['platform_id'])) {
@@ -112,7 +112,7 @@ class Report extends Base
             ->where($where_ladder)
             ->leftJoin('good_platform gp', 'gp.skuCode=gl.skuCode')
             ->leftJoin('good g', 'g.spuCode=gp.spuCode')
-            ->order('gl.id')
+            ->order('g.id')
             ->select()
             ->toArray();
 

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

@@ -166,6 +166,7 @@ Route::rule("area","admin/Addr/area");
 Route::rule("addrall","admin/Addr/all");
 
 Route::rule("goodlist","admin/Good/list");
+Route::rule("goodlistByYz","admin/Good/listByYz");
 Route::rule("goodwarn","admin/Good/SetWarn");
 Route::rule("goodstatus","admin/Good/SetStatus");
 Route::rule("goodstat","admin/Good/Stat");//库存概况