|
@@ -23,26 +23,29 @@ public function __construct(App $app){
|
|
|
}
|
|
|
/*列表*/
|
|
|
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;
|
|
|
+
|
|
|
+ $param = $this->request->filter('trim')->only(['page'=>1,'size'=>10,'name'=>'','code'=>'','is_platform'=>''],'post');
|
|
|
+
|
|
|
$where = [['is_del',"=",0]];
|
|
|
- $name = isset($this->post['name']) && $this->post['name'] !== "" ? trim($this->post['name']) : "";
|
|
|
- if ($name !== "") {
|
|
|
- $where[] = ["name","like", "%{$name}%"];
|
|
|
- }
|
|
|
- $code = isset($this->post['code']) && $this->post['code'] !== "" ? trim($this->post['code']) : "";
|
|
|
- if ($code !== "") {
|
|
|
- $where[] = ["code","=", $code];
|
|
|
- }
|
|
|
- $is_platform = isset($this->post['is_platform']) && $this->post['is_platform'] !== "" ? intval($this->post['is_platform']) : "";
|
|
|
- if ($is_platform !== "") {
|
|
|
- $where[] = ['is_platform',"=", $is_platform];
|
|
|
- }
|
|
|
+ if ($param['name'] !== "") $where[] = ["name","like", "%{$param['name']}%"];
|
|
|
+ if ($param['code'] !== "") $where[] = ["code","=", $param['code']];
|
|
|
+ if ($param['is_platform'] !== "") $where[] = ['is_platform',"=", $param['is_platform']];
|
|
|
|
|
|
$count = Db::name("supplier")->where($where)->count();
|
|
|
- $total = ceil($count/$size);
|
|
|
- $page = $page >= $total ? $total : $page;
|
|
|
- $list = Db::name('supplier')->where($where)->page($page,$size)->select();
|
|
|
+ $total = ceil($count/$param['size']);
|
|
|
+ $page = $param['page'] >= $total ? $total : $param['page'];
|
|
|
+ $list = Db::name('supplier')
|
|
|
+ ->where($where)
|
|
|
+ ->page($page, $param['size'])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ //这些供应商是否有启用的账号
|
|
|
+ $has_account = checkHasAccountBySupplierNos(array_column($list, 'code'));
|
|
|
+ foreach ($list as &$value) {
|
|
|
+ $value['has_account'] = (int)isset($has_account[$value['code']]);
|
|
|
+ }
|
|
|
+
|
|
|
return app_show(0,"获取成功",["list"=>$list,'count'=>$count]);
|
|
|
}
|
|
|
/*新建*/
|