UtilController.class.php 12 KB

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