|
@@ -23,38 +23,62 @@ class Stock extends Base
|
|
|
$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;
|
|
|
$status = isset($this->post['status'])&&$this->post['status']!=="" ? intval($this->post['status']) :"";
|
|
|
- $where=[];
|
|
|
+ $where=['a.is_del'=>0];
|
|
|
if($status!==""){
|
|
|
- $where['status'] = $status;
|
|
|
+ $where['a.status'] = $status;
|
|
|
}
|
|
|
$username = isset($this->post['username'])&&$this->post['username']!=="" ? trim($this->post['username']) :"";
|
|
|
if($username!=""){
|
|
|
- $where['username'] = ["like","%{$username}%"];
|
|
|
+ $where['a.username'] = ["like","%{$username}%"];
|
|
|
}
|
|
|
$nickname = isset($this->post['nickname'])&&$this->post['nickname']!=="" ? trim($this->post['nickname']) :"";
|
|
|
if($nickname!=""){
|
|
|
- $where['nickname'] = ["like","%{$nickname}%"];
|
|
|
+ $where['v.nickname'] = ["like","%{$nickname}%"];
|
|
|
}
|
|
|
$mobile = isset($this->post['mobile'])&&$this->post['mobile']!=="" ? trim($this->post['mobile']) :"";
|
|
|
if($mobile!=""){
|
|
|
- $where['mobile'] = ["like","%{$mobile}%"];
|
|
|
+ $where['v.mobile'] = ["like","%{$mobile}%"];
|
|
|
}
|
|
|
$stock_low = isset($this->post['stock_low'])&&$this->post['stock_low']!=="" ? intval($this->post['stock_low'])
|
|
|
:"";
|
|
|
- $wherestock="1=1";
|
|
|
+ // $wherestock="1=1";
|
|
|
if($stock_low!=""){
|
|
|
- // $where['stock_balance'] = [">=",$stock_low];
|
|
|
- $wherestock .=" and stock_balance>={$stock_low}";
|
|
|
+ $where['stock_balance'] = [">=",$stock_low];
|
|
|
+ // $wherestock .=" and stock_balance>={$stock_low}";
|
|
|
}
|
|
|
$stock_up = isset($this->post['stock_up'])&&$this->post['stock_up']!=="" ? intval($this->post['stock_up']) :"";
|
|
|
if($stock_up!=""){
|
|
|
- // $where['stock_balance'] = ["<=",$stock_up];
|
|
|
- $wherestock .=" and stock_balance<={$stock_up}";
|
|
|
+ $where['stock_balance'] = ["<=",$stock_up];
|
|
|
+ //$wherestock .=" and stock_balance<={$stock_up}";
|
|
|
}
|
|
|
- $count= Db::name("stock_list")->where($where)->where($wherestock)->count();
|
|
|
+ $count= Db::name("account")->alias('a')
|
|
|
+ ->join("fc_rela_account b","a.id = b.accountid","left")
|
|
|
+ ->join("fc_account_info v","b.account_info = v.id","left")
|
|
|
+ ->join("fc_account_stock d","a.id = d.accountid","left")
|
|
|
+ ->where($where)->count();
|
|
|
$total = ceil($count/$size);
|
|
|
$page = $page>=$total? $total:$page;
|
|
|
- $list = Db::name("stock_list")->where($where)->where($wherestock)->page($page,$size)->field("id,username,status,nickname,mobile,stock_balance,stock_update")->order("stock_update desc")->select();
|
|
|
+ $list = Db::name("account")->alias('a')->where($where)->page($page,$size)
|
|
|
+ ->join("fc_rela_account b","a.id = b.accountid","left")
|
|
|
+ ->join("fc_account_info v","b.account_info = v.id","left")
|
|
|
+ ->join("fc_account_stock d","a.id = d.accountid","left")
|
|
|
+ ->field("`a`.`id` AS `id`,
|
|
|
+ `a`.`username` AS `username`,
|
|
|
+ `a`.`status` AS `status`,
|
|
|
+ `a`.`starttime` AS `starttime`,
|
|
|
+ `a`.`expiretime` AS `expiretime`,
|
|
|
+ `a`.`activetime` AS `activetime`,
|
|
|
+ `a`.`addtime` AS `addtime`,
|
|
|
+ `v`.`nickname` AS `nickname`,
|
|
|
+ `v`.`avatar` AS `avatar`,
|
|
|
+ `v`.`mobile` AS `mobile`,
|
|
|
+ `v`.`remark` AS `remark`,
|
|
|
+ ifnull( `d`.`stock_total`, 0 ) AS `stock_total`,
|
|
|
+ ifnull( `d`.`stock_used`, 0 ) AS `stock_used`,
|
|
|
+ ifnull( `d`.`stock_balance`, 0 ) AS `stock_balance`,
|
|
|
+ ifnull( `d`.`stock_delivery`, 0 ) AS `stock_delivery`,
|
|
|
+ ifnull( `d`.`updatetime`, '' ) AS `stock_update` ")
|
|
|
+ ->order("d.updatetime desc")->select();
|
|
|
return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
|
|
|
}
|
|
|
|