|
@@ -312,43 +312,54 @@ class Reorder extends Base
|
|
|
public function list(){
|
|
|
$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 =[['sr.is_del',"=",0]];
|
|
|
$bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
|
|
|
if($bkcode!=""){
|
|
|
- $where[]=['returnCode',"like", "%{$bkcode}%"];
|
|
|
+ $where[]=['sr.returnCode',"like", "%{$bkcode}%"];
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
|
|
|
if($status!==""){
|
|
|
- $where[]=['status',"=", $status];
|
|
|
+ $where[]=['sr.status',"=", $status];
|
|
|
}
|
|
|
$orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
|
|
|
:"";
|
|
|
if($orderCode!=""){
|
|
|
- $where[]=['orderCode',"like", "%{$orderCode}%"];
|
|
|
+ $where[]=['sr.orderCode',"like", "%{$orderCode}%"];
|
|
|
}
|
|
|
$apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name'])
|
|
|
:"";
|
|
|
if($apply_name!=""){
|
|
|
- $where[]=['apply_name',"like", "%{$apply_name}%"];
|
|
|
+ $where[]=['sr.apply_name',"like", "%{$apply_name}%"];
|
|
|
}
|
|
|
$start =isset($this->post['start'])&&$this->post['start']!='' ? $this->post['start']:"";
|
|
|
if($start!==""){
|
|
|
- $where[]=['addtime',">=", $start.' 00:00:00'];
|
|
|
+ $where[]=['sr.addtime',">=", $start.' 00:00:00'];
|
|
|
}
|
|
|
$end =isset($this->post['end'])&&$this->post['end']!='' ? $this->post['end']:"";
|
|
|
if($end!==""){
|
|
|
- $where[]=['addtime',"<=", $end.' 23:59:59'];
|
|
|
+ $where[]=['sr.addtime',"<=", $end.' 23:59:59'];
|
|
|
}
|
|
|
$role=$this->checkRole();
|
|
|
$condition='';
|
|
|
if(!empty($role['write']) && $this->uid!=""){
|
|
|
- // $where[]=["a.apply_id","in",$role['write']];
|
|
|
- $condition .="cgderid = {$this->uid} or apply_id in (".implode(',',$role['write']).")";
|
|
|
+ // $where[]=["sr.apply_id","in",$role['write']];
|
|
|
+ $condition .="sr.cgderid = {$this->uid} or sr.apply_id in (".implode(',',$role['write']).")";
|
|
|
}
|
|
|
- $count=Db::name("sale_return")->where($where)->where($condition)->count();
|
|
|
+ $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
|
|
|
+ if ($company_name !== "") $where[] = ["sr.apply_id", 'in', get_company_item_user_by_name($company_name)];
|
|
|
+
|
|
|
+ $count=Db::name("sale_return")->alias('sr')->where($where)->where($condition)->count();
|
|
|
$total = ceil($count/$size);
|
|
|
$page = $total>=$page ? $page :$total;
|
|
|
- $list = Db::name("sale_return")->where($where)->where($condition)->order("addtime desc")->page($page,$size)->select();
|
|
|
+ $list = Db::name("sale_return")
|
|
|
+ ->alias('sr')
|
|
|
+ ->field('sr.*,u.itemid')
|
|
|
+ ->leftJoin("depart_user u", "u.uid=sr.apply_id AND u.is_del=0")
|
|
|
+ ->where($where)
|
|
|
+ ->where($condition)
|
|
|
+ ->order("addtime desc")
|
|
|
+ ->page($page,$size)
|
|
|
+ ->cursor();
|
|
|
// echo Db::name("sale_return")->getLastSql();
|
|
|
$data=[];
|
|
|
foreach ($list as $value){
|
|
@@ -361,6 +372,7 @@ class Reorder extends Base
|
|
|
$value['sale_price'] = isset($order['sale_price']) ?$order['sale_price']:0;
|
|
|
$value['return_total'] =$value['sale_price']*$value['num'] ;
|
|
|
$value['total_num'] =$order['good_num'] ;
|
|
|
+ $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
|
|
|
$data[]=$value ;
|
|
|
}
|
|
|
return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
|