request->isAjax && Yii::$app->request->isPost) { $post = Yii::$app->request->post(); $where = [['=', 'mall_id', $this->mall_id], ['<>', 'status' , StatusEnum::DELETE]]; if (isset($post['user_id']) && $post['user_id']) { $where[] = ['=', 'user_id', $post['user_id']]; } if (isset($post['nickname']) && $post['nickname']) { $user_ids = User::find() ->orWhere(['like', 'nickname', "%" . $post['nickname'] . "%", false]) ->orWhere(['like', 'mobile', "%" . $post['nickname'] . "%", false]) ->select('id') ->asArray() ->column(); $where[] = ['in', 'user_id', $user_ids]; } if (isset($post['recent_time']) && $post['recent_time']) { list ($start, $end) = $post['recent_time']; $where[] = ['>=', 'recent_time', strtotime($start)]; $where[] = ['<=', 'recent_time', strtotime($end)]; } $params = [ 'limit' => 10, 'with' => 'user', 'where' => $where, 'order' => 'id desc' ]; $list = BusinessCardMaterialsBrowse::listPage($params); return $this->success('操作成功', $list); } else { return $this->render('index'); } } /** * 观看记录 */ public function actionLog() { if (Yii::$app->request->isAjax && Yii::$app->request->isPost) { $post = Yii::$app->request->post(); $where = [['=', 'mall_id', $this->mall_id], ['<>', 'status' , StatusEnum::DELETE]]; if (isset($post['user_id']) && $post['user_id']) { $where[] = ['=', 'user_id', $post['user_id']]; } if (isset($post['material_id']) && $post['material_id']) { $where[] = ['=', 'material_id', $post['material_id']]; } if (isset($post['title']) && $post['title']) { $material_ids = BusinessCardMaterials::find() ->orWhere(['like', 'title', "%" . $post['title'] . "%", false]) ->select('id') ->asArray() ->column(); $where[] = ['in', 'material_id', $material_ids]; } if (isset($post['parent']) && $post['parent']) { $parent_ids = User::find() ->orWhere(['like', 'nickname', "%" . $post['parent'] . "%", false]) ->orWhere(['like', 'mobile', "%" . $post['parent'] . "%", false]) ->select('id') ->asArray() ->column(); $user_ids = BusinessCardUser::find() ->where(['in', 'parent_id', $parent_ids]) ->select('user_id') ->asArray() ->column(); $where[] = ['in', 'user_id', $user_ids]; } if (isset($post['nickname']) && $post['nickname']) { $user_ids = User::find() ->orWhere(['like', 'nickname', "%" . $post['nickname'] . "%", false]) ->orWhere(['like', 'mobile', "%" . $post['nickname'] . "%", false]) ->select('id') ->asArray() ->column(); $where[] = ['in', 'user_id', $user_ids]; } if (isset($post['created_at']) && $post['created_at']) { list ($start, $end) = $post['created_at']; $where[] = ['>=', 'created_at', strtotime($start)]; $where[] = ['<=', 'created_at', strtotime($end)]; } $params = [ 'limit' => 10, 'with' => ['user', 'material', 'shareuser'], 'where' => $where, 'order' => 'id desc' ]; $list = BusinessCardMaterialsBrowseLog::listPage($params); $list['list'] = is_array($list['list']) ? $list['list'] : []; // foreach ($list['list'] as $index => $item) { // // $list['list'][$index] = $item; // } return $this->success('操作成功', $list); } else { return $this->render('log'); } } }