IndexController.class.php 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849
  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. echo get_client_ip();
  45. die();
  46. $order_info = D('Home/SzyOrder')->getOrderGoodsByOrderId( $order_id );
  47. var_dump( $order_info );
  48. die();
  49. }
  50. public function diy_page()
  51. {
  52. $startadv = array();
  53. return $startadv;
  54. }
  55. public function spike_index()
  56. {
  57. }
  58. public function load_spike_data()
  59. {
  60. }
  61. public function index_info()
  62. {
  63. $gpc = I('request.');
  64. $item = M('lionfish_comshop_config')->where( array('name' => 'shop_index_share_title') )->find();
  65. $communityId = $gpc['communityId'];
  66. $is_community = D('Seller/Communityhead')->is_community($communityId);
  67. $postion = M('lionfish_community_head')->field('lat,lon')->where( array('id' => $communityId) )->find();
  68. //...lionfish_comshop_adv
  69. $params = array();
  70. $params[':uniacid'] = $uniacid;
  71. $params[':type'] = 'slider';
  72. $params[':enabled'] = 1;
  73. /** 调用滑动广告 **/
  74. $slider_list = M('lionfish_comshop_adv')->where( array('enabled' => 1,'type' => 'slider') )->order('displayorder desc, id desc')->select();
  75. if(!empty($slider_list))
  76. {
  77. foreach($slider_list as $key => $val)
  78. {
  79. $val['image'] = tomedia($val['thumb']);
  80. $val['link'] = htmlspecialchars_decode( $val['link'] );
  81. $slider_list[$key] = $val;
  82. }
  83. }else{
  84. $slider_list = array();
  85. }
  86. // 公告列表
  87. $notice_list = M('lionfish_comshop_notice')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->select();
  88. /** 调用导航图标 **/
  89. $nav_list = M('lionfish_comshop_adv')->where( array('enabled' => 1,'type' => 'nav') )->order('displayorder desc, id desc')->select();
  90. if(!empty($nav_list))
  91. {
  92. foreach($nav_list as $key => $val)
  93. {
  94. $val['image'] = tomedia($val['thumb']);
  95. $val['name'] = $val['advname'];
  96. $val['link'] = htmlspecialchars_decode($val['link']);
  97. $nav_list[$key] = $val;
  98. }
  99. }else{
  100. $nav_list = array();
  101. }
  102. /**
  103. 调用分类
  104. **/
  105. $gid = isset($gpc['gid']) ? intval($gpc['gid']) : 0;
  106. $category_list = D('Home/GoodsCategory')->get_all_goods_category('normal', -1);
  107. // 过滤分类
  108. $cateidArr = array();
  109. foreach ($category_list as $k => $v) {
  110. $cateidArr[] = $v['id'];
  111. }
  112. $new_category_list = array();
  113. foreach ($category_list as $k => $v) {
  114. if($v['is_show']==1) {
  115. if($v['pid']==0) {
  116. $new_category_list[] = $v;
  117. } else {
  118. if(in_array($v['pid'], $cateidArr)) {
  119. $new_category_list[] = $v;
  120. }
  121. }
  122. }
  123. }
  124. $category_list = $new_category_list;
  125. $shop_index_share_image = D('Home/Front')->get_config_by_name('shop_index_share_image');
  126. if( !empty($shop_index_share_image) )
  127. {
  128. $shop_index_share_image = tomedia($shop_index_share_image);
  129. }
  130. $index_loading_image = D('Home/Front')->get_config_by_name('loading');
  131. if( !empty($index_loading_image) )
  132. {
  133. $index_loading_image = tomedia($index_loading_image);
  134. }
  135. $index_bottom_image = D('Home/Front')->get_config_by_name('index_bottom_image');
  136. if( !empty($index_bottom_image) )
  137. {
  138. $index_bottom_image = tomedia($index_bottom_image);
  139. }
  140. $index_list_top_image = D('Home/Front')->get_config_by_name('index_list_top_image');
  141. if( !empty($index_list_top_image) )
  142. {
  143. $index_list_top_image = tomedia($index_list_top_image);
  144. }
  145. $index_list_top_image_on = D('Home/Front')->get_config_by_name('index_list_top_image_on');
  146. $common_header_backgroundimage = D('Home/Front')->get_config_by_name('index_header_backgroundimage');
  147. if( !empty($common_header_backgroundimage) )
  148. {
  149. $common_header_backgroundimage = tomedia($common_header_backgroundimage);
  150. }
  151. $open_diy_index_page = D('Home/Front')->get_config_by_name('open_diy_index_page');
  152. $is_show_index_lead_image = D('Home/Front')->get_config_by_name('is_show_index_lead_image');
  153. $index_lead_image = '';
  154. if($is_show_index_lead_image == 1){
  155. $index_lead_image = D('Home/Front')->get_config_by_name('index_lead_image');
  156. if( !empty($index_lead_image) )
  157. {
  158. $index_lead_image = tomedia($index_lead_image);
  159. }
  160. }
  161. $diypage = array();
  162. if($open_diy_index_page == 1)
  163. {
  164. $diypage = $this->diy_page();
  165. }
  166. $shoname = D('Home/Front')->get_config_by_name('shoname');
  167. $theme = D('Home/Front')->get_config_by_name('index_list_theme_type');
  168. $spike_data = array();
  169. $nav_bg_color = D('Home/Front')->get_config_by_name('nav_bg_color');
  170. $order_notify_switch = D('Home/Front')->get_config_by_name('order_notify_switch');
  171. $rushtime = D('Home/Pingoods')->get_min_time();
  172. $comming_goods_total = D('Home/Pingoods')->get_comming_goods_count();
  173. $index_share_switch = D('Home/Front')->get_config_by_name('index_share_switch');
  174. $is_show_list_count = D('Home/Front')->get_config_by_name('is_show_list_count');
  175. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  176. $index_change_cate_btn = D('Home/Front')->get_config_by_name('index_change_cate_btn');
  177. $is_comunity_rest = D('Seller/Communityhead')->is_community_rest($communityId);
  178. $index_top_img_bg_open = D('Home/Front')->get_config_by_name('index_top_img_bg_open');
  179. $index_top_font_color = D('Home/Front')->get_config_by_name('index_top_font_color');
  180. $index_service_switch = D('Home/Front')->get_config_by_name('index_service_switch');
  181. $index_switch_search = D('Home/Front')->get_config_by_name('index_switch_search');
  182. $is_show_new_buy = D('Home/Front')->get_config_by_name('is_show_new_buy');
  183. //抢购自定义
  184. $index_qgtab_bottom_color = D('Home/Front')->get_config_by_name('index_qgtab_bottom_color');
  185. $index_qgtab_one_select = D('Home/Front')->get_config_by_name('index_qgtab_one_select');
  186. $index_qgtab_one_selected = D('Home/Front')->get_config_by_name('index_qgtab_one_selected');
  187. $index_qgtab_two_select = D('Home/Front')->get_config_by_name('index_qgtab_two_select');
  188. $index_qgtab_two_selected = D('Home/Front')->get_config_by_name('index_qgtab_two_selected');
  189. $qgtab = array();
  190. $qgtab['bottom_color'] = $index_qgtab_bottom_color;
  191. if(!empty($index_qgtab_one_select)) {
  192. $qgtab['one_select'] = tomedia($index_qgtab_one_select);
  193. }
  194. if(!empty($index_qgtab_one_selected)) {
  195. $qgtab['one_selected'] = tomedia($index_qgtab_one_selected);
  196. }
  197. if(!empty($index_qgtab_two_select)) {
  198. $qgtab['two_select'] = tomedia($index_qgtab_two_select);
  199. }
  200. if(!empty($index_qgtab_two_selected)) {
  201. $qgtab['two_selected'] = tomedia($index_qgtab_two_selected);
  202. }
  203. $notice_setting = array();
  204. $index_notice_horn_image = D('Home/Front')->get_config_by_name('index_notice_horn_image');
  205. if(!empty($index_notice_horn_image)) {
  206. $notice_setting['horn'] = tomedia($index_notice_horn_image);
  207. }
  208. $notice_setting['font_color'] = D('Home/Front')->get_config_by_name('index_notice_font_color');
  209. $notice_setting['background_color'] = D('Home/Front')->get_config_by_name('index_notice_background_color');
  210. //前端隐藏 团长信息
  211. $index_hide_headdetail_address = D('Home/Front')->get_config_by_name('index_hide_headdetail_address');
  212. if( empty($index_hide_headdetail_address) )
  213. {
  214. $index_hide_headdetail_address = 0;
  215. }
  216. $is_show_spike_buy = D('Home/Front')->get_config_by_name('is_show_spike_buy');
  217. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  218. $hide_top_community = D('Home/Front')->get_config_by_name('hide_index_top_communityinfo');
  219. $index_type_first_name = D('Home/Front')->get_config_by_name('index_type_first_name');
  220. $index_qgtab_text = array();
  221. $index_qgtab_text[] = D('Home/Front')->get_config_by_name('index_qgtab_text_going');
  222. $index_qgtab_text[] = D('Home/Front')->get_config_by_name('index_qgtab_text_future');
  223. $ishow_index_copy_text = D('Home/Front')->get_config_by_name('ishow_index_copy_text');
  224. $index_communityinfo_showtype = D('Home/Front')->get_config_by_name('index_communityinfo_showtype');
  225. // 魔方图
  226. $cube = array();
  227. $cube = M('lionfish_comshop_cube')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->select();
  228. if(!empty($cube)) {
  229. foreach ($cube as $k => $cubeItem) {
  230. $thumb = unserialize($cubeItem['thumb']);
  231. if(!empty($thumb['cover']) && is_array($thumb['cover'])) {
  232. foreach ($thumb['cover'] as &$coverItem) {
  233. if($coverItem) $coverItem = tomedia($coverItem);
  234. }
  235. }
  236. if( !empty($thumb['link']) )
  237. {
  238. foreach($thumb['link'] as $kk => $links)
  239. {
  240. $thumb['link'][$kk] = htmlspecialchars_decode($links);
  241. }
  242. }
  243. if( !empty($thumb['webview']) )
  244. {
  245. foreach($thumb['webview'] as $kkk => $webview)
  246. {
  247. $thumb['webview'][$kkk] = htmlspecialchars_decode($webview);
  248. }
  249. }
  250. if( !empty($thumb['outlink']) )
  251. {
  252. foreach($thumb['outlink'] as $kkkk => $outlink)
  253. {
  254. $thumb['outlink'][$kkkk] = htmlspecialchars_decode($outlink);
  255. }
  256. }
  257. $cubeItem['thumb'] = $thumb;
  258. $cube[$k] = $cubeItem;
  259. }
  260. }
  261. //秒杀设置begin
  262. $seckill_is_open = D('Home/Front')->get_config_by_name('seckill_is_open');
  263. $seckill_is_show_index = D('Home/Front')->get_config_by_name('seckill_is_show_index');
  264. $scekill_show_time = D('Home/Front')->get_config_by_name('scekill_show_time');
  265. $seckill_bg_color = D('Home/Front')->get_config_by_name('seckill_bg_color');
  266. $hide_community_change_word = D('Home/Front')->get_config_by_name('hide_community_change_word');
  267. if( empty($seckill_bg_color) )
  268. {
  269. $seckill_bg_color = '#25d6e6';
  270. }
  271. if( empty($seckill_is_open) )
  272. {
  273. $seckill_is_open = 0;
  274. }
  275. if( empty($seckill_is_show_index) )
  276. {
  277. $seckill_is_show_index = 0;
  278. }
  279. $scekill_time_arr = array();
  280. if( $seckill_is_open == 1 )
  281. {
  282. if( $seckill_is_show_index == 1 )
  283. {
  284. if( isset($scekill_show_time) && !empty($scekill_show_time) )
  285. {
  286. $scekill_show_time_arr = unserialize($scekill_show_time);
  287. foreach($scekill_show_time_arr as $vv)
  288. {
  289. if( $vv != 25 )
  290. {
  291. $scekill_time_arr[] = $vv;
  292. }
  293. }
  294. }
  295. }
  296. }else{
  297. $seckill_is_show_index = 0;
  298. }
  299. //整点秒杀结束
  300. //返回顶部按钮
  301. $ishow_index_gotop = D('Home/Front')->get_config_by_name('ishow_index_gotop');
  302. $ishow_index_pickup_time = D('Home/Front')->get_config_by_name('ishow_index_pickup_time');
  303. // 视频
  304. $index_video_arr = array();
  305. $index_video_enabled = D('Home/Front')->get_config_by_name('index_video_enabled');
  306. $index_video_arr['enabled'] = $index_video_enabled;
  307. if($index_video_enabled==1) {
  308. $index_video_poster = D('Home/Front')->get_config_by_name('index_video_poster');
  309. $index_video_url = D('Home/Front')->get_config_by_name('index_video_url');
  310. if($index_video_poster){
  311. $index_video_arr['poster'] = tomedia($index_video_poster);
  312. }
  313. if($index_video_url){
  314. $index_video_arr['url'] = tomedia($index_video_url);
  315. }
  316. }
  317. // 抢购时间显示
  318. $index_qgtab_counttime = D('Home/Front')->get_config_by_name('index_qgtab_counttime');
  319. $hide_index_type = D('Home/Front')->get_config_by_name('hide_index_type');
  320. // 公众号关注组件
  321. $show_index_wechat_oa = D('Home/Front')->get_config_by_name('show_index_wechat_oa');
  322. $ishide_index_goodslist = D('Home/Front')->get_config_by_name('ishide_index_goodslist');
  323. $can_index_notice_alert = D('Home/Front')->get_config_by_name('can_index_notice_alert');
  324. //是否开启预售活动==begin
  325. $show_presale_index_goods = D('Home/Front')->get_config_by_name('isopen_presale');
  326. $show_presale_index_goods = !isset($show_presale_index_goods) || empty($show_presale_index_goods) ? 0 : 1;
  327. $presale_index_info = [];
  328. $presale_index_info['show_presale_index_goods'] = $show_presale_index_goods;
  329. $presale_index_info['goods_list'] = [];
  330. if( $show_presale_index_goods == 1 )
  331. {
  332. //1、获取封面
  333. $presale_index_coming_img = D('Home/Front')->get_config_by_name('presale_index_coming_img');
  334. if( isset($presale_index_coming_img) && !empty($presale_index_coming_img) )
  335. {
  336. $presale_index_info['presale_index_coming_img'] = tomedia($presale_index_coming_img);
  337. }
  338. //2、获取首页显示的商品。后台没有定义就显示5条最多
  339. $presale_result = D('Home/PresaleGoods')->getIndexPresaleGoods(1);
  340. if( $presale_result['code'] == 0 && !empty($presale_result['list']) )
  341. {
  342. $presale_index_info['goods_list'] = $presale_result['list'];
  343. }
  344. }
  345. //首页预售活动end
  346. //是否开启礼品卡 begin
  347. $virtualcard_info = [];
  348. $isopen_virtualcard = D('Home/Front')->get_config_by_name('isopen_virtualcard');
  349. $isopen_virtualcard = !isset($isopen_virtualcard) ? 0 : $isopen_virtualcard;
  350. $virtualcard_info['isopen_virtualcard'] = $isopen_virtualcard;
  351. $virtualcard_info['goods_list'] = [];
  352. if( $isopen_virtualcard == 1 )
  353. {
  354. //入口封面图
  355. $virtualcard_index_coming_img = D('Home/Front')->get_config_by_name('virtualcard_index_coming_img');
  356. $virtualcard_info['virtualcard_index_coming_img'] = empty($virtualcard_index_coming_img) ? '' : tomedia( tomedia($virtualcard_index_coming_img) );
  357. //礼品卡商品
  358. $virtualcard_result = D('Seller/VirtualCard')->getIndexVirturalCardGoods(1);
  359. if( $virtualcard_result['code'] == 0 && !empty($virtualcard_result['list']) )
  360. {
  361. $virtualcard_info['goods_list'] = $virtualcard_result['list'];
  362. }
  363. }
  364. //是否开启礼品卡 end
  365. echo json_encode(array('code'=>0,
  366. 'category_list' =>$category_list,
  367. 'spike_data' => array(),
  368. 'shop_index_share_image' => $shop_index_share_image,
  369. 'index_loading_image' => $index_loading_image,
  370. 'index_bottom_image' => $index_bottom_image,
  371. 'title' =>$item['value'],'shoname'=>$shoname,
  372. 'slider_list' => $slider_list,
  373. 'nav_list' => $nav_list,
  374. 'open_diy_index_page' => $open_diy_index_page,
  375. 'diypage' => $diypage,
  376. 'notice_list' => $notice_list ,
  377. 'index_list_top_image' => $index_list_top_image,
  378. 'is_community' => $is_community,
  379. 'index_lead_image' => $index_lead_image,
  380. 'theme' => $theme,
  381. 'common_header_backgroundimage' => $common_header_backgroundimage,
  382. 'nav_bg_color' => $nav_bg_color,
  383. 'order_notify_switch' => $order_notify_switch,
  384. 'is_quan' => $is_quan,
  385. 'index_list_top_image_on' => $index_list_top_image_on,
  386. 'postion' => $postion,
  387. 'rushtime' => $rushtime,
  388. 'comming_goods_total' => $comming_goods_total,
  389. 'index_share_switch' => $index_share_switch,
  390. 'is_show_list_count' => $is_show_list_count,
  391. 'is_show_list_timer' => $is_show_list_timer,
  392. 'is_comunity_rest' => $is_comunity_rest,
  393. 'index_change_cate_btn' => $index_change_cate_btn,
  394. 'index_top_img_bg_open' => $index_top_img_bg_open,
  395. 'index_top_font_color' => $index_top_font_color,
  396. 'index_service_switch' => $index_service_switch,
  397. 'index_switch_search' => $index_switch_search,
  398. 'is_show_new_buy' => $is_show_new_buy,
  399. 'qgtab' => $qgtab,
  400. 'notice_setting' => $notice_setting,
  401. 'index_hide_headdetail_address' => $index_hide_headdetail_address,
  402. 'is_show_spike_buy' => $is_show_spike_buy,
  403. 'hide_community_change_btn' => $hide_community_change_btn,
  404. 'hide_top_community' => $hide_top_community,
  405. 'index_type_first_name' => $index_type_first_name,
  406. 'index_qgtab_text' => $index_qgtab_text,
  407. 'ishow_index_copy_text' => $ishow_index_copy_text,
  408. 'index_communityinfo_showtype' => $index_communityinfo_showtype,
  409. 'cube' => $cube,
  410. 'seckill_is_open'=> $seckill_is_open,//是否开启整点秒杀功能
  411. 'seckill_is_show_index' => $seckill_is_show_index,//是否显示再首页上
  412. 'scekill_time_arr' => $scekill_time_arr,//整点秒杀的时间点数组, 0 点表示:0:00-0:59, 1 表示:1:00-1:59
  413. 'seckill_bg_color' => $seckill_bg_color,
  414. 'hide_community_change_word' => $hide_community_change_word,
  415. 'ishow_index_gotop' => $ishow_index_gotop,
  416. 'ishow_index_pickup_time' => $ishow_index_pickup_time,
  417. 'index_video_arr' => $index_video_arr,
  418. 'index_qgtab_counttime' => $index_qgtab_counttime,
  419. 'hide_index_type' => $hide_index_type,
  420. 'show_index_wechat_oa' => $show_index_wechat_oa,
  421. 'ishide_index_goodslist' => $ishide_index_goodslist,
  422. 'can_index_notice_alert' => $can_index_notice_alert,
  423. 'presale_index_info' => $presale_index_info,//首页预售商品信息
  424. 'virtualcard_info' => $virtualcard_info,//礼品卡首页信息
  425. )
  426. );
  427. die();
  428. }
  429. public function get_group_info()
  430. {
  431. $group_name = D('Home/Front')->get_config_by_name('group_name');
  432. $owner_name = D('Home/Front')->get_config_by_name('owner_name');
  433. $commiss_diy_name = D('Home/Front')->get_config_by_name('commiss_diy_name');
  434. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');
  435. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');
  436. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');
  437. // 下单页面
  438. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');
  439. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');
  440. $localtown_modifypickingname = D('Home/Front')->get_config_by_name('localtown_modifypickingname');
  441. $placeorder_tuan_name = $placeorder_tuan_name?$placeorder_tuan_name:"配送费";
  442. $placeorder_trans_name = $placeorder_trans_name?$placeorder_trans_name:"快递费";
  443. $localtown_modifypickingname = $localtown_modifypickingname?$localtown_modifypickingname:"包装费";
  444. $data = array(
  445. 'group_name'=>$group_name,
  446. 'owner_name'=>$owner_name,
  447. 'commiss_diy_name'=>$commiss_diy_name,
  448. 'delivery_ziti_name'=>$delivery_ziti_name,
  449. 'delivery_tuanzshipping_name'=>$delivery_tuanzshipping_name,
  450. 'delivery_express_name'=>$delivery_express_name,
  451. 'placeorder_tuan_name'=>$placeorder_tuan_name,
  452. 'placeorder_trans_name'=>$placeorder_trans_name,
  453. 'localtown_modifypickingname'=>$localtown_modifypickingname
  454. );
  455. echo json_encode(array('code'=>0, 'data' =>$data));
  456. }
  457. public function get_nav_bg_color()
  458. {
  459. $nav_bg_color = D('Home/Front')->get_config_by_name('nav_bg_color');
  460. $nav_font_color = D('Home/Front')->get_config_by_name('nav_font_color');
  461. echo json_encode(array('code'=>0, 'data' => $nav_bg_color, 'nav_font_color' => $nav_font_color));
  462. }
  463. public function get_auth_bg()
  464. {
  465. $auth_bg_image = D('Home/Front')->get_config_by_name('auth_bg_image');
  466. if( !empty($auth_bg_image) )
  467. {
  468. $auth_bg_image = tomedia($auth_bg_image);
  469. }
  470. echo json_encode(array('code'=>0, 'data' =>$auth_bg_image));
  471. }
  472. /**
  473. * 获取导航图标 lionfish_comshop_navigat
  474. */
  475. public function get_navigat()
  476. {
  477. $list = M('lionfish_comshop_navigat')->field('id,navname,thumb,link,type,appid')->where("enabled=1")->order('displayorder desc')->select();
  478. if( !empty($list) )
  479. {
  480. foreach ($list as $key => &$val) {
  481. $val['thumb'] = tomedia($val['thumb']);
  482. $val['link'] = htmlspecialchars_decode($val['link']);
  483. }
  484. }
  485. $result = array('code' =>0,'data' => $list);
  486. echo json_encode($result);
  487. die();
  488. }
  489. /**
  490. * 获取tabbar
  491. */
  492. public function get_tabbar()
  493. {
  494. $list = D('Home/Front')->get_config_by_name('wepro_tabbar_list');
  495. /**
  496. $param['wepro_tabbar_list'] = array();
  497. $param['wepro_tabbar_list']['t1'] = trim($data['wepro_tabbar_text1']);
  498. $param['wepro_tabbar_list']['t2'] = trim($data['wepro_tabbar_text2']);
  499. $param['wepro_tabbar_list']['t3'] = trim($data['wepro_tabbar_text3']);
  500. $param['wepro_tabbar_list']['s1'] = save_media($data['wepro_tabbar_selectedIconPath1']);
  501. $param['wepro_tabbar_list']['s2'] = save_media($data['wepro_tabbar_selectedIconPath2']);
  502. $param['wepro_tabbar_list']['s3'] = save_media($data['wepro_tabbar_selectedIconPath3']);
  503. $param['wepro_tabbar_list']['i1'] = save_media($data['wepro_tabbar_iconPath1']);
  504. $param['wepro_tabbar_list']['i2'] = save_media($data['wepro_tabbar_iconPath2']);
  505. $param['wepro_tabbar_list']['i3'] = save_media($data['wepro_tabbar_iconPath3']);
  506. **/
  507. $list = unserialize(htmlspecialchars_decode($list));
  508. $open_tabbar_type = D('Home/Front')->get_config_by_name('open_tabbar_type');
  509. $open_tabbar_out_weapp = D('Home/Front')->get_config_by_name('open_tabbar_out_weapp');
  510. $tabbar_out_appid = D('Home/Front')->get_config_by_name('tabbar_out_appid');
  511. $tabbar_out_link = D('Home/Front')->get_config_by_name('tabbar_out_link');
  512. $tabbar_out_type = D('Home/Front')->get_config_by_name('tabbar_out_type');
  513. $wepro_tabbar_selectedColor = D('Home/Front')->get_config_by_name('wepro_tabbar_selectedColor');
  514. $wepro_tabbar_bgColor = D('Home/Front')->get_config_by_name('wepro_tabbar_bgColor');
  515. if( !empty($list) )
  516. {
  517. if(!empty($list['i1'])) $list['i1'] = tomedia($list['i1']);
  518. if(!empty($list['i2'])) $list['i2'] = tomedia($list['i2']);
  519. if(!empty($list['i3'])) $list['i3'] = tomedia($list['i3']);
  520. if(!empty($list['i4'])) $list['i4'] = tomedia($list['i4']);
  521. if(!empty($list['i5'])) $list['i5'] = tomedia($list['i5']);
  522. if(!empty($list['s1'])) $list['s1'] = tomedia($list['s1']);
  523. if(!empty($list['s2'])) $list['s2'] = tomedia($list['s2']);
  524. if(!empty($list['s3'])) $list['s3'] = tomedia($list['s3']);
  525. if(!empty($list['s4'])) $list['s4'] = tomedia($list['s4']);
  526. if(!empty($list['s5'])) $list['s5'] = tomedia($list['s5']);
  527. }
  528. $result = array(
  529. 'code' => 0,
  530. 'data' => $list,
  531. 'open_tabbar_type' => $open_tabbar_type,
  532. 'open_tabbar_out_weapp' => $open_tabbar_out_weapp,
  533. 'tabbar_out_appid' => $tabbar_out_appid,
  534. 'tabbar_out_link' => $tabbar_out_link,
  535. 'tabbar_out_type' => $tabbar_out_type,
  536. 'wepro_tabbar_selectedColor' => $wepro_tabbar_selectedColor,
  537. 'wepro_tabbar_bgColor' => $wepro_tabbar_bgColor
  538. );
  539. echo json_encode($result);
  540. die();
  541. }
  542. public function get_community_config()
  543. {
  544. $tx_map_key = D('Home/Front')->get_config_by_name('tx_map_key');
  545. $shoname = D('Home/Front')->get_config_by_name('shoname');
  546. $shop_index_share_title = D('Home/Front')->get_config_by_name('shop_index_share_title');
  547. echo json_encode( array('code' => 0, 'tx_map_key' => $tx_map_key , 'shoname' => $shoname ,'shop_index_share_title' => $shop_index_share_title) );
  548. die();
  549. }
  550. public function load_history_community()
  551. {
  552. $gpc = I('request.');
  553. $token = $gpc['token'];
  554. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  555. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  556. {
  557. echo json_encode( array('code' => 2) );
  558. die();
  559. }
  560. $member_id = $weprogram_token['member_id'];
  561. $data = D('Home/Front')->get_history_community($member_id);
  562. if( empty($data) )
  563. {
  564. echo json_encode(array('code' => 1));
  565. die();
  566. }
  567. else {
  568. echo json_encode(array('code' => 0, 'list' => $data));
  569. die();
  570. }
  571. }
  572. /**
  573. * 切换、添加历史社区
  574. */
  575. public function switch_history_community(){
  576. $gpc = I('request.');
  577. $token = $gpc['token'];
  578. $head_id = $gpc['head_id'];
  579. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  580. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  581. {
  582. echo json_encode( array('code' => 2) );
  583. die();
  584. }
  585. $member_id = $weprogram_token['member_id'];
  586. $data = D('Home/Front')->update_history_community($member_id, $head_id);
  587. //删除 community_id
  588. M('lionfish_comshop_car')->where( "token='{$token}' and community_id!='{$head_id}' " )->delete();
  589. if( empty($data) )
  590. {
  591. echo json_encode(array('code' => 1));
  592. die();
  593. }
  594. else {
  595. echo json_encode(array('code' => 0, 'list' => $data));
  596. die();
  597. }
  598. }
  599. public function get_community_info()
  600. {
  601. $gpc = I('request.');
  602. $where = " and state=1 and enable=1 ";
  603. $community_id = $gpc['community_id'];
  604. if($community_id == 'undefined')
  605. {
  606. $community_id = 0;
  607. }
  608. $data = D('Home/Front')->get_community_byid($community_id , $where);
  609. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  610. $open_danhead_model = D('Home/Front')->get_config_by_name('open_danhead_model');
  611. if( empty($open_danhead_model) )
  612. {
  613. $open_danhead_model = 0;
  614. }
  615. $default_head_info = array();
  616. if( $open_danhead_model == 1 )
  617. {
  618. $default_head = M('lionfish_community_head')->field('id')->where( array('is_default' => 1) )->find();
  619. if( !empty($default_head) )
  620. {
  621. $default_head_info = D('Home/Front')->get_community_byid($default_head['id'], $where);
  622. }
  623. }
  624. 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));
  625. die();
  626. }
  627. public function load_gps_community()
  628. {
  629. $gpc = I('request.');
  630. $longitude = $gpc['longitude'];
  631. $latitude = $gpc['latitude'];
  632. $pageNum = $gpc['pageNum'];
  633. $city_id = $gpc['city_id'] ? $gpc['city_id'] : 0;
  634. $per_page = 10;
  635. $offset = ($pageNum - 1) * $per_page;
  636. $limit = "{$offset},{$per_page}";
  637. $token = $gpc['token'];
  638. $keyword = $gpc['inputValue'];
  639. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  640. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  641. {
  642. //echo json_encode( array('code' => 2) );
  643. //die();
  644. }
  645. $member_id = $weprogram_token['member_id'];
  646. $data = array();
  647. $open_danhead_model = D('Home/Front')->get_config_by_name('open_danhead_model');
  648. if( $open_danhead_model == 1 )
  649. {
  650. $default_head = M('lionfish_community_head')->field('id')->where( array('is_default' => 1) )->find();
  651. if( !empty($default_head) )
  652. {
  653. $data = D('Home/Front')->get_community_byid($default_head['id'], $where);
  654. }
  655. } else {
  656. $data = D('Home/Front')->get_gps_area_info($longitude,$latitude,$limit,$keyword,$city_id,0);
  657. }
  658. //前端隐藏 团长信息
  659. $index_hide_headdetail_address = D('Home/Front')->get_config_by_name('index_hide_headdetail_address');
  660. if( empty($index_hide_headdetail_address) )
  661. {
  662. $index_hide_headdetail_address = 0;
  663. }
  664. if( empty($data) )
  665. {
  666. echo json_encode(array('code'=>1,'index_hide_headdetail_address' => $index_hide_headdetail_address));
  667. die();
  668. }else{
  669. echo json_encode(array('code'=>0, 'list' => $data,'index_hide_headdetail_address' => $index_hide_headdetail_address));
  670. die();
  671. }
  672. }
  673. public function addhistory_community()
  674. {
  675. $gpc = I('request.');
  676. $token = $gpc['token'];
  677. $head_id = $gpc['community_id'];
  678. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  679. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  680. {
  681. echo json_encode( array('code' => 2) );
  682. die();
  683. }
  684. $member_id = $weprogram_token['member_id'];
  685. D('Seller/Community')->in_community_history($member_id,$head_id);
  686. echo json_encode( array('code' => 0) );
  687. die();
  688. }
  689. /**
  690. 获取已经过期的往期团购
  691. **/
  692. public function load_over_gps_goodslist()
  693. {
  694. $gpc = I('request.');
  695. $head_id = $gpc['head_id'];
  696. $pageNum = $gpc['pageNum'];
  697. $per_page = 10;
  698. $gid = $gpc['gid'];
  699. $offset = ($pageNum - 1) * $per_page;
  700. $limit = "{$offset},{$per_page}";
  701. if($head_id == 'undefined') $head_id = '';
  702. $is_only_express = $gpc['is_only_express'];
  703. $is_open_only_express = 0;
  704. if($is_only_express==1) {
  705. $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
  706. }
  707. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  708. {
  709. $gid = 0;
  710. }
  711. if( !empty($gid) && $gid > 0)
  712. {
  713. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid,'normal','','',1);
  714. $gidArr = array();
  715. $gidArr[] = $gid;
  716. foreach ($gids as $key => $val) {
  717. $gidArr[] = $val['id'];
  718. }
  719. $gid = implode(',', $gidArr);
  720. }
  721. $token = $gpc['token'];
  722. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  723. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  724. {
  725. //echo json_encode( array('code' => 2) );
  726. //die();
  727. }
  728. $member_id = $weprogram_token['member_id'];
  729. $now_time = time();
  730. $where = " g.grounding =1 and g.type ='normal' ";
  731. $is_index_show = isset($gpc['is_index_show']) ? $gpc['is_index_show'] : 0;
  732. if($is_index_show==1) {
  733. $where .= " and g.is_index_show = 1";
  734. }
  735. if($is_open_only_express==1 && $is_only_express==1) {
  736. $where .= " and gc.is_only_express =1 ";
  737. }
  738. $where .= " and gc.end_time <= {$now_time} and gc.is_new_buy=0 ";
  739. $community_goods = D('Home/Pingoods')->get_new_community_index_goods($head_id, $gid, 'g.*,gc.begin_time,gc.end_time,gc.big_img,gc.labelname,gc.video,gc.pick_up_type,gc.pick_up_modify ', $where,$offset,$per_page);
  740. if( !empty($community_goods) )
  741. {
  742. $list = array();
  743. $today_time = time();
  744. foreach($community_goods as $val)
  745. {
  746. $tmp_data = array();
  747. $tmp_data['actId'] = $val['id'];
  748. $goodsname = htmlspecialchars_decode($val['goodsname']);
  749. $tmp_data['spuName'] = $goodsname;
  750. $tmp_data['spuCanBuyNum'] = $val['total'];
  751. $tmp_data['spuDescribe'] = $val['subtitle'];
  752. $tmp_data['actEnd'] = time()>$val['end_time'];
  753. $tmp_data['end_time'] = $val['end_time'];
  754. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  755. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  756. if($val['pick_up_type'] == 0)
  757. {
  758. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  759. }else if( $val['pick_up_type'] == 1 ){
  760. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  761. }else if( $val['pick_up_type'] == 2 )
  762. {
  763. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  764. }
  765. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  766. $productprice = $val['productprice'];
  767. $tmp_data['marketPrice'] = explode('.', $productprice);
  768. if( !empty($val['big_img']) )
  769. {
  770. $tmp_data['bigImg'] = tomedia($val['big_img']);
  771. }
  772. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  773. if( !empty($good_image) )
  774. {
  775. $tmp_data['skuImage'] = tomedia($good_image['image']);
  776. }
  777. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  778. $price = $price_arr['price'];
  779. $tmp_data['actPrice'] = explode('.', $price);
  780. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  781. // 商品角标
  782. $label_id = unserialize($val['labelname']);
  783. if($label_id){
  784. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  785. if($label_info){
  786. if($label_info['type'] == 1){
  787. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  788. } else {
  789. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  790. }
  791. }
  792. $tmp_data['label_info'] = $label_info;
  793. }
  794. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  795. $list[] = $tmp_data;
  796. }
  797. $is_member_level_buy = 0;
  798. $is_vip_card_member = 0;
  799. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  800. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  801. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  802. $full_money = D('Home/Front')->get_config_by_name('full_money');
  803. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  804. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  805. {
  806. $is_open_fullreduction = 0;
  807. }
  808. echo json_encode(array('code' => 0, 'list' => $list , 'cur_time' => time(), 'is_vip_card_member' => $is_vip_card_member,'is_member_level_buy' => $is_member_level_buy, 'full_reducemoney' => $full_reducemoney, 'full_money' => $full_money,'is_open_vipcard_buy' => $is_open_vipcard_buy, 'is_open_fullreduction' => $is_open_fullreduction ));
  809. die();
  810. }else{
  811. echo json_encode( array('code' => 1) );
  812. die();
  813. }
  814. }
  815. public function load_gps_goodslist()
  816. {
  817. $gpc = I('request.');
  818. $token = $gpc['token'];
  819. $head_id = $gpc['head_id'];
  820. $is_only_express = $gpc['is_only_express'];
  821. $is_open_only_express = 0;
  822. if($is_only_express==1) {
  823. $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
  824. }
  825. if($head_id == 'undefined') $head_id = '';
  826. $pageNum = $gpc['pageNum'];
  827. $gid = $gpc['gid'];
  828. $keyword = $gpc['keyword'];
  829. $is_random = isset($gpc['is_random']) ? $gpc['is_random'] : 0;
  830. $is_video = isset($gpc['is_video']) ? $gpc['is_video'] : 0;
  831. $per_page = isset($gpc['per_page']) ? $gpc['per_page'] : 10;
  832. $cate_info = '';
  833. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  834. {
  835. $gid = 0;
  836. } else {
  837. $cate_info = M('lionfish_comshop_goods_category')->field('banner,name')->where( array('id' => $gid ) )->find();
  838. if(!empty($cate_info['banner'])) $cate_info['banner'] = tomedia($cate_info['banner']);
  839. }
  840. if( !empty($gid) && $gid > 0)
  841. {
  842. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid,'normal','','',1);
  843. $gidArr = array();
  844. $gidArr[] = $gid;
  845. foreach ($gids as $key => $val) {
  846. $gidArr[] = $val['id'];
  847. }
  848. $gid = implode(',', $gidArr);
  849. }
  850. //$per_page = 10;
  851. $offset = ($pageNum - 1) * $per_page;
  852. $limit = "{$offset},{$per_page}";
  853. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  854. $is_member_level_buy = 0;
  855. $is_vip_card_member = 0;
  856. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  857. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  858. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  859. {
  860. //echo json_encode( array('code' => 2) );
  861. //die();
  862. }else{
  863. $member_id = $weprogram_token['member_id'];
  864. $is_vip_card_member = 0;
  865. //member_id
  866. if( $member_id > 0 )
  867. {
  868. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  869. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  870. {
  871. $now_time = time();
  872. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  873. {
  874. $is_vip_card_member = 1;//还是会员
  875. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  876. $is_vip_card_member = 2;//已过期
  877. }
  878. }
  879. if($is_vip_card_member != 1 && $member_info['level_id'] >0 )
  880. {
  881. $is_member_level_buy = 1;
  882. }
  883. }
  884. }
  885. $member_id = $weprogram_token['member_id'];
  886. //整点秒杀begin
  887. $is_seckill = isset($gpc['is_seckill']) ? 1:0;
  888. $seckill_time = isset($gpc['seckill_time']) ? intval($gpc['seckill_time']):0;
  889. //整点秒杀end
  890. $now_time = time();
  891. if($is_seckill ==1)
  892. {
  893. $where = " g.grounding =1 and g.is_seckill =1 and g.type ='normal' ";
  894. }else
  895. {
  896. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  897. }
  898. //head_id
  899. if( !empty($keyword) )
  900. {
  901. $where .= " and g.goodsname like '%{$keyword}%' ";
  902. }
  903. //$where .= " and g.is_index_show = 1 and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  904. if($is_seckill ==1)
  905. {
  906. $bg_time = strtotime( date('Y-m-d').' '.$seckill_time.':00:00' );
  907. $ed_time = $bg_time + 3600;
  908. if($gid == 0 && $keyword == ''){
  909. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  910. } else {
  911. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  912. }
  913. } else {
  914. if($gid == 0 && $keyword == ''){
  915. $where .= " and g.is_index_show = 1 and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  916. } else {
  917. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  918. }
  919. }
  920. if($is_seckill ==1)
  921. {
  922. }else{
  923. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  924. }
  925. if( $is_video == 1 )
  926. {
  927. $where .= " and gc.video !='' ";
  928. }
  929. if($is_open_only_express==1 && $is_only_express==1) {
  930. $where .= " and gc.is_only_express =1 ";
  931. }
  932. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  933. if( empty($index_sort_method) )
  934. {
  935. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  936. }
  937. if( $index_sort_method == 1 )
  938. {
  939. $order_sort = 'g.index_sort desc,g.id desc ';
  940. }
  941. if($is_random == 1)
  942. {
  943. $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,gc.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page,$order_sort,' rand() ');
  944. }else{
  945. $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,gc.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page,$order_sort);
  946. }
  947. if( !empty($community_goods) )
  948. {
  949. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  950. $full_money = D('Home/Front')->get_config_by_name('full_money');
  951. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  952. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  953. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  954. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  955. {
  956. $is_open_fullreduction = 0;
  957. }
  958. $cart= D('Home/Car');
  959. $list = array();
  960. $copy_text_arr = array();
  961. $today_time = strtotime( date('Y-m-d').' 00:00:00' );
  962. foreach($community_goods as $val)
  963. {
  964. $tmp_data = array();
  965. $tmp_data['actId'] = $val['id'];
  966. $goodsname = htmlspecialchars_decode($val['goodsname']);
  967. $tmp_data['spuName'] = $goodsname;
  968. $tmp_data['spuCanBuyNum'] = $val['total'];
  969. $tmp_data['spuDescribe'] = $val['subtitle'];
  970. $tmp_data['end_time'] = $val['end_time'];
  971. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  972. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  973. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  974. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  975. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  976. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  977. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  978. if($val['pick_up_type'] == 0)
  979. {
  980. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  981. }else if( $val['pick_up_type'] == 1 ){
  982. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  983. }else if( $val['pick_up_type'] == 2 )
  984. {
  985. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  986. }
  987. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  988. $productprice = $val['productprice'];
  989. $tmp_data['marketPrice'] = explode('.', $productprice);
  990. if( !empty($val['big_img']) )
  991. {
  992. $tmp_data['bigImg'] = tomedia($val['big_img']);
  993. }
  994. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  995. if( !empty($good_image) )
  996. {
  997. $tmp_data['skuImage'] = tomedia($good_image['image']);
  998. }
  999. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1000. $price = $price_arr['price'];
  1001. if( $pageNum == 1 )
  1002. {
  1003. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  1004. }
  1005. $tmp_data['actPrice'] = explode('.', $price);
  1006. $tmp_data['card_price'] = $price_arr['card_price'];
  1007. $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  1008. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  1009. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1010. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1011. if( !empty($tmp_data['skuList']) )
  1012. {
  1013. $tmp_data['car_count'] = 0;
  1014. }else{
  1015. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1016. if( empty($car_count) )
  1017. {
  1018. $tmp_data['car_count'] = 0;
  1019. }else{
  1020. $tmp_data['car_count'] = $car_count;
  1021. }
  1022. }
  1023. if($is_open_fullreduction == 0)
  1024. {
  1025. $tmp_data['is_take_fullreduction'] = 0;
  1026. }else if($is_open_fullreduction == 1){
  1027. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1028. }
  1029. // 商品角标
  1030. $label_id = unserialize($val['labelname']);
  1031. if($label_id){
  1032. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1033. if($label_info){
  1034. if($label_info['type'] == 1){
  1035. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1036. } else {
  1037. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1038. }
  1039. }
  1040. $tmp_data['label_info'] = $label_info;
  1041. }
  1042. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1043. $list[] = $tmp_data;
  1044. }
  1045. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  1046. $index_list_theme_type = D('Home/Front')->get_config_by_name('index_list_theme_type');
  1047. // 3*3是也关闭
  1048. if($index_list_theme_type>=2) $is_show_list_timer==0;
  1049. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1050. 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 ));
  1051. die();
  1052. }else{
  1053. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1054. echo json_encode( array('code' => 1 , 'cate_info' => $cate_info , 'is_show_cate_tabbar'=>$is_show_cate_tabbar ) );
  1055. die();
  1056. }
  1057. }
  1058. public function get_index_category()
  1059. {
  1060. $gpc = I('request.');
  1061. $gid = $gpc['gid'];
  1062. $hot_list = M('lionfish_comshop_goods_category')->where( array('is_hot' => 1) )->order('sort_order desc')->select();
  1063. $need_data = array();
  1064. foreach($hot_list as $key => $cate)
  1065. {
  1066. $need_data[$key]['id'] = $cate['id'];
  1067. $need_data[$key]['name'] = $cate['name'];
  1068. $need_data[$key]['sort_order'] = $cate['sort_order'];
  1069. }
  1070. $result = array('code' =>0,'data' => $need_data);
  1071. echo json_encode($result);
  1072. die();
  1073. }
  1074. /**
  1075. * 获取首页公告
  1076. */
  1077. public function get_index_notice()
  1078. {
  1079. $list = M('lionfish_comshop_notice')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->limit(1)->select();
  1080. $result = array('code' =>0,'data' => $list);
  1081. echo json_encode($result);
  1082. die();
  1083. }
  1084. /**
  1085. * 即将抢购商品
  1086. */
  1087. public function load_comming_goodslist()
  1088. {
  1089. $gpc = I('request.');
  1090. $head_id = $gpc['head_id'];
  1091. $pageNum = $gpc['pageNum'];
  1092. $per_page = 10;
  1093. $gid = $gpc['gid'];
  1094. $offset = ($pageNum - 1) * $per_page;
  1095. $limit = "{$offset},{$per_page}";
  1096. if($head_id == 'undefined') $head_id = '';
  1097. $is_only_express = $gpc['is_only_express'];
  1098. $is_open_only_express = 0;
  1099. if($is_only_express==1) {
  1100. $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
  1101. }
  1102. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  1103. {
  1104. $gid = 0;
  1105. }
  1106. if( !empty($gid) && $gid > 0)
  1107. {
  1108. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid,'normal','','',1);
  1109. $gidArr = array();
  1110. $gidArr[] = $gid;
  1111. foreach ($gids as $key => $val) {
  1112. $gidArr[] = $val['id'];
  1113. }
  1114. $gid = implode(',', $gidArr);
  1115. }
  1116. $token = $gpc['token'];
  1117. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1118. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1119. {
  1120. //echo json_encode( array('code' => 2) );
  1121. //die();
  1122. }
  1123. $member_id = $weprogram_token['member_id'];
  1124. $now_time = time();
  1125. $where = " g.grounding =1 and g.type ='normal' ";
  1126. $is_index_show = isset($gpc['is_index_show']) ? $gpc['is_index_show'] : 0;
  1127. if($is_index_show==1) {
  1128. $where .= " and g.is_index_show = 1";
  1129. }
  1130. if($is_open_only_express==1 && $is_only_express==1) {
  1131. $where .= " and gc.is_only_express =1 ";
  1132. }
  1133. $where .= "and gc.begin_time > {$now_time} ";
  1134. $community_goods = D('Home/Pingoods')->get_new_community_index_goods($head_id, $gid, 'g.*,gc.begin_time,gc.end_time,gc.big_img,gc.labelname,gc.video,gc.pick_up_type,gc.pick_up_modify,gc.is_take_fullreduction ', $where,$offset,$per_page);
  1135. if( !empty($community_goods) )
  1136. {
  1137. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1138. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1139. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1140. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1141. {
  1142. $is_open_fullreduction = 0;
  1143. }
  1144. $list = array();
  1145. foreach($community_goods as $val)
  1146. {
  1147. $tmp_data = array();
  1148. $tmp_data['actId'] = $val['id'];
  1149. $tmp_data['spuName'] = $val['goodsname'];
  1150. $tmp_data['spuCanBuyNum'] = $val['total'];
  1151. $tmp_data['spuDescribe'] = $val['subtitle'];
  1152. $tmp_data['end_time'] = $val['end_time'];
  1153. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1154. $productprice = $val['productprice'];
  1155. $tmp_data['marketPrice'] = explode('.', $productprice);
  1156. if( !empty($val['big_img']) )
  1157. {
  1158. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1159. }
  1160. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1161. if( !empty($good_image) )
  1162. {
  1163. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1164. }
  1165. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'],$member_id);
  1166. $price = $price_arr['price'];
  1167. $tmp_data['actPrice'] = explode('.', $price);
  1168. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1169. if($is_open_fullreduction == 0)
  1170. {
  1171. $tmp_data['is_take_fullreduction'] = 0;
  1172. }else if($is_open_fullreduction == 1){
  1173. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1174. }
  1175. $list[] = $tmp_data;
  1176. }
  1177. 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 ));
  1178. die();
  1179. }else{
  1180. echo json_encode( array('code' => 1) );
  1181. die();
  1182. }
  1183. }
  1184. public function get_community_position()
  1185. {
  1186. $_GPC = I('request.');
  1187. $communityId = $_GPC['communityId'];
  1188. $postion = M('lionfish_community_head')->field('lat,lon')->where( array('id' => $communityId ) )->find();
  1189. echo json_encode(array('code' => 0, 'postion' => $postion));
  1190. die();
  1191. }
  1192. public function load_spikebuy_goodslist()
  1193. {
  1194. $_GPC = I('request.');
  1195. $head_id = $_GPC['head_id'];
  1196. $pageNum = $_GPC['pageNum'];
  1197. $per_page = 10000;
  1198. $offset = ($pageNum - 1) * $per_page;
  1199. $limit = "{$offset},{$per_page}";
  1200. $token = $_GPC['token'];
  1201. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1202. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1203. {
  1204. //echo json_encode( array('code' => 2) );
  1205. //die();
  1206. }
  1207. $member_id = $weprogram_token['member_id'];
  1208. $now_time = time();
  1209. $where = " g.grounding =1 ";
  1210. //head_id
  1211. if( !empty($head_id) && $head_id >0 )
  1212. {
  1213. $params = array();
  1214. $params['uniacid'] = $_W['uniacid'];
  1215. $params['head_id'] = $head_id;
  1216. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1217. .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 ";
  1218. $goods_ids_arr = M()->query($sql_goods_ids);
  1219. $ids_arr = array();
  1220. foreach($goods_ids_arr as $val){
  1221. $ids_arr[] = $val['goods_id'];
  1222. }
  1223. $goods_ids_nolimit_ids = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1224. .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 ";
  1225. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_ids);
  1226. if( !empty($goods_ids_nolimit_arr) )
  1227. {
  1228. foreach($goods_ids_nolimit_arr as $val){
  1229. $ids_arr[] = $val['id'];
  1230. }
  1231. }
  1232. $ids_str = implode(',',$ids_arr);
  1233. if( !empty($ids_str) )
  1234. {
  1235. $where .= " and g.id in ({$ids_str})";
  1236. } else{
  1237. $where .= " and 0 ";
  1238. }
  1239. }else{
  1240. //echo json_encode( array('code' => 1) );
  1241. //die();
  1242. $where .= " and gc.is_spike_buy = 1";
  1243. }
  1244. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1245. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1246. if( empty($index_sort_method) )
  1247. {
  1248. $index_sort_method = 0;
  1249. }
  1250. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1251. if( $index_sort_method == 1 )
  1252. {
  1253. $order_sort = 'g.index_sort desc,g.id desc ';
  1254. }
  1255. $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.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page,$order_sort);
  1256. if( !empty($community_goods) )
  1257. {
  1258. $is_show_spike_buy_time = D('Home/Front')->get_config_by_name('is_show_spike_buy_time');
  1259. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1260. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1261. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1262. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1263. {
  1264. $is_open_fullreduction = 0;
  1265. }
  1266. $cart= D('Home/Car');
  1267. $list = array();
  1268. foreach($community_goods as $val)
  1269. {
  1270. $tmp_data = array();
  1271. $tmp_data['actId'] = $val['id'];
  1272. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1273. $tmp_data['spuName'] = $goodsname;
  1274. $tmp_data['spuCanBuyNum'] = $val['total'];
  1275. $tmp_data['spuDescribe'] = $val['subtitle'];
  1276. $tmp_data['end_time'] = $val['end_time'];
  1277. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1278. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1279. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1280. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1281. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1282. $productprice = $val['productprice'];
  1283. $tmp_data['marketPrice'] = explode('.', $productprice);
  1284. if( !empty($val['big_img']) )
  1285. {
  1286. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1287. }
  1288. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1289. if( !empty($good_image) )
  1290. {
  1291. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1292. }
  1293. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1294. $price = $price_arr['price'];
  1295. $tmp_data['actPrice'] = explode('.', $price);
  1296. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1297. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1298. if( !empty($tmp_data['skuList']) )
  1299. {
  1300. $tmp_data['car_count'] = 0;
  1301. }else{
  1302. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1303. if( empty($car_count) )
  1304. {
  1305. $tmp_data['car_count'] = 0;
  1306. }else{
  1307. $tmp_data['car_count'] = $car_count;
  1308. }
  1309. }
  1310. $list[] = $tmp_data;
  1311. }
  1312. echo json_encode(array('code' => 0, 'list' => $list, 'is_show_spike_buy_time'=>$is_show_spike_buy_time ));
  1313. die();
  1314. }else{
  1315. echo json_encode( array('code' => 1) );
  1316. die();
  1317. }
  1318. }
  1319. public function load_new_buy_goodslist()
  1320. {
  1321. $_GPC = I('request.');
  1322. $head_id = $_GPC['head_id'];
  1323. $pageNum = $_GPC['pageNum'];
  1324. $per_page = 10;
  1325. $offset = ($pageNum - 1) * $per_page;
  1326. $limit = "{$offset},{$per_page}";
  1327. $token = $_GPC['token'];
  1328. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1329. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1330. {
  1331. //echo json_encode( array('code' => 2) );
  1332. //die();
  1333. }
  1334. $member_id = $weprogram_token['member_id'];
  1335. $now_time = time();
  1336. $where = " g.grounding =1 ";
  1337. //head_id
  1338. if( !empty($head_id) && $head_id >0 )
  1339. {
  1340. $params = array();
  1341. $params['uniacid'] = $_W['uniacid'];
  1342. $params['head_id'] = $head_id;
  1343. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1344. .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 ";
  1345. $goods_ids_arr = M()->query($sql_goods_ids);
  1346. $ids_arr = array();
  1347. foreach($goods_ids_arr as $val){
  1348. $ids_arr[] = $val['goods_id'];
  1349. }
  1350. $goods_ids_nolimit_ids = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1351. .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 ";
  1352. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_ids);
  1353. if( !empty($goods_ids_nolimit_arr) )
  1354. {
  1355. foreach($goods_ids_nolimit_arr as $val){
  1356. $ids_arr[] = $val['id'];
  1357. }
  1358. }
  1359. $ids_str = implode(',',$ids_arr);
  1360. if( !empty($ids_str) )
  1361. {
  1362. $where .= " and g.id in ({$ids_str})";
  1363. } else{
  1364. $where .= " and 0 ";
  1365. }
  1366. }else{
  1367. //echo json_encode( array('code' => 1) );
  1368. //die();
  1369. $where .= " and gc.is_new_buy = 1";
  1370. }
  1371. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1372. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1373. if( empty($index_sort_method) )
  1374. {
  1375. $index_sort_method = 0;
  1376. }
  1377. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1378. if( $index_sort_method == 1 )
  1379. {
  1380. $order_sort = 'g.index_sort desc,g.id desc ';
  1381. }
  1382. $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.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page,$order_sort);
  1383. if( !empty($community_goods) )
  1384. {
  1385. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1386. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1387. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1388. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1389. {
  1390. $is_open_fullreduction = 0;
  1391. }
  1392. $cart= D('Home/Car');
  1393. $list = array();
  1394. foreach($community_goods as $val)
  1395. {
  1396. $tmp_data = array();
  1397. $tmp_data['actId'] = $val['id'];
  1398. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1399. $tmp_data['spuName'] = $goodsname;
  1400. $tmp_data['spuCanBuyNum'] = $val['total'];
  1401. $tmp_data['spuDescribe'] = $val['subtitle'];
  1402. $tmp_data['end_time'] = $val['end_time'];
  1403. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1404. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1405. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1406. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1407. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1408. $productprice = $val['productprice'];
  1409. $tmp_data['marketPrice'] = explode('.', $productprice);
  1410. if( !empty($val['big_img']) )
  1411. {
  1412. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1413. }
  1414. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1415. if( !empty($good_image) )
  1416. {
  1417. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1418. }
  1419. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1420. $price = $price_arr['price'];
  1421. $tmp_data['actPrice'] = explode('.', $price);
  1422. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1423. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1424. if( !empty($tmp_data['skuList']) )
  1425. {
  1426. $tmp_data['car_count'] = 0;
  1427. }else{
  1428. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1429. if( empty($car_count) )
  1430. {
  1431. $tmp_data['car_count'] = 0;
  1432. }else{
  1433. $tmp_data['car_count'] = $car_count;
  1434. }
  1435. }
  1436. $list[] = $tmp_data;
  1437. }
  1438. echo json_encode(array('code' => 0, 'list' => $list ));
  1439. die();
  1440. }else{
  1441. echo json_encode( array('code' => 1) );
  1442. die();
  1443. }
  1444. }
  1445. /**
  1446. * 条件搜索商品
  1447. */
  1448. public function load_condition_goodslist()
  1449. {
  1450. $_GPC = I('request.');
  1451. $head_id = $_GPC['head_id'];
  1452. if($head_id == 'undefined')
  1453. $head_id = '';
  1454. $pageNum = $_GPC['pageNum'];
  1455. $per_page = 10;
  1456. $offset = ($pageNum - 1) * $per_page;
  1457. $limit = "{$offset},{$per_page}";
  1458. $gid = $_GPC['gid']; //分类id
  1459. $keyword = $_GPC['keyword'];
  1460. $good_ids = $_GPC['good_ids'];
  1461. $type = $_GPC['type']; //空:关键词搜索,1:指定分类,2:指定多个商品
  1462. $token = $_GPC['token'];
  1463. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1464. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1465. {
  1466. //echo json_encode( array('code' => 2) );
  1467. //die();
  1468. }
  1469. $member_id = $weprogram_token['member_id'];
  1470. $now_time = time();
  1471. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  1472. if( !empty($head_id) && $head_id >0 )
  1473. {
  1474. $params = array();
  1475. $params['uniacid'] = $_W['uniacid'];
  1476. $params['head_id'] = $head_id;
  1477. $goods_ids_arr = array();
  1478. if(!empty($keyword) && $type==0) {
  1479. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1480. .C('DB_PREFIX')."lionfish_comshop_goods as g
  1481. where pg.goods_id = g.id and g.goodsname like '%{$keyword}%' and pg.head_id = {$head_id} order by pg.id desc ";
  1482. $goods_ids_arr = M()->query($sql_goods_ids);
  1483. }
  1484. if($type==1){
  1485. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1486. .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 ";
  1487. $goods_ids_arr = M()->query($sql_goods_ids);
  1488. }
  1489. if($type == 2){
  1490. $goods_ids_arr = M()->query('SELECT goods_id FROM ' . C('DB_PREFIX'). "lionfish_community_head_goods
  1491. WHERE head_id={$head_id} order by id desc ");
  1492. }
  1493. $ids_arr = array();
  1494. foreach($goods_ids_arr as $val){
  1495. $ids_arr[] = $val['goods_id'];
  1496. }
  1497. if(!empty($keyword) && $type==0) {
  1498. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX'). "lionfish_comshop_goods
  1499. WHERE is_all_sale=1 and goodsname like '%{$keyword}%' " );
  1500. }
  1501. if($type==1){
  1502. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg, "
  1503. .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 ";
  1504. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1505. }
  1506. if($type==2){
  1507. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX') . "lionfish_comshop_goods
  1508. WHERE is_all_sale=1 ");
  1509. }
  1510. if( !empty($goods_ids_nolimit_arr) )
  1511. {
  1512. foreach($goods_ids_nolimit_arr as $val){
  1513. $ids_arr[] = $val['id'];
  1514. }
  1515. }
  1516. if($type==2){
  1517. $good_ids_arr = explode(',',$good_ids);
  1518. $new_ids_arr = array();
  1519. if(count($good_ids_arr)>0){
  1520. foreach ($good_ids_arr as $val) {
  1521. if(in_array($val, $ids_arr)){
  1522. $new_ids_arr[] = $val;
  1523. }
  1524. }
  1525. }
  1526. $ids_arr = $new_ids_arr;
  1527. }
  1528. $ids_str = implode(',',$ids_arr);
  1529. if( !empty($ids_str) )
  1530. {
  1531. $where .= " and g.id in ({$ids_str})";
  1532. } else{
  1533. $where .= " and 0 ";
  1534. }
  1535. }else{
  1536. //echo json_encode( array('code' => 1) );
  1537. //die();
  1538. }
  1539. if(empty($head_id) && $type == 0 && !empty($keyword)) {
  1540. $where .= " and g.goodsname like '%{$keyword}%'";
  1541. }
  1542. if($type==1) {
  1543. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  1544. }
  1545. //$where .= " and gc.begin_time <= {$now_time} and gc.end_time > {$now_time} and g.total > 0 ";
  1546. $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.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page);
  1547. if( !empty($community_goods) )
  1548. {
  1549. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1550. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1551. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1552. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1553. {
  1554. $is_open_fullreduction = 0;
  1555. }
  1556. $list = array();
  1557. foreach($community_goods as $val)
  1558. {
  1559. $tmp_data = array();
  1560. $tmp_data['actId'] = $val['id'];
  1561. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1562. $tmp_data['spuName'] = $goodsname;
  1563. $tmp_data['spuCanBuyNum'] = $val['total'];
  1564. $tmp_data['spuDescribe'] = $val['subtitle'];
  1565. $tmp_data['end_time'] = $val['end_time'];
  1566. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1567. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1568. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1569. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1570. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1571. $productprice = $val['productprice'];
  1572. $tmp_data['marketPrice'] = explode('.', $productprice);
  1573. if( !empty($val['big_img']) )
  1574. {
  1575. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1576. }
  1577. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1578. if( !empty($good_image) )
  1579. {
  1580. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1581. }
  1582. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1583. $price = $price_arr['price'];
  1584. $tmp_data['actPrice'] = explode('.', $price);
  1585. /**
  1586. $tmp_data['skuList'] = array(
  1587. array('spec' => 'xl','canBuyNum' => 100,'spuName' => 1, 'actPrice' => array(1,2), 'marketPrice' => array(2,3),'skuImage' => tomedia($good_image['image'])),
  1588. array('spec' => 'x2','canBuyNum' => 200, 'spuName' => 2, 'actPrice' => array(1,2), 'marketPrice' => array(2,3),'skuImage' => tomedia($good_image['image']))
  1589. );
  1590. **/
  1591. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1592. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1593. if( !empty($tmp_data['skuList']) )
  1594. {
  1595. $tmp_data['car_count'] = 0;
  1596. }else{
  1597. if(!empty($head_id) && $head_id > 0){
  1598. $car_count = D('Home/Car')->get_wecart_goods($val['id'],"",$head_id ,$token);
  1599. if( empty($car_count) )
  1600. {
  1601. $tmp_data['car_count'] = 0;
  1602. }else{
  1603. $tmp_data['car_count'] = $car_count;
  1604. }
  1605. }
  1606. }
  1607. if($is_open_fullreduction == 0)
  1608. {
  1609. $tmp_data['is_take_fullreduction'] = 0;
  1610. }else if($is_open_fullreduction == 1){
  1611. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1612. }
  1613. $list[] = $tmp_data;
  1614. }
  1615. 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 ));
  1616. die();
  1617. }else{
  1618. echo json_encode( array('code' => 1) );
  1619. die();
  1620. }
  1621. }
  1622. public function get_newauth_bg()
  1623. {
  1624. $newauth_bg_image = D('Home/Front')->get_config_by_name('newauth_bg_image');
  1625. if( !empty($newauth_bg_image) )
  1626. {
  1627. $newauth_bg_image = tomedia($newauth_bg_image);
  1628. }
  1629. $newauth_cancel_image = D('Home/Front')->get_config_by_name('newauth_cancel_image');
  1630. if( !empty($newauth_cancel_image) )
  1631. {
  1632. $newauth_cancel_image = tomedia($newauth_cancel_image);
  1633. }
  1634. $newauth_confirm_image = D('Home/Front')->get_config_by_name('newauth_confirm_image');
  1635. if( !empty($newauth_confirm_image) )
  1636. {
  1637. $newauth_confirm_image = tomedia($newauth_confirm_image);
  1638. }
  1639. echo json_encode(
  1640. array(
  1641. 'code'=>0,
  1642. 'data' => array(
  1643. 'newauth_bg_image'=>$newauth_bg_image,
  1644. 'newauth_confirm_image'=>$newauth_confirm_image,
  1645. 'newauth_cancel_image'=>$newauth_cancel_image
  1646. )
  1647. )
  1648. );
  1649. }
  1650. /**
  1651. 进入小程序初始加载方法,
  1652. 以后有类似需要参数,都在这里初始化
  1653. **/
  1654. public function get_firstload_msg()
  1655. {
  1656. $_GPC = I('request.');
  1657. $token = isset($_GPC['token']) ? $_GPC['token'] : '';
  1658. $new_head_id = 0;
  1659. $default_head_info = array();
  1660. //是否强制手机
  1661. $isparse_formdata = 0;
  1662. if( !empty($token) )
  1663. {
  1664. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1665. $community_history = M('lionfish_community_history')->field('head_id')->where( array('member_id' => $weprogram_token['member_id'] ) )->order('addtime desc')->find();
  1666. if( !empty($community_history) )
  1667. {
  1668. $cur_community_info = M('lionfish_community_head')->field('id')->where( array('id' => $community_history['head_id'] ) )->find();
  1669. if( !empty($cur_community_info) )
  1670. {
  1671. $new_head_id = $cur_community_info['id'];
  1672. $default_head_info = D('Home/Front')->get_community_byid($new_head_id);
  1673. }
  1674. }
  1675. //是否强制手机
  1676. $is_get_formdata = D('Home/Front')->get_config_by_name('is_get_formdata');
  1677. if( isset($is_get_formdata) && $is_get_formdata == 1 )
  1678. {
  1679. $now_member_info = M('lionfish_comshop_member')->where( array('member_id' => $weprogram_token['member_id'] ))->find();
  1680. if( $now_member_info['is_apply_state'] != 1 && $now_member_info['is_write_form'] != 1 )
  1681. {
  1682. $isparse_formdata = 1;
  1683. }
  1684. }
  1685. }
  1686. $skin = D('Home/Front')->get_config_by_name('skin');
  1687. $common_header_backgroundimage = D('Home/Front')->get_config_by_name('common_header_backgroundimage');
  1688. if( !empty($common_header_backgroundimage) )
  1689. {
  1690. $common_header_backgroundimage = tomedia($common_header_backgroundimage);
  1691. }
  1692. $goods_sale_unit = D('Home/goods')->get_sale_unit();
  1693. echo json_encode( array('code' => 0,'new_head_id' => $new_head_id,'isparse_formdata' => $isparse_formdata , 'default_head_info' => $default_head_info, 'skin'=>$skin, 'common_header_backgroundimage'=>$common_header_backgroundimage, 'goods_sale_unit'=>$goods_sale_unit ) );
  1694. die();
  1695. }
  1696. /**
  1697. * 加载分类详情页
  1698. * @return [type] [description]
  1699. */
  1700. public function load_cate_goodslist()
  1701. {
  1702. $_GPC = I('request.');
  1703. $head_id = $_GPC['head_id'];
  1704. if($head_id == 'undefined')
  1705. $head_id = '';
  1706. $pid = $_GPC['gid'];
  1707. $token = $_GPC['token'];
  1708. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1709. $member_id = $weprogram_token['member_id'];
  1710. // vip身份
  1711. $is_vip_card_member = 0;
  1712. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1713. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  1714. $member_id = $weprogram_token['member_id'];
  1715. $is_vip_card_member = 0;
  1716. if( $member_id > 0 )
  1717. {
  1718. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  1719. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1720. {
  1721. $now_time = time();
  1722. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1723. {
  1724. $is_vip_card_member = 1;//还是会员
  1725. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1726. $is_vip_card_member = 2;//已过期
  1727. }
  1728. }
  1729. }
  1730. if($pid == 'undefined' || $pid =='')
  1731. {
  1732. echo json_encode(
  1733. array(
  1734. 'code' => 1,
  1735. 'data'=> array(),
  1736. 'msg' => '分类id错误'
  1737. )
  1738. );
  1739. die();
  1740. }
  1741. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1742. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1743. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1744. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1745. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  1746. $is_show_vipcard_price = D('Home/Front')->get_config_by_name('is_show_vipcard_price');
  1747. if( $is_open_vipcard_buy == 1 )
  1748. {
  1749. if( !empty($is_show_vipcard_price) && $is_show_vipcard_price == 1 ) $is_open_vipcard_buy = 0;
  1750. }
  1751. if(empty($full_reducemoney) || $full_reducemoney <= 0) $is_open_fullreduction = 0;
  1752. $cateList = $cateArr = array();
  1753. $parent_cate = M('lionfish_comshop_goods_category')->field('id,banner,name')->where( array('cate_type' =>'normal','id' => $pid ) )->find();
  1754. if($parent_cate){
  1755. $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();
  1756. if($cate_info){
  1757. $cateArr = array_merge(array($parent_cate), $cate_info);
  1758. }else {
  1759. $cateArr[] = $parent_cate;
  1760. }
  1761. foreach ($cateArr as $key => $val) {
  1762. $gid = $val['id'];
  1763. $cate_info = array();
  1764. $cate_info['name'] = $val['name'];
  1765. $cate_info['banner'] = $val['banner'] && !empty($val['banner']) ? tomedia($val['banner']) : '';
  1766. $cate_info['logo'] = $val['logo'] && !empty($val['logo']) ? tomedia($val['logo']) : '';
  1767. $now_time = time();
  1768. $where = " g.grounding =1 ";
  1769. if( !empty($head_id) && $head_id >0 )
  1770. {
  1771. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1772. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  1773. where pg.goods_id = g.goods_id and g.cate_id={$gid} and pg.head_id = {$head_id}
  1774. order by pg.id desc ";
  1775. $goods_ids_arr = M()->query($sql_goods_ids);
  1776. $ids_arr = array();
  1777. foreach($goods_ids_arr as $val){
  1778. $ids_arr[] = $val['goods_id'];
  1779. }
  1780. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1781. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id={$gid}
  1782. and pg.is_all_sale=1 ";
  1783. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1784. if( !empty($goods_ids_nolimit_arr) )
  1785. {
  1786. foreach($goods_ids_nolimit_arr as $val){
  1787. $ids_arr[] = $val['id'];
  1788. }
  1789. }
  1790. $ids_str = implode(',',$ids_arr);
  1791. if( !empty($ids_str) )
  1792. {
  1793. $where .= " and g.id in ({$ids_str})";
  1794. } else{
  1795. $where .= " and 0 ";
  1796. }
  1797. }else{
  1798. $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
  1799. where pg.id = g.goods_id and g.cate_id = {$gid} ";
  1800. $goods_ids_nohead_arr = M()->query($goods_ids_nohead_sql);
  1801. $ids_arr = array();
  1802. if( !empty($goods_ids_nohead_arr) )
  1803. {
  1804. foreach($goods_ids_nohead_arr as $val){
  1805. $ids_arr[] = $val['id'];
  1806. }
  1807. }
  1808. $ids_str = implode(',',$ids_arr);
  1809. if( !empty($ids_str) )
  1810. {
  1811. $where .= " and g.id in ({$ids_str})";
  1812. } else{
  1813. $where .= " and 0 ";
  1814. }
  1815. }
  1816. // $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1817. $where .= " and gc.begin_time <={$now_time} ";
  1818. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 and g.is_seckill = 0 ";
  1819. $community_goods = '';
  1820. $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,gc.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where, 0, 10000);
  1821. $list = $cart = array();
  1822. if( !empty($community_goods) )
  1823. {
  1824. $cart= D('Home/Car');
  1825. foreach($community_goods as $val)
  1826. {
  1827. $tmp_data = array();
  1828. $tmp_data['actId'] = $val['id'];
  1829. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1830. $tmp_data['spuName'] = $goodsname;
  1831. $tmp_data['spuCanBuyNum'] = $val['total'];
  1832. $tmp_data['spuDescribe'] = $val['subtitle'];
  1833. $tmp_data['end_time'] = $val['end_time'];
  1834. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  1835. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1836. $tmp_data['actEnd'] = time()>$val['end_time'];
  1837. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1838. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1839. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1840. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1841. $productprice = $val['productprice'];
  1842. $tmp_data['marketPrice'] = explode('.', $productprice);
  1843. if( !empty($val['big_img']) )
  1844. {
  1845. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1846. }
  1847. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1848. if( !empty($good_image) )
  1849. {
  1850. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1851. }
  1852. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1853. $price = $price_arr['price'];
  1854. $tmp_data['actPrice'] = explode('.', $price);
  1855. $tmp_data['card_price'] = $price_arr['card_price'];
  1856. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1857. if( !empty($tmp_data['skuList']) )
  1858. {
  1859. $tmp_data['car_count'] = 0;
  1860. }else{
  1861. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1862. if( empty($car_count) )
  1863. {
  1864. $tmp_data['car_count'] = 0;
  1865. }else{
  1866. $tmp_data['car_count'] = $car_count;
  1867. }
  1868. }
  1869. if($is_open_fullreduction == 0)
  1870. {
  1871. $tmp_data['is_take_fullreduction'] = 0;
  1872. }else if($is_open_fullreduction == 1){
  1873. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1874. }
  1875. // 商品角标
  1876. $label_id = unserialize($val['labelname']);
  1877. if($label_id){
  1878. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1879. if($label_info){
  1880. if($label_info['type'] == 1){
  1881. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1882. } else {
  1883. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1884. }
  1885. }
  1886. $tmp_data['label_info'] = $label_info;
  1887. }
  1888. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1889. $list[] = $tmp_data;
  1890. }
  1891. }
  1892. $cateList[] = array('cate_info'=>$cate_info, 'list'=>$list);
  1893. }
  1894. }
  1895. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1896. // 客服按钮
  1897. $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
  1898. $theme = D('Home/Front')->get_config_by_name('index_list_theme_type');
  1899. echo json_encode(
  1900. array(
  1901. 'code' => 0,
  1902. 'list' => $cateList,
  1903. 'is_vip_card_member' => $is_vip_card_member,
  1904. 'cur_time' => time(),
  1905. 'full_reducemoney' => $full_reducemoney,
  1906. 'full_money' => $full_money,
  1907. 'is_open_vipcard_buy' => $is_open_vipcard_buy,
  1908. 'is_open_fullreduction' => $is_open_fullreduction,
  1909. 'is_show_cate_tabbar' => $is_show_cate_tabbar,
  1910. 'user_service_switch' => $user_service_switch,
  1911. 'theme' => $theme
  1912. )
  1913. );
  1914. die();
  1915. }
  1916. public function load_gps_goodslist_new()
  1917. {
  1918. $gpc = I('request.');
  1919. $token = $gpc['token'];
  1920. $head_id = $gpc['head_id'];
  1921. $is_only_express = $gpc['is_only_express'];
  1922. $is_open_only_express = 0;
  1923. if($is_only_express==1) {
  1924. $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
  1925. }
  1926. if($head_id == 'undefined') $head_id = '';
  1927. $pageNum = $gpc['pageNum'];
  1928. $gid = $gpc['gid'];
  1929. $keyword = $gpc['keyword'];
  1930. $is_random = isset($gpc['is_random']) ? $gpc['is_random'] : 0;
  1931. $is_video = isset($gpc['is_video']) ? $gpc['is_video'] : 0;
  1932. $per_page = isset($gpc['per_page']) ? $gpc['per_page'] : 10;
  1933. $cate_info = '';
  1934. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  1935. {
  1936. $gid = 0;
  1937. } else {
  1938. $cate_info = M('lionfish_comshop_goods_category')->field('banner,name')->where( array('id' => $gid ) )->find();
  1939. if(!empty($cate_info['banner'])) $cate_info['banner'] = tomedia($cate_info['banner']);
  1940. }
  1941. if( !empty($gid) && $gid > 0)
  1942. {
  1943. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid,'normal','','',1);
  1944. $gidArr = array();
  1945. $gidArr[] = $gid;
  1946. foreach ($gids as $key => $val) {
  1947. $gidArr[] = $val['id'];
  1948. }
  1949. $gid = implode(',', $gidArr);
  1950. }
  1951. $offset = ($pageNum - 1) * $per_page;
  1952. $limit = "{$offset},{$per_page}";
  1953. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1954. $is_member_level_buy = 0;
  1955. $is_vip_card_member = 0;
  1956. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1957. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  1958. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1959. {
  1960. //echo json_encode( array('code' => 2) );
  1961. //die();
  1962. }else{
  1963. $member_id = $weprogram_token['member_id'];
  1964. $is_vip_card_member = 0;
  1965. //member_id
  1966. if( $member_id > 0 )
  1967. {
  1968. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  1969. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1970. {
  1971. $now_time = time();
  1972. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1973. {
  1974. $is_vip_card_member = 1;//还是会员
  1975. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1976. $is_vip_card_member = 2;//已过期
  1977. }
  1978. }
  1979. if($is_vip_card_member != 1 && $member_info['level_id'] >0 )
  1980. {
  1981. $is_member_level_buy = 1;
  1982. }
  1983. }
  1984. }
  1985. $member_id = $weprogram_token['member_id'];
  1986. //整点秒杀begin
  1987. $is_seckill = isset($gpc['is_seckill']) ? 1:0;
  1988. $seckill_time = isset($gpc['seckill_time']) ? intval($gpc['seckill_time']):0;
  1989. //整点秒杀end
  1990. $now_time = time();
  1991. if($is_seckill ==1)
  1992. {
  1993. $where = " g.grounding =1 and g.is_seckill =1 and g.type ='normal' ";
  1994. }else
  1995. {
  1996. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  1997. }
  1998. //head_id
  1999. if( !empty($keyword) )
  2000. {
  2001. $where .= " and g.goodsname like '%{$keyword}%' ";
  2002. }
  2003. if($is_seckill ==1)
  2004. {
  2005. $bg_time = strtotime( date('Y-m-d').' '.$seckill_time.':00:00' );
  2006. $ed_time = $bg_time + 3600;
  2007. if($gid == 0 && $keyword == ''){
  2008. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  2009. } else {
  2010. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  2011. }
  2012. } else {
  2013. if($gid == 0 && $keyword == ''){
  2014. $where .= " and g.is_index_show = 1 ";
  2015. }
  2016. }
  2017. if($is_seckill ==1)
  2018. {
  2019. }else{
  2020. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  2021. }
  2022. if( $is_video == 1 )
  2023. {
  2024. $where .= " and gc.video !='' ";
  2025. }
  2026. if($is_open_only_express==1 && $is_only_express==1) {
  2027. $where .= " and gc.is_only_express =1 ";
  2028. }
  2029. $now_time = time();
  2030. $where .= " and gc.begin_time <={$now_time} ";
  2031. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  2032. if( empty($index_sort_method) )
  2033. {
  2034. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  2035. }
  2036. if( $index_sort_method == 1 )
  2037. {
  2038. $order_sort = 'g.index_sort desc,g.id desc ';
  2039. }
  2040. if($is_random == 1)
  2041. {
  2042. $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,gc.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page,$order_sort,' rand() ');
  2043. }else{
  2044. $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,gc.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count ', $where,$offset,$per_page,$order_sort);
  2045. }
  2046. if( !empty($community_goods) )
  2047. {
  2048. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  2049. $full_money = D('Home/Front')->get_config_by_name('full_money');
  2050. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  2051. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  2052. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  2053. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  2054. {
  2055. $is_open_fullreduction = 0;
  2056. }
  2057. $cart= D('Home/Car');
  2058. $list = array();
  2059. $copy_text_arr = array();
  2060. $today_time = strtotime( date('Y-m-d').' 00:00:00' );
  2061. foreach($community_goods as $val)
  2062. {
  2063. $tmp_data = array();
  2064. $tmp_data['actId'] = $val['id'];
  2065. $goodsname = htmlspecialchars_decode($val['goodsname']);
  2066. $tmp_data['spuName'] = $goodsname;
  2067. $tmp_data['spuCanBuyNum'] = $val['total'];
  2068. $tmp_data['spuDescribe'] = $val['subtitle'];
  2069. $tmp_data['end_time'] = $val['end_time'];
  2070. $tmp_data['actEnd'] = time()>$val['end_time'];
  2071. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  2072. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  2073. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  2074. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  2075. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  2076. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  2077. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  2078. if($val['pick_up_type'] == 0)
  2079. {
  2080. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  2081. }else if( $val['pick_up_type'] == 1 ){
  2082. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  2083. }else if( $val['pick_up_type'] == 2 )
  2084. {
  2085. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  2086. }
  2087. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  2088. $productprice = $val['productprice'];
  2089. $tmp_data['marketPrice'] = explode('.', $productprice);
  2090. if( !empty($val['big_img']) )
  2091. {
  2092. $tmp_data['bigImg'] = tomedia($val['big_img']);
  2093. }
  2094. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  2095. if( !empty($good_image) )
  2096. {
  2097. $tmp_data['skuImage'] = tomedia($good_image['image']);
  2098. }
  2099. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  2100. $price = $price_arr['price'];
  2101. if( $pageNum == 1 )
  2102. {
  2103. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  2104. }
  2105. $tmp_data['actPrice'] = explode('.', $price);
  2106. $tmp_data['card_price'] = $price_arr['card_price'];
  2107. $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  2108. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  2109. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  2110. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  2111. if( !empty($tmp_data['skuList']) )
  2112. {
  2113. $tmp_data['car_count'] = 0;
  2114. }else{
  2115. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  2116. if( empty($car_count) )
  2117. {
  2118. $tmp_data['car_count'] = 0;
  2119. }else{
  2120. $tmp_data['car_count'] = $car_count;
  2121. }
  2122. }
  2123. if($is_open_fullreduction == 0)
  2124. {
  2125. $tmp_data['is_take_fullreduction'] = 0;
  2126. }else if($is_open_fullreduction == 1){
  2127. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  2128. }
  2129. // 商品角标
  2130. $label_id = unserialize($val['labelname']);
  2131. if($label_id){
  2132. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  2133. if($label_info){
  2134. if($label_info['type'] == 1){
  2135. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  2136. } else {
  2137. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  2138. }
  2139. }
  2140. $tmp_data['label_info'] = $label_info;
  2141. }
  2142. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  2143. $list[] = $tmp_data;
  2144. }
  2145. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  2146. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  2147. 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 ));
  2148. die();
  2149. }else{
  2150. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  2151. echo json_encode( array('code' => 1 , 'cate_info' => $cate_info , 'is_show_cate_tabbar'=>$is_show_cate_tabbar ) );
  2152. die();
  2153. }
  2154. }
  2155. /**
  2156. * 图片广告
  2157. * @return [json] [description]
  2158. */
  2159. public function get_advimg(){
  2160. $data = M('lionfish_comshop_advimg')->order('id desc')->find();
  2161. if(!empty($data)) {
  2162. if(!empty($data['enabled'])){
  2163. $data['thumb'] = tomedia($data['thumb']);
  2164. $data['pos'] = explode(',', $data['pos']);
  2165. echo json_encode( array('code' => 0, 'data' => $data ) );
  2166. die();
  2167. }else{
  2168. echo json_encode( array('code' => 1, 'msg' => "广告图片已关闭" ) );
  2169. die();
  2170. }
  2171. }
  2172. echo json_encode( array('code' => 1, 'msg' => "无广告图片" ) );
  2173. die();
  2174. }
  2175. public function get_diy_info()
  2176. {
  2177. $index_diy_json = D('Home/Front')->get_config_by_name('index_diy_json');
  2178. if($index_diy_json) {
  2179. $data = unserialize($index_diy_json);
  2180. $diyData = htmlspecialchars_decode($data['value']);
  2181. if(!$diyData) {
  2182. $newdata = D('Seller/Diydata')->get_all_config();
  2183. if(!empty($newdata)) $diyJson = $newdata;
  2184. if(!empty($diyJson)) {
  2185. foreach($diyJson as $k=>$v) {
  2186. $v->host = $this->staticHost();
  2187. if($v->type=="RICH_TEXT") {
  2188. $v->html= $this->replaceRichtextImgSrc($v->html);
  2189. }
  2190. $diyJson[$k] = $v;
  2191. }
  2192. }
  2193. if($data) {
  2194. $global = json_decode(htmlspecialchars_decode($data["global"]));
  2195. // var_dump($global);die();
  2196. }
  2197. } else {
  2198. $diyDataJson = json_decode($diyData, true);
  2199. $diyJson = $diyDataJson['value'];
  2200. $global = $diyDataJson['global'];
  2201. if(!empty($diyJson)) {
  2202. foreach($diyJson as $k=>$v) {
  2203. $v['host'] = $this->staticHost();
  2204. if($v['type']=="RICH_TEXT") {
  2205. $v['html'] = $this->replaceRichtextImgSrc($v['html']);
  2206. }
  2207. $diyJson[$k] = $v;
  2208. }
  2209. }
  2210. }
  2211. echo json_encode( array('code' => 0, 'global' => $global, 'diyJson' => $diyJson ) );
  2212. die();
  2213. } else {
  2214. echo json_encode( array('code' => 1, 'msg' => 'DIY页面未设置' ) );
  2215. die();
  2216. }
  2217. }
  2218. public function staticHost() {
  2219. $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : '80';
  2220. $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
  2221. return "https://" . $host;
  2222. }
  2223. public function replaceRichtextImgSrc($html) {
  2224. $pattern = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png|\.jpeg]))[\'|\"].*?[\/]?>/i";
  2225. $result = preg_replace_callback($pattern, function ($ma) {
  2226. $newUrl = $ma[1];
  2227. $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : '80';
  2228. $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
  2229. if (strpos($ma[1], 'http') == false) {
  2230. $newUrl = "https://" . $host . $newUrl;
  2231. }
  2232. return str_replace($ma[1], tomedia($newUrl), $ma[0]);
  2233. }, $html);
  2234. return $result;
  2235. }
  2236. }