request; if ($retuest->isAjax) { if ($retuest->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 = AddonsXhsContent::exceptNullVal($post); //趋势分析 $statistical_list = AddonsXhsStatistics::statistics($this->mall_id,$post['start_time'],$post['end_time']); //数据汇总 $Yesterdaywhere[] = ['=','mall_id',$this->mall_id]; $yesterday_data = AddonsXhsAllStatistics::getOne($Yesterdaywhere,true); $yesterday_data = AddonsXhsStatistics::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); 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); 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); } }