ConfigindexController.class.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class ConfigindexController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. //'pinjie' => '拼团介绍',
  19. }
  20. public function navigat()
  21. {
  22. $_GPC = I('request.');
  23. $pindex = max(1, intval($_GPC['page']));
  24. $psize = 20;
  25. $condition = "";
  26. if (!empty($_GPC['keyword'])) {
  27. $condition .= ' and navname like "%'.trim($_GPC['keyword']).'%"';
  28. }
  29. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  30. $condition .= ' and enabled = ' . $_GPC['enabled'];
  31. } else {
  32. $_GPC['enabled'] = -1;
  33. }
  34. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_navigat
  35. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  36. $total = M('lionfish_comshop_navigat')->where('1 '. $condition )->count();
  37. $pager = pagination2($total, $pindex, $psize);
  38. $this->_GPC = $_GPC;
  39. $this->list = $list;
  40. $this->display();
  41. }
  42. public function slider()
  43. {
  44. $condition = ' type="slider" ';
  45. $pindex = I('request.page', 1);
  46. $psize = 20;
  47. $keyword = I('request.keyword');
  48. $this->keyword = $keyword;
  49. if (!empty($keyword)) {
  50. $condition .= ' and advname like '.'"%' . $keyword . '%"';
  51. }
  52. $enabled = I('request.enabled');
  53. if (!empty($enabled) && $enabled >= 0) {
  54. $condition .= ' and enabled = ' . $enabled;
  55. } else {
  56. $enabled = -1;
  57. }
  58. $this->enabled = $enabled;
  59. $list = M()->query('SELECT id,advname,thumb,link,type,displayorder,enabled FROM ' .
  60. C('DB_PREFIX'). "lionfish_comshop_adv \r\n
  61. WHERE " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  62. $total = M('lionfish_comshop_adv')->where($condition)->count();
  63. $pager = pagination2($total, $pindex, $psize);
  64. $this->list = $list;
  65. $this->pager = $pager;
  66. $this->display();
  67. }
  68. public function category()
  69. {
  70. $condition = ' type="slider" ';
  71. $pindex = I('request.page', 1);
  72. $psize = 20;
  73. $keyword = I('request.keyword');
  74. $this->keyword = $keyword;
  75. if (!empty($keyword)) {
  76. $condition .= ' and advname like '.'"%' . $keyword . '%"';
  77. }
  78. $enabled = I('request.enabled',-1);
  79. if (!empty($enabled) && $enabled >= 0) {
  80. $condition .= ' and enabled = ' . $enabled;
  81. } else {
  82. $enabled = -1;
  83. }
  84. $this->enabled = $enabled;
  85. $list = M()->query('SELECT id,cate_id,advname,thumb,link,type,displayorder,enabled FROM ' .
  86. C('DB_PREFIX'). "lionfish_comshop_adv_category \r\n
  87. WHERE " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  88. if( !empty($list) )
  89. {
  90. foreach( $list as $key => $val )
  91. {
  92. $cate_info = M('lionfish_comshop_goods_category')->field('id,name')->where("id=".$val['cate_id'])->find();
  93. $val['cate_name'] = '无分类';
  94. if( !empty($cate_info) )
  95. {
  96. $val['cate_name'] = $cate_info['name'];
  97. }
  98. $list[$key] = $val;
  99. }
  100. }
  101. $total = M('lionfish_comshop_adv')->where($condition)->count();
  102. $pager = pagination2($total, $pindex, $psize);
  103. $this->list = $list;
  104. $this->pager = $pager;
  105. $this->display();
  106. }
  107. //
  108. public function addnavigat()
  109. {
  110. $_GPC = I('request.');
  111. $id = intval($_GPC['id']);
  112. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  113. $this->category = $category;
  114. if (!empty($id)) {
  115. // $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  116. // $this->category = $category;
  117. $item = M('lionfish_comshop_navigat')->where( array('id' => $id) )->find();
  118. if($item['type']==6) {
  119. $couponinfo = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $item['link'] . ' ) ')->select();
  120. $this->couponinfo = $couponinfo;
  121. }
  122. $this->item = $item;
  123. }
  124. if (IS_POST) {
  125. $data = $_GPC['data'];
  126. if($data['type']==3 || $data['type']==4){
  127. $data['link'] = $data['cid'];
  128. }
  129. if($data['type']==6){
  130. $coupon_id_list = $_GPC['coupon_id'];
  131. $data['link'] = implode(',', $coupon_id_list);
  132. }
  133. D('Seller/Adv')->navigat_update($data);
  134. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  135. }
  136. $this->display();
  137. }
  138. public function changenavigat()
  139. {
  140. $_GPC = I('request.');
  141. $id = intval($_GPC['id']);
  142. //ids
  143. if (empty($id)) {
  144. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  145. }
  146. if (empty($id)) {
  147. show_json(0, array('message' => '参数错误'));
  148. }
  149. $type = trim($_GPC['type']);
  150. $value = trim($_GPC['value']);
  151. if (!(in_array($type, array('enabled', 'displayorder')))) {
  152. show_json(0, array('message' => '参数错误'));
  153. }
  154. $items = M('lionfish_comshop_navigat')->field('id')->where('id in( ' . $id . ' ) ')->select();
  155. foreach ($items as $item) {
  156. M('lionfish_comshop_navigat')->where( array('id' => $item['id']) )->save( array($type => $value) );
  157. }
  158. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  159. }
  160. public function deletenavigat()
  161. {
  162. $_GPC = I('request.');
  163. $id = intval($_GPC['id']);
  164. //ids
  165. if (empty($id)) {
  166. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  167. }
  168. if (empty($id)) {
  169. show_json(0, array('message' => '参数错误'));
  170. }
  171. $items = M('lionfish_comshop_navigat')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  172. foreach ($items as $item) {
  173. M('lionfish_comshop_navigat')->where( array('id' => $item['id']) )->delete();
  174. }
  175. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  176. }
  177. //
  178. public function addslider()
  179. {
  180. $_GPC = I('request.');
  181. $id = I('request.id');
  182. if (!empty($id)) {
  183. $item = M('lionfish_comshop_adv')->where( array('id' => $id) )->find();
  184. if($item['linktype']==6&&$item['link']) {
  185. $couponinfo = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $item['link'] . ' ) ')->select();
  186. $this->couponinfo = $couponinfo;
  187. }
  188. $this->item = $item;
  189. }
  190. if (IS_POST) {
  191. $data = I('request.data');
  192. if($data['linktype']==6){
  193. $coupon_id_list = $_GPC['coupon_id'];
  194. $data['link'] = implode(',', $coupon_id_list);
  195. }
  196. D('Seller/Adv')->update($data);
  197. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  198. }
  199. $this->display();
  200. }
  201. public function addcategory()
  202. {
  203. $_GPC = I('request.');
  204. $id = I('request.id');
  205. if (!empty($id)) {
  206. $item = M('lionfish_comshop_adv_category')->where( array('id' => $id) )->find();
  207. if($item['linktype']==6&&$item['link']) {
  208. $couponinfo = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $item['link'] . ' ) ')->select();
  209. $this->couponinfo = $couponinfo;
  210. }
  211. $this->item = $item;
  212. }
  213. if (IS_POST) {
  214. $data = I('request.data');
  215. if($data['linktype']==6){
  216. $coupon_id_list = $_GPC['coupon_id'];
  217. $data['link'] = implode(',', $coupon_id_list);
  218. }
  219. D('Seller/Adv')->updatecagetory($data);
  220. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  221. }
  222. $goods_category_list = M('lionfish_comshop_goods_category')->field('id,name')->where("pid=0 and cate_type='normal' ")->select();
  223. $this->goods_category_list = $goods_category_list;
  224. $this->display();
  225. }
  226. public function changecategory()
  227. {
  228. $id = I('request.id');
  229. //ids
  230. if (empty($id)) {
  231. $ids = I('request.ids');
  232. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  233. }
  234. if (empty($id)) {
  235. show_json(0, array('message' => '参数错误'));
  236. }
  237. $type = I('request.type');
  238. $value = I('request.value');
  239. if (!(in_array($type, array('enabled', 'displayorder')))) {
  240. show_json(0, array('message' => '参数错误'));
  241. }
  242. $items = M('lionfish_comshop_adv_category')->where( array('id' => array('in', $id)) )->select();
  243. foreach ($items as $item) {
  244. M('lionfish_comshop_adv_category')->where( array('id' => $item['id']) )->save( array($type => $value) );
  245. }
  246. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  247. }
  248. public function changeslider()
  249. {
  250. $id = I('request.id');
  251. //ids
  252. if (empty($id)) {
  253. $ids = I('request.ids');
  254. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  255. }
  256. if (empty($id)) {
  257. show_json(0, array('message' => '参数错误'));
  258. }
  259. $type = I('request.type');
  260. $value = I('request.value');
  261. if (!(in_array($type, array('enabled', 'displayorder')))) {
  262. show_json(0, array('message' => '参数错误'));
  263. }
  264. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  265. foreach ($items as $item) {
  266. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->save( array($type => $value) );
  267. }
  268. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  269. }
  270. public function delete()
  271. {
  272. $id = I('request.id');
  273. //ids
  274. if (empty($id)) {
  275. $ids = I('request.ids');
  276. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  277. }
  278. if (empty($id)) {
  279. show_json(0, array('message' => '参数错误'));
  280. }
  281. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  282. foreach ($items as $item) {
  283. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->delete();
  284. }
  285. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  286. }
  287. public function deletecategory()
  288. {
  289. $id = I('request.id');
  290. //ids
  291. if (empty($id)) {
  292. $ids = I('request.ids');
  293. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  294. }
  295. if (empty($id)) {
  296. show_json(0, array('message' => '参数错误'));
  297. }
  298. $items = M('lionfish_comshop_adv_category')->where( array('id' => array('in', $id)) )->select();
  299. foreach ($items as $item) {
  300. M('lionfish_comshop_adv_category')->where( array('id' => $item['id']) )->delete();
  301. }
  302. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  303. }
  304. /**
  305. * 公告管理
  306. */
  307. public function notice()
  308. {
  309. $pindex = I('request.page',1);
  310. $psize = 20;
  311. $keyword = I('request.keyword','','trim');
  312. $this->keyword = $keyword;
  313. if (!empty($keyword)) {
  314. $condition .= ' and content like "%'.$keyword.'%" ';
  315. }
  316. $enabled = I('request.enabled',-1);
  317. if (isset($enabled) && $enabled >= 0) {
  318. $condition .= ' and enabled = ' . $enabled;
  319. } else {
  320. $enabled = -1;
  321. }
  322. $this->enabled = $enabled;
  323. $list = M()->query('SELECT id,content,displayorder,enabled FROM ' .
  324. C('DB_PREFIX')."lionfish_comshop_notice
  325. WHERE 1=1 " . $condition . ' order by displayorder desc, id desc
  326. limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  327. $total = M('lionfish_comshop_notice')->where( "1=1 ".$condition )->count();
  328. $pager = pagination2($total, $pindex, $psize);
  329. $this->list = $list;
  330. $this->pager = $pager;
  331. $this->display();
  332. }
  333. /**
  334. * 添加公告
  335. */
  336. public function addnotice()
  337. {
  338. $id = I('request.id');
  339. if (!empty($id)) {
  340. $item = M('lionfish_comshop_notice')->where( array('id' => $id) )->find();
  341. $this->item = $item;
  342. }
  343. if (IS_POST) {
  344. $data = I('request.data');
  345. D('Seller/Notice')->update($data);
  346. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  347. }
  348. $this->display();
  349. }
  350. /**
  351. * 改变公告状态
  352. */
  353. public function changenotice()
  354. {
  355. $id = I('request.id');
  356. //ids
  357. if (empty($id)) {
  358. $ids = I('request.ids');
  359. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  360. }
  361. if (empty($id)) {
  362. show_json(0, array('message' => '参数错误'));
  363. }
  364. $type = I('request.type');
  365. $value = I('request.value');
  366. if (!(in_array($type, array('enabled', 'displayorder')))) {
  367. show_json(0, array('message' => '参数错误'));
  368. }
  369. $items = M('lionfish_comshop_notice')->where( array('id' => array('in', $id)) )->select();
  370. foreach ($items as $item) {
  371. M('lionfish_comshop_notice')->where( array('id' => $item['id']) )->save( array($type => $value) );
  372. }
  373. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  374. }
  375. /**
  376. * 删除公告
  377. */
  378. public function deletenotice()
  379. {
  380. $id = I('request.id');
  381. if (empty($id)) {
  382. $ids = I('request.ids');
  383. $id = (is_array($ids) ? implode(',', $ids) : 0);
  384. }
  385. $items = M('lionfish_comshop_notice')->field('id,content')->where( array('id' => array('in',$id)) )->select();
  386. if (empty($item)) {
  387. $item = array();
  388. }
  389. foreach ($items as $item) {
  390. M('lionfish_comshop_notice')->where( array('id' => $item['id']) )->delete();
  391. }
  392. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  393. }
  394. public function index()
  395. {
  396. if (IS_POST) {
  397. $data = I('request.parameter');
  398. $param = array();
  399. if(trim($data['wechat_apiclient_cert_pem'])) $param['wechat_apiclient_cert_pem'] = trim($data['wechat_apiclient_cert_pem']);
  400. if(trim($data['wechat_apiclient_key_pem'])) $param['wechat_apiclient_key_pem'] = trim($data['wechat_apiclient_key_pem']);
  401. if(trim($data['wechat_rootca_pem'])) $param['wechat_rootca_pem'] = trim($data['wechat_rootca_pem']);
  402. if(trim($data['weapp_apiclient_cert_pem'])) $param['weapp_apiclient_cert_pem'] = trim($data['weapp_apiclient_cert_pem']);
  403. if(trim($data['weapp_apiclient_key_pem'])) $param['weapp_apiclient_key_pem'] = trim($data['weapp_apiclient_key_pem']);
  404. if(trim($data['weapp_rootca_pem'])) $param['weapp_rootca_pem'] = trim($data['weapp_rootca_pem']);
  405. if(trim($data['app_apiclient_cert_pem'])) $param['app_apiclient_cert_pem'] = trim($data['app_apiclient_cert_pem']);
  406. if(trim($data['app_apiclient_key_pem'])) $param['app_apiclient_key_pem'] = trim($data['app_apiclient_key_pem']);
  407. if(trim($data['app_rootca_pem'])) $param['app_rootca_pem'] = trim($data['app_rootca_pem']);
  408. D('Seller/Config')->update($param);
  409. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  410. }
  411. $data = D('Seller/Config')->get_all_config();
  412. $this->data = $data;
  413. $this->display();
  414. }
  415. public function noticesetting()
  416. {
  417. if (IS_POST) {
  418. $data = I('request.parameter');
  419. $data['index_notice_horn_image'] = save_media($data['index_notice_horn_image']);
  420. D('Seller/Config')->update($data);
  421. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  422. }
  423. $data = D('Seller/Config')->get_all_config();
  424. $this->data = $data;
  425. $this->display();
  426. }
  427. public function qgtab()
  428. {
  429. if (IS_POST) {
  430. $data = I('request.parameter');
  431. $data['index_qgtab_one_select'] = save_media($data['index_qgtab_one_select']);
  432. $data['index_qgtab_one_selected'] = save_media($data['index_qgtab_one_selected']);
  433. $data['index_qgtab_two_select'] = save_media($data['index_qgtab_two_select']);
  434. $data['index_qgtab_two_selected'] = save_media($data['index_qgtab_two_selected']);
  435. D('Seller/Config')->update($data);
  436. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  437. }
  438. $data = D('Seller/Config')->get_all_config();
  439. $this->data = $data;
  440. $this->display();
  441. }
  442. /**
  443. * 图片魔方
  444. */
  445. public function cube()
  446. {
  447. $_GPC = I('request.');
  448. $condition = '';
  449. $pindex = max(1, intval($_GPC['page']));
  450. $psize = 20;
  451. if (!empty($_GPC['keyword'])) {
  452. $_GPC['keyword'] = trim($_GPC['keyword']);
  453. $condition .= ' and name like "%'.$_GPC['keyword'].'%"';
  454. }
  455. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  456. $_GPC['enabled'] = trim($_GPC['enabled']);
  457. $condition .= ' and enabled = ' . $_GPC['enabled'];
  458. } else {
  459. $_GPC['enabled'] = -1;
  460. }
  461. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_cube
  462. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  463. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_cube WHERE 1 ' . $condition );
  464. $total = $total_arr['0']['count'];
  465. $pager = pagination2($total, $pindex, $psize);
  466. $this->list = $list;
  467. $this->pager = $pager;
  468. $this->_GPC =$_GPC;
  469. $this->display();
  470. }
  471. /**
  472. * 添加魔方图片
  473. */
  474. public function addcube()//
  475. {
  476. $_GPC = I('request.');
  477. $id = intval($_GPC['id']);
  478. if (!empty($id)) {
  479. $item = M('lionfish_comshop_cube')->where( array('id' => $id ) )->find();
  480. $item['thumb'] = unserialize($item['thumb']);
  481. $couponinfo = array();
  482. if($item['thumb'] && $item['thumb']['cover']) {
  483. $thumb = $item['thumb'];
  484. $cover = $item['thumb']['cover'];
  485. foreach ($cover as $k => $vv) {
  486. if($thumb['linktype'][$k]==6&&$thumb['link'][$k]) {
  487. $couponinfo[] = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $thumb['link'][$k] . ' ) ')->select();
  488. } else {
  489. $couponinfo[] = '';
  490. }
  491. }
  492. }
  493. $this->couponinfo = $couponinfo;
  494. $this->item = $item;
  495. }
  496. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  497. $this->category = $category;
  498. if ( IS_POST ) {
  499. $data = $_GPC['data'];
  500. $thumb = $cover = $link = array();
  501. $cover[] = $data["thumb_0"];
  502. $cover[] = $data["thumb_1"];
  503. $cover[] = $data["thumb_2"];
  504. $cover[] = $data["thumb_3"];
  505. if($data["linktype_0"]==6) {
  506. $coupon_id_list_0 = $_GPC['coupon_id_0'];
  507. $link[] = implode(',', $coupon_id_list_0);
  508. } else {
  509. $link[] = $data["link_0"];
  510. }
  511. if($data["linktype_1"]==6) {
  512. $coupon_id_list_1 = $_GPC['coupon_id_1'];
  513. $link[] = implode(',', $coupon_id_list_1);
  514. } else {
  515. $link[] = $data["link_1"];
  516. }
  517. if($data["linktype_2"]==6) {
  518. $coupon_id_list_2 = $_GPC['coupon_id_2'];
  519. $link[] = implode(',', $coupon_id_list_2);
  520. } else {
  521. $link[] = $data["link_2"];
  522. }
  523. if($data["linktype_3"]==6) {
  524. $coupon_id_list_3 = $_GPC['coupon_id_3'];
  525. $link[] = implode(',', $coupon_id_list_3);
  526. } else {
  527. $link[] = $data["link_3"];
  528. }
  529. $linktype[] = $data["linktype_0"];
  530. $linktype[] = $data["linktype_1"];
  531. $linktype[] = $data["linktype_2"];
  532. $linktype[] = $data["linktype_3"];
  533. $webview[] = $data["webview_0"];
  534. $webview[] = $data["webview_1"];
  535. $webview[] = $data["webview_2"];
  536. $webview[] = $data["webview_3"];
  537. $cateid[] = $data["cateid_0"];
  538. $cateid[] = $data["cateid_1"];
  539. $cateid[] = $data["cateid_2"];
  540. $cateid[] = $data["cateid_3"];
  541. $appid[] = $data["appid_0"];
  542. $appid[] = $data["appid_1"];
  543. $appid[] = $data["appid_2"];
  544. $appid[] = $data["appid_3"];
  545. $outlink[] = $data["outlink_0"];
  546. $outlink[] = $data["outlink_1"];
  547. $outlink[] = $data["outlink_2"];
  548. $outlink[] = $data["outlink_3"];
  549. $num = $data['num'];
  550. if($num==4){
  551. $thumb['cover'] = $cover;
  552. $thumb['link'] = $link;
  553. $thumb['linktype'] = $linktype;
  554. $thumb['webview'] = $webview;
  555. $thumb['cateid'] = $cateid;
  556. $thumb['appid'] = $appid;
  557. $thumb['outlink'] = $outlink;
  558. } else {
  559. $coverArr = array_chunk($cover, $num);
  560. $linkArr = array_chunk($link, $num);
  561. $linktypeArr = array_chunk($linktype, $num);
  562. $webviewArr = array_chunk($webview, $num);
  563. $cateidArr = array_chunk($cateid, $num);
  564. $appidArr = array_chunk($appid, $num);
  565. $outlinkArr = array_chunk($outlink, $num);
  566. $thumb['cover'] = $coverArr[0];
  567. $thumb['link'] = $linkArr[0];
  568. $thumb['linktype'] = $linktypeArr[0];
  569. $thumb['webview'] = $webviewArr[0];
  570. $thumb['cateid'] = $cateidArr[0];
  571. $thumb['appid'] = $appidArr[0];
  572. $thumb['outlink'] = $outlinkArr[0];
  573. }
  574. $params = array();
  575. $params['name'] = $data['name'];
  576. $params['displayorder'] = $data['displayorder'];
  577. $params['enabled'] = $data['enabled'];
  578. $params['name'] = $data['name'];
  579. $params['type'] = $data['type'];
  580. $params['thumb'] = serialize($thumb);
  581. $params['num'] = $data['num'];
  582. $params['linktype'] = 1;
  583. $params['addtime'] = time();
  584. if( !empty($id) && $id > 0 )
  585. {
  586. unset($params['addtime']);
  587. M('lionfish_comshop_cube')->where( array('id' => $id) )->save( $params );
  588. $id = $data['id'];
  589. }else{
  590. $id = M('lionfish_comshop_cube')->add( $params );
  591. }
  592. $url2 =U("configindex/cube");
  593. show_json(1, array('url' => $url2));
  594. }
  595. $this->display();
  596. }
  597. /**
  598. * 切换魔方图显示隐藏 排序
  599. */
  600. public function changeCube()
  601. {
  602. $_GPC = I('request.');
  603. $id = intval($_GPC['id']);
  604. //ids
  605. if (empty($id)) {
  606. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  607. }
  608. if (empty($id)) {
  609. show_json(0, array('message' => '参数错误'));
  610. }
  611. $type = trim($_GPC['type']);
  612. $value = trim($_GPC['value']);
  613. if (!(in_array($type, array('enabled', 'displayorder')))) {
  614. show_json(0, array('message' => '参数错误'));
  615. }
  616. $items = M('lionfish_comshop_cube')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  617. foreach ($items as $item) {
  618. M('lionfish_comshop_cube')->where( array('id' => $item['id']) )->save( array($type => $value) );
  619. }
  620. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  621. }
  622. /**
  623. * 删除魔方图
  624. * @return [json] [description]
  625. */
  626. public function deleteCube()
  627. {
  628. $_GPC = I('request.');
  629. $id = intval($_GPC['id']);
  630. //ids
  631. if (empty($id)) {
  632. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  633. }
  634. if (empty($id)) {
  635. show_json(0, array('message' => '参数错误'));
  636. }
  637. $items = M('lionfish_comshop_cube')->field('id')->where( 'id in( ' . $id . ' ) ' )->select();
  638. foreach ($items as $item) {
  639. M('lionfish_comshop_cube')->where( array('id' => $item['id'] ) )->delete();
  640. }
  641. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  642. }
  643. /**
  644. * 首页视频
  645. * @return [Json] [description]
  646. */
  647. public function video()
  648. {
  649. $_GPC = I('request.');
  650. if ( IS_POST ) {
  651. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  652. $data['index_video_poster'] = save_media($data['index_video_poster']);
  653. $data['index_video_url'] = save_media($data['index_video_url']);
  654. $data['index_video_url'] = D('Seller/Goods')->check_douyin_video($data['index_video_url']);
  655. // var_dump($data['index_video_url']);
  656. // die();
  657. D('Seller/Config')->update($data);
  658. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  659. }
  660. $data = D('Seller/Config')->get_all_config();
  661. $this->data = $data;
  662. $this->display();
  663. }
  664. }
  665. ?>