|
@@ -376,38 +376,39 @@ class Purch extends \app\BaseController
|
|
|
public function difflist(){
|
|
|
$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 = [['is_del',"=",0]];
|
|
|
+ $where = [['a.is_del',"=",0],['b.is_del',"=",0]];
|
|
|
$cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ? trim($this->post['cgdNo']):"";
|
|
|
if($cgdNo!=""){
|
|
|
- $where[]=['cgdNo',"like", "%$cgdNo%"];
|
|
|
+ $where[]=['a.cgdNo',"like", "%$cgdNo%"];
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"";
|
|
|
if($status!==""){
|
|
|
- $where[]=['status',"=",$status];
|
|
|
+ $where[]=['a.status',"=",$status];
|
|
|
}
|
|
|
$start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
if ($start !="") {
|
|
|
- $where[]= ["addtime",'>=',$start];
|
|
|
+ $where[]= ["a.addtime",'>=',$start];
|
|
|
}
|
|
|
$end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
if($end !=""){
|
|
|
- $where[]= ["addtime",'<=',$end];
|
|
|
+ $where[]= ["a.addtime",'<=',$end];
|
|
|
}
|
|
|
$apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !==""? intval($this->post['apply_name']):"";
|
|
|
if($apply_name!==""){
|
|
|
- $where[]=['apply_name',"like","%$apply_name%"];
|
|
|
+ $where[]=['a.apply_name',"like","%$apply_name%"];
|
|
|
}
|
|
|
- $count = Db::name('purchease_diff')->alias('a')->where($where)->count();
|
|
|
+ $count = Db::name('purchease_diff')->alias('a')->join("good b","b.good_code=a.good_code","left")
|
|
|
+ ->where($where)->count();
|
|
|
$total = ceil($count/$size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
- $list = Db::name('purchease_diff')//->alias('a')->join("purchease_order b","b.cgdNo=a.cgdNo","left")
|
|
|
- ->where($where)->page($page,$size)->order("addtime desc")->select();
|
|
|
-// $data=[];
|
|
|
-// foreach ($list as $value){
|
|
|
-// $value['can']= isset($value['good_catid']) && $value['good_catid'] !=0 ? made($value['good_catid']):[];
|
|
|
-// $data[]=$value;
|
|
|
-// }
|
|
|
- return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
|
|
|
+ $list = Db::name('purchease_diff')->alias('a')->join("good b","b.good_code=a.good_code","left")
|
|
|
+ ->where($where)->page($page,$size)->order("a.addtime desc")->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
|
|
|
+ $data[]=$value;
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
}
|
|
|
public function diffinfo(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? trim($this->post['id']) :"";
|
|
@@ -418,6 +419,12 @@ class Purch extends \app\BaseController
|
|
|
if($idinf==false){
|
|
|
return error_show(1002,"未找到采购工差单数据");
|
|
|
}
|
|
|
+ $goon = Db::name('good')->where(['good_code'=>$idinf['good_code']])->find();
|
|
|
+ if(empty($goon)){
|
|
|
+ return error_show(1002,"未找到商品数据");
|
|
|
+ }
|
|
|
+ $int= isset($goon['cat_id']) && $goon['cat_id'] !=0 ? made($goon['cat_id']):[];
|
|
|
+ $idinf['can']=$int;
|
|
|
return app_show(0,"获取成功",$idinf);
|
|
|
|
|
|
}
|