public function actionGetList()
{
$currentPage = Yii::$app->request->get("currentPage", 1);
$pageSize = Yii::$app->request->get("pageSize", 10);
$offset = ($currentPage - 1) * $pageSize;
$sortName = "_id";
$sortDesc = Yii::$app->request->get('sortDesc', 'ASC');
$sort = $sortName . ' ' . $sortDesc;
$keyword = Yii::$app->request->get("keyword", '');
$query = new Query();
$accountId = $this->getAccountId();
if ($keyword == '') {
$records = $query->from('uhkklpOrder')->select(['_id', 'createdAt', 'name', 'mobile', 'restaurantName', 'address', 'businessForm', 'product'])->where(['accountId' => $accountId])->orderBy($sort)->offset($offset)->limit($pageSize)->all();
} else {
$records = $query->from('uhkklpOrder')->select(['_id', 'createdAt', 'name', 'mobile', 'restaurantName', 'address', 'businessForm', 'product'])->where(['accountId' => $accountId])->andWhere(['like', 'mobile', $keyword])->orderBy($sort)->offset($offset)->limit($pageSize)->all();
}
for ($i = 0; $i < count($records); $i++) {
$records[$i]['createdAt'] = MongodbUtil::MongoDate2String($records[$i]['createdAt'], 'Y-m-d H:i:s', null);
$records[$i]['_id'] = (string) $records[$i]['_id'];
}
$query = new Query();
if ($keyword == '') {
$totalPageCount = $query->from('uhkklpOrder')->where(['accountId' => $accountId])->count();
} else {
$totalPageCount = $query->from('uhkklpOrder')->where(['accountId' => $accountId])->andWhere(['like', 'name', $keyword])->count();
}
// LogUtil::error(date('Y-m-d h:i:s') . ' $totalPageCount: ' . $totalPageCount);
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return ['code' => 200, 'list' => $records, 'totalPageCount' => $totalPageCount];
}