ScekillController.class.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * 拼团模块
  6. * @author fish
  7. *
  8. */
  9. namespace Home\Controller;
  10. class ScekillController extends CommonController {
  11. protected function _initialize()
  12. {
  13. parent::_initialize();
  14. }
  15. public function get_scekill_info()
  16. {
  17. //秒杀设置begin
  18. $seckill_is_open = D('Home/Front')->get_config_by_name('seckill_is_open');
  19. $seckill_is_show_index = D('Home/Front')->get_config_by_name('seckill_is_show_index');
  20. $scekill_show_time = D('Home/Front')->get_config_by_name('scekill_show_time');
  21. if( empty($seckill_is_open) )
  22. {
  23. $seckill_is_open = 0;
  24. }
  25. if( empty($seckill_is_show_index) )
  26. {
  27. $seckill_is_show_index = 0;
  28. }
  29. $scekill_time_arr = array();
  30. if( isset($scekill_show_time) && !empty($scekill_show_time) )
  31. {
  32. $scekill_show_time_arr = unserialize($scekill_show_time);
  33. foreach($scekill_show_time_arr as $vv)
  34. {
  35. if( $vv != 25 )
  36. {
  37. $scekill_time_arr[] = $vv;
  38. }
  39. }
  40. }
  41. //秒杀主页标题
  42. $seckill_page_title = D('Home/Front')->get_config_by_name('seckill_page_title');
  43. if( empty($seckill_page_title) )
  44. {
  45. $seckill_page_title = '商品秒杀';
  46. }
  47. //首页秒杀活动背景色
  48. $seckill_bg_color = D('Home/Front')->get_config_by_name('seckill_bg_color');
  49. //秒杀活动分享标题
  50. $seckill_share_title = D('Home/Front')->get_config_by_name('seckill_share_title');
  51. $seckill_share_image = D('Home/Front')->get_config_by_name('seckill_share_image');
  52. if( !empty($seckill_share_image) )
  53. {
  54. $seckill_share_image = tomedia( $seckill_share_image );
  55. }
  56. //是否显示tabbar
  57. $showTabbar = false;
  58. $tabbar_out_type = D('Home/Front')->get_config_by_name('tabbar_out_type');
  59. $tabbar_out_link = D('Home/Front')->get_config_by_name('tabbar_out_link');
  60. if($tabbar_out_type==1 && $tabbar_out_link == '/lionfish_comshop/moduleA/seckill/list') $showTabbar = true;
  61. //整点秒杀结束
  62. $need_data = array();
  63. $need_data['seckill_is_open'] = $seckill_is_open;
  64. $need_data['seckill_is_show_index'] = $seckill_is_show_index;
  65. $need_data['scekill_time_arr'] = $scekill_time_arr;
  66. $need_data['seckill_page_title'] = $seckill_page_title;
  67. $need_data['seckill_bg_color'] = $seckill_bg_color;
  68. $need_data['seckill_share_title'] = $seckill_share_title;
  69. $need_data['seckill_share_image'] = $seckill_share_image;
  70. $need_data['showTabbar'] = $showTabbar;
  71. echo json_encode( array('code' => 0 ,'data' => $need_data ) );
  72. die();
  73. }
  74. public function load_gps_goodslist()
  75. {
  76. $_GPC = I('request.');
  77. $head_id = $_GPC['head_id'];
  78. if($head_id == 'undefined') $head_id = '';
  79. $pageNum = $_GPC['pageNum'];
  80. $gid = $_GPC['gid'];
  81. $keyword = $_GPC['keyword'];
  82. $is_random = isset($_GPC['is_random']) ? $_GPC['is_random'] : 0;
  83. $per_page = isset($_GPC['per_page']) ? $_GPC['per_page'] : 10;
  84. $cate_info = '';
  85. if($gid == 'undefined' || $gid =='')
  86. {
  87. $gid = 0;
  88. } else {
  89. $cate_info = M('lionfish_comshop_goods_category')->field('banner,name')->where( array('id' => $gid ) )->find();
  90. if(!empty($cate_info['banner'])) $cate_info['banner'] = tomedia($cate_info['banner']);
  91. }
  92. if(!$keyword){
  93. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid);
  94. $gidArr = array();
  95. $gidArr[] = $gid;
  96. foreach ($gids as $key => $val) {
  97. $gidArr[] = $val['id'];
  98. }
  99. $gid = implode(',', $gidArr);
  100. }
  101. $offset = ($pageNum - 1) * $per_page;
  102. $limit = "{$offset},{$per_page}";
  103. $token = $_GPC['token'];
  104. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  105. $is_member_level_buy = 0;
  106. $is_vip_card_member = 0;
  107. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  108. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  109. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  110. {
  111. // echo json_encode( array('code' => 2) );
  112. // die();
  113. }else{
  114. $member_id = $weprogram_token['member_id'];
  115. //member_id
  116. if( $member_id > 0 )
  117. {
  118. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  119. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  120. {
  121. $now_time = time();
  122. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  123. {
  124. $is_vip_card_member = 1;//还是会员
  125. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  126. $is_vip_card_member = 2;//已过期
  127. }
  128. }
  129. if($is_vip_card_member != 1 && $member_info['level_id'] >0 )
  130. {
  131. $is_member_level_buy = 1;
  132. }
  133. }
  134. }
  135. $now_time = time();
  136. $where = " g.grounding =1 and g.type ='normal' ";
  137. //head_id
  138. if( !empty($head_id) && $head_id >0 )
  139. {
  140. if(!empty($keyword)) {
  141. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  142. .C('DB_PREFIX')."lionfish_comshop_goods as g
  143. where pg.goods_id = g.id and g.goodsname like '%{$keyword}%' and pg.head_id = {$head_id} order by pg.id desc ";
  144. $goods_ids_arr = M()->query($sql_goods_ids);
  145. } else {
  146. if($gid == 0){
  147. $goods_ids_arr = M()->query('SELECT goods_id FROM ' . C('DB_PREFIX'). "lionfish_community_head_goods
  148. WHERE head_id=".$head_id." order by id desc " );
  149. } else {
  150. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  151. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  152. where pg.goods_id = g.goods_id and g.cate_id in ({$gid}) and pg.head_id = {$head_id} order by pg.id desc ";
  153. $goods_ids_arr = M()->query($sql_goods_ids);
  154. }
  155. }
  156. $ids_arr = array();
  157. foreach($goods_ids_arr as $val){
  158. $ids_arr[] = $val['goods_id'];
  159. }
  160. if(!empty($keyword)) {
  161. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX'). "lionfish_comshop_goods
  162. WHERE is_all_sale=1 and goodsname like '%{$keyword}%' " );
  163. } else {
  164. if($gid == 0){
  165. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX') . "lionfish_comshop_goods
  166. WHERE is_all_sale=1 " );
  167. } else {
  168. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  169. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  170. where pg.id = g.goods_id and g.cate_id in ({$gid}) and pg.is_all_sale=1 ";
  171. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  172. }
  173. }
  174. if( !empty($goods_ids_nolimit_arr) )
  175. {
  176. foreach($goods_ids_nolimit_arr as $val){
  177. $ids_arr[] = $val['id'];
  178. }
  179. }
  180. $ids_str = implode(',',$ids_arr);
  181. if( !empty($ids_str) )
  182. {
  183. $where .= " and g.id in ({$ids_str})";
  184. } else{
  185. $where .= " and 0 ";
  186. }
  187. }else{
  188. //echo json_encode( array('code' => 1) );
  189. // die();
  190. if(!empty($keyword)) {
  191. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX'). "lionfish_comshop_goods
  192. WHERE goodsname like '%{$keyword}%' and type='normal' " );
  193. } else {
  194. if($gid == 0){
  195. $goods_ids_nohead_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX'). "lionfish_comshop_goods
  196. WHERE type='normal' " );
  197. } else {
  198. $goods_ids_nohead_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  199. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id in ({$gid}) and type='normal' ";
  200. $goods_ids_nohead_arr = M()->query($goods_ids_nohead_sql);
  201. }
  202. }
  203. $ids_arr = array();
  204. if( !empty($goods_ids_nohead_arr) )
  205. {
  206. foreach($goods_ids_nohead_arr as $val){
  207. $ids_arr[] = $val['id'];
  208. }
  209. }
  210. $ids_str = implode(',',$ids_arr);
  211. if( !empty($ids_str) )
  212. {
  213. $where .= " and g.id in ({$ids_str})";
  214. } else{
  215. $where .= " and 0 ";
  216. }
  217. }
  218. if($gid == 0 && $keyword == ''){
  219. $where .= " and g.is_index_show = 1 and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  220. // $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  221. } else {
  222. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  223. }
  224. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  225. //$is_random $order='g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc '
  226. if($is_random == 1)
  227. {
  228. $community_goods = D('Home/Pingoods')->get_community_index_goods('g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video ', $where,$offset,$per_page,' rand() ');
  229. }else{
  230. $community_goods = D('Home/Pingoods')->get_community_index_goods('g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video ', $where,$offset,$per_page);
  231. }
  232. if( !empty($community_goods) )
  233. {
  234. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  235. $full_money = D('Home/Front')->get_config_by_name('full_money');
  236. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  237. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  238. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  239. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  240. {
  241. $is_open_fullreduction = 0;
  242. }
  243. $cart= D('Home/Car');
  244. $list = array();
  245. $copy_text_arr = array();
  246. foreach($community_goods as $val)
  247. {
  248. $tmp_data = array();
  249. $tmp_data['actId'] = $val['id'];
  250. $tmp_data['spuName'] = $val['goodsname'];
  251. $tmp_data['spuCanBuyNum'] = $val['total'];
  252. $tmp_data['spuDescribe'] = $val['subtitle'];
  253. $tmp_data['end_time'] = $val['end_time'];
  254. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  255. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  256. $productprice = $val['productprice'];
  257. $tmp_data['marketPrice'] = explode('.', $productprice);
  258. if( !empty($val['big_img']) )
  259. {
  260. $tmp_data['bigImg'] = tomedia($val['big_img']);
  261. }
  262. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  263. if( !empty($good_image) )
  264. {
  265. $tmp_data['skuImage'] = tomedia($good_image['image']);
  266. }
  267. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  268. $price = $price_arr['price'];
  269. if( $pageNum == 1 )
  270. {
  271. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  272. }
  273. $tmp_data['actPrice'] = explode('.', $price);
  274. $tmp_data['card_price'] = $price_arr['card_price'];
  275. $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  276. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  277. //card_price
  278. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  279. if( !empty($tmp_data['skuList']) )
  280. {
  281. $tmp_data['car_count'] = 0;
  282. }else{
  283. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  284. if( empty($car_count) )
  285. {
  286. $tmp_data['car_count'] = 0;
  287. }else{
  288. $tmp_data['car_count'] = $car_count;
  289. }
  290. }
  291. if($is_open_fullreduction == 0)
  292. {
  293. $tmp_data['is_take_fullreduction'] = 0;
  294. }else if($is_open_fullreduction == 1){
  295. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  296. }
  297. // 商品角标
  298. $label_id = unserialize($val['labelname']);
  299. if($label_id){
  300. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  301. if($label_info){
  302. if($label_info['type'] == 1){
  303. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  304. } else {
  305. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  306. }
  307. }
  308. $tmp_data['label_info'] = $label_info;
  309. }
  310. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  311. $list[] = $tmp_data;
  312. }
  313. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  314. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  315. echo json_encode(array('code' => 0, 'list' => $list ,'is_vip_card_member' => $is_vip_card_member,'is_member_level_buy' => $is_member_level_buy ,'copy_text_arr' => $copy_text_arr, 'cur_time' => time() ,'full_reducemoney' => $full_reducemoney,'full_money' => $full_money,'is_open_vipcard_buy' => $is_open_vipcard_buy,'is_open_fullreduction' => $is_open_fullreduction,'is_show_list_timer'=>$is_show_list_timer, 'cate_info' => $cate_info, 'is_show_cate_tabbar'=>$is_show_cate_tabbar ));
  316. die();
  317. }else{
  318. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  319. echo json_encode( array('code' => 1, 'cate_info' => $cate_info, 'is_show_cate_tabbar'=>$is_show_cate_tabbar) );
  320. die();
  321. }
  322. }
  323. }