IndexController.class.php 90 KB

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