Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

ProdController.php 13 KiB

3 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <?php
  2. namespace admin\controllers\prod;
  3. use admin\service\prod\ProdService;
  4. use common\Controller\AdminController;
  5. use common\models\BusTicket;
  6. use common\service\admin\LoginService;
  7. use common\util\Util;
  8. use Yii;
  9. class ProdController extends AdminController
  10. {
  11. /**
  12. * Des:获取
  13. * Name: service
  14. * @author 付泓程
  15. */
  16. public function service()
  17. {
  18. if ($this->service == '') {
  19. $this->service = new ProdService();
  20. }
  21. return $this->service;
  22. }
  23. /**
  24. * Function Description:新增产品
  25. * Function Name: actionAddProd
  26. *
  27. * @return string
  28. *
  29. * @author 付泓程
  30. */
  31. public function actionAddProd()
  32. {
  33. $price_type = $this->_post('price_type');
  34. $param = [
  35. 'category_id' => $this->_post('category_id'),
  36. 'pro_cate_name' => $this->_post('pro_cate_name'),
  37. 'price_type' => json_decode($price_type, true),
  38. // 'price_type'=>[['price_type_name'=>'成人票','price_type_price'=>369],['price_type_price'=>368,'price_type_name'=>'儿童票']],
  39. 'show_img' => $this->_post('show_img', ''),
  40. 'prod_des' => $this->_post('prod_des', ''), //產品描述
  41. 'memo' => $this->_post('memo'), //预订须知
  42. 'trip_desc' => $this->_post('trip_desc'), //行程说明
  43. 'close_sale_time' => $this->_post('close_sale_time', '24') //截止售卖时间 2017-05-18 fuhc
  44. ];
  45. $result = $this->service()->AddProd($param);
  46. return json_encode($result);
  47. }
  48. public function actionUptOriginalPrice()
  49. {
  50. $original_price = $this->_post('original_price', 0);
  51. $pro_cate_id = $this->_post('pro_cate_id', '');
  52. $param = [
  53. 'original_price' => $original_price,
  54. 'pro_cate_id' => $pro_cate_id
  55. ];
  56. $result = $this->service()->UptOriginalPrice($param);
  57. return json_encode($result);
  58. }
  59. public function actionUptShowPrice()
  60. {
  61. $show_price = $this->_post('show_price', 0);
  62. $pro_cate_id = $this->_post('pro_cate_id', '');
  63. $param = [
  64. 'show_price' => $show_price,
  65. 'pro_cate_id' => $pro_cate_id
  66. ];
  67. $result = $this->service()->UptShowPrice($param);
  68. return json_encode($result);
  69. }
  70. /**
  71. * Function Description:修改产品信息
  72. * Function Name: actionUptProd
  73. *
  74. *
  75. * @author 付泓程
  76. */
  77. public function actionUptProd()
  78. {
  79. $price_type = $this->_post('price_type');
  80. $param = [
  81. 'pro_cate_id' => $this->_post('pro_cate_id'),
  82. 'category_id' => $this->_post('category_id'),
  83. 'pro_cate_name' => $this->_post('pro_cate_name'),
  84. 'price_type' => json_decode($price_type, true),
  85. // 'price_type'=>[['price_type_name'=>'成人','price_type_price'=>31,'prod_id'=>3],['price_type_price'=>368,'price_type_name'=>'儿童','prod_id'=>555555]],
  86. 'show_img' => $this->_post('show_img'),
  87. 'prod_des' => $this->_post('prod_des', ''), //產品描述
  88. 'memo' => $this->_post('memo'), //预订须知
  89. 'trip_desc' => $this->_post('trip_desc'), //行程说明
  90. 'close_sale_time' => $this->_post('close_sale_time', '24') //截止售卖时间 2017-05-18 fuhc
  91. ];
  92. // return json_encode($param);
  93. $result = $this->service()->UptProd($param);
  94. return json_encode($result);
  95. }
  96. /*
  97. * 产品列表
  98. */
  99. public function actionProdList()
  100. {
  101. $param = [
  102. 'category_id' => $this->_post('category_id'),
  103. 'pro_cate_name_keywords' => $this->_post('pro_cate_name_keywords'),
  104. 'bs_type' => $this->_post('bs_type', 0),
  105. 'current_page' => $this->_post('current_page', 1),
  106. 'page_size' => $this->_post('page_size', 10)
  107. ];
  108. $result = $this->service()->getProdList($param);
  109. return json_encode($result);
  110. }
  111. /*
  112. * 自定义佣金
  113. */
  114. public function actionDefineCommission()
  115. {
  116. $uid = LoginService::$uid;
  117. if (in_array($uid,[8,18,10]) == false) {
  118. return Util::returnJsEr('无佣金自定义权限!');
  119. }
  120. $pro_cate_id = $this->_post('pro_cate_id');
  121. $commission = $this->_post('commission');
  122. $result = $this->service()->DefineCommission($pro_cate_id, $commission);
  123. return json_encode($result);
  124. }
  125. /*
  126. * 自定义佣金
  127. */
  128. public function actionDefineCommissionProd()
  129. {
  130. $prod_commission_arr = $this->_post('prod_commission_arr');
  131. $result = $this->service()->DefineCommissionByProdId(["prod_commission_arr" => $prod_commission_arr]);
  132. return json_encode($result);
  133. }
  134. /*
  135. * 图片上传
  136. */
  137. public function actionUploadImg()
  138. {
  139. if (!empty($_FILES['file_upload'])) {
  140. $imgFile = $_FILES['file_upload'];
  141. $result = $this->service()->uploadImg($imgFile);
  142. return json_encode($result);
  143. }
  144. return Util::returnJsEr('上传失败!请选择图片!');
  145. }
  146. /*
  147. * 图片上传
  148. */
  149. public function actionUploadImgForAdmin()
  150. {
  151. if (!empty($_FILES['file_upload'])) {
  152. $imgFile = $_FILES['file_upload'];
  153. $result = $this->service()->uploadImgForAdmin($imgFile);
  154. return json_encode($result);
  155. }
  156. return Util::returnJsEr('上传失败!请选择图片!');
  157. }
  158. /*
  159. * 新增产品分类
  160. */
  161. public function actionAddProdCategory()
  162. {
  163. $param = [
  164. 'system_id' => $this->_post('system_id'),
  165. 'prod_name' => $this->_post('prod_name')
  166. ];
  167. $result = $this->service()->addProdCategory($param);
  168. return json_encode($result);
  169. }
  170. /*
  171. * 获取产品分类
  172. */
  173. public function actionGetProdCategoryList()
  174. {
  175. $param = [
  176. 'system_id' => $this->_post('system_id'),
  177. 'current_page' => $this->_post('current_page'),
  178. 'page_size' => $this->_post('page_size')
  179. ];
  180. $result = $this->service()->getProdCategoryList($param);
  181. return json_encode($result);
  182. }
  183. /*
  184. * 删除产品分类
  185. */
  186. public function actionDelProdCategory()
  187. {
  188. $param = [
  189. 'system_id' => $this->_post('system_id'),
  190. 'cms_category_id' => $this->_post('cms_category_id')
  191. ];
  192. $result = $this->service()->delProdCategory($param);
  193. return json_encode($result);
  194. }
  195. /*
  196. * 修改产品排序
  197. */
  198. public function actionChangeShowsort()
  199. {
  200. $param = [
  201. 'system_id' => $this->_post('system_id'),
  202. 'show_sort' => $this->_post('show_sort'),
  203. 'cms_category_id' => $this->_post('cms_category_id')
  204. ];
  205. $result = $this->service()->changeShowsort($param);
  206. return json_encode($result);
  207. }
  208. /*
  209. * 获取产品分类标题
  210. */
  211. public function actionGetCategoryTitle()
  212. {
  213. $system_id = $this->_post('system_id');
  214. $result = $this->service()->getCategoryTitle($system_id);
  215. return json_encode($result);
  216. }
  217. /*
  218. * 获取子产品分类标题
  219. */
  220. public function actionGetChildProdList()
  221. {
  222. $param = [
  223. 'system_id' => $this->_post('system_id'),
  224. 'cms_category_id' => $this->_post('cms_category_id'),
  225. 'page_size' => $this->_post('page_size'),
  226. 'current_page' => $this->_post('current_page')
  227. ];
  228. $result = $this->service()->getChildProdList($param);
  229. return json_encode($result);
  230. }
  231. /*
  232. * 获取主产品列表
  233. */
  234. public function actionGetMainProdList()
  235. {
  236. $param = [
  237. 'system_id' => $this->_post('system_id'),
  238. 'cms_category_id' => $this->_post('cms_category_id'),
  239. 'page_size' => $this->_post('page_size'),
  240. 'current_page' => $this->_post('current_page'),
  241. 'base_category_id' => $this->_post('base_category_id'),
  242. 'prod_name' => $this->_post('prod_name')
  243. ];
  244. $result = $this->service()->getMainProdList($param);
  245. return json_encode($result);
  246. }
  247. /*
  248. * 选择产品
  249. */
  250. public function actionSelectProd()
  251. {
  252. $param = [
  253. 'pro_cate_id' => $this->_post('pro_cate_id'),
  254. 'system_id' => $this->_post('system_id'),
  255. 'cms_cate_id' => $this->_post('cms_cate_id')
  256. ];
  257. $result = $this->service()->selectProd($param);
  258. return json_encode($result);
  259. }
  260. /*
  261. * 取消或删除产品
  262. */
  263. public function actionCancelSelectProd()
  264. {
  265. $param = [
  266. 'pro_cate_id' => $this->_post('pro_cate_id'),
  267. 'system_id' => $this->_post('system_id'),
  268. 'cms_cate_id' => $this->_post('cms_cate_id')
  269. ];
  270. $result = $this->service()->cancelSelectProd($param);
  271. return json_encode($result);
  272. }
  273. /*
  274. * 取消或删除产品
  275. */
  276. public function actionChangeProdSort()
  277. {
  278. $param = [
  279. 'system_id' => $this->_post('system_id'),
  280. 'cms_cate_id' => $this->_post('cms_cate_id'),
  281. 'show_sort' => $this->_post('show_sort'),
  282. 'prod_cate_id' => $this->_post('prod_cate_id')
  283. ];
  284. $result = $this->service()->changeProdSort($param);
  285. return json_encode($result);
  286. }
  287. /**
  288. * Function Description:查找额外补充信息
  289. * Function Name: getExtraInfo
  290. * @return string
  291. * @author 田玲菲
  292. */
  293. public function actionGetExtraInfo()
  294. {
  295. $param = [
  296. 'category_id' => $this->_post('category_id', '')
  297. ];
  298. $result = $this->service()->getCategoryExtraInfo($param);
  299. return json_encode($result);
  300. }
  301. /**
  302. * Function Description:增加或者修改额外补充信息
  303. * Function Name: changeExtraInfo
  304. * @return string
  305. * @author 田玲菲
  306. */
  307. public function actionChangeExtraInfo()
  308. {
  309. $param = [
  310. 'category_id' => $this->_post('category_id'),
  311. 'category_name' => $this->_post('category_name'),
  312. 'img_url' => $this->_post('img_url', ''),
  313. 'category_describe' => $this->_post('category_describe', '')
  314. ];
  315. $rst = $this->service()->existExtraInfo($param);
  316. if ($rst) {
  317. $res = $this->service()->changeInfo($param);
  318. } else {
  319. $res = $this->service()->insertInfo($param);
  320. }
  321. return json_encode($res);
  322. }
  323. /**
  324. * Function Description:查找行程攻略信息
  325. * Function Name: getItinerary
  326. * @return string
  327. * @author 田玲菲
  328. */
  329. public function actionGetItinerary()
  330. {
  331. $param = [
  332. 'category_id' => $this->_post('category_id', '')
  333. ];
  334. $res = $this->service()->getItineraryInfo($param);
  335. return json_encode($res);
  336. }
  337. /**
  338. * Function Description:新增或者修改行程攻略
  339. * Function Name: changeItinerary
  340. * @return string
  341. * @author 田玲菲
  342. */
  343. public function actionChangeItinerary()
  344. {
  345. $param = [
  346. 'category_id' => $this->_post('category_id'),
  347. 'category_name' => $this->_post('category_name'),
  348. 'scenc_introduce' => $this->_post('scenc_introduce'),
  349. 'scenc_play' => $this->_post('scenc_play'),
  350. 'folk_customs' => $this->_post('folk_customs'),
  351. 'local_specialities' => $this->_post('local_specialities'),
  352. 'travel_tips' => $this->_post('travel_tips')
  353. ];
  354. $res = $this->service()->existItinerary($param);
  355. if ($res) {
  356. $result = $this->service()->changeItineraryInfo($param);
  357. } else {
  358. $result = $this->service()->insertItinerary($param);
  359. }
  360. return json_encode($result);
  361. }
  362. /**
  363. * Function Description:查找所有有用的品类
  364. * Function Name: getAllCategory
  365. * @return string
  366. * @author 田玲菲
  367. */
  368. public function actionGetAllCategory()
  369. {
  370. $rst = $this->service()->getCategory();
  371. return json_encode($rst);
  372. }
  373. /**
  374. * Function Description:修改品类描述和图片
  375. * Function Name: actionUptCategoryExtra
  376. *
  377. * @return array
  378. *
  379. * @author 娄梦宁
  380. */
  381. public function actionUptCategoryExtra()
  382. {
  383. $param = [
  384. 'cms_category_id' => $this->_post('cms_category_id'),
  385. 'describe' => $this->_post('describe'),
  386. 'img_url' => $this->_post('img_url'),
  387. 'city_id' => $this->_post('city_id'),
  388. ];
  389. $result = $this->service()->uptCategoryExtra($param);
  390. return json_encode($result);
  391. }
  392. /**
  393. * Function Description:获取所有poi信息
  394. * Function Name: actionGetAreaId
  395. *
  396. * @return string
  397. *
  398. * @author 娄梦宁
  399. */
  400. public function actionGetAreaId()
  401. {
  402. $bus_tickets = new BusTicket();
  403. $all_area_id = $bus_tickets->getAllArea();
  404. return json_encode(Util::returnArrSu('', $all_area_id));
  405. }
  406. /**
  407. * Des:更新巴士自由行产品
  408. * Name: actionUptEntranceTicket
  409. * @author 倪宗锋
  410. */
  411. public function actionUpFreeWalker()
  412. {
  413. $shell = 'php ' . ROOT_PATH . '/yii synchro/up-free-walker ' . YII_ENV;
  414. shell_exec($shell);
  415. return '更新完成';
  416. }
  417. }