|
|
@@ -31,19 +31,19 @@ class CanteenController extends Controller
|
|
|
|
|
|
public function actionList()
|
|
|
{
|
|
|
- $filter = ['is_del' => 0];
|
|
|
+ $filter = ['t.is_del' => 0];
|
|
|
$schoolId = Helper::getPostString('school_id');
|
|
|
if ($schoolId) {
|
|
|
if (!$this->checkSchoolId($schoolId)) {
|
|
|
- $filter['school_id'] = -1;
|
|
|
+ $filter['t.school_id'] = -1;
|
|
|
} else {
|
|
|
- $filter['school_id'] = $schoolId;
|
|
|
+ $filter['t.school_id'] = $schoolId;
|
|
|
}
|
|
|
} else {
|
|
|
- $filter['school_id'] = $this->getSchoolFilter();
|
|
|
+ $filter['t.school_id'] = $this->getSchoolFilter();
|
|
|
}
|
|
|
if ($name = Helper::getPostString('name')) {
|
|
|
- $filter['name'] = '%' . $name;
|
|
|
+ $filter['t.name'] = '%' . $name;
|
|
|
}
|
|
|
if ($company_id = Helper::getPostInt('company_id')) {
|
|
|
$rs = Helper::arrayColumn(
|
|
|
@@ -53,17 +53,22 @@ class CanteenController extends Controller
|
|
|
),
|
|
|
'canteen_id'
|
|
|
);
|
|
|
- $filter['id'] = $rs ?: [-1];
|
|
|
+ $filter['t.id'] = $rs ?: [-1];
|
|
|
}
|
|
|
- $cri = DbCriteria::simpleCompareWithPage($filter)->setOrder('id desc');
|
|
|
+ $cri = DbCriteria::simpleCompareWithPage($filter)
|
|
|
+ ->setAlias('t')
|
|
|
+ ->setSelect('t.*, group_concat(sf.id) AS follow_ids')
|
|
|
+ ->addJoin('LEFT JOIN wx_canteen_follow AS sf ON sf.canteen_id = t.id')
|
|
|
+ ->setGroup('t.id')
|
|
|
+ ->setOrder('t.id desc');
|
|
|
if ($date = Helper::getPostDate('date')) {
|
|
|
$cri->addBetweenCondition('create_date', $date, $date . ' 23:59:59');
|
|
|
}
|
|
|
$data = DB::getListWithCriteria(self::$table, $cri);
|
|
|
if (!empty($data['records'])) {
|
|
|
$users = Helper::arrayColumn(
|
|
|
- DB::getListWithCriteria('useradmin', DbCriteria::simpleCompare(['id' => array_column($data['records'], 'last_user_id')])->setSelect('id, username')),
|
|
|
- 'username',
|
|
|
+ DB::getListWithCriteria('useradmin', DbCriteria::simpleCompare(['id' => array_column($data['records'], 'last_user_id')])->setSelect('id, username,avatar')),
|
|
|
+ null,
|
|
|
'id'
|
|
|
);
|
|
|
$schools = Helper::arrayColumn(
|
|
|
@@ -80,6 +85,7 @@ class CanteenController extends Controller
|
|
|
'name',
|
|
|
'canteen_id'
|
|
|
);
|
|
|
+ $data['records'] = FollowSrv::formatWithFollowList($data['records'], 'wx_canteen_follow', $users);
|
|
|
$data['records'] = array_map(function ($item) use ($users, $schools, $relations) {
|
|
|
$item['last_user_name'] = $users[$item['last_user_id']] ?? '-';
|
|
|
$item['school_name'] = $schools[$item['school_id']] ?? '-';
|