request; if ($retuest->isAjax) { if ($retuest->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params, [ [['page'],'safe'] ]); $params = AddonsAlbum::exceptNullVal($params); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['>=','status',StatusEnum::DISABLED]; $order = 'id desc'; $params = array('where' => $where, 'order'=>$order); $list = AddonsAlbum::listPage($params, false, true); $get_system_setting = PlatformSetting::getConfByGroup('system', true); $list['api_url'] = $get_system_setting['api_url']['value']; $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'],'safe'] ]); }else{ $res = Yii::$app->services->validate->validate($params, [ [['title'], 'required'], [['page_data','goods_ids','bg_type','id','album_image','bg_image','bg_video','bg_color','size_type','type'],'safe'], [['file','share_title','share_desc','share_image','author_id','author_nick','author_mobile'],'safe'] ]); } if(!$params['id']){ $params = AddonsAlbum::exceptNullVal($params); } if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['mall_id'] = $this->mall_id; //添加默认封面 if(!$params['album_image']){ $get_system_setting = PlatformSetting::getConfByGroup('system', true); $api_url = $get_system_setting['api_url']['value']; $params['album_image'] = $api_url.'/resources/addons/album/album.jpg'; } if(!empty($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']; } //复制 $type = $params['type']; if($type == '2') unset($params['id'],$params['type']); //统计数量 $goods_count = 0; $page_count = 0; if(!empty($params['page_data'])){ $page_count = count($params['page_data']); foreach ($params['page_data'] as $k => $v){ if($v['goods_ids']){ //$v['goods_ids'] = explode(',',$v['goods_ids']); $goods_count += count($v['goods_ids']); } } } if(!empty($params['goods_ids'])) { $goods_count += count($params['goods_ids']); $params['goods_ids'] = implode(',',$params['goods_ids']); } $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['>', 'status', StatusEnum::DISABLED]; $params['goods_count'] = $goods_count; $params['page_num'] = $page_count; $res = AddonsAlbum::setData($params); //插入页面 if($res&&!empty($params['page_data'])){ foreach ($params['page_data'] as $k => $v){ if(is_array($v['goods_ids'])) $v['goods_ids'] = implode(',',$v['goods_ids']); if($v['id'] && $type != '2'){ $page_params['id'] = $v['id']; }else{ $page_params['id'] = ''; } $page_params['mall_id'] = $this->mall_id; $page_params['album_id'] = $res->id; $page_params['image'] = $v['image']; if($v['goods_ids']){ $page_params['goods_ids'] = $v['goods_ids']; }else{ $page_params['goods_ids'] = ''; } $page_params['sort'] = $k; $page_params['status'] = StatusEnum::ENABLED; AddonsAlbumPage::setData($page_params); } } if ($res === false) throw new Exception(AddonsAlbum::getStaticError()); $data['id'] = $res->id; return $this->success('操作成功',$data); } if($request->isGet){ $params = Yii::$app->request->get(); $res = Yii::$app->services->validate->validate($params, [ [['id'],'required'] ]); $params = AddonsAlbum::exceptNullVal($params); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $detail = AddonsAlbum::getOne([['id' => $params['id']]],true,['user']); //$detail['bg_video'] = json_decode($detail['bg_video']); $where[] = ['=','album_id',$params['id']]; $where[] = ['=','status',StatusEnum::ENABLED]; $params = array('where' => $where,'order' => 'sort'); $page_list = AddonsAlbumPage::lists($params,true); if($page_list){ foreach ($page_list as $k=>$v){ if($v['goods_ids']){ $goods_ids = explode(',',$v['goods_ids']); $goods_where = []; $goods_where[] = ['in','id',$goods_ids]; $goods_list = Goods::lists(['where' => $goods_where],true); $page_list[$k]['goods_list'] = $goods_list; $page_list[$k]['goods_ids'] = $goods_ids; }else{ $page_list[$k]['goods_list'] = []; $page_list[$k]['goods_ids'] = []; } } } if($detail['goods_ids']){ $goods_ids = explode(',',$detail['goods_ids']); $goods_where = []; $goods_where[] = ['in','id',$goods_ids]; $goods_list = Goods::lists(['where' => $goods_where],true); $detail['goods_list'] = $goods_list; $detail['goods_ids'] = $goods_ids; }else{ $detail['goods_list'] = []; $detail['goods_ids'] = []; } $detail['page_data'] = $page_list; $this->success('操作成功', $detail); } } } catch (\Exception $e) { return $this->error($e->getMessage(), []); } $params = Yii::$app->request->get(); return $this->render($this->action->id,$params); } /** * @Author: ltm * @DateTime: 2022/2/21 0021 9:27 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $data * @return string */ public function actionDelpage(){ $request = Yii::$app->request; if($request->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params, [ [['id'], 'required'] ]); $params = AddonsAlbum::exceptNullVal($params); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['status'] = StatusEnum::DELETE; $params['mall_id'] = $this->mall_id; $res = AddonsAlbumPage::setData($params); if ($res === false) throw new Exception(AddonsAlbumPage::getStaticError()); $this->success('操作成功'); } } /** * @Author: ltm 获取会员信息 * @DateTime: 2022/2/17 0017 16:59 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $data * @return string */ public function actionUser(){ $retuest = Yii::$app->request; if ($retuest->isAjax && $retuest->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params,[[['keyword'], 'string'], [['keyword'], 'required']]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 搜索用户列表 $list = User::getUserList([['mall_id' => $this->mall_id],['like','mobile',$params['keyword']]], 'id,mobile,nickname,avatar_url', [], 1); $this->success('获取成功', $list); } } }