IndexController.class.php 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866
  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. //mead
  967. // $val['price'] = meadMoney($val['price'],$val['mead_money_num']);
  968. // $val['productprice'] = meadMoney($val['productprice'],$val['mead_money_num']);
  969. $goodsname = htmlspecialchars_decode($val['goodsname']);
  970. $tmp_data['spuName'] = $goodsname;
  971. $tmp_data['spuCanBuyNum'] = $val['total'];
  972. $tmp_data['spuDescribe'] = $val['subtitle'];
  973. $tmp_data['end_time'] = $val['end_time'];
  974. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  975. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  976. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  977. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  978. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  979. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  980. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  981. if($val['pick_up_type'] == 0)
  982. {
  983. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  984. }else if( $val['pick_up_type'] == 1 ){
  985. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  986. }else if( $val['pick_up_type'] == 2 )
  987. {
  988. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  989. }
  990. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  991. $productprice = $val['productprice'];
  992. $tmp_data['marketPrice'] = explode('.', $productprice);
  993. if( !empty($val['big_img']) )
  994. {
  995. $tmp_data['bigImg'] = tomedia($val['big_img']);
  996. }
  997. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  998. if( !empty($good_image) )
  999. {
  1000. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1001. }
  1002. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1003. $price = $price_arr['price'];
  1004. if( $pageNum == 1 )
  1005. {
  1006. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  1007. }
  1008. $tmp_data['actPrice'] = explode('.', $price);
  1009. $tmp_data['card_price'] = $price_arr['card_price'];
  1010. // $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  1011. //mead-2
  1012. $tmp_data['levelprice'] = meadMoney($price_arr['levelprice'],$val['mead_money_num']);; // 会员等级价格
  1013. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  1014. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1015. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1016. if( !empty($tmp_data['skuList']) )
  1017. {
  1018. $tmp_data['car_count'] = 0;
  1019. }else{
  1020. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1021. if( empty($car_count) )
  1022. {
  1023. $tmp_data['car_count'] = 0;
  1024. }else{
  1025. $tmp_data['car_count'] = $car_count;
  1026. }
  1027. }
  1028. if($is_open_fullreduction == 0)
  1029. {
  1030. $tmp_data['is_take_fullreduction'] = 0;
  1031. }else if($is_open_fullreduction == 1){
  1032. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1033. }
  1034. // 商品角标
  1035. $label_id = unserialize($val['labelname']);
  1036. if($label_id){
  1037. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1038. if($label_info){
  1039. if($label_info['type'] == 1){
  1040. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1041. } else {
  1042. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1043. }
  1044. }
  1045. $tmp_data['label_info'] = $label_info;
  1046. }
  1047. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1048. $list[] = $tmp_data;
  1049. }
  1050. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  1051. $index_list_theme_type = D('Home/Front')->get_config_by_name('index_list_theme_type');
  1052. // 3*3是也关闭
  1053. if($index_list_theme_type>=2) $is_show_list_timer==0;
  1054. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1055. 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 ));
  1056. die();
  1057. }else{
  1058. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1059. echo json_encode( array('code' => 1 , 'cate_info' => $cate_info , 'is_show_cate_tabbar'=>$is_show_cate_tabbar ) );
  1060. die();
  1061. }
  1062. }
  1063. public function get_index_category()
  1064. {
  1065. $gpc = I('request.');
  1066. $gid = $gpc['gid'];
  1067. $hot_list = M('lionfish_comshop_goods_category')->where( array('is_hot' => 1) )->order('sort_order desc')->select();
  1068. $need_data = array();
  1069. foreach($hot_list as $key => $cate)
  1070. {
  1071. $need_data[$key]['id'] = $cate['id'];
  1072. $need_data[$key]['name'] = $cate['name'];
  1073. $need_data[$key]['sort_order'] = $cate['sort_order'];
  1074. }
  1075. $result = array('code' =>0,'data' => $need_data);
  1076. echo json_encode($result);
  1077. die();
  1078. }
  1079. /**
  1080. * 获取首页公告
  1081. */
  1082. public function get_index_notice()
  1083. {
  1084. $list = M('lionfish_comshop_notice')->where( array('enabled' => 1) )->order('displayorder desc, addtime desc')->limit(1)->select();
  1085. $result = array('code' =>0,'data' => $list);
  1086. echo json_encode($result);
  1087. die();
  1088. }
  1089. /**
  1090. * 即将抢购商品
  1091. */
  1092. public function load_comming_goodslist()
  1093. {
  1094. $gpc = I('request.');
  1095. $head_id = $gpc['head_id'];
  1096. $pageNum = $gpc['pageNum'];
  1097. $per_page = 10;
  1098. $gid = $gpc['gid'];
  1099. $offset = ($pageNum - 1) * $per_page;
  1100. $limit = "{$offset},{$per_page}";
  1101. if($head_id == 'undefined') $head_id = '';
  1102. $is_only_express = $gpc['is_only_express'];
  1103. $is_open_only_express = 0;
  1104. if($is_only_express==1) {
  1105. $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
  1106. }
  1107. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  1108. {
  1109. $gid = 0;
  1110. }
  1111. if( !empty($gid) && $gid > 0)
  1112. {
  1113. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid,'normal','','',1);
  1114. $gidArr = array();
  1115. $gidArr[] = $gid;
  1116. foreach ($gids as $key => $val) {
  1117. $gidArr[] = $val['id'];
  1118. }
  1119. $gid = implode(',', $gidArr);
  1120. }
  1121. $token = $gpc['token'];
  1122. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1123. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1124. {
  1125. //echo json_encode( array('code' => 2) );
  1126. //die();
  1127. }
  1128. $member_id = $weprogram_token['member_id'];
  1129. $now_time = time();
  1130. $where = " g.grounding =1 and g.type ='normal' ";
  1131. $is_index_show = isset($gpc['is_index_show']) ? $gpc['is_index_show'] : 0;
  1132. if($is_index_show==1) {
  1133. $where .= " and g.is_index_show = 1";
  1134. }
  1135. if($is_open_only_express==1 && $is_only_express==1) {
  1136. $where .= " and gc.is_only_express =1 ";
  1137. }
  1138. $where .= "and gc.begin_time > {$now_time} ";
  1139. $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);
  1140. if( !empty($community_goods) )
  1141. {
  1142. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1143. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1144. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1145. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1146. {
  1147. $is_open_fullreduction = 0;
  1148. }
  1149. $list = array();
  1150. foreach($community_goods as $val)
  1151. {
  1152. $tmp_data = array();
  1153. $tmp_data['actId'] = $val['id'];
  1154. $tmp_data['spuName'] = $val['goodsname'];
  1155. $tmp_data['spuCanBuyNum'] = $val['total'];
  1156. $tmp_data['spuDescribe'] = $val['subtitle'];
  1157. $tmp_data['end_time'] = $val['end_time'];
  1158. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1159. $productprice = $val['productprice'];
  1160. $tmp_data['marketPrice'] = explode('.', $productprice);
  1161. if( !empty($val['big_img']) )
  1162. {
  1163. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1164. }
  1165. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1166. if( !empty($good_image) )
  1167. {
  1168. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1169. }
  1170. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'],$member_id);
  1171. $price = $price_arr['price'];
  1172. $tmp_data['actPrice'] = explode('.', $price);
  1173. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1174. if($is_open_fullreduction == 0)
  1175. {
  1176. $tmp_data['is_take_fullreduction'] = 0;
  1177. }else if($is_open_fullreduction == 1){
  1178. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1179. }
  1180. $list[] = $tmp_data;
  1181. }
  1182. 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 ));
  1183. die();
  1184. }else{
  1185. echo json_encode( array('code' => 1) );
  1186. die();
  1187. }
  1188. }
  1189. public function get_community_position()
  1190. {
  1191. $_GPC = I('request.');
  1192. $communityId = $_GPC['communityId'];
  1193. $postion = M('lionfish_community_head')->field('lat,lon')->where( array('id' => $communityId ) )->find();
  1194. echo json_encode(array('code' => 0, 'postion' => $postion));
  1195. die();
  1196. }
  1197. public function load_spikebuy_goodslist()
  1198. {
  1199. $_GPC = I('request.');
  1200. $head_id = $_GPC['head_id'];
  1201. $pageNum = $_GPC['pageNum'];
  1202. $per_page = 10000;
  1203. $offset = ($pageNum - 1) * $per_page;
  1204. $limit = "{$offset},{$per_page}";
  1205. $token = $_GPC['token'];
  1206. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1207. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1208. {
  1209. //echo json_encode( array('code' => 2) );
  1210. //die();
  1211. }
  1212. $member_id = $weprogram_token['member_id'];
  1213. $now_time = time();
  1214. $where = " g.grounding =1 ";
  1215. //head_id
  1216. if( !empty($head_id) && $head_id >0 )
  1217. {
  1218. $params = array();
  1219. $params['uniacid'] = $_W['uniacid'];
  1220. $params['head_id'] = $head_id;
  1221. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1222. .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 ";
  1223. $goods_ids_arr = M()->query($sql_goods_ids);
  1224. $ids_arr = array();
  1225. foreach($goods_ids_arr as $val){
  1226. $ids_arr[] = $val['goods_id'];
  1227. }
  1228. $goods_ids_nolimit_ids = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1229. .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 ";
  1230. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_ids);
  1231. if( !empty($goods_ids_nolimit_arr) )
  1232. {
  1233. foreach($goods_ids_nolimit_arr as $val){
  1234. $ids_arr[] = $val['id'];
  1235. }
  1236. }
  1237. $ids_str = implode(',',$ids_arr);
  1238. if( !empty($ids_str) )
  1239. {
  1240. $where .= " and g.id in ({$ids_str})";
  1241. } else{
  1242. $where .= " and 0 ";
  1243. }
  1244. }else{
  1245. //echo json_encode( array('code' => 1) );
  1246. //die();
  1247. $where .= " and gc.is_spike_buy = 1";
  1248. }
  1249. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1250. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1251. if( empty($index_sort_method) )
  1252. {
  1253. $index_sort_method = 0;
  1254. }
  1255. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1256. if( $index_sort_method == 1 )
  1257. {
  1258. $order_sort = 'g.index_sort desc,g.id desc ';
  1259. }
  1260. $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);
  1261. if( !empty($community_goods) )
  1262. {
  1263. $is_show_spike_buy_time = D('Home/Front')->get_config_by_name('is_show_spike_buy_time');
  1264. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1265. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1266. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1267. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1268. {
  1269. $is_open_fullreduction = 0;
  1270. }
  1271. $cart= D('Home/Car');
  1272. $list = array();
  1273. foreach($community_goods as $val)
  1274. {
  1275. $tmp_data = array();
  1276. $tmp_data['actId'] = $val['id'];
  1277. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1278. $tmp_data['spuName'] = $goodsname;
  1279. $tmp_data['spuCanBuyNum'] = $val['total'];
  1280. $tmp_data['spuDescribe'] = $val['subtitle'];
  1281. $tmp_data['end_time'] = $val['end_time'];
  1282. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1283. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1284. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1285. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1286. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1287. $productprice = $val['productprice'];
  1288. $tmp_data['marketPrice'] = explode('.', $productprice);
  1289. if( !empty($val['big_img']) )
  1290. {
  1291. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1292. }
  1293. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1294. if( !empty($good_image) )
  1295. {
  1296. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1297. }
  1298. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1299. $price = $price_arr['price'];
  1300. //mead
  1301. $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  1302. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  1303. $tmp_data['levelPrice'] = explode('.', $tmp_data['levelprice']);
  1304. $tmp_data['actPrice'] = explode('.', $price);
  1305. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1306. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1307. if( !empty($tmp_data['skuList']) )
  1308. {
  1309. $tmp_data['car_count'] = 0;
  1310. }else{
  1311. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1312. if( empty($car_count) )
  1313. {
  1314. $tmp_data['car_count'] = 0;
  1315. }else{
  1316. $tmp_data['car_count'] = $car_count;
  1317. }
  1318. }
  1319. $list[] = $tmp_data;
  1320. }
  1321. echo json_encode(array('code' => 0, 'list' => $list, 'is_show_spike_buy_time'=>$is_show_spike_buy_time ));
  1322. die();
  1323. }else{
  1324. echo json_encode( array('code' => 1) );
  1325. die();
  1326. }
  1327. }
  1328. public function load_new_buy_goodslist()
  1329. {
  1330. $_GPC = I('request.');
  1331. $head_id = $_GPC['head_id'];
  1332. $pageNum = $_GPC['pageNum'];
  1333. $per_page = 10;
  1334. $offset = ($pageNum - 1) * $per_page;
  1335. $limit = "{$offset},{$per_page}";
  1336. $token = $_GPC['token'];
  1337. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1338. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1339. {
  1340. //echo json_encode( array('code' => 2) );
  1341. //die();
  1342. }
  1343. $member_id = $weprogram_token['member_id'];
  1344. $now_time = time();
  1345. $where = " g.grounding =1 ";
  1346. //head_id
  1347. if( !empty($head_id) && $head_id >0 )
  1348. {
  1349. $params = array();
  1350. $params['uniacid'] = $_W['uniacid'];
  1351. $params['head_id'] = $head_id;
  1352. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1353. .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 ";
  1354. $goods_ids_arr = M()->query($sql_goods_ids);
  1355. $ids_arr = array();
  1356. foreach($goods_ids_arr as $val){
  1357. $ids_arr[] = $val['goods_id'];
  1358. }
  1359. $goods_ids_nolimit_ids = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1360. .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 ";
  1361. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_ids);
  1362. if( !empty($goods_ids_nolimit_arr) )
  1363. {
  1364. foreach($goods_ids_nolimit_arr as $val){
  1365. $ids_arr[] = $val['id'];
  1366. }
  1367. }
  1368. $ids_str = implode(',',$ids_arr);
  1369. if( !empty($ids_str) )
  1370. {
  1371. $where .= " and g.id in ({$ids_str})";
  1372. } else{
  1373. $where .= " and 0 ";
  1374. }
  1375. }else{
  1376. //echo json_encode( array('code' => 1) );
  1377. //die();
  1378. $where .= " and gc.is_new_buy = 1";
  1379. }
  1380. $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1381. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  1382. if( empty($index_sort_method) )
  1383. {
  1384. $index_sort_method = 0;
  1385. }
  1386. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  1387. if( $index_sort_method == 1 )
  1388. {
  1389. $order_sort = 'g.index_sort desc,g.id desc ';
  1390. }
  1391. $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);
  1392. if( !empty($community_goods) )
  1393. {
  1394. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1395. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1396. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1397. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1398. {
  1399. $is_open_fullreduction = 0;
  1400. }
  1401. $cart= D('Home/Car');
  1402. $list = array();
  1403. foreach($community_goods as $val)
  1404. {
  1405. $tmp_data = array();
  1406. $tmp_data['actId'] = $val['id'];
  1407. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1408. $tmp_data['spuName'] = $goodsname;
  1409. $tmp_data['spuCanBuyNum'] = $val['total'];
  1410. $tmp_data['spuDescribe'] = $val['subtitle'];
  1411. $tmp_data['end_time'] = $val['end_time'];
  1412. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1413. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1414. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1415. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1416. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1417. $productprice = $val['productprice'];
  1418. $tmp_data['marketPrice'] = explode('.', $productprice);
  1419. if( !empty($val['big_img']) )
  1420. {
  1421. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1422. }
  1423. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1424. if( !empty($good_image) )
  1425. {
  1426. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1427. }
  1428. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1429. $price = $price_arr['price'];
  1430. $tmp_data['actPrice'] = explode('.', $price);
  1431. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1432. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1433. if( !empty($tmp_data['skuList']) )
  1434. {
  1435. $tmp_data['car_count'] = 0;
  1436. }else{
  1437. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1438. if( empty($car_count) )
  1439. {
  1440. $tmp_data['car_count'] = 0;
  1441. }else{
  1442. $tmp_data['car_count'] = $car_count;
  1443. }
  1444. }
  1445. $list[] = $tmp_data;
  1446. }
  1447. echo json_encode(array('code' => 0, 'list' => $list ));
  1448. die();
  1449. }else{
  1450. echo json_encode( array('code' => 1) );
  1451. die();
  1452. }
  1453. }
  1454. /**
  1455. * 条件搜索商品
  1456. */
  1457. public function load_condition_goodslist()
  1458. {
  1459. $_GPC = I('request.');
  1460. $head_id = $_GPC['head_id'];
  1461. if($head_id == 'undefined')
  1462. $head_id = '';
  1463. $pageNum = $_GPC['pageNum'];
  1464. $per_page = 10;
  1465. $offset = ($pageNum - 1) * $per_page;
  1466. $limit = "{$offset},{$per_page}";
  1467. $gid = $_GPC['gid']; //分类id
  1468. $keyword = $_GPC['keyword'];
  1469. $good_ids = $_GPC['good_ids'];
  1470. $type = $_GPC['type']; //空:关键词搜索,1:指定分类,2:指定多个商品
  1471. $token = $_GPC['token'];
  1472. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1473. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1474. {
  1475. //echo json_encode( array('code' => 2) );
  1476. //die();
  1477. }
  1478. $member_id = $weprogram_token['member_id'];
  1479. $now_time = time();
  1480. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  1481. if( !empty($head_id) && $head_id >0 )
  1482. {
  1483. $params = array();
  1484. $params['uniacid'] = $_W['uniacid'];
  1485. $params['head_id'] = $head_id;
  1486. $goods_ids_arr = array();
  1487. if(!empty($keyword) && $type==0) {
  1488. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1489. .C('DB_PREFIX')."lionfish_comshop_goods as g
  1490. where pg.goods_id = g.id and g.goodsname like '%{$keyword}%' and pg.head_id = {$head_id} order by pg.id desc ";
  1491. $goods_ids_arr = M()->query($sql_goods_ids);
  1492. }
  1493. if($type==1){
  1494. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1495. .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 ";
  1496. $goods_ids_arr = M()->query($sql_goods_ids);
  1497. }
  1498. if($type == 2){
  1499. $goods_ids_arr = M()->query('SELECT goods_id FROM ' . C('DB_PREFIX'). "lionfish_community_head_goods
  1500. WHERE head_id={$head_id} order by id desc ");
  1501. }
  1502. $ids_arr = array();
  1503. foreach($goods_ids_arr as $val){
  1504. $ids_arr[] = $val['goods_id'];
  1505. }
  1506. if(!empty($keyword) && $type==0) {
  1507. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX'). "lionfish_comshop_goods
  1508. WHERE is_all_sale=1 and goodsname like '%{$keyword}%' " );
  1509. }
  1510. if($type==1){
  1511. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg, "
  1512. .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 ";
  1513. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1514. }
  1515. if($type==2){
  1516. $goods_ids_nolimit_arr = M()->query('SELECT id FROM ' . C('DB_PREFIX') . "lionfish_comshop_goods
  1517. WHERE is_all_sale=1 ");
  1518. }
  1519. if( !empty($goods_ids_nolimit_arr) )
  1520. {
  1521. foreach($goods_ids_nolimit_arr as $val){
  1522. $ids_arr[] = $val['id'];
  1523. }
  1524. }
  1525. if($type==2){
  1526. $good_ids_arr = explode(',',$good_ids);
  1527. $new_ids_arr = array();
  1528. if(count($good_ids_arr)>0){
  1529. foreach ($good_ids_arr as $val) {
  1530. if(in_array($val, $ids_arr)){
  1531. $new_ids_arr[] = $val;
  1532. }
  1533. }
  1534. }
  1535. $ids_arr = $new_ids_arr;
  1536. }
  1537. $ids_str = implode(',',$ids_arr);
  1538. if( !empty($ids_str) )
  1539. {
  1540. $where .= " and g.id in ({$ids_str})";
  1541. } else{
  1542. $where .= " and 0 ";
  1543. }
  1544. }else{
  1545. //echo json_encode( array('code' => 1) );
  1546. //die();
  1547. }
  1548. if(empty($head_id) && $type == 0 && !empty($keyword)) {
  1549. $where .= " and g.goodsname like '%{$keyword}%'";
  1550. }
  1551. if($type==1) {
  1552. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  1553. }
  1554. //$where .= " and gc.begin_time <= {$now_time} and gc.end_time > {$now_time} and g.total > 0 ";
  1555. $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);
  1556. if( !empty($community_goods) )
  1557. {
  1558. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1559. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1560. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1561. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1562. {
  1563. $is_open_fullreduction = 0;
  1564. }
  1565. $list = array();
  1566. foreach($community_goods as $val)
  1567. {
  1568. $tmp_data = array();
  1569. $tmp_data['actId'] = $val['id'];
  1570. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1571. $tmp_data['spuName'] = $goodsname;
  1572. $tmp_data['spuCanBuyNum'] = $val['total'];
  1573. $tmp_data['spuDescribe'] = $val['subtitle'];
  1574. $tmp_data['end_time'] = $val['end_time'];
  1575. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1576. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1577. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1578. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1579. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1580. $productprice = $val['productprice'];
  1581. $tmp_data['marketPrice'] = explode('.', $productprice);
  1582. if( !empty($val['big_img']) )
  1583. {
  1584. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1585. }
  1586. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1587. if( !empty($good_image) )
  1588. {
  1589. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1590. }
  1591. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1592. $price = $price_arr['price'];
  1593. //mead-2
  1594. // $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  1595. $tmp_data['levelprice'] = meadMoney($price_arr['levelprice'],$val['mead_money_num']);; // 会员等级价格
  1596. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  1597. $tmp_data['levelPrice'] = explode('.', $tmp_data['levelprice']);
  1598. $tmp_data['actPrice'] = explode('.', $price);
  1599. /**
  1600. $tmp_data['skuList'] = array(
  1601. array('spec' => 'xl','canBuyNum' => 100,'spuName' => 1, 'actPrice' => array(1,2), 'marketPrice' => array(2,3),'skuImage' => tomedia($good_image['image'])),
  1602. array('spec' => 'x2','canBuyNum' => 200, 'spuName' => 2, 'actPrice' => array(1,2), 'marketPrice' => array(2,3),'skuImage' => tomedia($good_image['image']))
  1603. );
  1604. **/
  1605. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  1606. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  1607. if( !empty($tmp_data['skuList']) )
  1608. {
  1609. $tmp_data['car_count'] = 0;
  1610. }else{
  1611. if(!empty($head_id) && $head_id > 0){
  1612. $car_count = D('Home/Car')->get_wecart_goods($val['id'],"",$head_id ,$token);
  1613. if( empty($car_count) )
  1614. {
  1615. $tmp_data['car_count'] = 0;
  1616. }else{
  1617. $tmp_data['car_count'] = $car_count;
  1618. }
  1619. }
  1620. }
  1621. if($is_open_fullreduction == 0)
  1622. {
  1623. $tmp_data['is_take_fullreduction'] = 0;
  1624. }else if($is_open_fullreduction == 1){
  1625. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1626. }
  1627. $list[] = $tmp_data;
  1628. }
  1629. 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 ));
  1630. die();
  1631. }else{
  1632. echo json_encode( array('code' => 1) );
  1633. die();
  1634. }
  1635. }
  1636. public function get_newauth_bg()
  1637. {
  1638. $newauth_bg_image = D('Home/Front')->get_config_by_name('newauth_bg_image');
  1639. if( !empty($newauth_bg_image) )
  1640. {
  1641. $newauth_bg_image = tomedia($newauth_bg_image);
  1642. }
  1643. $newauth_cancel_image = D('Home/Front')->get_config_by_name('newauth_cancel_image');
  1644. if( !empty($newauth_cancel_image) )
  1645. {
  1646. $newauth_cancel_image = tomedia($newauth_cancel_image);
  1647. }
  1648. $newauth_confirm_image = D('Home/Front')->get_config_by_name('newauth_confirm_image');
  1649. if( !empty($newauth_confirm_image) )
  1650. {
  1651. $newauth_confirm_image = tomedia($newauth_confirm_image);
  1652. }
  1653. echo json_encode(
  1654. array(
  1655. 'code'=>0,
  1656. 'data' => array(
  1657. 'newauth_bg_image'=>$newauth_bg_image,
  1658. 'newauth_confirm_image'=>$newauth_confirm_image,
  1659. 'newauth_cancel_image'=>$newauth_cancel_image
  1660. )
  1661. )
  1662. );
  1663. }
  1664. /**
  1665. 进入小程序初始加载方法,
  1666. 以后有类似需要参数,都在这里初始化
  1667. **/
  1668. public function get_firstload_msg()
  1669. {
  1670. $_GPC = I('request.');
  1671. $token = isset($_GPC['token']) ? $_GPC['token'] : '';
  1672. $new_head_id = 0;
  1673. $default_head_info = array();
  1674. //是否强制手机
  1675. $isparse_formdata = 0;
  1676. if( !empty($token) )
  1677. {
  1678. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1679. $community_history = M('lionfish_community_history')->field('head_id')->where( array('member_id' => $weprogram_token['member_id'] ) )->order('addtime desc')->find();
  1680. if( !empty($community_history) )
  1681. {
  1682. $cur_community_info = M('lionfish_community_head')->field('id')->where( array('id' => $community_history['head_id'] ) )->find();
  1683. if( !empty($cur_community_info) )
  1684. {
  1685. $new_head_id = $cur_community_info['id'];
  1686. $default_head_info = D('Home/Front')->get_community_byid($new_head_id);
  1687. }
  1688. }
  1689. //是否强制手机
  1690. $is_get_formdata = D('Home/Front')->get_config_by_name('is_get_formdata');
  1691. if( isset($is_get_formdata) && $is_get_formdata == 1 )
  1692. {
  1693. $now_member_info = M('lionfish_comshop_member')->where( array('member_id' => $weprogram_token['member_id'] ))->find();
  1694. if( $now_member_info['is_apply_state'] != 1 && $now_member_info['is_write_form'] != 1 )
  1695. {
  1696. $isparse_formdata = 1;
  1697. }
  1698. }
  1699. }
  1700. $skin = D('Home/Front')->get_config_by_name('skin');
  1701. $common_header_backgroundimage = D('Home/Front')->get_config_by_name('common_header_backgroundimage');
  1702. if( !empty($common_header_backgroundimage) )
  1703. {
  1704. $common_header_backgroundimage = tomedia($common_header_backgroundimage);
  1705. }
  1706. $goods_sale_unit = D('Home/goods')->get_sale_unit();
  1707. 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 ) );
  1708. die();
  1709. }
  1710. /**
  1711. * 加载分类详情页
  1712. * @return [type] [description]
  1713. */
  1714. public function load_cate_goodslist()
  1715. {
  1716. $_GPC = I('request.');
  1717. $head_id = $_GPC['head_id'];
  1718. if($head_id == 'undefined')
  1719. $head_id = '';
  1720. $pid = $_GPC['gid'];
  1721. $token = $_GPC['token'];
  1722. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1723. $member_id = $weprogram_token['member_id'];
  1724. // vip身份
  1725. $is_vip_card_member = 0;
  1726. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1727. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  1728. $member_id = $weprogram_token['member_id'];
  1729. $is_vip_card_member = 0;
  1730. if( $member_id > 0 )
  1731. {
  1732. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  1733. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1734. {
  1735. $now_time = time();
  1736. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1737. {
  1738. $is_vip_card_member = 1;//还是会员
  1739. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1740. $is_vip_card_member = 2;//已过期
  1741. }
  1742. }
  1743. }
  1744. if($pid == 'undefined' || $pid =='')
  1745. {
  1746. echo json_encode(
  1747. array(
  1748. 'code' => 1,
  1749. 'data'=> array(),
  1750. 'msg' => '分类id错误'
  1751. )
  1752. );
  1753. die();
  1754. }
  1755. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1756. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1757. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1758. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1759. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  1760. $is_show_vipcard_price = D('Home/Front')->get_config_by_name('is_show_vipcard_price');
  1761. if( $is_open_vipcard_buy == 1 )
  1762. {
  1763. if( !empty($is_show_vipcard_price) && $is_show_vipcard_price == 1 ) $is_open_vipcard_buy = 0;
  1764. }
  1765. if(empty($full_reducemoney) || $full_reducemoney <= 0) $is_open_fullreduction = 0;
  1766. $cateList = $cateArr = array();
  1767. $parent_cate = M('lionfish_comshop_goods_category')->field('id,banner,name')->where( array('cate_type' =>'normal','id' => $pid ) )->find();
  1768. if($parent_cate){
  1769. $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();
  1770. if($cate_info){
  1771. $cateArr = array_merge(array($parent_cate), $cate_info);
  1772. }else {
  1773. $cateArr[] = $parent_cate;
  1774. }
  1775. foreach ($cateArr as $key => $val) {
  1776. $gid = $val['id'];
  1777. $cate_info = array();
  1778. $cate_info['name'] = $val['name'];
  1779. $cate_info['banner'] = $val['banner'] && !empty($val['banner']) ? tomedia($val['banner']) : '';
  1780. $cate_info['logo'] = $val['logo'] && !empty($val['logo']) ? tomedia($val['logo']) : '';
  1781. $now_time = time();
  1782. $where = " g.grounding =1 ";
  1783. if( !empty($head_id) && $head_id >0 )
  1784. {
  1785. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg,"
  1786. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g
  1787. where pg.goods_id = g.goods_id and g.cate_id={$gid} and pg.head_id = {$head_id}
  1788. order by pg.id desc ";
  1789. $goods_ids_arr = M()->query($sql_goods_ids);
  1790. $ids_arr = array();
  1791. foreach($goods_ids_arr as $val){
  1792. $ids_arr[] = $val['goods_id'];
  1793. }
  1794. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg,"
  1795. .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id={$gid}
  1796. and pg.is_all_sale=1 ";
  1797. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1798. if( !empty($goods_ids_nolimit_arr) )
  1799. {
  1800. foreach($goods_ids_nolimit_arr as $val){
  1801. $ids_arr[] = $val['id'];
  1802. }
  1803. }
  1804. $ids_str = implode(',',$ids_arr);
  1805. if( !empty($ids_str) )
  1806. {
  1807. $where .= " and g.id in ({$ids_str})";
  1808. } else{
  1809. $where .= " and 0 ";
  1810. }
  1811. }else{
  1812. $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
  1813. where pg.id = g.goods_id and g.cate_id = {$gid} ";
  1814. $goods_ids_nohead_arr = M()->query($goods_ids_nohead_sql);
  1815. $ids_arr = array();
  1816. if( !empty($goods_ids_nohead_arr) )
  1817. {
  1818. foreach($goods_ids_nohead_arr as $val){
  1819. $ids_arr[] = $val['id'];
  1820. }
  1821. }
  1822. $ids_str = implode(',',$ids_arr);
  1823. if( !empty($ids_str) )
  1824. {
  1825. $where .= " and g.id in ({$ids_str})";
  1826. } else{
  1827. $where .= " and 0 ";
  1828. }
  1829. }
  1830. // $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1831. $where .= " and gc.begin_time <={$now_time} ";
  1832. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 and g.is_seckill = 0 ";
  1833. $community_goods = '';
  1834. $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);
  1835. $list = $cart = array();
  1836. if( !empty($community_goods) )
  1837. {
  1838. $cart= D('Home/Car');
  1839. foreach($community_goods as $val)
  1840. {
  1841. $tmp_data = array();
  1842. $tmp_data['actId'] = $val['id'];
  1843. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1844. $tmp_data['spuName'] = $goodsname;
  1845. $tmp_data['spuCanBuyNum'] = $val['total'];
  1846. $tmp_data['spuDescribe'] = $val['subtitle'];
  1847. $tmp_data['end_time'] = $val['end_time'];
  1848. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  1849. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1850. $tmp_data['actEnd'] = time()>$val['end_time'];
  1851. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1852. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1853. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1854. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1855. $productprice = $val['productprice'];
  1856. $tmp_data['marketPrice'] = explode('.', $productprice);
  1857. if( !empty($val['big_img']) )
  1858. {
  1859. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1860. }
  1861. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1862. if( !empty($good_image) )
  1863. {
  1864. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1865. }
  1866. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1867. $price = $price_arr['price'];
  1868. $tmp_data['actPrice'] = explode('.', $price);
  1869. $tmp_data['card_price'] = $price_arr['card_price'];
  1870. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1871. if( !empty($tmp_data['skuList']) )
  1872. {
  1873. $tmp_data['car_count'] = 0;
  1874. }else{
  1875. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1876. if( empty($car_count) )
  1877. {
  1878. $tmp_data['car_count'] = 0;
  1879. }else{
  1880. $tmp_data['car_count'] = $car_count;
  1881. }
  1882. }
  1883. if($is_open_fullreduction == 0)
  1884. {
  1885. $tmp_data['is_take_fullreduction'] = 0;
  1886. }else if($is_open_fullreduction == 1){
  1887. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1888. }
  1889. // 商品角标
  1890. $label_id = unserialize($val['labelname']);
  1891. if($label_id){
  1892. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1893. if($label_info){
  1894. if($label_info['type'] == 1){
  1895. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1896. } else {
  1897. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1898. }
  1899. }
  1900. $tmp_data['label_info'] = $label_info;
  1901. }
  1902. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1903. $list[] = $tmp_data;
  1904. }
  1905. }
  1906. $cateList[] = array('cate_info'=>$cate_info, 'list'=>$list);
  1907. }
  1908. }
  1909. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  1910. // 客服按钮
  1911. $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
  1912. $theme = D('Home/Front')->get_config_by_name('index_list_theme_type');
  1913. echo json_encode(
  1914. array(
  1915. 'code' => 0,
  1916. 'list' => $cateList,
  1917. 'is_vip_card_member' => $is_vip_card_member,
  1918. 'cur_time' => time(),
  1919. 'full_reducemoney' => $full_reducemoney,
  1920. 'full_money' => $full_money,
  1921. 'is_open_vipcard_buy' => $is_open_vipcard_buy,
  1922. 'is_open_fullreduction' => $is_open_fullreduction,
  1923. 'is_show_cate_tabbar' => $is_show_cate_tabbar,
  1924. 'user_service_switch' => $user_service_switch,
  1925. 'theme' => $theme
  1926. )
  1927. );
  1928. die();
  1929. }
  1930. public function load_gps_goodslist_new()
  1931. {
  1932. $gpc = I('request.');
  1933. $token = $gpc['token'];
  1934. $head_id = $gpc['head_id'];
  1935. $is_only_express = $gpc['is_only_express'];
  1936. $is_open_only_express = 0;
  1937. if($is_only_express==1) {
  1938. $is_open_only_express = D('Home/Front')->get_config_by_name('is_open_only_express');
  1939. }
  1940. if($head_id == 'undefined') $head_id = '';
  1941. $pageNum = $gpc['pageNum'];
  1942. $gid = $gpc['gid'];
  1943. $keyword = $gpc['keyword'];
  1944. $is_random = isset($gpc['is_random']) ? $gpc['is_random'] : 0;
  1945. $is_video = isset($gpc['is_video']) ? $gpc['is_video'] : 0;
  1946. $per_page = isset($gpc['per_page']) ? $gpc['per_page'] : 10;
  1947. $cate_info = '';
  1948. if($gid == 'undefined' || $gid =='' || $gid =='null' || $gid ==0)
  1949. {
  1950. $gid = 0;
  1951. } else {
  1952. $cate_info = M('lionfish_comshop_goods_category')->field('banner,name')->where( array('id' => $gid ) )->find();
  1953. if(!empty($cate_info['banner'])) $cate_info['banner'] = tomedia($cate_info['banner']);
  1954. }
  1955. if( !empty($gid) && $gid > 0)
  1956. {
  1957. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid,'normal','','',1);
  1958. $gidArr = array();
  1959. $gidArr[] = $gid;
  1960. foreach ($gids as $key => $val) {
  1961. $gidArr[] = $val['id'];
  1962. }
  1963. $gid = implode(',', $gidArr);
  1964. }
  1965. $offset = ($pageNum - 1) * $per_page;
  1966. $limit = "{$offset},{$per_page}";
  1967. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1968. $is_member_level_buy = 0;
  1969. $is_vip_card_member = 0;
  1970. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1971. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  1972. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1973. {
  1974. //echo json_encode( array('code' => 2) );
  1975. //die();
  1976. }else{
  1977. $member_id = $weprogram_token['member_id'];
  1978. $is_vip_card_member = 0;
  1979. //member_id
  1980. if( $member_id > 0 )
  1981. {
  1982. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  1983. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1984. {
  1985. $now_time = time();
  1986. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1987. {
  1988. $is_vip_card_member = 1;//还是会员
  1989. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1990. $is_vip_card_member = 2;//已过期
  1991. }
  1992. }
  1993. if($is_vip_card_member != 1 && $member_info['level_id'] >0 )
  1994. {
  1995. $is_member_level_buy = 1;
  1996. }
  1997. }
  1998. }
  1999. $member_id = $weprogram_token['member_id'];
  2000. //整点秒杀begin
  2001. $is_seckill = isset($gpc['is_seckill']) ? 1:0;
  2002. $seckill_time = isset($gpc['seckill_time']) ? intval($gpc['seckill_time']):0;
  2003. //整点秒杀end
  2004. $now_time = time();
  2005. if($is_seckill ==1)
  2006. {
  2007. $where = " g.grounding =1 and g.is_seckill =1 and g.type ='normal' ";
  2008. }else
  2009. {
  2010. $where = " g.grounding =1 and g.is_seckill =0 and g.type ='normal' ";
  2011. }
  2012. //head_id
  2013. if( !empty($keyword) )
  2014. {
  2015. $where .= " and g.goodsname like '%{$keyword}%' ";
  2016. }
  2017. if($is_seckill ==1)
  2018. {
  2019. $bg_time = strtotime( date('Y-m-d').' '.$seckill_time.':00:00' );
  2020. $ed_time = $bg_time + 3600;
  2021. if($gid == 0 && $keyword == ''){
  2022. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  2023. } else {
  2024. $where .= " and gc.begin_time >={$bg_time} and gc.begin_time <{$ed_time} ";
  2025. }
  2026. } else {
  2027. if($gid == 0 && $keyword == ''){
  2028. $where .= " and g.is_index_show = 1 ";
  2029. }
  2030. }
  2031. if($is_seckill ==1)
  2032. {
  2033. }else{
  2034. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 ";
  2035. }
  2036. if( $is_video == 1 )
  2037. {
  2038. $where .= " and gc.video !='' ";
  2039. }
  2040. if($is_open_only_express==1 && $is_only_express==1) {
  2041. $where .= " and gc.is_only_express =1 ";
  2042. }
  2043. $now_time = time();
  2044. $where .= " and gc.begin_time <={$now_time} ";
  2045. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  2046. if( empty($index_sort_method) )
  2047. {
  2048. $order_sort = 'g.istop DESC, g.settoptime DESC,g.index_sort desc,g.id desc ';
  2049. }
  2050. if( $index_sort_method == 1 )
  2051. {
  2052. $order_sort = 'g.index_sort desc,g.id desc ';
  2053. }
  2054. if($is_random == 1)
  2055. {
  2056. $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() ');
  2057. }else{
  2058. $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);
  2059. }
  2060. if( !empty($community_goods) )
  2061. {
  2062. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  2063. $full_money = D('Home/Front')->get_config_by_name('full_money');
  2064. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  2065. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  2066. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 ? 1:0;
  2067. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  2068. {
  2069. $is_open_fullreduction = 0;
  2070. }
  2071. $cart= D('Home/Car');
  2072. $list = array();
  2073. $copy_text_arr = array();
  2074. $today_time = strtotime( date('Y-m-d').' 00:00:00' );
  2075. foreach($community_goods as $val)
  2076. {
  2077. $tmp_data = array();
  2078. $tmp_data['actId'] = $val['id'];
  2079. $goodsname = htmlspecialchars_decode($val['goodsname']);
  2080. $tmp_data['spuName'] = $goodsname;
  2081. $tmp_data['spuCanBuyNum'] = $val['total'];
  2082. $tmp_data['spuDescribe'] = $val['subtitle'];
  2083. $tmp_data['end_time'] = $val['end_time'];
  2084. $tmp_data['actEnd'] = time()>$val['end_time'];
  2085. $tmp_data['is_take_vipcard'] = $val['is_take_vipcard'];
  2086. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  2087. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  2088. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  2089. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  2090. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  2091. $tmp_data['begin_time'] = date('Y-m-d', $val['begin_time']);
  2092. if($val['pick_up_type'] == 0)
  2093. {
  2094. $val['pick_up_modify'] = date('Y-m-d', $today_time);
  2095. }else if( $val['pick_up_type'] == 1 ){
  2096. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  2097. }else if( $val['pick_up_type'] == 2 )
  2098. {
  2099. $val['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  2100. }
  2101. $tmp_data['pick_up_modify'] = $val['pick_up_modify'];
  2102. $productprice = $val['productprice'];
  2103. $tmp_data['marketPrice'] = explode('.', $productprice);
  2104. if( !empty($val['big_img']) )
  2105. {
  2106. $tmp_data['bigImg'] = tomedia($val['big_img']);
  2107. }
  2108. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  2109. if( !empty($good_image) )
  2110. {
  2111. $tmp_data['skuImage'] = tomedia($good_image['image']);
  2112. }
  2113. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  2114. $price = $price_arr['price'];
  2115. if( $pageNum == 1 )
  2116. {
  2117. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  2118. }
  2119. $tmp_data['actPrice'] = explode('.', $price);
  2120. $tmp_data['card_price'] = $price_arr['card_price'];
  2121. $tmp_data['levelprice'] = $price_arr['levelprice']; // 会员等级价格
  2122. $tmp_data['is_mb_level_buy'] = $price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  2123. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  2124. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  2125. if( !empty($tmp_data['skuList']) )
  2126. {
  2127. $tmp_data['car_count'] = 0;
  2128. }else{
  2129. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  2130. if( empty($car_count) )
  2131. {
  2132. $tmp_data['car_count'] = 0;
  2133. }else{
  2134. $tmp_data['car_count'] = $car_count;
  2135. }
  2136. }
  2137. if($is_open_fullreduction == 0)
  2138. {
  2139. $tmp_data['is_take_fullreduction'] = 0;
  2140. }else if($is_open_fullreduction == 1){
  2141. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  2142. }
  2143. // 商品角标
  2144. $label_id = unserialize($val['labelname']);
  2145. if($label_id){
  2146. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  2147. if($label_info){
  2148. if($label_info['type'] == 1){
  2149. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  2150. } else {
  2151. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  2152. }
  2153. }
  2154. $tmp_data['label_info'] = $label_info;
  2155. }
  2156. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  2157. $list[] = $tmp_data;
  2158. }
  2159. $is_show_list_timer = D('Home/Front')->get_config_by_name('is_show_list_timer');
  2160. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  2161. 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 ));
  2162. die();
  2163. }else{
  2164. $is_show_cate_tabbar = D('Home/Front')->get_config_by_name('is_show_cate_tabbar');
  2165. echo json_encode( array('code' => 1 , 'cate_info' => $cate_info , 'is_show_cate_tabbar'=>$is_show_cate_tabbar ) );
  2166. die();
  2167. }
  2168. }
  2169. /**
  2170. * 图片广告
  2171. * @return [json] [description]
  2172. */
  2173. public function get_advimg(){
  2174. $data = M('lionfish_comshop_advimg')->order('id desc')->find();
  2175. if(!empty($data)) {
  2176. if(!empty($data['enabled'])){
  2177. $data['thumb'] = tomedia($data['thumb']);
  2178. $data['pos'] = explode(',', $data['pos']);
  2179. echo json_encode( array('code' => 0, 'data' => $data ) );
  2180. die();
  2181. }else{
  2182. echo json_encode( array('code' => 1, 'msg' => "广告图片已关闭" ) );
  2183. die();
  2184. }
  2185. }
  2186. echo json_encode( array('code' => 1, 'msg' => "无广告图片" ) );
  2187. die();
  2188. }
  2189. public function get_diy_info()
  2190. {
  2191. $index_diy_json = D('Home/Front')->get_config_by_name('index_diy_json');
  2192. if($index_diy_json) {
  2193. $data = unserialize($index_diy_json);
  2194. $diyData = htmlspecialchars_decode($data['value']);
  2195. if(!$diyData) {
  2196. $newdata = D('Seller/Diydata')->get_all_config();
  2197. if(!empty($newdata)) $diyJson = $newdata;
  2198. if(!empty($diyJson)) {
  2199. foreach($diyJson as $k=>$v) {
  2200. $v->host = $this->staticHost();
  2201. if($v->type=="RICH_TEXT") {
  2202. $v->html= $this->replaceRichtextImgSrc($v->html);
  2203. }
  2204. $diyJson[$k] = $v;
  2205. }
  2206. }
  2207. if($data) {
  2208. $global = json_decode(htmlspecialchars_decode($data["global"]));
  2209. // var_dump($global);die();
  2210. }
  2211. } else {
  2212. $diyDataJson = json_decode($diyData, true);
  2213. $diyJson = $diyDataJson['value'];
  2214. $global = $diyDataJson['global'];
  2215. if(!empty($diyJson)) {
  2216. foreach($diyJson as $k=>$v) {
  2217. $v['host'] = $this->staticHost();
  2218. if($v['type']=="RICH_TEXT") {
  2219. $v['html'] = $this->replaceRichtextImgSrc($v['html']);
  2220. }
  2221. $diyJson[$k] = $v;
  2222. }
  2223. }
  2224. }
  2225. echo json_encode( array('code' => 0, 'global' => $global, 'diyJson' => $diyJson ) );
  2226. die();
  2227. } else {
  2228. echo json_encode( array('code' => 1, 'msg' => 'DIY页面未设置' ) );
  2229. die();
  2230. }
  2231. }
  2232. public function staticHost() {
  2233. $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : '80';
  2234. $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
  2235. return "https://" . $host;
  2236. }
  2237. public function replaceRichtextImgSrc($html) {
  2238. $pattern = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png|\.jpeg]))[\'|\"].*?[\/]?>/i";
  2239. $result = preg_replace_callback($pattern, function ($ma) {
  2240. $newUrl = $ma[1];
  2241. $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : '80';
  2242. $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
  2243. if (strpos($ma[1], 'http') == false) {
  2244. $newUrl = "https://" . $host . $newUrl;
  2245. }
  2246. return str_replace($ma[1], tomedia($newUrl), $ma[0]);
  2247. }, $html);
  2248. return $result;
  2249. }
  2250. }