request; if ($retuest->isAjax) { if ($retuest->isPost) { $post = Yii::$app->request->post(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($post,[ [['id','level'], 'integer'], [['title','check_status','mobile','date_end','date_start','user_id','user_name'], 'safe'], [['limit'],'default','value' => '15'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $post = AddonsXhsContent::exceptNullVal($post); // 根据搜索手机号查询用户id if (!empty($post['mobile'])) { $user_ids = User::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['like', 'mobile', $post['mobile'] . '%', false])->asArray()->column(); if (empty($user_ids)) $this->success('查无此用户'); $where[] = ['in', 'user_id', $user_ids]; } // 根据搜索会员昵称查询用户id if (!empty($post['user_name'])) { $user_ids = User::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['like', 'nickname', $post['user_name'] . '%', false])->asArray()->column(); $where[] = ['in', 'user_id', $user_ids]; } if($post['user_id']) $where[] = ['=', 'user_id', $post['user_id']]; if($post['date_start'] && $post['date_end']) $where[] = ['between', 'created_at', strtotime($post['date_start']),strtotime($post['date_end'])]; $where[] = ['=', 'mall_id', $this->mall_id]; if($post['title']) $where[] = ['like', 'title', $post['title']]; if(in_array($post['check_status'],[StatusEnum::ENABLED,StatusEnum::DISABLED,'2'])) $where[] = ['=', 'check_status', $post['check_status']]; else $where[] = ['=', 'check_status', StatusEnum::ENABLED]; $where[] = ['>=','status',StatusEnum::DISABLED]; $order = 'id desc'; $params = array('where' => $where, 'order'=>$order, 'limit' => $post['limit'],'with' => ['cate','goods','user','goodsstatistics']); $list = AddonsXhsContent::listPage($params, false, true); if($list['list']) { foreach ($list['list'] as $k => $v) { $list['list'][$k]['source'] = json_decode($v['source']); $list['list'][$k]['order_count'] = $v['goodsstatistics']['order_num']; $list['list'][$k]['goods_amount'] = $v['goodsstatistics']['total_amount']; $list['list'][$k]['bought_count'] = $v['goodsstatistics']['bought_count']; } } $this->success('获取成功', $list); } } else { return $this->render($this->action->id); } } /** * 编辑 * @Author: ltm * @DateTime: 2021/12/13 0021 18:29 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionEdit() { try { $request = Yii::$app->request; if ($request->isAjax) { //提交内容 if ($request->isPost) { $params = Yii::$app->request->post(); if($params['type'] == StatusEnum::ENABLED){ //禁用操作和删除操作和审核操作 $res = Yii::$app->services->validate->validate($params, [ [['id','status','check_status','check_remark'],'safe'] ]); }else{ $res = Yii::$app->services->validate->validate($params, [ [['cate_id','describe','download_type'], 'required'], [['user_name','user_avatar_url','pic_url','id','virtual_download_num','goods_id','thumb_url','status','video_url'],'safe'] ]); } $params = AddonsXhsContent::exceptNullVal($params); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['mall_id'] = $this->mall_id; if($params['id']) $params['updated_at'] = time();else $params['create_at'] = time();//更新时间 //删除操作 if(isset($params['status']) && in_array($params['status'],[StatusEnum::DISABLED,StatusEnum::ENABLED,StatusEnum::DELETE])) { $params['status'] = $params['status']; } $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['>', 'status', StatusEnum::DISABLED]; //审核操作 if($params['check_status']) { $params['check_status'] = $params['check_status']; $params['status'] = StatusEnum::ENABLED; $params['check_time'] = time(); } if($params['pic_url']) $params['pic_url'] = json_encode($params['pic_url']); $res = AddonsXhsContent::setData($params); if ($res === false) throw new Exception(AddonsXhsContent::getStaticError()); return $this->success('操作成功'); } } } catch (\Exception $e) { return $this->error($e->getMessage(), []); } return $this->render($this->action->id); } /** * 审核 * @Author: ltm * @DateTime: 2021/12/13 0021 18:29 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|string|void */ public function actionCheck(){ 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['content'])){ $where[] = ['like', 'content', $params['content']]; } 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'])]; } $params['where'] = $where; $params['order'] = 'id desc'; $params['with'] = ['user']; $comment_list = AddonsXhsComment::listPage($params); if($comment_list==false) return $this->error(AddonsXhsComment::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]; AddonsXhsComment::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']]; AddonsXhsComment::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']]; AddonsXhsComment::updateData($post); return $this->success('成功'); } } }