|
@@ -77,25 +77,39 @@ class Account
|
|
|
public static function getAccountList(array $param = [])
|
|
|
{
|
|
|
|
|
|
- $db = new SupplierRelationUserModel();
|
|
|
+ $db = new SupplierUserModel();
|
|
|
+
|
|
|
|
|
|
$rs = $db
|
|
|
- ->alias('a')
|
|
|
- ->leftJoin('supplier_user b', 'b.uid=a.uid AND b.is_del=0')
|
|
|
- ->where([
|
|
|
- 'a.is_del' => $db::$is_del_normal,
|
|
|
- 'a.supplierNo' => $param['supplierNo'],
|
|
|
- ]);
|
|
|
+ ->where('is_del', $db::$is_del_normal);
|
|
|
+
|
|
|
+ if ($param['keyword'] != '') $rs->whereLike('nickname|mobile', '%' . $param['keyword'] . '%');
|
|
|
+ if ($param['status'] != '') $rs->where('status', $param['status']);
|
|
|
+ if ($param['supplierNo'] != '') {
|
|
|
+ $uids = SupplierRelationUserModel::where([
|
|
|
+ 'is_del' => $db::$is_del_normal,
|
|
|
+ 'supplierNo' => $param['supplierNo']
|
|
|
+ ])->column('uid');
|
|
|
+
|
|
|
+ $rs->whereIn('uid', $uids);
|
|
|
+ }
|
|
|
|
|
|
- if ($param['keyword'] != '') $rs->whereLike('b.nickname|b.mobile', '%' . $param['keyword'] . '%');
|
|
|
- if ($param['status'] != '') $rs->where('a.status', $param['status']);
|
|
|
+ $count = $rs->count('uid');
|
|
|
|
|
|
- $count = $rs->count('a.id');
|
|
|
|
|
|
$list = $rs
|
|
|
- ->field('a.id,b.uid,b.nickname,b.mobile,b.email,a.status,a.addtime,a.creater')
|
|
|
- ->order('a.addtime', 'desc')
|
|
|
+ ->field('uid,nickname,mobile,email,status,addtime,creater')
|
|
|
+ ->order('addtime', 'desc')
|
|
|
->page($param['page'], $param['size'])
|
|
|
+ ->append(['supplier_list'])
|
|
|
+ ->withAttr('supplier_list', function ($val, $data) use ($db) {
|
|
|
+ return SupplierRelationUserModel::where([
|
|
|
+ 'is_del' => $db::$is_del_normal,
|
|
|
+ 'uid' => $data['uid']
|
|
|
+ ])->field('supplierNo,supplierName,status')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ })
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|