*/ class MessageHistoryController extends BaseController { use MerchantCurd; /** * @var messageHistory */ public $modelClass = MessageHistory::class; /** * 首页 * * @return string * @throws \yii\web\NotFoundHttpException */ public function actionIndex() { $startTime = Yii::$app->request->get('start_time', date('Y-m-d', strtotime("-10 day"))); $endTime = Yii::$app->request->get('end_time', date('Y-m-d', strtotime("+1 day"))); $searchModel = new SearchModel([ 'model' => $this->modelClass, 'scenario' => 'default', 'partialMatchAttributes' => ['message'], // 模糊查询 'defaultOrder' => [ 'id' => SORT_DESC ], 'pageSize' => $this->pageSize ]); $dataProvider = $searchModel ->search(Yii::$app->request->queryParams); $dataProvider->query ->andWhere(['>=', 'status', StatusEnum::DISABLED]) ->andFilterWhere(['merchant_id' => $this->getMerchantId()]) ->andFilterWhere(['between', 'created_at', !empty($startTime) ? strtotime($startTime) : '', !empty($endTime) ? strtotime($endTime) : '']) ->with(['fans', 'auth', 'rule']); return $this->render($this->action->id, [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'moduleExplain' => RuleModuleEnum::getMap(), 'startTime' => $startTime, 'endTime' => $endTime, ]); } }