UtilController.class.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 UtilController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. $this->full = intval($_GPC['full']);
  19. $this->platform = trim($_GPC['platform']);
  20. $this->defaultUrl = trim($_GPC['url']);
  21. $this->allUrls = array(
  22. array(
  23. 'name' => '商城页面',
  24. 'title' => "BASICS_LINK",
  25. 'list' => array(
  26. array('name' => '社区团购首页', 'title' => "INDEX", 'url' => '/lionfish_comshop/pages/index/index', 'url_wxapp' => '/lionfish_comshop/pages/index/index'),
  27. array('name' => '购物车', 'title' => "CART", 'url' => '/lionfish_comshop/pages/order/shopCart', 'url_wxapp' => '/lionfish_comshop/pages/order/shopCart'),
  28. array('name' => '团长申请页面', 'title' => "GROUPCENTER_APPLY", 'url' => '/lionfish_comshop/moduleA/groupCenter/apply', 'url_wxapp' => '/lionfish_comshop/moduleA/groupCenter/apply'),
  29. array('name' => '团长申请介绍页面', 'title' => "GROUPCENTER_RECRUIT", 'url' => '/lionfish_comshop/moduleA/groupCenter/recruit', 'url_wxapp' => '/lionfish_comshop/moduleA/groupCenter/recruit'),
  30. array('name' => '供应商申请页面', 'title' => "SUPPLY_APPLY", 'url' => '/lionfish_comshop/pages/supply/apply', 'url_wxapp' => '/lionfish_comshop/pages/supply/apply'),
  31. array('name' => '供应商介绍页面地址', 'title' => "SUPPLY_RECRUIT", 'url' => '/lionfish_comshop/pages/supply/recruit', 'url_wxapp' => '/lionfish_comshop/pages/supply/recruit'),
  32. // array('name' => '会员表单信息收集页面', 'title' => "FORM_APPLY", 'url' => '/lionfish_comshop/pages/form/apply', 'url_wxapp' => '/lionfish_comshop/pages/form/apply'),
  33. array('name' => '分类页', 'title' => "CATE", 'url' => '/lionfish_comshop/pages/type/index', 'url_wxapp' => '/lionfish_comshop/pages/type/index'),
  34. array('name' => '余额充值', 'title' => "USER_CHARGE", 'url' => '/lionfish_comshop/pages/user/charge', 'url_wxapp' => '/lionfish_comshop/pages/user/charge'),
  35. array('name' => '视频商品列表', 'title' => "VIDEO", 'url' => '/lionfish_comshop/moduleA/video/index', 'url_wxapp' => '/lionfish_comshop/moduleA/video/index'),
  36. array('name' => '群接龙', 'title' => "SOLITAIRE", 'url' => '/lionfish_comshop/moduleA/solitaire/index', 'url_wxapp' => '/lionfish_comshop/moduleA/solitaire/index'),
  37. array('name' => '仅快递商品列表页', 'title' => "GENERALMALL", 'url' => '/lionfish_comshop/moduleB/generalmall/index', 'url_wxapp' => '/lionfish_comshop/moduleB/generalmall/index'),
  38. ),
  39. ),
  40. /**
  41. array(
  42. 'name' => '商品属性',
  43. 'list' => array(
  44. array('name' => '分类搜索', 'url' => '/lionfish_comshop/pages/goods/search', 'url_wxapp' => '/lionfish_comshop/pages/goods/search'),
  45. ),
  46. ),
  47. **/
  48. array(
  49. 'name' => '会员中心',
  50. 'title' => "MEMBER_LINK",
  51. 'list' => array(
  52. array('name' => '会员中心', 'title' => "MEMBER", 'url' => '/lionfish_comshop/pages/user/me', 'url_wxapp' => '/lionfish_comshop/pages/user/me'),
  53. array('name' => '订单列表', 'title' => "ORDER_LIST", 'url' => '/lionfish_comshop/pages/order/index', 'url_wxapp' => '/lionfish_comshop/pages/order/index'),
  54. array('name' => '关于我们', 'title' => "ABOUT_US", 'url' => '/lionfish_comshop/pages/user/articleProtocol?about=1', 'url_wxapp' => '/lionfish_comshop/pages/user/articleProtocol?about=1'),
  55. array('name' => '常见帮助', 'title' => "HELP", 'url' => '/lionfish_comshop/pages/user/protocol', 'url_wxapp' => '/lionfish_comshop/pages/user/protocol'),
  56. // array('name' => '订单列表', 'url' => '/lionfish_comshop/pages/order/pintuan', 'url_wxapp' => '/lionfish_comshop/pages/order/pintuan'),
  57. // array('name' => '拼团列表', 'url' => '/lionfish_comshop/pages/order/pintuan', 'url_wxapp' => '/lionfish_comshop/pages/order/pintuan'),
  58. // array('name' => '我的收藏', 'url' => '/lionfish_comshop/pages/dan/myfav', 'url_wxapp' => '/lionfish_comshop/pages/dan/myfav'),
  59. // array('name' => '我的优惠券', 'url' => '/lionfish_comshop/pages/dan/quan', 'url_wxapp' => '/lionfish_comshop/pages/dan/quan'),
  60. ),
  61. ),
  62. array(
  63. 'name' => '其他',
  64. 'title' => "OTHER_LINK",
  65. 'list' => array(
  66. array('name' => '供应商列表', 'title' => "SUPPLY_INDEX", 'url' => '/lionfish_comshop/pages/supply/index', 'url_wxapp' => '/lionfish_comshop/pages/supply/index'),
  67. array('name' => '专题列表', 'title' => "SPECIAL_INDEX", 'url' => '/lionfish_comshop/moduleA/special/list', 'url_wxapp' => '/lionfish_comshop/pages/special/list'),
  68. array('name' => '拼团首页', 'title' => "PIN_INDEX", 'url' => '/lionfish_comshop/moduleA/pin/index', 'url_wxapp' => '/lionfish_comshop/moduleA/pin/index'),
  69. array('name' => '付费会员首页', 'title' => "VIP_UPGRADE", 'url' => '/lionfish_comshop/moduleA/vip/upgrade', 'url_wxapp' => '/lionfish_comshop/moduleA/vip/upgrade'),
  70. array('name' => '积分/签到/兑换', 'title' => "SCORE_SIGNIN", 'url' => '/lionfish_comshop/moduleA/score/signin', 'url_wxapp' => '/lionfish_comshop/moduleA/score/signin'),
  71. array('name' => '菜谱', 'title' => "MENU_INDEX", 'url' => '/lionfish_comshop/moduleA/menu/index', 'url_wxapp' => '/lionfish_comshop/moduleA/menu/index'),
  72. array('name' => '整点秒杀', 'title' => "DECKILL_INDEX", 'url' => '/lionfish_comshop/moduleA/seckill/list', 'url_wxapp' => '/lionfish_comshop/moduleA/seckill/list'),
  73. array('name' => '直播列表', 'title' => "LIVE_INDEX", 'url' => '/lionfish_comshop/moduleB/live/index', 'url_wxapp' => '/lionfish_comshop/moduleB/live/index'),
  74. array('name' => '商品预售', 'title' => "PRESALE_INDEX", 'url' => '/lionfish_comshop/moduleB/presale/index', 'url_wxapp' => '/lionfish_comshop/moduleB/presale/index'),
  75. array('name' => '礼品卡中心', 'title' => "VIRTUALCARD_INDEX", 'url' => '/lionfish_comshop/moduleB/virtualcard/index', 'url_wxapp' => '/lionfish_comshop/moduleB/virtualcard/index'),
  76. array('name' => '分销中心', 'title' => "DISTRIBUTION_CENTER", 'url' => '/lionfish_comshop/distributionCenter/pages/me', 'url_wxapp' => '/lionfish_comshop/distributionCenter/pages/me'),
  77. array('name' => '邀请有礼', 'title' => "INVITE_INDEX", 'url' => '/lionfish_comshop/moduleB/invite/index', 'url_wxapp' => '/lionfish_comshop/moduleB/invite/index'),
  78. )
  79. )
  80. );
  81. }
  82. public function selecturl()
  83. {
  84. $platform = $this->platform;
  85. $full = $this->full;
  86. $allUrls = $this->allUrls;
  87. $this->display();
  88. }
  89. public function query()
  90. {
  91. $type = I('request.type');
  92. $kw = I('request.kw');
  93. $full = I('request.full');
  94. $platform = I('request.platform');
  95. $this->type = $type;
  96. $this->kw = $kw;
  97. $this->full = $full;
  98. $this->platform = $platform;
  99. if (!empty($kw) && !empty($type)) {
  100. if ($type == 'good') {
  101. $list = M()->query('SELECT id,goodsname as title,productprice,price as marketprice,sales,type FROM ' .
  102. C('DB_PREFIX') . 'lionfish_comshop_goods WHERE grounding=1 and total > 0
  103. AND goodsname LIKE "'.'%' . $kw . '%'.'" ');
  104. if (!empty($list)) {
  105. foreach ($list as &$val) {
  106. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $val['id']) )->order('id asc')->find();
  107. $val['thumb'] = tomedia($thumb['image']);
  108. }
  109. }
  110. //$list = set_medias($list, 'thumb');
  111. //thumb
  112. } else if ($type == 'article') {
  113. $list = M('lionfish_comshop_article')->field('id,title')->where( " (title LIKE '%".$kw."%' or id like '%".$kw."%' ) and enabled=1" )->select();
  114. } else if ($type == 'coupon') {
  115. $list = M('lionfish_comshop_coupon')->field('id,voucher_title')->where( " (voucher_title LIKE '%".$kw."%' or id like '%".$kw."%' ) " )->select();
  116. } else if ($type == 'groups') {
  117. } else if ($type == 'sns') {
  118. } else if ($type == 'url') {
  119. $list = $this->searchUrl($this->allUrls, "name", $kw);
  120. } else if ($type == 'special') {
  121. $list = M('lionfish_comshop_special')->field('id,name')->where("name LIKE '%{$kw}%' and enabled=1 ")->select();
  122. }
  123. else if ($type == 'category') {
  124. $list = M('lionfish_comshop_goods_category')->field('id,name')->where( " name LIKE '%{$kw}%' " )->where(['cate_type'=>'normal'])->select();
  125. }
  126. else if ($type == 'solitaire') {
  127. $list = M('lionfish_comshop_solitaire')->field('id,solitaire_name as name')->where( " solitaire_name LIKE '%{$kw}%' and state = 1 " )->select();
  128. }
  129. else if ($type == 'pintuan') {
  130. $list = M('lionfish_comshop_goods')->field('id,goodsname as name')->where( " goodsname LIKE '%{$kw}%' and type = 'pin' and grounding = 1 " )->select();
  131. $list = M()->query("SELECT id,goodsname as title,productprice,price as marketprice,sales,type FROM " .
  132. C('DB_PREFIX') . "lionfish_comshop_goods WHERE grounding=1 and total > 0 and type = 'pin' "
  133. . " AND goodsname LIKE '%" . $kw . "%'");
  134. if (!empty($list)) {
  135. foreach ($list as &$val) {
  136. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $val['id']) )->order('id asc')->find();
  137. $val['thumb'] = tomedia($thumb['image']);
  138. }
  139. }
  140. }
  141. else {
  142. if ($type == 'creditshop') {
  143. }
  144. }
  145. }
  146. $this->list = $list;
  147. //dump($list);die;
  148. $this->display('Util/selecturl_tpl');
  149. }
  150. public function diygeturl() {
  151. $allUrls = $this->allUrls;
  152. $link = I('request.link', array());
  153. $name = I('request.name', array());
  154. $is_array = true;
  155. if (!empty($link)) {
  156. $link = htmlspecialchars_decode($link);
  157. $link = json_decode($link, true);
  158. $is_array = is_array($link);
  159. }
  160. $data = array();
  161. $temp_link = [];
  162. foreach($allUrls as $pk => $pitem) {
  163. $data[] = array(
  164. "addon_name" => "",
  165. "child_list" => array(),
  166. "name" => $pitem['title'],
  167. "title" => $pitem['name'],
  168. "parent" => "MALL_LINK",
  169. "wap_url" => "",
  170. "web_url" => ""
  171. );
  172. if(isset($pitem['list'])) {
  173. foreach($pitem['list'] as $ck => $citem) {
  174. $tempArr = array(
  175. "addon_name" => "",
  176. "child_list" => array(),
  177. "name" => $citem['title'],
  178. "title" => $citem['name'],
  179. "parent" => $pitem['title'],
  180. "selected" => false,
  181. "wap_url" => $citem['url_wxapp'],
  182. "web_url" => ""
  183. );
  184. if ($value[ 'addon_name' ] == '') {
  185. if (!empty($link) && $is_array && $link['name'] == $citem[ 'title' ]) {
  186. $tempArr['selected'] = true;
  187. } elseif (!empty($link) && !$is_array && strtolower($link) == strtolower($citem['url_wxapp'])) {
  188. $tempArr['selected'] = true;
  189. $temp_link = $tempArr;
  190. }
  191. }
  192. $data[$pk]['child_list'][] = $tempArr;
  193. }
  194. }
  195. }
  196. if (!$is_array) {
  197. $link = $temp_link;
  198. }
  199. $res = array( "link" => $link, "list" => $data );
  200. echo json_encode($res);
  201. die();
  202. }
  203. }
  204. ?>