request; if ($request->isAjax) { if ($request->isPost) { $post = Yii::$app->request->post(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($post, [ [['start_time', 'end_time'], 'safe'], ]); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $post = AddonsOperatingNoteContent::exceptNullVal($post); //趋势分析 $statistical_list = AddonsOperatingNoteStatistics::statistics($this->mall_id, isset($post['start_time']) ? $post['start_time'] : '', isset($post['end_time']) ? $post['end_time'] : ''); //数据汇总 $Yesterdaywhere[] = ['=', 'mall_id', $this->mall_id]; $yesterday_data = AddonsOperatingNoteStatistics::getOne($Yesterdaywhere, true); $yesterday_data = AddonsOperatingNoteStatistics::format($yesterday_data); //人气排行TOP5 $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['>=', 'status', StatusEnum::DISABLED]; $post['limit'] = 5; $order = 'stars_count desc'; $params = array('where' => $where, 'order' => $order, 'limit' => $post['limit']); // $start_list = AddonsXhsContent::lists($params, true); $start_list = []; if ($start_list) foreach ($start_list as $k => $v) $start_list[$k]['source'] = json_decode($v['source']); //带货排行TOP5 $order = 'total_amount desc'; $goods_where[] = ['=', 'mall_id', $this->mall_id]; $params = array('where' => $goods_where, 'order' => $order, 'limit' => $post['limit'], 'with' => ['goods']); // $goods_list = AddonsXhsGoodsStatistics::lists($params, true); $goods_list = []; if ($goods_list) foreach ($goods_list as $k => $v) $goods_list[$k]['source'] = json_decode($v['source']); $this->success('获取成功', compact('start_list', 'goods_list', 'yesterday_data', 'statistical_list')); } } return $this->render($this->action->id); } public function actionCommentList() { if (\Yii::$app->request->isAjax) { if (\Yii::$app->request->isGet) { $params = \Yii::$app->request->get(); $where[] = ['mall_id' => $this->mall_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]; !empty($params['user_id']) && $where[] = ['=', 'user_id', $params['user_id']]; if (!empty($params['mobile'])) { $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id, 'mobile' => $params['mobile'], 'status' => StatusEnum::ENABLED])->scalar() ?? 0; $where[] = ['=', 'user_id', $user_id]; } if (!empty($params['start_at']) && !empty($params['end_at'])) { $where[] = ['between', 'created_at', strtotime($params['start_at']), strtotime($params['end_at'])]; } if(!empty($params['content'])){ $where[] = ['like', 'content', $params['content']]; } $params['where'] = $where; $params['order'] = 'id desc'; $params['with'] = ['user']; $comment_list = AddonsOperatingNoteComment::listPage($params); if($comment_list==false) return $this->error(AddonsOperatingNoteComment::getStaticError()); if (!empty($comment_list['list'])) { } return $this->success('success', $comment_list); } } else { return $this->render('comment-list'); } } public function actionCommentDel() { $request = \Yii::$app->request; if ($request->isAjax && $request->isPost) { // 检查提交的参数 $post = $request->post(); $res = \Yii::$app->services->validate->validate($post, [ [['id'], 'required'], ]); if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); $post['mall_id'] = $this->mall_id; $post['attributes'] = ['status'=>StatusEnum::DELETE]; AddonsOperatingNoteComment::updateData($post); return $this->success('成功'); } } public function actionCommentUpTop() { $request = \Yii::$app->request; if ($request->isAjax && $request->isPost) { // 检查提交的参数 $post = $request->post(); $res = \Yii::$app->services->validate->validate($post, [ [['id','is_top'], 'required'], ['is_top', 'integer', 'min' => 0, 'max' => 1], ]); if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); $post['mall_id'] = $this->mall_id; $post['attributes'] = ['is_top'=>$post['is_top']]; AddonsOperatingNoteComment::updateData($post); return $this->success('成功'); } } public function actionCommentChangeStatus() { $request = \Yii::$app->request; if ($request->isAjax && $request->isPost) { // 检查提交的参数 $post = $request->post(); $res = \Yii::$app->services->validate->validate($post, [ [['id','status'], 'required'], ['status', 'integer', 'min' => 0, 'max' => 1], ]); if ($res == false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); $post['mall_id'] = $this->mall_id; $post['attributes'] = ['status'=> $post['status']]; AddonsOperatingNoteComment::updateData($post); return $this->success('成功'); } } }