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); } }