|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- <?php
-
- namespace admin\controllers\prod;
-
- use admin\service\prod\ProdService;
- use common\Controller\AdminController;
- use common\models\BusTicket;
- use common\service\admin\LoginService;
- use common\util\Util;
- use Yii;
-
- class ProdController extends AdminController
- {
- /**
- * Des:获取
- * Name: service
- * @author 付泓程
- */
- public function service()
- {
- if ($this->service == '') {
- $this->service = new ProdService();
- }
- return $this->service;
- }
-
- /**
- * Function Description:新增产品
- * Function Name: actionAddProd
- *
- * @return string
- *
- * @author 付泓程
- */
- public function actionAddProd()
- {
- $price_type = $this->_post('price_type');
- $param = [
- 'category_id' => $this->_post('category_id'),
- 'pro_cate_name' => $this->_post('pro_cate_name'),
- 'price_type' => json_decode($price_type, true),
- // 'price_type'=>[['price_type_name'=>'成人票','price_type_price'=>369],['price_type_price'=>368,'price_type_name'=>'儿童票']],
- 'show_img' => $this->_post('show_img', ''),
- 'prod_des' => $this->_post('prod_des', ''), //產品描述
- 'memo' => $this->_post('memo'), //预订须知
- 'trip_desc' => $this->_post('trip_desc'), //行程说明
- 'close_sale_time' => $this->_post('close_sale_time', '24') //截止售卖时间 2017-05-18 fuhc
- ];
- $result = $this->service()->AddProd($param);
- return json_encode($result);
- }
-
- public function actionUptOriginalPrice()
- {
- $original_price = $this->_post('original_price', 0);
- $pro_cate_id = $this->_post('pro_cate_id', '');
- $param = [
- 'original_price' => $original_price,
- 'pro_cate_id' => $pro_cate_id
- ];
- $result = $this->service()->UptOriginalPrice($param);
- return json_encode($result);
- }
-
- public function actionUptShowPrice()
- {
- $show_price = $this->_post('show_price', 0);
- $pro_cate_id = $this->_post('pro_cate_id', '');
- $param = [
- 'show_price' => $show_price,
- 'pro_cate_id' => $pro_cate_id
- ];
- $result = $this->service()->UptShowPrice($param);
- return json_encode($result);
- }
-
- /**
- * Function Description:修改产品信息
- * Function Name: actionUptProd
- *
- *
- * @author 付泓程
- */
- public function actionUptProd()
- {
- $price_type = $this->_post('price_type');
- $param = [
- 'pro_cate_id' => $this->_post('pro_cate_id'),
- 'category_id' => $this->_post('category_id'),
- 'pro_cate_name' => $this->_post('pro_cate_name'),
- 'price_type' => json_decode($price_type, true),
- // 'price_type'=>[['price_type_name'=>'成人','price_type_price'=>31,'prod_id'=>3],['price_type_price'=>368,'price_type_name'=>'儿童','prod_id'=>555555]],
- 'show_img' => $this->_post('show_img'),
- 'prod_des' => $this->_post('prod_des', ''), //產品描述
- 'memo' => $this->_post('memo'), //预订须知
- 'trip_desc' => $this->_post('trip_desc'), //行程说明
- 'close_sale_time' => $this->_post('close_sale_time', '24') //截止售卖时间 2017-05-18 fuhc
- ];
- // return json_encode($param);
- $result = $this->service()->UptProd($param);
- return json_encode($result);
- }
-
- /*
- * 产品列表
- */
- public function actionProdList()
- {
- $param = [
- 'category_id' => $this->_post('category_id'),
- 'pro_cate_name_keywords' => $this->_post('pro_cate_name_keywords'),
- 'bs_type' => $this->_post('bs_type', 0),
- 'current_page' => $this->_post('current_page', 1),
- 'page_size' => $this->_post('page_size', 10)
- ];
- $result = $this->service()->getProdList($param);
- return json_encode($result);
- }
-
- /*
- * 自定义佣金
- */
- public function actionDefineCommission()
- {
- $uid = LoginService::$uid;
- if (in_array($uid,[8,18,10]) == false) {
- return Util::returnJsEr('无佣金自定义权限!');
- }
- $pro_cate_id = $this->_post('pro_cate_id');
- $commission = $this->_post('commission');
- $result = $this->service()->DefineCommission($pro_cate_id, $commission);
- return json_encode($result);
- }
-
- /*
- * 自定义佣金
- */
- public function actionDefineCommissionProd()
- {
- $prod_commission_arr = $this->_post('prod_commission_arr');
- $result = $this->service()->DefineCommissionByProdId(["prod_commission_arr" => $prod_commission_arr]);
- return json_encode($result);
- }
-
- /*
- * 图片上传
- */
- public function actionUploadImg()
- {
- if (!empty($_FILES['file_upload'])) {
- $imgFile = $_FILES['file_upload'];
- $result = $this->service()->uploadImg($imgFile);
- return json_encode($result);
- }
- return Util::returnJsEr('上传失败!请选择图片!');
- }
-
- /*
- * 图片上传
- */
- public function actionUploadImgForAdmin()
- {
- if (!empty($_FILES['file_upload'])) {
- $imgFile = $_FILES['file_upload'];
- $result = $this->service()->uploadImgForAdmin($imgFile);
- return json_encode($result);
- }
- return Util::returnJsEr('上传失败!请选择图片!');
- }
-
- /*
- * 新增产品分类
- */
- public function actionAddProdCategory()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'prod_name' => $this->_post('prod_name')
- ];
- $result = $this->service()->addProdCategory($param);
- return json_encode($result);
- }
-
- /*
- * 获取产品分类
- */
- public function actionGetProdCategoryList()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'current_page' => $this->_post('current_page'),
- 'page_size' => $this->_post('page_size')
- ];
- $result = $this->service()->getProdCategoryList($param);
- return json_encode($result);
- }
-
- /*
- * 删除产品分类
- */
- public function actionDelProdCategory()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'cms_category_id' => $this->_post('cms_category_id')
- ];
- $result = $this->service()->delProdCategory($param);
- return json_encode($result);
- }
-
- /*
- * 修改产品排序
- */
- public function actionChangeShowsort()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'show_sort' => $this->_post('show_sort'),
- 'cms_category_id' => $this->_post('cms_category_id')
- ];
- $result = $this->service()->changeShowsort($param);
- return json_encode($result);
- }
-
- /*
- * 获取产品分类标题
- */
- public function actionGetCategoryTitle()
- {
- $system_id = $this->_post('system_id');
- $result = $this->service()->getCategoryTitle($system_id);
- return json_encode($result);
- }
-
- /*
- * 获取子产品分类标题
- */
- public function actionGetChildProdList()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'cms_category_id' => $this->_post('cms_category_id'),
- 'page_size' => $this->_post('page_size'),
- 'current_page' => $this->_post('current_page')
- ];
- $result = $this->service()->getChildProdList($param);
- return json_encode($result);
- }
-
-
- /*
- * 获取主产品列表
- */
- public function actionGetMainProdList()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'cms_category_id' => $this->_post('cms_category_id'),
- 'page_size' => $this->_post('page_size'),
- 'current_page' => $this->_post('current_page'),
- 'base_category_id' => $this->_post('base_category_id'),
- 'prod_name' => $this->_post('prod_name')
- ];
- $result = $this->service()->getMainProdList($param);
- return json_encode($result);
- }
-
- /*
- * 选择产品
- */
- public function actionSelectProd()
- {
- $param = [
- 'pro_cate_id' => $this->_post('pro_cate_id'),
- 'system_id' => $this->_post('system_id'),
- 'cms_cate_id' => $this->_post('cms_cate_id')
- ];
- $result = $this->service()->selectProd($param);
- return json_encode($result);
-
- }
-
- /*
- * 取消或删除产品
- */
- public function actionCancelSelectProd()
- {
- $param = [
- 'pro_cate_id' => $this->_post('pro_cate_id'),
- 'system_id' => $this->_post('system_id'),
- 'cms_cate_id' => $this->_post('cms_cate_id')
- ];
- $result = $this->service()->cancelSelectProd($param);
- return json_encode($result);
- }
-
- /*
- * 取消或删除产品
- */
- public function actionChangeProdSort()
- {
- $param = [
- 'system_id' => $this->_post('system_id'),
- 'cms_cate_id' => $this->_post('cms_cate_id'),
- 'show_sort' => $this->_post('show_sort'),
- 'prod_cate_id' => $this->_post('prod_cate_id')
- ];
- $result = $this->service()->changeProdSort($param);
- return json_encode($result);
- }
-
-
- /**
- * Function Description:查找额外补充信息
- * Function Name: getExtraInfo
- * @return string
- * @author 田玲菲
- */
- public function actionGetExtraInfo()
- {
- $param = [
- 'category_id' => $this->_post('category_id', '')
- ];
- $result = $this->service()->getCategoryExtraInfo($param);
- return json_encode($result);
- }
-
-
- /**
- * Function Description:增加或者修改额外补充信息
- * Function Name: changeExtraInfo
- * @return string
- * @author 田玲菲
- */
- public function actionChangeExtraInfo()
- {
- $param = [
- 'category_id' => $this->_post('category_id'),
- 'category_name' => $this->_post('category_name'),
- 'img_url' => $this->_post('img_url', ''),
- 'category_describe' => $this->_post('category_describe', '')
- ];
- $rst = $this->service()->existExtraInfo($param);
- if ($rst) {
- $res = $this->service()->changeInfo($param);
- } else {
- $res = $this->service()->insertInfo($param);
- }
- return json_encode($res);
- }
-
-
- /**
- * Function Description:查找行程攻略信息
- * Function Name: getItinerary
- * @return string
- * @author 田玲菲
- */
- public function actionGetItinerary()
- {
- $param = [
- 'category_id' => $this->_post('category_id', '')
- ];
- $res = $this->service()->getItineraryInfo($param);
- return json_encode($res);
- }
-
-
- /**
- * Function Description:新增或者修改行程攻略
- * Function Name: changeItinerary
- * @return string
- * @author 田玲菲
- */
- public function actionChangeItinerary()
- {
- $param = [
- 'category_id' => $this->_post('category_id'),
- 'category_name' => $this->_post('category_name'),
- 'scenc_introduce' => $this->_post('scenc_introduce'),
- 'scenc_play' => $this->_post('scenc_play'),
- 'folk_customs' => $this->_post('folk_customs'),
- 'local_specialities' => $this->_post('local_specialities'),
- 'travel_tips' => $this->_post('travel_tips')
- ];
- $res = $this->service()->existItinerary($param);
- if ($res) {
- $result = $this->service()->changeItineraryInfo($param);
- } else {
- $result = $this->service()->insertItinerary($param);
- }
- return json_encode($result);
- }
-
-
- /**
- * Function Description:查找所有有用的品类
- * Function Name: getAllCategory
- * @return string
- * @author 田玲菲
- */
- public function actionGetAllCategory()
- {
- $rst = $this->service()->getCategory();
- return json_encode($rst);
- }
-
- /**
- * Function Description:修改品类描述和图片
- * Function Name: actionUptCategoryExtra
- *
- * @return array
- *
- * @author 娄梦宁
- */
- public function actionUptCategoryExtra()
- {
- $param = [
- 'cms_category_id' => $this->_post('cms_category_id'),
- 'describe' => $this->_post('describe'),
- 'img_url' => $this->_post('img_url'),
- 'city_id' => $this->_post('city_id'),
- ];
- $result = $this->service()->uptCategoryExtra($param);
- return json_encode($result);
- }
-
- /**
- * Function Description:获取所有poi信息
- * Function Name: actionGetAreaId
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionGetAreaId()
- {
- $bus_tickets = new BusTicket();
- $all_area_id = $bus_tickets->getAllArea();
- return json_encode(Util::returnArrSu('', $all_area_id));
- }
-
- /**
- * Des:更新巴士自由行产品
- * Name: actionUptEntranceTicket
- * @author 倪宗锋
- */
- public function actionUpFreeWalker()
- {
- $shell = 'php ' . ROOT_PATH . '/yii synchro/up-free-walker ' . YII_ENV;
- shell_exec($shell);
- return '更新完成';
- }
- }
|