IndexController.class.php 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386
  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 Home\Controller;
  15. class IndexController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. public function index_share()
  21. {
  22. $item = M('lionfish_comshop_config')->where( array('name' => 'shop_index_share_title') )->find();
  23. echo json_encode( array('code'=>0, 'title' =>$item['value']) );
  24. die();
  25. }
  26. public function test_sql()
  27. {
  28. include ROOT_PATH .'Data/sql.php';
  29. /**
  30. $res = check_db_field_exist( 'oscshop_lionfish_community_head_commiss_order','fen_type' );
  31. if( !$res )
  32. {
  33. $sql_content ="
  34. ALTER TABLE `oscshop_lionfish_community_head_commiss_order` ADD `fen_type` TINYINT(1) NULL DEFAULT '0' COMMENT '0,按照比例计算的,1按照实际金额计算的' AFTER `type`;
  35. ";
  36. M()->execute($sql_content);
  37. }
  38. **/
  39. echo 3;die();
  40. }
  41. //$filePath = ROOT_PATH.'64df107ec8374b0bc0d8cb1c9a06d819.jpeg';
  42. public function test()
  43. {
  44. $order_id = 786;
  45. $pin_order = M('lionfish_comshop_pin_order')->where( array('order_id' => $order_id ) )->find();
  46. D('Home/Pin')->insertNotifyOrder($order_id);
  47. $is_pin_success = D('Home/Pin')->checkPinSuccess($pin_order['pin_id']);
  48. var_dump($is_pin_success, $pin_order['pin_id']);
  49. die();
  50. if($is_pin_success) {
  51. D('Home/Pin')->updatePintuanSuccess($pin_order['pin_id']);
  52. }
  53. die();
  54. include_once ROOT_PATH .'Modules/Lib/Redis.class.php';
  55. $config = array(
  56. 'host'=>'101.37.168.12',
  57. 'port'=>'6379',
  58. 'auth' => 'Ychg1988',
  59. );
  60. if(!class_exists('Redis')){
  61. echo '请先安装php-redis扩展';
  62. die();
  63. }
  64. $redis = \Redisgo::getInstance($config, array('db_id'=>1,'timeout' => 60 ));
  65. $key = 'test';
  66. //$redis->set($key,'10');
  67. //$val = $redis->get($key);
  68. $redis->del($key);
  69. $res=$redis->llen('goods_1');
  70. $count=10;
  71. for($i=0;$i<$count;$i++){
  72. $redis->lpush('goods_1',1);
  73. }
  74. //$ret = $redis->lrem('city', 'guangzhou', -2);
  75. var_dump($res);die();
  76. //https://blog.csdn.net/nuli888/article/details/51865401 参考这里就可以解决高并发 的问题
  77. }
  78. public function diy_page()
  79. {
  80. $startadv = array();
  81. return $startadv;
  82. }
  83. public function spike_index()
  84. {
  85. }
  86. public function load_spike_data()
  87. {
  88. }
  89. public function index_info()
  90. {
  91. $gpc = I('request.');
  92. $item = M('lionfish_comshop_config')->where( array('name' => 'shop_index_share_title') )->find();
  93. $communityId = $gpc['communityId'];
  94. $is_community = D('Seller/Communityhead')->is_community($communityId);
  95. $postion = M('lionfish_community_head')->field('lat,lon')->where( array('id' => $communityId) )->find();
  96. //...lionfish_comshop_adv
  97. $params = array();
  98. $params[':uniacid'] = $uniacid;
  99. $params[':type'] = 'slider';
  100. $params[':enabled'] = 1;
  101. /** 调用滑动广告 **/
  102. $slider_list = M('lionfish_comshop_adv')->where( array('enabled' => 1,'type' => 'slider') )->order('displayorder desc, id desc')->select();
  103. if(!empty($slider_list))
  104. {
  105. foreach($slider_list as $key => $val)
  106. {
  107. $val['image'] = tomedia($val['thumb']);
  108. $slider_list[$key] = $val;
  109. }
  110. }else{
  111. $slider_list = array();
  112. }
  113. // 公告列表
  114. $notice_list = M('lionfish_comshop_notice')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->select();
  115. /** 调用导航图标 **/
  116. $nav_list = M('lionfish_comshop_adv')->where( array('enabled' => 1,'type' => 'nav') )->order('displayorder desc, id desc')->select();
  117. if(!empty($nav_list))
  118. {
  119. foreach($nav_list as $key => $val)
  120. {
  121. $val['image'] = tomedia($val['thumb']);
  122. $val['name'] = $val['advname'];
  123. $nav_list[$key] = $val;
  124. }
  125. }else{
  126. $nav_list = array();
  127. }
  128. /**
  129. 调用分类
  130. **/
  131. $gid = isset($gpc['gid']) ? intval($gpc['gid']) : 0;
  132. $category_list = D('Home/GoodsCategory')->get_index_goods_category($gid);
  133. $shop_index_share_image = D('Home/Front')->get_config_by_name('shop_index_share_image');
  134. if( !empty($shop_index_share_image) )
  135. {
  136. $shop_index_share_image = tomedia($shop_index_share_image);
  137. }
  138. $index_loading_image = D('Home/Front')->get_config_by_name('loading');
  139. if( !empty($index_loading_image) )
  140. {
  141. $index_loading_image = tomedia($index_loading_image);
  142. }
  143. $index_bottom_image = D('Home/Front')->get_config_by_name('index_bottom_image');
  144. if( !empty($index_bottom_image) )
  145. {
  146. $index_bottom_image = tomedia($index_bottom_image);
  147. }
  148. $index_list_top_image = D('Home/Front')->get_config_by_name('index_list_top_image');
  149. if( !empty($index_list_top_image) )
  150. {
  151. $index_list_top_image = tomedia($index_list_top_image);
  152. }
  153. $index_list_top_image_on = D('Home/Front')->get_config_by_name('index_list_top_image_on');
  154. $common_header_backgroundimage = D('Home/Front')->get_config_by_name('common_header_backgroundimage');
  155. if( !empty($common_header_backgroundimage) )
  156. {
  157. $common_header_backgroundimage = tomedia($common_header_backgroundimage);
  158. }
  159. $open_diy_index_page = D('Home/Front')->get_config_by_name('open_diy_index_page');
  160. $is_show_index_lead_image = D('Home/Front')->get_config_by_name('is_show_index_lead_image');
  161. $index_lead_image = '';
  162. if($is_show_index_lead_image == 1){
  163. $index_lead_image = D('Home/Front')->get_config_by_name('index_lead_image');
  164. if( !empty($index_lead_image) )
  165. {
  166. $index_lead_image = tomedia($index_lead_image);
  167. }
  168. }
  169. $diypage = array();
  170. if($open_diy_index_page == 1)
  171. {
  172. $diypage = $this->diy_page();
  173. }
  174. $shoname = D('Home/Front')->get_config_by_name('shoname');
  175. $theme = D('Home/Front')->get_config_by_name('index_list_theme_type');
  176. $spike_data = array();
  177. $nav_bg_color = D('Home/Front')->get_config_by_name('nav_bg_color');
  178. $order_notify_switch = D('Home/Front')->get_config_by_name('order_notify_switch');
  179. $rushtime = D('Home/Pingoods')->get_min_time();
  180. $comming_goods_total = D('Home/Pingoods')->get_comming_goods_count();
  181. $index_share_switch = D('Home/Front')->get_config_by_name('index_share_switch');
  182. $is_show_list_count = D('Home/Front')->get_config_by_name('is_show_list_count');
  183. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  184. $index_change_cate_btn = D('Home/Front')->get_config_by_name('index_change_cate_btn');
  185. $is_comunity_rest = D('Seller/Communityhead')->is_community_rest($communityId);
  186. $index_top_img_bg_open = D('Home/Front')->get_config_by_name('index_top_img_bg_open');
  187. $index_top_font_color = D('Home/Front')->get_config_by_name('index_top_font_color');
  188. $index_service_switch = D('Home/Front')->get_config_by_name('index_service_switch');
  189. $index_switch_search = D('Home/Front')->get_config_by_name('index_switch_search');
  190. $is_show_new_buy = D('Home/Front')->get_config_by_name('is_show_new_buy');
  191. //抢购自定义
  192. $index_qgtab_bottom_color = D('Home/Front')->get_config_by_name('index_qgtab_bottom_color');
  193. $index_qgtab_one_select = D('Home/Front')->get_config_by_name('index_qgtab_one_select');
  194. $index_qgtab_one_selected = D('Home/Front')->get_config_by_name('index_qgtab_one_selected');
  195. $index_qgtab_two_select = D('Home/Front')->get_config_by_name('index_qgtab_two_select');
  196. $index_qgtab_two_selected = D('Home/Front')->get_config_by_name('index_qgtab_two_selected');
  197. $qgtab = array();
  198. $qgtab['bottom_color'] = $index_qgtab_bottom_color;
  199. if(!empty($index_qgtab_one_select)) {
  200. $qgtab['one_select'] = tomedia($index_qgtab_one_select);
  201. }
  202. if(!empty($index_qgtab_one_selected)) {
  203. $qgtab['one_selected'] = tomedia($index_qgtab_one_selected);
  204. }
  205. if(!empty($index_qgtab_two_select)) {
  206. $qgtab['two_select'] = tomedia($index_qgtab_two_select);
  207. }
  208. if(!empty($index_qgtab_two_selected)) {
  209. $qgtab['two_selected'] = tomedia($index_qgtab_two_selected);
  210. }
  211. $notice_setting = array();
  212. $index_notice_horn_image = D('Home/Front')->get_config_by_name('index_notice_horn_image');
  213. if(!empty($index_notice_horn_image)) {
  214. $notice_setting['horn'] = tomedia($index_notice_horn_image);
  215. }
  216. $notice_setting['font_color'] = D('Home/Front')->get_config_by_name('index_notice_font_color');
  217. $notice_setting['background_color'] = D('Home/Front')->get_config_by_name('index_notice_background_color');
  218. //前端隐藏 团长信息
  219. $index_hide_headdetail_address = D('Home/Front')->get_config_by_name('index_hide_headdetail_address');
  220. if( empty($index_hide_headdetail_address) )
  221. {
  222. $index_hide_headdetail_address = 0;
  223. }
  224. $is_show_spike_buy = D('Home/Front')->get_config_by_name('is_show_spike_buy');
  225. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  226. $hide_top_community = D('Home/Front')->get_config_by_name('hide_index_top_communityinfo');
  227. $index_type_first_name = D('Home/Front')->get_config_by_name('index_type_first_name');
  228. $index_qgtab_text = array();
  229. $index_qgtab_text[] = D('Home/Front')->get_config_by_name('index_qgtab_text_going');
  230. $index_qgtab_text[] = D('Home/Front')->get_config_by_name('index_qgtab_text_future');
  231. $ishow_index_copy_text = D('Home/Front')->get_config_by_name('ishow_index_copy_text');
  232. $index_communityinfo_showtype = D('Home/Front')->get_config_by_name('index_communityinfo_showtype');
  233. // 魔方图
  234. $cube = array();
  235. $cube = M('lionfish_comshop_cube')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->select();
  236. if(!empty($cube)) {
  237. foreach ($cube as $k => $cubeItem) {
  238. $thumb = unserialize($cubeItem['thumb']);
  239. if(!empty($thumb['cover']) && is_array($thumb['cover'])) {
  240. foreach ($thumb['cover'] as &$coverItem) {
  241. if($coverItem) $coverItem = tomedia($coverItem);
  242. }
  243. }
  244. $cubeItem['thumb'] = $thumb;
  245. $cube[$k] = $cubeItem;
  246. }
  247. }
  248. //秒杀设置begin
  249. $seckill_is_open = D('Home/Front')->get_config_by_name('seckill_is_open');
  250. $seckill_is_show_index = D('Home/Front')->get_config_by_name('seckill_is_show_index');
  251. $scekill_show_time = D('Home/Front')->get_config_by_name('scekill_show_time');
  252. $seckill_bg_color = D('Home/Front')->get_config_by_name('seckill_bg_color');
  253. $hide_community_change_word = D('Home/Front')->get_config_by_name('hide_community_change_word');
  254. if( empty($seckill_bg_color) )
  255. {
  256. $seckill_bg_color = '#25d6e6';
  257. }
  258. if( empty($seckill_is_open) )
  259. {
  260. $seckill_is_open = 0;
  261. }
  262. if( empty($seckill_is_show_index) )
  263. {
  264. $seckill_is_show_index = 0;
  265. }
  266. $scekill_time_arr = array();
  267. if( $seckill_is_open == 1 )
  268. {
  269. if( $seckill_is_show_index == 1 )
  270. {
  271. if( isset($scekill_show_time) && !empty($scekill_show_time) )
  272. {
  273. $scekill_show_time_arr = unserialize($scekill_show_time);
  274. foreach($scekill_show_time_arr as $vv)
  275. {
  276. if( $vv != 25 )
  277. {
  278. $scekill_time_arr[] = $vv;
  279. }
  280. }
  281. }
  282. }
  283. }else{
  284. $seckill_is_show_index = 0;
  285. }
  286. //整点秒杀结束
  287. //返回顶部按钮
  288. $ishow_index_gotop = D('Home/Front')->get_config_by_name('ishow_index_gotop');
  289. $ishow_index_pickup_time = D('Home/Front')->get_config_by_name('ishow_index_pickup_time');
  290. // 视频
  291. $index_video_arr = array();
  292. $index_video_enabled = D('Home/Front')->get_config_by_name('index_video_enabled');
  293. $index_video_arr['enabled'] = $index_video_enabled;
  294. if($index_video_enabled==1) {
  295. $index_video_poster = D('Home/Front')->get_config_by_name('index_video_poster');
  296. $index_video_url = D('Home/Front')->get_config_by_name('index_video_url');
  297. if($index_video_poster){
  298. $index_video_arr['poster'] = tomedia($index_video_poster);
  299. }
  300. if($index_video_url){
  301. $index_video_arr['url'] = tomedia($index_video_url);
  302. }
  303. }
  304. // 抢购时间显示
  305. $index_qgtab_counttime = D('Home/Front')->get_config_by_name('index_qgtab_counttime');
  306. $hide_index_type = D('Home/Front')->get_config_by_name('hide_index_type');
  307. // 公众号关注组件
  308. $show_index_wechat_oa = D('Home/Front')->get_config_by_name('show_index_wechat_oa');
  309. echo json_encode(array('code'=>0,
  310. 'category_list' =>$category_list,
  311. 'spike_data' => array(),
  312. 'shop_index_share_image' => $shop_index_share_image,
  313. 'index_loading_image' => $index_loading_image,
  314. 'index_bottom_image' => $index_bottom_image,
  315. 'title' =>$item['value'],'shoname'=>$shoname,
  316. 'slider_list' => $slider_list,
  317. 'nav_list' => $nav_list,
  318. 'open_diy_index_page' => $open_diy_index_page,
  319. 'diypage' => $diypage,
  320. 'notice_list' => $notice_list ,
  321. 'index_list_top_image' => $index_list_top_image,
  322. 'is_community' => $is_community,
  323. 'index_lead_image' => $index_lead_image,
  324. 'theme' => $theme,
  325. 'common_header_backgroundimage' => $common_header_backgroundimage,
  326. 'nav_bg_color' => $nav_bg_color,
  327. 'order_notify_switch' => $order_notify_switch,
  328. 'is_quan' => $is_quan,
  329. 'index_list_top_image_on' => $index_list_top_image_on,
  330. 'postion' => $postion,
  331. 'rushtime' => $rushtime,
  332. 'comming_goods_total' => $comming_goods_total,
  333. 'index_share_switch' => $index_share_switch,
  334. 'is_show_list_count' => $is_show_list_count,
  335. 'is_show_list_timer' => $is_show_list_timer,
  336. 'is_comunity_rest' => $is_comunity_rest,
  337. 'index_change_cate_btn' => $index_change_cate_btn,
  338. 'index_top_img_bg_open' => $index_top_img_bg_open,
  339. 'index_top_font_color' => $index_top_font_color,
  340. 'index_service_switch' => $index_service_switch,
  341. 'index_switch_search' => $index_switch_search,
  342. 'is_show_new_buy' => $is_show_new_buy,
  343. 'qgtab' => $qgtab,
  344. 'notice_setting' => $notice_setting,
  345. 'index_hide_headdetail_address' => $index_hide_headdetail_address,
  346. 'is_show_spike_buy' => $is_show_spike_buy,
  347. 'hide_community_change_btn' => $hide_community_change_btn,
  348. 'hide_top_community' => $hide_top_community,
  349. 'index_type_first_name' => $index_type_first_name,
  350. 'index_qgtab_text' => $index_qgtab_text,
  351. 'ishow_index_copy_text' => $ishow_index_copy_text,
  352. 'index_communityinfo_showtype' => $index_communityinfo_showtype,
  353. 'cube' => $cube,
  354. 'seckill_is_open'=> $seckill_is_open,//是否开启整点秒杀功能
  355. 'seckill_is_show_index' => $seckill_is_show_index,//是否显示再首页上
  356. 'scekill_time_arr' => $scekill_time_arr,//整点秒杀的时间点数组, 0 点表示:0:00-0:59, 1 表示:1:00-1:59
  357. 'seckill_bg_color' => $seckill_bg_color,
  358. 'hide_community_change_word' => $hide_community_change_word,
  359. 'ishow_index_gotop' => $ishow_index_gotop,
  360. 'ishow_index_pickup_time' => $ishow_index_pickup_time,
  361. 'index_video_arr' => $index_video_arr,
  362. 'index_qgtab_counttime' => $index_qgtab_counttime,
  363. 'hide_index_type' => $hide_index_type,
  364. 'show_index_wechat_oa' => $show_index_wechat_oa
  365. )
  366. );
  367. die();
  368. }
  369. public function get_group_info()
  370. {
  371. $group_name = D('Home/Front')->get_config_by_name('group_name');
  372. $owner_name = D('Home/Front')->get_config_by_name('owner_name');
  373. $commiss_diy_name = D('Home/Front')->get_config_by_name('commiss_diy_name');
  374. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');
  375. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');
  376. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');
  377. // 下单页面
  378. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');
  379. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');
  380. $placeorder_tuan_name = $placeorder_tuan_name?$placeorder_tuan_name:"配送费";
  381. $placeorder_trans_name = $placeorder_trans_name?$placeorder_trans_name:"快递费";
  382. $data = array(
  383. 'group_name'=>$group_name,
  384. 'owner_name'=>$owner_name,
  385. 'commiss_diy_name'=>$commiss_diy_name,
  386. 'delivery_ziti_name'=>$delivery_ziti_name,
  387. 'delivery_tuanzshipping_name'=>$delivery_tuanzshipping_name,
  388. 'delivery_express_name'=>$delivery_express_name,
  389. 'placeorder_tuan_name'=>$placeorder_tuan_name,
  390. 'placeorder_trans_name'=>$placeorder_trans_name
  391. );
  392. echo json_encode(array('code'=>0, 'data' =>$data));
  393. }
  394. public function get_nav_bg_color()
  395. {
  396. $nav_bg_color = D('Home/Front')->get_config_by_name('nav_bg_color');
  397. $nav_font_color = D('Home/Front')->get_config_by_name('nav_font_color');
  398. echo json_encode(array('code'=>0, 'data' => $nav_bg_color, 'nav_font_color' => $nav_font_color));
  399. }
  400. public function get_auth_bg()
  401. {
  402. $auth_bg_image = D('Home/Front')->get_config_by_name('auth_bg_image');
  403. if( !empty($auth_bg_image) )
  404. {
  405. $auth_bg_image = tomedia($auth_bg_image);
  406. }
  407. echo json_encode(array('code'=>0, 'data' =>$auth_bg_image));
  408. }
  409. /**
  410. * 获取导航图标 lionfish_comshop_navigat
  411. */
  412. public function get_navigat()
  413. {
  414. $list = M('lionfish_comshop_navigat')->field('id,navname,thumb,link,type,appid')->where("enabled=1")->order('displayorder desc')->select();
  415. if( !empty($list) )
  416. {
  417. foreach ($list as $key => &$val) {
  418. $val['thumb'] = tomedia($val['thumb']);
  419. }
  420. }
  421. $result = array('code' =>0,'data' => $list);
  422. echo json_encode($result);
  423. die();
  424. }
  425. /**
  426. * 获取tabbar
  427. */
  428. public function get_tabbar()
  429. {
  430. $list = D('Home/Front')->get_config_by_name('wepro_tabbar_list');
  431. /**
  432. $param['wepro_tabbar_list'] = array();
  433. $param['wepro_tabbar_list']['t1'] = trim($data['wepro_tabbar_text1']);
  434. $param['wepro_tabbar_list']['t2'] = trim($data['wepro_tabbar_text2']);
  435. $param['wepro_tabbar_list']['t3'] = trim($data['wepro_tabbar_text3']);
  436. $param['wepro_tabbar_list']['s1'] = save_media($data['wepro_tabbar_selectedIconPath1']);
  437. $param['wepro_tabbar_list']['s2'] = save_media($data['wepro_tabbar_selectedIconPath2']);
  438. $param['wepro_tabbar_list']['s3'] = save_media($data['wepro_tabbar_selectedIconPath3']);
  439. $param['wepro_tabbar_list']['i1'] = save_media($data['wepro_tabbar_iconPath1']);
  440. $param['wepro_tabbar_list']['i2'] = save_media($data['wepro_tabbar_iconPath2']);
  441. $param['wepro_tabbar_list']['i3'] = save_media($data['wepro_tabbar_iconPath3']);
  442. **/
  443. $list = unserialize(htmlspecialchars_decode($list));
  444. $open_tabbar_type = D('Home/Front')->get_config_by_name('open_tabbar_type');
  445. $open_tabbar_out_weapp = D('Home/Front')->get_config_by_name('open_tabbar_out_weapp');
  446. $tabbar_out_appid = D('Home/Front')->get_config_by_name('tabbar_out_appid');
  447. $tabbar_out_link = D('Home/Front')->get_config_by_name('tabbar_out_link');
  448. $tabbar_out_type = D('Home/Front')->get_config_by_name('tabbar_out_type');
  449. $wepro_tabbar_selectedColor = D('Home/Front')->get_config_by_name('wepro_tabbar_selectedColor');
  450. if( !empty($list) )
  451. {
  452. if(!empty($list['i1'])) $list['i1'] = tomedia($list['i1']);
  453. if(!empty($list['i2'])) $list['i2'] = tomedia($list['i2']);
  454. if(!empty($list['i3'])) $list['i3'] = tomedia($list['i3']);
  455. if(!empty($list['i4'])) $list['i4'] = tomedia($list['i4']);
  456. if(!empty($list['i5'])) $list['i5'] = tomedia($list['i5']);
  457. if(!empty($list['s1'])) $list['s1'] = tomedia($list['s1']);
  458. if(!empty($list['s2'])) $list['s2'] = tomedia($list['s2']);
  459. if(!empty($list['s3'])) $list['s3'] = tomedia($list['s3']);
  460. if(!empty($list['s4'])) $list['s4'] = tomedia($list['s4']);
  461. if(!empty($list['s5'])) $list['s5'] = tomedia($list['s5']);
  462. }
  463. $result = array(
  464. 'code' => 0,
  465. 'data' => $list,
  466. 'open_tabbar_type' => $open_tabbar_type,
  467. 'open_tabbar_out_weapp' => $open_tabbar_out_weapp,
  468. 'tabbar_out_appid' => $tabbar_out_appid,
  469. 'tabbar_out_link' => $tabbar_out_link,
  470. 'tabbar_out_type' => $tabbar_out_type,
  471. 'wepro_tabbar_selectedColor' => $wepro_tabbar_selectedColor
  472. );
  473. echo json_encode($result);
  474. die();
  475. }
  476. public function get_community_config()
  477. {
  478. $tx_map_key = D('Home/Front')->get_config_by_name('tx_map_key');
  479. $shoname = D('Home/Front')->get_config_by_name('shoname');
  480. $shop_index_share_title = D('Home/Front')->get_config_by_name('shop_index_share_title');
  481. echo json_encode( array('code' => 0, 'tx_map_key' => $tx_map_key , 'shoname' => $shoname ,'shop_index_share_title' => $shop_index_share_title) );
  482. die();
  483. }
  484. public function load_history_community()
  485. {
  486. $gpc = I('request.');
  487. $token = $gpc['token'];
  488. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  489. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  490. {
  491. echo json_encode( array('code' => 2) );
  492. die();
  493. }
  494. $member_id = $weprogram_token['member_id'];
  495. $data = D('Home/Front')->get_history_community($member_id);
  496. if( empty($data) )
  497. {
  498. echo json_encode(array('code' => 1));
  499. die();
  500. }
  501. else {
  502. echo json_encode(array('code' => 0, 'list' => $data));
  503. die();
  504. }
  505. }
  506. /**
  507. * 切换、添加历史社区
  508. */
  509. public function switch_history_community(){
  510. $gpc = I('request.');
  511. $token = $gpc['token'];
  512. $head_id = $gpc['head_id'];
  513. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  514. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  515. {
  516. echo json_encode( array('code' => 2) );
  517. die();
  518. }
  519. $member_id = $weprogram_token['member_id'];
  520. $data = D('Home/Front')->update_history_community($member_id, $head_id);
  521. //删除 community_id
  522. M('lionfish_comshop_car')->where( "token='{$token}' and community_id!='{$head_id}' " )->delete();
  523. if( empty($data) )
  524. {
  525. echo json_encode(array('code' => 1));
  526. die();
  527. }
  528. else {
  529. echo json_encode(array('code' => 0, 'list' => $data));
  530. die();
  531. }
  532. }
  533. public function get_community_info()
  534. {
  535. $gpc = I('request.');
  536. $where = " and state=1 and enable=1 ";
  537. $community_id = $gpc['community_id'];
  538. if($community_id == 'undefined')
  539. {
  540. $community_id = 0;
  541. }
  542. $data = D('Home/Front')->get_community_byid($community_id , $where);
  543. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  544. $open_danhead_model = D('Home/Front')->get_config_by_name('open_danhead_model');
  545. if( empty($open_danhead_model) )
  546. {
  547. $open_danhead_model = 0;
  548. }
  549. $default_head_info = array();
  550. if( $open_danhead_model == 1 )
  551. {
  552. $default_head = M('lionfish_community_head')->field('id')->where( array('is_default' => 1) )->find();
  553. if( !empty($default_head) )
  554. {
  555. $default_head_info = D('Home/Front')->get_community_byid($default_head['id'], $where);
  556. }
  557. }
  558. echo json_encode(array('code' => 0, 'data' => $data, 'open_danhead_model' => $open_danhead_model,'default_head_info' => $default_head_info, 'hide_community_change_btn' => $hide_community_change_btn));
  559. die();
  560. }
  561. public function load_gps_community()
  562. {
  563. $gpc = I('request.');
  564. $longitude = $gpc['longitude'];
  565. $latitude = $gpc['latitude'];
  566. $pageNum = $gpc['pageNum'];
  567. $city_id = $gpc['city_id'] ? $gpc['city_id'] : 0;
  568. $per_page = 10;
  569. $offset = ($pageNum - 1) * $per_page;
  570. $limit = "{$offset},{$per_page}";
  571. $token = $gpc['token'];
  572. $keyword = $gpc['inputValue'];
  573. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  574. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  575. {
  576. //echo json_encode( array('code' => 2) );
  577. //die();
  578. }
  579. $member_id = $weprogram_token['member_id'];
  580. $data = D('Home/Front')->get_gps_area_info($longitude,$latitude,$limit,$keyword,$city_id,0);
  581. //前端隐藏 团长信息
  582. $index_hide_headdetail_address = D('Home/Front')->get_config_by_name('index_hide_headdetail_address');
  583. if( empty($index_hide_headdetail_address) )
  584. {
  585. $index_hide_headdetail_address = 0;
  586. }
  587. if( empty($data) )
  588. {
  589. echo json_encode(array('code'=>1,'index_hide_headdetail_address' => $index_hide_headdetail_address));
  590. die();
  591. }else{
  592. echo json_encode(array('code'=>0, 'list' => $data,'index_hide_headdetail_address' => $index_hide_headdetail_address));
  593. die();
  594. }
  595. }
  596. public function addhistory_community()
  597. {
  598. $gpc = I('request.');
  599. $token = $gpc['token'];
  600. $head_id = $gpc['community_id'];
  601. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  602. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  603. {
  604. echo json_encode( array('code' => 2) );
  605. die();
  606. }
  607. $member_id = $weprogram_token['member_id'];
  608. D('Seller/Community')->in_community_history($member_id,$head_id);
  609. echo json_encode( array('code' => 0) );
  610. die();
  611. }
  612. /**
  613. 获取已经过期的往期团购
  614. **/
  615. public function load_over_gps_goodslist()
  616. {
  617. $gpc = I('request.');
  618. $head_id = $gpc['head_id'];
  619. $pageNum = $gpc['pageNum'];
  620. $per_page = 10;
  621. $gid = $gpc['gid'];
  622. $offset = ($pageNum - 1) * $per_page;
  623. $limit = "{$offset},{$per_page}";
  624. $token = $gpc['token'];
  625. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  626. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  627. {
  628. //echo json_encode( array('code' => 2) );
  629. //die();
  630. }
  631. $member_id = $weprogram_token['member_id'];
  632. $now_time = time();
  633. $where = " g.grounding =1 and g.type ='normal' ";
  634. //head_id
  635. if( !empty($head_id) && $head_id >0 )
  636. {
  637. if($gid == 0){
  638. $goods_ids_arr = M('lionfish_community_head_goods')->field('goods_id')->where( array('head_id' => $head_id) )->order('id desc')->select();
  639. } else {
  640. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  641. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  642. where pg.goods_id = g.goods_id and g.cate_id = {$gid} and pg.head_id = {$head_id} order by pg.id desc ";
  643. $goods_ids_arr = M()->query($sql_goods_ids);
  644. }
  645. $ids_arr = array();
  646. foreach($goods_ids_arr as $val){
  647. $ids_arr[] = $val['goods_id'];
  648. }
  649. if($gid == 0){
  650. $goods_ids_nolimit_arr = M('lionfish_comshop_goods')->field('id')->where( array('is_all_sale' => 1) )->select();
  651. } else {
  652. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  653. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  654. where pg.id = g.goods_id and g.cate_id = {$gid} and pg.is_all_sale=1 ";
  655. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  656. }
  657. if( !empty($goods_ids_nolimit_arr) )
  658. {
  659. foreach($goods_ids_nolimit_arr as $val){
  660. $ids_arr[] = $val['id'];
  661. }
  662. }
  663. $ids_str = implode(',',$ids_arr);
  664. if( !empty($ids_str) )
  665. {
  666. $where .= " and g.id in ({$ids_str})";
  667. } else{
  668. $where .= " and 0 ";
  669. }
  670. }else{
  671. //echo json_encode( array('code' => 1) );
  672. //die();
  673. }
  674. $is_index_show = isset($gpc['is_index_show']) ? $gpc['is_index_show'] : 0;
  675. if($is_index_show==1) {
  676. $where .= " and g.is_index_show = 1";
  677. }
  678. $where .= " and gc.end_time <= {$now_time} and gc.is_new_buy=0 ";
  679. $community_goods = D('Home/Pingoods')->get_community_index_goods('g.*,gc.begin_time,gc.end_time,gc.big_img,gc.labelname,gc.video ', $where,$offset,$per_page);
  680. if( !empty($community_goods) )
  681. {
  682. $list = array();
  683. $today_time = time();
  684. foreach($community_goods as $val)
  685. {
  686. $tmp_data = array();
  687. $tmp_data['actId'] = $val['id'];
  688. $tmp_data['spuName'] = $val['goodsname'];
  689. $tmp_data['spuCanBuyNum'] = $val['total'];
  690. $tmp_data['spuDescribe'] = $val['subtitle'];
  691. $tmp_data['end_time'] = $val['end_time'];
  692. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  693. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  694. if($val['pick_up_type'] == 0)
  695. {
  696. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  697. }else if( $val['pick_up_type'] == 1 ){
  698. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  699. }else if( $val['pick_up_type'] == 2 )
  700. {
  701. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  702. }
  703. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  704. $productprice = $val['productprice'];
  705. $tmp_data['marketPrice'] = explode('.', $productprice);
  706. if( !empty($val['big_img']) )
  707. {
  708. $tmp_data['bigImg'] = tomedia($val['big_img']);
  709. }
  710. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  711. if( !empty($good_image) )
  712. {
  713. $tmp_data['skuImage'] = tomedia($good_image['image']);
  714. }
  715. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  716. $price = $price_arr['price'];
  717. $tmp_data['actPrice'] = explode('.', $price);
  718. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  719. // 商品角标
  720. $label_id = unserialize($val['labelname']);
  721. if($label_id){
  722. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  723. if($label_info){
  724. if($label_info['type'] == 1){
  725. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  726. } else {
  727. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  728. }
  729. }
  730. $tmp_data['label_info'] = $label_info;
  731. }
  732. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  733. $list[] = $tmp_data;
  734. }
  735. echo json_encode(array('code' => 0, 'list' => $list , 'cur_time' => time() ));
  736. die();
  737. }else{
  738. echo json_encode( array('code' => 1) );
  739. die();
  740. }
  741. }
  742. public function load_gps_goodslist()
  743. {
  744. $gpc = I('request.');
  745. $token = $gpc['token'];
  746. $head_id = $gpc['head_id'];
  747. if($head_id == 'undefined') $head_id = '';
  748. $pageNum = $gpc['pageNum'];
  749. $gid = $gpc['gid'];
  750. $keyword = $gpc['keyword'];
  751. $is_random = isset($gpc['is_random']) ? $gpc['is_random'] : 0;
  752. $is_video = isset($gpc['is_video']) ? $gpc['is_video'] : 0;
  753. $per_page = isset($gpc['per_page']) ? $gpc['per_page'] : 10;
  754. $cate_info = '';
  755. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  756. {
  757. $gid = 0;
  758. } else {
  759. $cate_info = M('lionfish_comshop_goods_category')->field('banner,name')->where( array('id' => $gid ) )->find();
  760. if(!empty($cate_info['banner'])) $cate_info['banner'] = tomedia($cate_info['banner']);
  761. }
  762. if( !empty($gid) && $gid > 0)
  763. {
  764. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid);
  765. $gidArr = array();
  766. $gidArr[] = $gid;
  767. foreach ($gids as $key => $val) {
  768. $gidArr[] = $val['id'];
  769. }
  770. $gid = implode(',', $gidArr);
  771. }
  772. //$per_page = 10;
  773. $offset = ($pageNum - 1) * $per_page;
  774. $limit = "{$offset},{$per_page}";
  775. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  776. $is_member_level_buy = 0;
  777. $is_vip_card_member = 0;
  778. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  779. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  780. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  781. {
  782. //echo json_encode( array('code' => 2) );
  783. //die();
  784. }else{
  785. $member_id = $weprogram_token['member_id'];
  786. $is_vip_card_member = 0;
  787. //member_id
  788. if( $member_id > 0 )
  789. {
  790. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  791. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  792. {
  793. $now_time = time();
  794. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  795. {
  796. $is_vip_card_member = 1;//还是会员
  797. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  798. $is_vip_card_member = 2;//已过期
  799. }
  800. }
  801. if($is_vip_card_member != 1 && $member_info['level_id'] >0 )
  802. {
  803. $is_member_level_buy = 1;
  804. }
  805. }
  806. }
  807. $member_id = $weprogram_token['member_id'];
  808. //整点秒杀begin
  809. $is_seckill = isset($gpc['is_seckill']) ? 1:0;
  810. $seckill_time = isset($gpc['seckill_time']) ? intval($gpc['seckill_time']):0;
  811. //整点秒杀end
  812. $now_time = time();
  813. if($is_seckill ==1)
  814. {
  815. $where = " g.grounding =1 and g.is_seckill =1 and g.type ='normal' ";
  816. }else
  817. {
  818. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  819. }
  820. //head_id
  821. if( !empty($keyword) )
  822. {
  823. $where .= " and g.goodsname like '%{$keyword}%' ";
  824. }
  825. //$where .= " and g.is_index_show = 1 and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  826. if($is_seckill ==1)
  827. {
  828. $bg_time = strtotime( date('Y-m-d').' '.$seckill_time.':00:00' );
  829. $ed_time = $bg_time + 3600;
  830. if($gid == 0 && $keyword == ''){
  831. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  832. } else {
  833. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  834. }
  835. }else
  836. {
  837. if($gid == 0 && $keyword == ''){
  838. $where .= " and g.is_index_show = 1 and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  839. } else {
  840. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  841. }
  842. }
  843. if($is_seckill ==1)
  844. {
  845. }else{
  846. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  847. }
  848. if( $is_video == 1 )
  849. {
  850. $where .= " and gc.video !='' ";
  851. }
  852. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  853. if( empty($index_sort_method) )
  854. {
  855. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  856. }
  857. if( $index_sort_method == 1 )
  858. {
  859. $order_sort = 'g.index_sort desc,g.id desc ';
  860. }
  861. if($is_random == 1)
  862. {
  863. $community_goods = D('Home/Pingoods')->get_new_community_index_goods($head_id,$gid,'g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video,gc.pick_up_type,gc.pick_up_modify ', $where,$offset,$per_page,$order_sort,' rand() ');
  864. }else{
  865. $community_goods = D('Home/Pingoods')->get_new_community_index_goods($head_id,$gid,'g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video,gc.pick_up_type,gc.pick_up_modify ', $where,$offset,$per_page,$order_sort);
  866. }
  867. if( !empty($community_goods) )
  868. {
  869. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  870. $full_money = D('Home/Front')->get_config_by_name('full_money');
  871. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  872. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  873. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  874. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  875. {
  876. $is_open_fullreduction = 0;
  877. }
  878. $cart= D('Home/Car');
  879. $list = array();
  880. $copy_text_arr = array();
  881. $today_time = strtotime( date('Y-m-d').' 00:00:00' );
  882. foreach($community_goods as $val)
  883. {
  884. $tmp_data = array();
  885. $tmp_data['actId'] = $val['id'];
  886. $tmp_data['spuName'] = $val['goodsname'];
  887. $tmp_data['spuCanBuyNum'] = $val['total'];
  888. $tmp_data['spuDescribe'] = $val['subtitle'];
  889. $tmp_data['end_time'] = $val['end_time'];
  890. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  891. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  892. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  893. if($val['pick_up_type'] == 0)
  894. {
  895. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  896. }else if( $val['pick_up_type'] == 1 ){
  897. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  898. }else if( $val['pick_up_type'] == 2 )
  899. {
  900. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  901. }
  902. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  903. $productprice = $val['productprice'];
  904. $tmp_data['marketPrice'] = explode('.', $productprice);
  905. if( !empty($val['big_img']) )
  906. {
  907. $tmp_data['bigImg'] = tomedia($val['big_img']);
  908. }
  909. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  910. if( !empty($good_image) )
  911. {
  912. $tmp_data['skuImage'] = tomedia($good_image['image']);
  913. }
  914. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  915. $price = $price_arr['price'];
  916. if( $pageNum == 1 )
  917. {
  918. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  919. }
  920. $tmp_data['actPrice'] = explode('.', $price);
  921. $tmp_data['card_price'] = $price_arr['card_price'];
  922. $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  923. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  924. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  925. if( !empty($tmp_data['skuList']) )
  926. {
  927. $tmp_data['car_count'] = 0;
  928. }else{
  929. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  930. if( empty($car_count) )
  931. {
  932. $tmp_data['car_count'] = 0;
  933. }else{
  934. $tmp_data['car_count'] = $car_count;
  935. }
  936. }
  937. if($is_open_fullreduction == 0)
  938. {
  939. $tmp_data['is_take_fullreduction'] = 0;
  940. }else if($is_open_fullreduction == 1){
  941. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  942. }
  943. // 商品角标
  944. $label_id = unserialize($val['labelname']);
  945. if($label_id){
  946. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  947. if($label_info){
  948. if($label_info['type'] == 1){
  949. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  950. } else {
  951. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  952. }
  953. }
  954. $tmp_data['label_info'] = $label_info;
  955. }
  956. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  957. $list[] = $tmp_data;
  958. }
  959. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  960. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  961. echo json_encode(array('code' => 0,'now_time' => time(), 'list' => $list ,'is_show_cate_tabbar' => $is_show_cate_tabbar,'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 ));
  962. die();
  963. }else{
  964. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  965. echo json_encode( array('code' => 1 , 'cate_info' => $cate_info , 'is_show_cate_tabbar'=>$is_show_cate_tabbar ) );
  966. die();
  967. }
  968. }
  969. public function get_index_category()
  970. {
  971. $gpc = I('request.');
  972. $gid = $gpc['gid'];
  973. $hot_list = M('lionfish_comshop_goods_category')->where( array('is_hot' => 1) )->order('sort_order desc')->select();
  974. $need_data = array();
  975. foreach($hot_list as $key => $cate)
  976. {
  977. $need_data[$key]['id'] = $cate['id'];
  978. $need_data[$key]['name'] = $cate['name'];
  979. $need_data[$key]['sort_order'] = $cate['sort_order'];
  980. }
  981. $result = array('code' =>0,'data' => $need_data);
  982. echo json_encode($result);
  983. die();
  984. }
  985. /**
  986. * 获取首页公告
  987. */
  988. public function get_index_notice()
  989. {
  990. $list = M('lionfish_comshop_notice')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->limit(1)->select();
  991. $result = array('code' =>0,'data' => $list);
  992. echo json_encode($result);
  993. die();
  994. }
  995. /**
  996. * 即将抢购商品
  997. */
  998. public function load_comming_goodslist()
  999. {
  1000. $_GPC = I('request.');
  1001. $head_id = $_GPC['head_id'];
  1002. $pageNum = $_GPC['pageNum'];
  1003. $per_page = 10;
  1004. $offset = ($pageNum - 1) * $per_page;
  1005. $limit = "{$offset},{$per_page}";
  1006. $gid = $_GPC['gid'];
  1007. $token = $_GPC['token'];
  1008. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1009. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1010. {
  1011. //echo json_encode( array('code' => 2) );
  1012. // die();
  1013. }
  1014. $member_id = $weprogram_token['member_id'];
  1015. $now_time = time();
  1016. $where = " g.grounding =1 ";
  1017. //head_id
  1018. if( !empty($head_id) && $head_id >0 )
  1019. {
  1020. if($gid == 0){
  1021. $goods_ids_arr = M('lionfish_community_head_goods')->field('goods_id')->where( array('head_id' => $head_id) )->order('id desc')->select();
  1022. } else {
  1023. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg, "
  1024. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.goods_id = g.goods_id and g.cate_id = {$gid} and pg.head_id = {$head_id} order by pg.id desc ";
  1025. $goods_ids_arr = M()->query($sql_goods_ids);
  1026. }
  1027. $ids_arr = array();
  1028. foreach($goods_ids_arr as $val){
  1029. $ids_arr[] = $val['goods_id'];
  1030. }
  1031. //
  1032. if($gid == 0){
  1033. $goods_ids_nolimit_arr = M('lionfish_comshop_goods')->field('id')->where( array('is_all_sale' => 1) )->select();
  1034. } else {
  1035. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg, "
  1036. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id = {$gid} and pg.is_all_sale=1 ";
  1037. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1038. }
  1039. //
  1040. if( !empty($goods_ids_nolimit_arr) )
  1041. {
  1042. foreach($goods_ids_nolimit_arr as $val){
  1043. $ids_arr[] = $val['id'];
  1044. }
  1045. }
  1046. $ids_str = implode(',',$ids_arr);
  1047. if( !empty($ids_str) )
  1048. {
  1049. $where .= " and g.id in ({$ids_str})";
  1050. } else{
  1051. $where .= " and 0 ";
  1052. }
  1053. }else{
  1054. echo json_encode( array('code' => 1) );
  1055. die();
  1056. }
  1057. $where .= " and gc.begin_time > {$now_time} ";
  1058. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1059. if( empty($index_sort_method) )
  1060. {
  1061. $index_sort_method = 0;
  1062. }
  1063. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1064. if( $index_sort_method == 1 )
  1065. {
  1066. $order_sort = 'g.index_sort desc,g.id desc ';
  1067. }
  1068. $community_goods = D('Home/Pingoods')->get_community_index_goods('g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction ', $where,$offset,$per_page ,$order_sort );
  1069. if( !empty($community_goods) )
  1070. {
  1071. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1072. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1073. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1074. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1075. {
  1076. $is_open_fullreduction = 0;
  1077. }
  1078. $list = array();
  1079. foreach($community_goods as $val)
  1080. {
  1081. $tmp_data = array();
  1082. $tmp_data['actId'] = $val['id'];
  1083. $tmp_data['spuName'] = $val['goodsname'];
  1084. $tmp_data['spuCanBuyNum'] = $val['total'];
  1085. $tmp_data['spuDescribe'] = $val['subtitle'];
  1086. $tmp_data['end_time'] = $val['end_time'];
  1087. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1088. $productprice = $val['productprice'];
  1089. $tmp_data['marketPrice'] = explode('.', $productprice);
  1090. if( !empty($val['big_img']) )
  1091. {
  1092. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1093. }
  1094. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1095. if( !empty($good_image) )
  1096. {
  1097. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1098. }
  1099. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'],$member_id);
  1100. $price = $price_arr['price'];
  1101. $tmp_data['actPrice'] = explode('.', $price);
  1102. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1103. if($is_open_fullreduction == 0)
  1104. {
  1105. $tmp_data['is_take_fullreduction'] = 0;
  1106. }else if($is_open_fullreduction == 1){
  1107. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1108. }
  1109. $list[] = $tmp_data;
  1110. }
  1111. echo json_encode(array('code' => 0, 'list' => $list , 'cur_time' => time() ,'full_reducemoney' => $full_reducemoney,'full_money' => $full_money,'is_open_fullreduction' => $is_open_fullreduction ));
  1112. die();
  1113. }else{
  1114. echo json_encode( array('code' => 1) );
  1115. die();
  1116. }
  1117. }
  1118. public function get_community_position()
  1119. {
  1120. $_GPC = I('request.');
  1121. $communityId = $_GPC['communityId'];
  1122. $postion = M('lionfish_community_head')->field('lat,lon')->where( array('id' => $communityId ) )->find();
  1123. echo json_encode(array('code' => 0, 'postion' => $postion));
  1124. die();
  1125. }
  1126. public function load_spikebuy_goodslist()
  1127. {
  1128. $_GPC = I('request.');
  1129. $head_id = $_GPC['head_id'];
  1130. $pageNum = $_GPC['pageNum'];
  1131. $per_page = 10000;
  1132. $offset = ($pageNum - 1) * $per_page;
  1133. $limit = "{$offset},{$per_page}";
  1134. $token = $_GPC['token'];
  1135. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1136. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1137. {
  1138. //echo json_encode( array('code' => 2) );
  1139. //die();
  1140. }
  1141. $member_id = $weprogram_token['member_id'];
  1142. $now_time = time();
  1143. $where = " g.grounding =1 ";
  1144. //head_id
  1145. if( !empty($head_id) && $head_id >0 )
  1146. {
  1147. $params = array();
  1148. $params['uniacid'] = $_W['uniacid'];
  1149. $params['head_id'] = $head_id;
  1150. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1151. .C('DB_PREFIX')."lionfish_comshop_good_common as g where pg.goods_id = g.goods_id and g.is_spike_buy = 1 and pg.head_id = {$head_id} order by pg.id desc ";
  1152. $goods_ids_arr = M()->query($sql_goods_ids);
  1153. $ids_arr = array();
  1154. foreach($goods_ids_arr as $val){
  1155. $ids_arr[] = $val['goods_id'];
  1156. }
  1157. $goods_ids_nolimit_ids = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1158. .C('DB_PREFIX')."lionfish_comshop_good_common as g where pg.id = g.goods_id and g.is_spike_buy = 1 and pg.is_all_sale=1 order by pg.id desc ";
  1159. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_ids);
  1160. if( !empty($goods_ids_nolimit_arr) )
  1161. {
  1162. foreach($goods_ids_nolimit_arr as $val){
  1163. $ids_arr[] = $val['id'];
  1164. }
  1165. }
  1166. $ids_str = implode(',',$ids_arr);
  1167. if( !empty($ids_str) )
  1168. {
  1169. $where .= " and g.id in ({$ids_str})";
  1170. } else{
  1171. $where .= " and 0 ";
  1172. }
  1173. }else{
  1174. //echo json_encode( array('code' => 1) );
  1175. //die();
  1176. $where .= " and gc.is_spike_buy = 1";
  1177. }
  1178. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1179. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1180. if( empty($index_sort_method) )
  1181. {
  1182. $index_sort_method = 0;
  1183. }
  1184. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1185. if( $index_sort_method == 1 )
  1186. {
  1187. $order_sort = 'g.index_sort desc,g.id desc ';
  1188. }
  1189. $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 ', $where,$offset,$per_page,$order_sort);
  1190. if( !empty($community_goods) )
  1191. {
  1192. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1193. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1194. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1195. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1196. {
  1197. $is_open_fullreduction = 0;
  1198. }
  1199. $cart= D('Home/Car');
  1200. $list = array();
  1201. foreach($community_goods as $val)
  1202. {
  1203. $tmp_data = array();
  1204. $tmp_data['actId'] = $val['id'];
  1205. $tmp_data['spuName'] = $val['goodsname'];
  1206. $tmp_data['spuCanBuyNum'] = $val['total'];
  1207. $tmp_data['spuDescribe'] = $val['subtitle'];
  1208. $tmp_data['end_time'] = $val['end_time'];
  1209. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1210. $productprice = $val['productprice'];
  1211. $tmp_data['marketPrice'] = explode('.', $productprice);
  1212. if( !empty($val['big_img']) )
  1213. {
  1214. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1215. }
  1216. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1217. if( !empty($good_image) )
  1218. {
  1219. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1220. }
  1221. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1222. $price = $price_arr['price'];
  1223. $tmp_data['actPrice'] = explode('.', $price);
  1224. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1225. if( !empty($tmp_data['skuList']) )
  1226. {
  1227. $tmp_data['car_count'] = 0;
  1228. }else{
  1229. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1230. if( empty($car_count) )
  1231. {
  1232. $tmp_data['car_count'] = 0;
  1233. }else{
  1234. $tmp_data['car_count'] = $car_count;
  1235. }
  1236. }
  1237. $list[] = $tmp_data;
  1238. }
  1239. echo json_encode(array('code' => 0, 'list' => $list ));
  1240. die();
  1241. }else{
  1242. echo json_encode( array('code' => 1) );
  1243. die();
  1244. }
  1245. }
  1246. public function load_new_buy_goodslist()
  1247. {
  1248. $_GPC = I('request.');
  1249. $head_id = $_GPC['head_id'];
  1250. $pageNum = $_GPC['pageNum'];
  1251. $per_page = 10;
  1252. $offset = ($pageNum - 1) * $per_page;
  1253. $limit = "{$offset},{$per_page}";
  1254. $token = $_GPC['token'];
  1255. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1256. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1257. {
  1258. //echo json_encode( array('code' => 2) );
  1259. //die();
  1260. }
  1261. $member_id = $weprogram_token['member_id'];
  1262. $now_time = time();
  1263. $where = " g.grounding =1 ";
  1264. //head_id
  1265. if( !empty($head_id) && $head_id >0 )
  1266. {
  1267. $params = array();
  1268. $params['uniacid'] = $_W['uniacid'];
  1269. $params['head_id'] = $head_id;
  1270. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1271. .C('DB_PREFIX')."lionfish_comshop_good_common as g where pg.goods_id = g.goods_id and g.is_new_buy = 1 and pg.head_id = {$head_id} order by pg.id desc ";
  1272. $goods_ids_arr = M()->query($sql_goods_ids);
  1273. $ids_arr = array();
  1274. foreach($goods_ids_arr as $val){
  1275. $ids_arr[] = $val['goods_id'];
  1276. }
  1277. $goods_ids_nolimit_ids = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1278. .C('DB_PREFIX')."lionfish_comshop_good_common as g where pg.id = g.goods_id and g.is_new_buy = 1 and pg.is_all_sale=1 order by pg.id desc ";
  1279. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_ids);
  1280. if( !empty($goods_ids_nolimit_arr) )
  1281. {
  1282. foreach($goods_ids_nolimit_arr as $val){
  1283. $ids_arr[] = $val['id'];
  1284. }
  1285. }
  1286. $ids_str = implode(',',$ids_arr);
  1287. if( !empty($ids_str) )
  1288. {
  1289. $where .= " and g.id in ({$ids_str})";
  1290. } else{
  1291. $where .= " and 0 ";
  1292. }
  1293. }else{
  1294. //echo json_encode( array('code' => 1) );
  1295. //die();
  1296. $where .= " and gc.is_new_buy = 1";
  1297. }
  1298. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1299. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1300. if( empty($index_sort_method) )
  1301. {
  1302. $index_sort_method = 0;
  1303. }
  1304. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1305. if( $index_sort_method == 1 )
  1306. {
  1307. $order_sort = 'g.index_sort desc,g.id desc ';
  1308. }
  1309. $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 ', $where,$offset,$per_page,$order_sort);
  1310. if( !empty($community_goods) )
  1311. {
  1312. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1313. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1314. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1315. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1316. {
  1317. $is_open_fullreduction = 0;
  1318. }
  1319. $cart= D('Home/Car');
  1320. $list = array();
  1321. foreach($community_goods as $val)
  1322. {
  1323. $tmp_data = array();
  1324. $tmp_data['actId'] = $val['id'];
  1325. $tmp_data['spuName'] = $val['goodsname'];
  1326. $tmp_data['spuCanBuyNum'] = $val['total'];
  1327. $tmp_data['spuDescribe'] = $val['subtitle'];
  1328. $tmp_data['end_time'] = $val['end_time'];
  1329. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1330. $productprice = $val['productprice'];
  1331. $tmp_data['marketPrice'] = explode('.', $productprice);
  1332. if( !empty($val['big_img']) )
  1333. {
  1334. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1335. }
  1336. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1337. if( !empty($good_image) )
  1338. {
  1339. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1340. }
  1341. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1342. $price = $price_arr['price'];
  1343. $tmp_data['actPrice'] = explode('.', $price);
  1344. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1345. if( !empty($tmp_data['skuList']) )
  1346. {
  1347. $tmp_data['car_count'] = 0;
  1348. }else{
  1349. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1350. if( empty($car_count) )
  1351. {
  1352. $tmp_data['car_count'] = 0;
  1353. }else{
  1354. $tmp_data['car_count'] = $car_count;
  1355. }
  1356. }
  1357. $list[] = $tmp_data;
  1358. }
  1359. echo json_encode(array('code' => 0, 'list' => $list ));
  1360. die();
  1361. }else{
  1362. echo json_encode( array('code' => 1) );
  1363. die();
  1364. }
  1365. }
  1366. /**
  1367. * 条件搜索商品
  1368. */
  1369. public function load_condition_goodslist()
  1370. {
  1371. $_GPC = I('request.');
  1372. $head_id = $_GPC['head_id'];
  1373. if($head_id == 'undefined')
  1374. $head_id = '';
  1375. $pageNum = $_GPC['pageNum'];
  1376. $per_page = 10;
  1377. $offset = ($pageNum - 1) * $per_page;
  1378. $limit = "{$offset},{$per_page}";
  1379. $gid = $_GPC['gid']; //分类id
  1380. $keyword = $_GPC['keyword'];
  1381. $good_ids = $_GPC['good_ids'];
  1382. $type = $_GPC['type']; //空:关键词搜索,1:指定分类,2:指定多个商品
  1383. $token = $_GPC['token'];
  1384. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1385. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1386. {
  1387. //echo json_encode( array('code' => 2) );
  1388. //die();
  1389. }
  1390. $member_id = $weprogram_token['member_id'];
  1391. $now_time = time();
  1392. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  1393. if( !empty($head_id) && $head_id >0 )
  1394. {
  1395. $params = array();
  1396. $params['uniacid'] = $_W['uniacid'];
  1397. $params['head_id'] = $head_id;
  1398. $goods_ids_arr = array();
  1399. if(!empty($keyword) && $type==0) {
  1400. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1401. .C('DB_PREFIX')."lionfish_comshop_goods as g
  1402. where pg.goods_id = g.id and g.goodsname like '%{$keyword}%' and pg.head_id = {$head_id} order by pg.id desc ";
  1403. $goods_ids_arr = M()->query($sql_goods_ids);
  1404. }
  1405. if($type==1){
  1406. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1407. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.goods_id = g.goods_id and g.cate_id = {$gid} and pg.head_id = {$head_id} order by pg.id desc ";
  1408. $goods_ids_arr = M()->query($sql_goods_ids);
  1409. }
  1410. if($type == 2){
  1411. $goods_ids_arr = M()->query('SELECT goods_id FROM ' . C('DB_PREFIX'). "lionfish_community_head_goods
  1412. WHERE head_id={$head_id} order by id desc ");
  1413. }
  1414. $ids_arr = array();
  1415. foreach($goods_ids_arr as $val){
  1416. $ids_arr[] = $val['goods_id'];
  1417. }
  1418. if(!empty($keyword) && $type==0) {
  1419. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX'). "lionfish_comshop_goods
  1420. WHERE is_all_sale=1 and goodsname like '%{$keyword}%' " );
  1421. }
  1422. if($type==1){
  1423. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg, "
  1424. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id = {$gid} and pg.is_all_sale=1 ";
  1425. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1426. }
  1427. if($type==2){
  1428. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX') . "lionfish_comshop_goods
  1429. WHERE is_all_sale=1 ");
  1430. }
  1431. if( !empty($goods_ids_nolimit_arr) )
  1432. {
  1433. foreach($goods_ids_nolimit_arr as $val){
  1434. $ids_arr[] = $val['id'];
  1435. }
  1436. }
  1437. if($type==2){
  1438. $good_ids_arr = explode(',',$good_ids);
  1439. $new_ids_arr = array();
  1440. if(count($good_ids_arr)>0){
  1441. foreach ($good_ids_arr as $val) {
  1442. if(in_array($val, $ids_arr)){
  1443. $new_ids_arr[] = $val;
  1444. }
  1445. }
  1446. }
  1447. $ids_arr = $new_ids_arr;
  1448. }
  1449. $ids_str = implode(',',$ids_arr);
  1450. if( !empty($ids_str) )
  1451. {
  1452. $where .= " and g.id in ({$ids_str})";
  1453. } else{
  1454. $where .= " and 0 ";
  1455. }
  1456. }else{
  1457. //echo json_encode( array('code' => 1) );
  1458. //die();
  1459. }
  1460. if(empty($head_id) && $type == 0 && !empty($keyword)) {
  1461. $where .= " and g.goodsname like '%{$keyword}%'";
  1462. }
  1463. if($type==1) {
  1464. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  1465. }
  1466. //$where .= " and gc.begin_time <= {$now_time} and gc.end_time > {$now_time} and g.total > 0 ";
  1467. $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 ', $where,$offset,$per_page);
  1468. if( !empty($community_goods) )
  1469. {
  1470. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1471. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1472. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1473. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1474. {
  1475. $is_open_fullreduction = 0;
  1476. }
  1477. $list = array();
  1478. foreach($community_goods as $val)
  1479. {
  1480. $tmp_data = array();
  1481. $tmp_data['actId'] = $val['id'];
  1482. $tmp_data['spuName'] = $val['goodsname'];
  1483. $tmp_data['spuCanBuyNum'] = $val['total'];
  1484. $tmp_data['spuDescribe'] = $val['subtitle'];
  1485. $tmp_data['end_time'] = $val['end_time'];
  1486. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1487. $productprice = $val['productprice'];
  1488. $tmp_data['marketPrice'] = explode('.', $productprice);
  1489. if( !empty($val['big_img']) )
  1490. {
  1491. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1492. }
  1493. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1494. if( !empty($good_image) )
  1495. {
  1496. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1497. }
  1498. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1499. $price = $price_arr['price'];
  1500. $tmp_data['actPrice'] = explode('.', $price);
  1501. /**
  1502. $tmp_data['skuList'] = array(
  1503. array('spec' => 'xl','canBuyNum' => 100,'spuName' => 1, 'actPrice' => array(1,2), 'marketPrice' => array(2,3),'skuImage' => tomedia($good_image['image'])),
  1504. array('spec' => 'x2','canBuyNum' => 200, 'spuName' => 2, 'actPrice' => array(1,2), 'marketPrice' => array(2,3),'skuImage' => tomedia($good_image['image']))
  1505. );
  1506. **/
  1507. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1508. if( !empty($tmp_data['skuList']) )
  1509. {
  1510. $tmp_data['car_count'] = 0;
  1511. }else{
  1512. if(!empty($head_id) && $head_id > 0){
  1513. $car_count = D('Home/Car')->get_wecart_goods($val['id'],"",$head_id ,$token);
  1514. if( empty($car_count) )
  1515. {
  1516. $tmp_data['car_count'] = 0;
  1517. }else{
  1518. $tmp_data['car_count'] = $car_count;
  1519. }
  1520. }
  1521. }
  1522. if($is_open_fullreduction == 0)
  1523. {
  1524. $tmp_data['is_take_fullreduction'] = 0;
  1525. }else if($is_open_fullreduction == 1){
  1526. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1527. }
  1528. $list[] = $tmp_data;
  1529. }
  1530. echo json_encode(array('code' => 0, 'list' => $list , 'cur_time' => time() ,'full_reducemoney' => $full_reducemoney,'full_money' => $full_money,'is_open_fullreduction' => $is_open_fullreduction ));
  1531. die();
  1532. }else{
  1533. echo json_encode( array('code' => 1) );
  1534. die();
  1535. }
  1536. }
  1537. public function get_newauth_bg()
  1538. {
  1539. $newauth_bg_image = D('Home/Front')->get_config_by_name('newauth_bg_image');
  1540. if( !empty($newauth_bg_image) )
  1541. {
  1542. $newauth_bg_image = tomedia($newauth_bg_image);
  1543. }
  1544. $newauth_cancel_image = D('Home/Front')->get_config_by_name('newauth_cancel_image');
  1545. if( !empty($newauth_cancel_image) )
  1546. {
  1547. $newauth_cancel_image = tomedia($newauth_cancel_image);
  1548. }
  1549. $newauth_confirm_image = D('Home/Front')->get_config_by_name('newauth_confirm_image');
  1550. if( !empty($newauth_confirm_image) )
  1551. {
  1552. $newauth_confirm_image = tomedia($newauth_confirm_image);
  1553. }
  1554. echo json_encode(
  1555. array(
  1556. 'code'=>0,
  1557. 'data' => array(
  1558. 'newauth_bg_image'=>$newauth_bg_image,
  1559. 'newauth_confirm_image'=>$newauth_confirm_image,
  1560. 'newauth_cancel_image'=>$newauth_cancel_image
  1561. )
  1562. )
  1563. );
  1564. }
  1565. /**
  1566. 进入小程序初始加载方法,
  1567. 以后有类似需要参数,都在这里初始化
  1568. **/
  1569. public function get_firstload_msg()
  1570. {
  1571. $_GPC = I('request.');
  1572. $token = isset($_GPC['token']) ? $_GPC['token'] : '';
  1573. $new_head_id = 0;
  1574. $default_head_info = array();
  1575. if( !empty($token) )
  1576. {
  1577. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1578. $community_history = M('lionfish_community_history')->field('head_id')->where( array('member_id' => $weprogram_token['member_id'] ) )->order('addtime desc')->find();
  1579. if( !empty($community_history) )
  1580. {
  1581. $cur_community_info = M('lionfish_community_head')->field('id')->where( array('id' => $community_history['head_id'] ) )->find();
  1582. if( !empty($cur_community_info) )
  1583. {
  1584. $new_head_id = $cur_community_info['id'];
  1585. $default_head_info = D('Home/Front')->get_community_byid($new_head_id);
  1586. }
  1587. }
  1588. }
  1589. $skin = D('Home/Front')->get_config_by_name('skin');
  1590. echo json_encode( array('code' => 0,'new_head_id' => $new_head_id, 'default_head_info' => $default_head_info, 'skin'=>$skin ) );
  1591. die();
  1592. }
  1593. /**
  1594. * 加载分类详情页
  1595. * @return [type] [description]
  1596. */
  1597. public function load_cate_goodslist()
  1598. {
  1599. $_GPC = I('request.');
  1600. $head_id = $_GPC['head_id'];
  1601. if($head_id == 'undefined')
  1602. $head_id = '';
  1603. $pid = $_GPC['gid'];
  1604. $token = $_GPC['token'];
  1605. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1606. $member_id = $weprogram_token['member_id'];
  1607. // vip身份
  1608. $is_vip_card_member = 0;
  1609. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1610. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  1611. $member_id = $weprogram_token['member_id'];
  1612. $is_vip_card_member = 0;
  1613. if( $member_id > 0 )
  1614. {
  1615. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  1616. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1617. {
  1618. $now_time = time();
  1619. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1620. {
  1621. $is_vip_card_member = 1;//还是会员
  1622. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1623. $is_vip_card_member = 2;//已过期
  1624. }
  1625. }
  1626. }
  1627. if($pid == 'undefined' || $pid =='')
  1628. {
  1629. echo json_encode(
  1630. array(
  1631. 'code' => 1,
  1632. 'data'=> array(),
  1633. 'msg' => '分类id错误'
  1634. )
  1635. );
  1636. die();
  1637. }
  1638. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1639. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1640. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1641. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1642. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  1643. $is_show_vipcard_price = D('Home/Front')->get_config_by_name('is_show_vipcard_price');
  1644. if( $is_open_vipcard_buy == 1 )
  1645. {
  1646. if( !empty($is_show_vipcard_price) && $is_show_vipcard_price == 1 ) $is_open_vipcard_buy = 0;
  1647. }
  1648. if(empty($full_reducemoney) || $full_reducemoney <= 0) $is_open_fullreduction = 0;
  1649. $cateList = $cateArr = array();
  1650. $parent_cate = M('lionfish_comshop_goods_category')->field('id,banner,name')->where( array('cate_type' =>'normal','id' => $pid ) )->find();
  1651. if($parent_cate){
  1652. $cate_info = M('lionfish_comshop_goods_category')->field('id,banner,name,logo')->where( array('cate_type' =>'normal','pid' => $parent_cate['id'] ) )->order('sort_order desc, id desc')->select();
  1653. if($cate_info){
  1654. $cateArr = array_merge(array($parent_cate), $cate_info);
  1655. }else {
  1656. $cateArr[] = $parent_cate;
  1657. }
  1658. foreach ($cateArr as $key => $val) {
  1659. $gid = $val['id'];
  1660. $cate_info = array();
  1661. $cate_info['name'] = $val['name'];
  1662. $cate_info['banner'] = $val['banner'] && !empty($val['banner']) ? tomedia($val['banner']) : '';
  1663. $cate_info['logo'] = $val['logo'] && !empty($val['logo']) ? tomedia($val['logo']) : '';
  1664. $now_time = time();
  1665. $where = " g.grounding =1 ";
  1666. if( !empty($head_id) && $head_id >0 )
  1667. {
  1668. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1669. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  1670. where pg.goods_id = g.goods_id and g.cate_id={$gid} and pg.head_id = {$head_id}
  1671. order by pg.id desc ";
  1672. $goods_ids_arr = M()->query($sql_goods_ids);
  1673. $ids_arr = array();
  1674. foreach($goods_ids_arr as $val){
  1675. $ids_arr[] = $val['goods_id'];
  1676. }
  1677. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1678. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id={$gid}
  1679. and pg.is_all_sale=1 ";
  1680. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1681. if( !empty($goods_ids_nolimit_arr) )
  1682. {
  1683. foreach($goods_ids_nolimit_arr as $val){
  1684. $ids_arr[] = $val['id'];
  1685. }
  1686. }
  1687. $ids_str = implode(',',$ids_arr);
  1688. if( !empty($ids_str) )
  1689. {
  1690. $where .= " and g.id in ({$ids_str})";
  1691. } else{
  1692. $where .= " and 0 ";
  1693. }
  1694. }else{
  1695. $goods_ids_nohead_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg," .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  1696. where pg.id = g.goods_id and g.cate_id = {$gid} ";
  1697. $goods_ids_nohead_arr = M()->query($goods_ids_nohead_sql);
  1698. $ids_arr = array();
  1699. if( !empty($goods_ids_nohead_arr) )
  1700. {
  1701. foreach($goods_ids_nohead_arr as $val){
  1702. $ids_arr[] = $val['id'];
  1703. }
  1704. }
  1705. $ids_str = implode(',',$ids_arr);
  1706. if( !empty($ids_str) )
  1707. {
  1708. $where .= " and g.id in ({$ids_str})";
  1709. } else{
  1710. $where .= " and 0 ";
  1711. }
  1712. }
  1713. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1714. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  1715. $community_goods = '';
  1716. $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, 0, 10000);
  1717. $list = $cart = array();
  1718. if( !empty($community_goods) )
  1719. {
  1720. $cart= D('Home/Car');
  1721. foreach($community_goods as $val)
  1722. {
  1723. $tmp_data = array();
  1724. $tmp_data['actId'] = $val['id'];
  1725. $tmp_data['spuName'] = $val['goodsname'];
  1726. $tmp_data['spuCanBuyNum'] = $val['total'];
  1727. $tmp_data['spuDescribe'] = $val['subtitle'];
  1728. $tmp_data['end_time'] = $val['end_time'];
  1729. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  1730. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1731. $productprice = $val['productprice'];
  1732. $tmp_data['marketPrice'] = explode('.', $productprice);
  1733. if( !empty($val['big_img']) )
  1734. {
  1735. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1736. }
  1737. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1738. if( !empty($good_image) )
  1739. {
  1740. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1741. }
  1742. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1743. $price = $price_arr['price'];
  1744. $tmp_data['actPrice'] = explode('.', $price);
  1745. $tmp_data['card_price'] = $price_arr['card_price'];
  1746. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1747. if( !empty($tmp_data['skuList']) )
  1748. {
  1749. $tmp_data['car_count'] = 0;
  1750. }else{
  1751. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1752. if( empty($car_count) )
  1753. {
  1754. $tmp_data['car_count'] = 0;
  1755. }else{
  1756. $tmp_data['car_count'] = $car_count;
  1757. }
  1758. }
  1759. if($is_open_fullreduction == 0)
  1760. {
  1761. $tmp_data['is_take_fullreduction'] = 0;
  1762. }else if($is_open_fullreduction == 1){
  1763. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1764. }
  1765. // 商品角标
  1766. $label_id = unserialize($val['labelname']);
  1767. if($label_id){
  1768. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1769. if($label_info){
  1770. if($label_info['type'] == 1){
  1771. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1772. } else {
  1773. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1774. }
  1775. }
  1776. $tmp_data['label_info'] = $label_info;
  1777. }
  1778. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1779. $list[] = $tmp_data;
  1780. }
  1781. }
  1782. $cateList[] = array('cate_info'=>$cate_info, 'list'=>$list);
  1783. }
  1784. }
  1785. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1786. echo json_encode(
  1787. array(
  1788. 'code' => 0,
  1789. 'list' => $cateList,
  1790. 'is_vip_card_member' => $is_vip_card_member,
  1791. 'cur_time' => time(),
  1792. 'full_reducemoney' => $full_reducemoney,
  1793. 'full_money' => $full_money,
  1794. 'is_open_vipcard_buy' => $is_open_vipcard_buy,
  1795. 'is_open_fullreduction' => $is_open_fullreduction,
  1796. 'is_show_cate_tabbar' => $is_show_cate_tabbar
  1797. )
  1798. );
  1799. die();
  1800. }
  1801. }