| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\plugins\food\controllers;
- use app\models\User;
- use app\plugins\food\models\FoodOrder;
- use app\plugins\food\models\FoodOrderDetail;
- class OrderController extends BaseController
- {
- public function actionList() {
- $status = get_params('status', -1);
- $key = get_params('keyword');
- $dateStart = get_params('dateStart');
- $dateEnd = get_params('dateEnd');
- $query = FoodOrder::find()->alias('fo')->where(['fo.store_id' => get_store_id()])->leftJoin(['u' => User::tableName()],'u.id=fo.user_id');
- if (!empty($key)) {
- $query->andWhere([
- 'or',
- ['like', 'u.nickname', $key],
- ['like', 'u.real_name', $key],
- ['like', 'fo.order_no', $key],
- ['like', 'u.binding', $key],
- ]);
- }
- if ($dateStart) {
- $query->andWhere(['>=', 'fo.created_at', strtotime($dateStart)]);
- }
- if ($dateEnd) {
- $query->andWhere(['<=', 'fo.created_at', strtotime($dateEnd)]);
- }
- if (in_array($status, [0, 1])) {
- $query->andWhere(['fo.is_pay' => $status]);
- }
- $query->select('fo.*, u.nickname, u.real_name, u.binding')->orderBy(['fo.created_at' => SORT_DESC]);
- $list = pagination_make($query);
- foreach ($list['list'] as &$val) {
- $val['goods_list'] = FoodOrderDetail::find()->where(['order_id' => $val['id']])->asArray()->all();
- }
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ],
- ];
- }
- }
|