|
@@ -115,7 +115,13 @@ class Good extends Base
|
|
|
// 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 = Db::name('good')
|
|
|
+ ->alias("a")
|
|
|
+ ->leftJoin("good_platform b","a.spuCode=b.spuCode")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
|
|
|
+ ->leftJoin("platform p","p.id=b.platform_code")
|
|
|
+ ->where('p.platform_type',0)//只筛选非对接平台的商品
|
|
|
+ ->where($where)
|
|
|
->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
@@ -128,6 +134,8 @@ class Good extends Base
|
|
|
->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")
|
|
|
+ ->leftJoin("platform p","p.id=b.platform_code")
|
|
|
+ ->where('p.platform_type',0)//只筛选非对接平台的商品
|
|
|
->where($where)
|
|
|
->page($page,$size)
|
|
|
->order("b.addtime desc")
|
|
@@ -174,113 +182,109 @@ class Good extends Base
|
|
|
}
|
|
|
|
|
|
//获取跟有赞对接的平台所属的商品上线信息
|
|
|
- public function listByYz(){
|
|
|
-
|
|
|
+ public function listByYz()
|
|
|
+ {
|
|
|
$param = $this->request->only([
|
|
|
- 'page'=>1,
|
|
|
- 'size'=>10,
|
|
|
- 'cat_id'=>'',
|
|
|
- 'good_name'=>'',
|
|
|
- 'skucode'=>'',
|
|
|
- 'spucode'=>'',
|
|
|
- 'start'=>'',
|
|
|
- 'end'=>'',
|
|
|
- 'is_stock'=>'',
|
|
|
- 'good_type'=>'',
|
|
|
- 'supplierNo'=>'',
|
|
|
- 'companyNo'=>'',
|
|
|
- 'creater'=>'',
|
|
|
- 'createrid'=>'',
|
|
|
- 'status'=>'',
|
|
|
- 'platform_code'=>'',
|
|
|
- 'plat_code'=>'',
|
|
|
- 'exam_status'=>'',
|
|
|
- 'brand_id'=>'',
|
|
|
- 'company_name'=>'',
|
|
|
- ],'post','trim');
|
|
|
- $where =[["a.is_del","=",0]];
|
|
|
- if($param['cat_id']!=="") $where[]=['a.cat_id',"=",$param['cat_id']];
|
|
|
- if($param['good_name']!=="") $where[]=['a.good_name','like','%'.$param['good_name'].'%'];
|
|
|
- if($param['skucode']!=='') $where [] = ['b.skucode','like','%'.$param['skucode'].'%'];
|
|
|
- if($param['spucode']!=='') $where [] = ['b.spucode','like','%'.$param['spucode'].'%'];
|
|
|
- if($param['start']!=='') $where[]=['b.addtime','>=',date('Y-m-d H:i:s',strtotime($param['start']))];
|
|
|
- if($param['end']!=="") $where[]=['b.addtime',"<",date('Y-m-d H:i:s',strtotime($param['end'])+24*3600)];
|
|
|
- if($param['is_stock']!=="") $where[]=['a.is_stock',"=",$param['is_stock']];
|
|
|
- if($param['good_type']!=="") $where[]=['a.good_type',"=",$param['good_type']];
|
|
|
- if($param['supplierNo']!=="") $where[]=['a.supplierNo',"=",$param['supplierNo']];
|
|
|
- if($param['companyNo']!=="") $where[]=['a.companyNo',"like",'%'.$param['companyNo'].'%'];
|
|
|
- if($param['creater']!=='') $where[]=['a.creater',"like",'%'.$param['creater'].'%'];
|
|
|
- if($param['createrid']!=='') $where[]=['a.createrid',"=",$param['createrid']];
|
|
|
- if($param['status']!=='') $where[]=['a.status','=',$param['status']];
|
|
|
- if($param['platform_code']!=="") $where[]=["platform_code",'=',$param['platform_code']];
|
|
|
- if($param['plat_code']!=='') $where[]=["b.plat_code","like",'%'.$param['plat_code'].'%'];
|
|
|
- if($param['exam_status']!=='') $where[]=['b.exam_status',"=",$param['exam_status']];
|
|
|
- if($param['brand_id']!=="") $where[]=['a.brand_id',"=",$param['brand_id']];
|
|
|
- $role=$this->checkRole();
|
|
|
- if(!empty($role['write']) ) $where[]=["a.createrid","in",$role['write']];
|
|
|
+ 'page' => 1,
|
|
|
+ 'size' => 10,
|
|
|
+ 'cat_id' => '',
|
|
|
+ 'good_name' => '',
|
|
|
+ 'skucode' => '',
|
|
|
+ 'spucode' => '',
|
|
|
+ 'start' => '',
|
|
|
+ 'end' => '',
|
|
|
+ 'is_stock' => '',
|
|
|
+ 'good_type' => '',
|
|
|
+ 'supplierNo' => '',
|
|
|
+ 'companyNo' => '',
|
|
|
+ 'creater' => '',
|
|
|
+ 'createrid' => '',
|
|
|
+ 'status' => '',
|
|
|
+ 'platform_code' => '',
|
|
|
+ 'plat_code' => '',
|
|
|
+ 'exam_status' => '',
|
|
|
+ 'brand_id' => '',
|
|
|
+ 'company_name' => '',
|
|
|
+ ], 'post', 'trim');
|
|
|
+ $where = [["a.is_del", "=", 0]];
|
|
|
+ if ($param['cat_id'] !== "") $where[] = ['a.cat_id', "=", $param['cat_id']];
|
|
|
+ if ($param['good_name'] !== "") $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
|
|
|
+ if ($param['skucode'] !== '') $where [] = ['b.skucode', 'like', '%' . $param['skucode'] . '%'];
|
|
|
+ if ($param['spucode'] !== '') $where [] = ['b.spucode', 'like', '%' . $param['spucode'] . '%'];
|
|
|
+ if ($param['start'] !== '') $where[] = ['b.addtime', '>=', date('Y-m-d H:i:s', strtotime($param['start']))];
|
|
|
+ if ($param['end'] !== "") $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($param['end']) + 24 * 3600)];
|
|
|
+ if ($param['is_stock'] !== "") $where[] = ['a.is_stock', "=", $param['is_stock']];
|
|
|
+ if ($param['good_type'] !== "") $where[] = ['a.good_type', "=", $param['good_type']];
|
|
|
+ if ($param['supplierNo'] !== "") $where[] = ['a.supplierNo', "=", $param['supplierNo']];
|
|
|
+ if ($param['companyNo'] !== "") $where[] = ['a.companyNo', "like", '%' . $param['companyNo'] . '%'];
|
|
|
+ if ($param['creater'] !== '') $where[] = ['a.creater', "like", '%' . $param['creater'] . '%'];
|
|
|
+ if ($param['createrid'] !== '') $where[] = ['a.createrid', "=", $param['createrid']];
|
|
|
+ if ($param['status'] !== '') $where[] = ['a.status', '=', $param['status']];
|
|
|
+ if ($param['platform_code'] !== "") $where[] = ["platform_code", '=', $param['platform_code']];
|
|
|
+ if ($param['plat_code'] !== '') $where[] = ["b.plat_code", "like", '%' . $param['plat_code'] . '%'];
|
|
|
+ if ($param['exam_status'] !== '') $where[] = ['b.exam_status', "=", $param['exam_status']];
|
|
|
+ if ($param['brand_id'] !== "") $where[] = ['a.brand_id', "=", $param['brand_id']];
|
|
|
+ $role = $this->checkRole();
|
|
|
+ if (!empty($role['write'])) $where[] = ["a.createrid", "in", $role['write']];
|
|
|
if ($param['company_name'] !== '') $where[] = ["a.createrid", 'in', get_company_item_user_by_name($param['company_name'])];
|
|
|
|
|
|
$count = Db::name('good')
|
|
|
->alias("a")
|
|
|
- ->leftJoin("good_platform b","a.spuCode=b.spuCode")
|
|
|
+ ->leftJoin("platform_youzan b", "a.spuCode=b.spuCode")
|
|
|
->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
|
|
|
- ->leftJoin("platform p","p.id=b.platform_code")
|
|
|
->where($where)
|
|
|
- ->where('p.platform_type',1)//只筛选有赞对接平台的商品
|
|
|
->count();
|
|
|
|
|
|
$total = ceil($count / $param['size']);
|
|
|
$param['size'] = $param['page'] >= $total ? $total : $param['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")
|
|
|
+ ->field("b.skuCode,b.platform_id platform_code,b.plat_code,b.id as platform_youzan_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("platform_youzan b", "a.spuCode=b.spuCode")
|
|
|
->leftJoin("depart_user u", "u.uid=a.createrid AND u.is_del=0")
|
|
|
- ->leftJoin("platform p","p.id=b.platform_code")
|
|
|
->where($where)
|
|
|
- ->where('p.platform_type',1)//只筛选有赞对接平台的商品
|
|
|
- ->page($param['page'],$param['size'])
|
|
|
+ ->page($param['page'], $param['size'])
|
|
|
->order("b.addtime desc")
|
|
|
->cursor();
|
|
|
- $data=[];
|
|
|
- foreach ($list as $value){
|
|
|
- $value['cat_info']= made($value['cat_id'],[]);
|
|
|
- $platform = Db::name("platform")->field('id,platform_name')->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")->field('id,name')->where(["code"=>$value['supplierNo']])->find();
|
|
|
- $value['supplier_name'] = isset($supplier['name']) ? $supplier['name']:"";
|
|
|
- $brand=Db::name("brand")->field('id,brand_name')->where(["id"=>$value['brand_id']])->find();
|
|
|
- $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
|
|
|
- $unit = Db::name("unit")->field('id,unit')->where(["id"=>$value['good_unit']])->find();
|
|
|
- $value['unit'] =isset($unit['unit'])?$unit['unit']:"";
|
|
|
- $company = Db::name("business")->field('id,company')->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']);
|
|
|
+ $data = [];
|
|
|
+ foreach ($list as $value) {
|
|
|
+ $value['cat_info'] = made($value['cat_id'], []);
|
|
|
+ $platform = Db::name("platform")->field('id,platform_name')->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")->field('id,name')->where(["code" => $value['supplierNo']])->find();
|
|
|
+ $value['supplier_name'] = isset($supplier['name']) ? $supplier['name'] : "";
|
|
|
+ $brand = Db::name("brand")->field('id,brand_name')->where(["id" => $value['brand_id']])->find();
|
|
|
+ $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
|
|
|
+ $unit = Db::name("unit")->field('id,unit')->where(["id" => $value['good_unit']])->find();
|
|
|
+ $value['unit'] = isset($unit['unit']) ? $unit['unit'] : "";
|
|
|
+ $company = Db::name("business")->field('id,company')->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;
|
|
|
+ $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['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;
|
|
|
+ $data[] = $value;
|
|
|
}
|
|
|
- return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
+ return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|
|
|
}
|
|
|
|
|
|
public function info(){
|