GoodsController.class.php 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author fish
  7. *
  8. */
  9. namespace Home\Controller;
  10. class GoodsController extends CommonController {
  11. /**
  12. 获取商品规格数据
  13. **/
  14. public function get_goods_option_data()
  15. {
  16. $gpc = I('request.');
  17. $id = $gpc['id'];
  18. $token = $gpc['token'];
  19. $sku_str = $gpc['sku_str'];
  20. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  21. $member_id = $weprogram_token['member_id'];
  22. $goods_option_mult_value = M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' => $id) )->order('id asc')->select();
  23. $goods_option_mult_value_ref = array();
  24. foreach ($goods_option_mult_value as $key => $val) {
  25. $image_info = D('Home/Front')->get_goods_sku_image($val['id']);
  26. $val['image'] = isset($image_info['thumb']) ? tomedia($image_info['thumb']) : '';
  27. $val['pin_price'] = $val['pinprice'];
  28. $val['dan_price'] = $val['marketprice'];
  29. $goods_option_mult_value[$key] = $val;
  30. $goods_option_mult_value_ref[$val['option_item_ids']] = $val;
  31. }
  32. $need_data = array();
  33. //$level_info = $goods_model->get_member_level_info($member_id, $id);
  34. $level_info = array();
  35. $member_disc = 100;
  36. if( !empty($level_info) )
  37. {
  38. $member_disc = $level_info['member_discount'];
  39. }
  40. //$max_member_level = M('member_level')->order('level desc')->find();
  41. $max_member_level = array();
  42. $goods_option_mult_value_ref[$sku_str]['member_pin_price'] = round( ($goods_option_mult_value_ref[$sku_str]['pin_price'] * $member_disc) / 100 ,2);
  43. $goods_option_mult_value_ref[$sku_str]['memberprice'] = round( ($goods_option_mult_value_ref[$sku_str]['dan_price'] * $member_disc) / 100 ,2);
  44. $goods_option_mult_value_ref[$sku_str]['max_member_pin_price'] = 0;
  45. $goods_option_mult_value_ref[$sku_str]['max_memberprice'] = 0;
  46. if( !empty($max_member_level) )
  47. {
  48. $goods_option_mult_value_ref[$sku_str]['max_member_pin_price'] = round( ($goods_option_mult_value_ref[$sku_str]['pin_price'] * (100 - $max_member_level['discount']) ) / 100 ,2);
  49. $goods_option_mult_value_ref[$sku_str]['max_memberprice'] = round( ($goods_option_mult_value_ref[$sku_str]['dan_price'] * (100 - $max_member_level['discount']) ) / 100 ,2);
  50. }
  51. $need_data['value'] = $goods_option_mult_value_ref[$sku_str];
  52. echo json_encode( array('code' =>0 , 'data' =>$need_data ) );
  53. die();
  54. }
  55. public function getQuan()
  56. {
  57. $_GPC = I('request.');
  58. $token = $_GPC['token'];
  59. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  60. $member_id = $weprogram_token['member_id'];
  61. $result = array('code' => 0,'msg' => '被抢光啦');
  62. $quan_id = $_GPC['quan_id'];
  63. if($quan_id >0){
  64. $res = D('Home/Voucher')->send_user_voucher_byId($quan_id,$member_id,true);
  65. //1 被抢光了 2 已领过 3 领取成功
  66. $mes_arr = array(1 => '抢光了',2 => '已领过', 3 => '领取成功', 4 => '新人专享优惠券');
  67. $result['code'] = $res;
  68. $result['msg'] = $mes_arr[$res];
  69. $result['is_hide'] = D('Home/Voucher')->checkUserCanGetOneVoucher($quan_id,$member_id,true);
  70. }
  71. echo json_encode($result);
  72. die();
  73. }
  74. public function get_seller_quan()
  75. {
  76. $_GPC = I('request.');
  77. $token = isset( $_GPC['token'] ) && !empty($_GPC['token']) ? $_GPC['token']:'';
  78. $member_id = 0;
  79. if( !empty($token) )
  80. {
  81. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  82. if( !empty($weprogram_token) )
  83. {
  84. $member_id = $weprogram_token['member_id'];
  85. }
  86. }
  87. $where = "";
  88. $where = " and (total_count =-1 or total_count>send_count) and is_index_alert=0 and is_index_show=1 and ((timelimit=1 and end_time>".time().") or timelimit=0 ) ";
  89. $quan_list = M()->query("select * from ".C('DB_PREFIX')."lionfish_comshop_coupon where 1 {$where} order by displayorder desc ,id asc limit 100 ");
  90. $need_list = array();
  91. foreach($quan_list as $key => $val )
  92. {
  93. $val['thumb'] = tomedia($val['thumb']);
  94. $voucher_id = $val['id'];
  95. $voucher_info = M('lionfish_comshop_coupon')->where( array('id' => $voucher_id ) )->find();
  96. if($val['total_count'] != -1 && $voucher_info['total_count'] <= $voucher_info['send_count']){
  97. continue;
  98. }else {
  99. $get_count = M('lionfish_comshop_coupon_list')->where( array('user_id' => $member_id,'voucher_id' => $voucher_id ) )->count();
  100. if($voucher_info['person_limit_count'] > 0 && $voucher_info['person_limit_count'] <= $get_count) {
  101. continue;
  102. }
  103. }
  104. //判断是否新人券
  105. if( $voucher_info['is_new_man'] == 1 )
  106. {
  107. //检测是否购买过
  108. $od_status = "1,2,4,6,7,8,9,10,11,12,14";
  109. $buy_count_sql = "select count(order_id) as count from ".C('DB_PREFIX')."lionfish_comshop_order
  110. where order_status_id in ({$od_status}) and member_id={$member_id} " ;
  111. $buy_count_arr = M()->query($buy_count_sql);
  112. $buy_count = $buy_count_arr[0]['count'];
  113. if( !empty($buy_count) && $buy_count >0 )
  114. {
  115. continue;
  116. }
  117. }
  118. $need_list[$key] = $val;
  119. }
  120. $where2 = "";
  121. $where2 = " and (total_count=-1 or total_count>send_count) and is_index_alert =1 and (end_time>".time()." or timelimit =0 ) ";
  122. $quan_list2 = M()->query("select * from ".C('DB_PREFIX')."lionfish_comshop_coupon where 1 {$where2} order by displayorder desc ,id asc limit 100 ");
  123. $need_list2 = array();
  124. //if( !empty($member_id) && $member_id > 0 )
  125. //{
  126. foreach($quan_list2 as $key => $val )
  127. {
  128. $val['thumb'] = tomedia($val['thumb']);
  129. $voucher_id = $val['id'];
  130. $voucher_info = M('lionfish_comshop_coupon')->where( array('id' => $voucher_id ) )->find();
  131. if($voucher_info['total_count'] != -1 && $voucher_info['total_count'] <= $voucher_info['send_count']){
  132. continue;
  133. }else {
  134. $get_count = M('lionfish_comshop_coupon_list')->where( array('user_id' => $member_id,'voucher_id' => $voucher_id ) )->count();
  135. if($voucher_info['person_limit_count'] > 0 && $voucher_info['person_limit_count'] <= $get_count) {
  136. continue;
  137. }
  138. }
  139. if( $member_id > 0 )
  140. { //判断是否新人券
  141. if( $voucher_info['is_new_man'] == 1 )
  142. {
  143. //检测是否购买过
  144. $od_status = "1,2,4,6,7,8,9,10,11,12,14";
  145. $buy_count_sql = "select count(order_id) as count from ".C('DB_PREFIX')."lionfish_comshop_order
  146. where order_status_id in ({$od_status}) and member_id={$member_id} " ;
  147. $buy_count_arr = M()->query($buy_count_sql);
  148. $buy_count = $buy_count_arr[0]['count'];
  149. if( !empty($buy_count) && $buy_count >0 )
  150. {
  151. continue;
  152. }
  153. }
  154. //如果有未使用完的就不送了吧
  155. if( $member_id > 0 )
  156. {
  157. $get_unuse_count = M('lionfish_comshop_coupon_list')->where( array('consume'=>'N','user_id' => $member_id,'voucher_id' => $voucher_id ) )->count();
  158. // if( empty($get_unuse_count) || $get_unuse_count <=0 )
  159. // {
  160. D('Home/Voucher')->send_user_voucher_byId($voucher_id,$member_id,true);
  161. // }
  162. }
  163. }
  164. $need_list2[$key] = $val;
  165. }
  166. //}
  167. echo json_encode( array('code' => 0, 'quan_list' => $need_list, 'alert_quan_list' => $need_list2) );
  168. die();
  169. }
  170. /**
  171. 商品评价
  172. **/
  173. public function comment_info()
  174. {
  175. $_GPC = I('request.');
  176. $token = $_GPC['token'];
  177. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  178. $member_id = $weprogram_token['member_id'];
  179. $goods_id = $_GPC['goods_id'];
  180. $result = array('code' => 2);
  181. if( empty($member_id))
  182. {
  183. //$result['msg'] = '未登录';
  184. //echo json_encode($result);
  185. //die();
  186. }
  187. $goods_info = M('lionfish_comshop_goods')->where( array('id' => $goods_id ) )->find();
  188. if(empty($goods_info)) {
  189. $result = array('code' => 2);
  190. $result['msg'] = '没有此商品';
  191. echo json_encode($result);
  192. die();
  193. }
  194. $page = isset($_GPC['page']) ? $_GPC['page'] : 1;
  195. $per_page = isset($_GPC['per_page']) ? $_GPC['per_page'] : 10;
  196. // $per_page = 4; C('DB_PREFIX')
  197. $offset = ($page - 1) * $per_page;
  198. $sql = "select o.*,m.username as name2,m.avatar as avatar2 from ".C('DB_PREFIX')."lionfish_comshop_order_comment as o left join ".C('DB_PREFIX')."lionfish_comshop_member as m on o.member_id=m.member_id
  199. where o.state =1 and o.goods_id = {$goods_id} order by o.add_time desc limit {$offset},{$per_page}";
  200. $list = M()->query($sql);
  201. foreach($list as $key => $val)
  202. {
  203. if( empty($val['user_name']) )
  204. {
  205. $val['name'] = $val['name2'];
  206. $val['avatar'] = tomedia($val['avatar2']);
  207. }else{
  208. $val['name'] = $val['user_name'];
  209. $val['avatar'] = tomedia($val['avatar']);
  210. }
  211. if($val['type'] == 0)
  212. {
  213. $order_goods_info = M('lionfish_comshop_order_goods')->field('order_goods_id')->where( array('order_id' => $val['order_id'],'goods_id' => $id) )->find();
  214. $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_goods_id' => $order_goods_info['order_goods_id'],'order_id' => $val['order_id'] ) )->select();
  215. $option_arr = array();
  216. foreach($order_option_info as $option)
  217. {
  218. $option_arr[] = $option['value'];
  219. }
  220. $option_str = implode(',', $option_arr);
  221. }else{
  222. $option_str = '';
  223. }
  224. $img_str = unserialize($val['images']);
  225. if( !empty($val['images']) && $img_str != 'undefined' )
  226. {
  227. // $img_str = unserialize($val['images']);
  228. $img_list = explode(',', $img_str);
  229. if(!empty($img_list))
  230. {
  231. $need_img_list = array();
  232. foreach($img_list as $kk => $vv)
  233. {
  234. if( empty($vv) )
  235. {
  236. continue;
  237. }
  238. $vv = tomedia($vv);
  239. $img_list[$kk] = $vv;
  240. $need_img_list[$kk] = $vv;
  241. }
  242. $val['images'] = $need_img_list;
  243. }else{
  244. $val['images'] = array();
  245. }
  246. } else {
  247. $val['images'] = array();
  248. }
  249. //<view class="time span">{{item.addtime}}</view>
  250. // <view class="style span">{{item.option_str}} </view>
  251. $val['add_time'] = date('Y-m-d', $val['add_time']) ;
  252. $val['option_str'] = $option_str;
  253. $list[$key] = $val;
  254. }
  255. $result = array();
  256. $result['code'] = 0;
  257. $result['list'] = $list;
  258. if(!empty($list))
  259. {
  260. $result['code'] = 0;
  261. }else{
  262. $result['code'] = 1;
  263. }
  264. echo json_encode($result);
  265. die();
  266. }
  267. public function get_user_goods_qrcode()
  268. {
  269. $gpc = I('request.');
  270. $id = $gpc['goods_id'];
  271. $community_id = $gpc['community_id'];
  272. $token = $gpc['token'];
  273. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  274. $member_id = $weprogram_token['member_id'];
  275. if(!empty($member_id)){
  276. $goods_share_image = M('lionfish_comshop_goods_share_image')->where( array('member_id' => $member_id, 'goods_id' => $id) )->find();
  277. if( !empty($goods_share_image) && false)
  278. {
  279. $result = array('code' => 0, 'image_path' => $goods_share_image['image_path']);
  280. echo json_encode($result);
  281. die();
  282. }else {
  283. $member_info = M('lionfish_comshop_member')->field('avatar,username,wepro_qrcode')->where( array('member_id' => $member_id) )->find();
  284. $goods_model = D('Home/Pingoods');
  285. if( !empty($member_info['wepro_qrcode']) && false)
  286. {
  287. $wepro_qrcode = $member_info['wepro_qrcode'];
  288. }else{
  289. $wepro_qrcode = $goods_model->get_goods_user_avatar($member_info['avatar'], $member_id, 6);
  290. }
  291. $goods_description = M('lionfish_comshop_good_common')->field('wepro_qrcode_image')->where(array('goods_id' => $id))->find();
  292. if( empty($goods_description['wepro_qrcode_image']) || true)
  293. {
  294. $goods_model->get_weshare_image($id , $member_id);
  295. $goods_description = M('lionfish_comshop_good_common')->field('wepro_qrcode_image')->where( array('goods_id' => $id) )->find();
  296. }
  297. $rocede_path = $goods_model->_get_goods_user_wxqrcode($id,$member_id,$community_id);
  298. $res = $goods_model->_get_compare_qrcode_bgimg('Uploads/image/'.$goods_description['wepro_qrcode_image'], $rocede_path,$wepro_qrcode,$member_info['username']);
  299. $url = D('Home/Front')->get_config_by_name('shop_domain').'/';
  300. $attachment_type_arr = M('lionfish_comshop_config')->where( array('name' => 'attachment_type') )->find();
  301. $fullname = ROOT_PATH.$res['full_path'];
  302. $data = array();
  303. $data['member_id'] = $member_id;
  304. $data['goods_id'] = $id;
  305. if( $attachment_type_arr['value'] == 1 )
  306. {
  307. save_image_to_qiniu($fullname,$res['full_path']);
  308. $qiniu_url = D('Seller/Front')->get_config_by_name('qiniu_url');
  309. $data['image_path'] = $qiniu_url. $res['full_path'];
  310. }else if( $attachment_type_arr['value'] == 2 ){
  311. save_image_to_alioss($fullname,$res['full_path']);
  312. $alioss_url = D('Seller/Front')->get_config_by_name('alioss_url');
  313. $data['image_path'] = $alioss_url. $res['full_path'];
  314. }else if( $attachment_type_arr['value'] == 3 )
  315. {
  316. save_image_to_txyun($fullname,$res['full_path']);
  317. $txyun_url = D('Seller/Front')->get_config_by_name('tx_url');
  318. $data['image_path'] = $txyun_url. $res['full_path'];
  319. }else{
  320. $data['image_path'] = $url. $res['full_path'];
  321. }
  322. $data['addtime'] = time();
  323. M('lionfish_comshop_goods_share_image')->add($data);
  324. $result = array('code' => 0, 'image_path' => $data['image_path'] );
  325. echo json_encode($result);
  326. die();
  327. }
  328. }else{
  329. $result = array('code' => 1);
  330. echo json_encode($result);
  331. die();
  332. }
  333. }
  334. public function doPageUpload(){
  335. //$image_dir = ROOT_PATH.'Uploads/image/';
  336. //$send_path = 'goods'.date('Y-m-d').'/';
  337. //$image_dir .= $send_path;
  338. //RecursiveMkdir($image_dir);
  339. $uptypes = array('image/jpg', 'image/jpeg', 'image/png', 'image/pjpeg', 'image/gif', 'image/bmp', 'image/x-png');
  340. $max_file_size = 10000000; //上传文件大小限制, 单位BYTE
  341. $send_path = "Uploads/image/goods/".date('Y-m-d')."/";
  342. $send_path_re = "goods/".date('Y-m-d')."/";
  343. $destination_folder = ROOT_PATH.$send_path; //上传文件路径
  344. $result = array();
  345. $result['code'] = 1;
  346. RecursiveMkdir($destination_folder);
  347. //fileinfo 检测begin
  348. $fip = finfo_open(FILEINFO_MIME_TYPE);
  349. $min_result = finfo_file($fip , $_FILES['upfile']['tmp_name']);
  350. fclose( $fip );
  351. $min_type_arr = array();
  352. $min_type_arr[] = 'image/jpeg';
  353. $min_type_arr[] = 'image/gif';
  354. $min_type_arr[] = 'image/jpg';
  355. $min_type_arr[] = 'image/png';
  356. $min_type_arr[] = 'video/mp4';
  357. if( !in_array($min_result , $min_type_arr ) )
  358. {
  359. die();
  360. }
  361. //fileinfo 检测end
  362. if (!is_uploaded_file($_FILES["upfile"]['tmp_name']))
  363. //是否存在文件
  364. {
  365. $result['msg'] = "图片不存在!";
  366. echo json_encode($result);
  367. exit;
  368. }
  369. $file = $_FILES["upfile"];
  370. if ($max_file_size < $file["size"])
  371. //检查文件大小
  372. {
  373. $result['msg'] = "文件太大!";
  374. echo json_encode($result);
  375. exit;
  376. }
  377. if (!in_array($file["type"], $uptypes))
  378. //检查文件类型
  379. {
  380. $result['msg'] = "文件类型不符!" . $file["type"];
  381. echo json_encode($result);
  382. exit;
  383. }
  384. $filename = $file["tmp_name"];
  385. $pinfo = pathinfo($file["name"]);
  386. $ftype = $pinfo['extension'];
  387. $file_name = str_shuffle(time() . rand(111111, 999999)) . "." . $ftype;
  388. $destination = $destination_folder . $file_name;
  389. if (!move_uploaded_file($filename, $destination)) {
  390. $result['msg'] = "移动文件出错!";
  391. echo json_encode($result);
  392. exit;
  393. }
  394. $pinfo = pathinfo($destination);
  395. $fname = $pinfo['basename'];
  396. //6956182894169131.png
  397. $thumb = resize($send_path_re.$file_name, 200,200);
  398. $image_thumb = $thumb ;
  399. $image_o = $send_path.$file_name;
  400. $url = D('Home/Front')->get_config_by_name('shop_domain').'/';
  401. echo json_encode( array('code' => 0,'image_thumb' =>$url.$image_thumb, 'image_o' => $url.$image_o , 'image_o_full' => $url.tomedia($send_path_re.$file_name) ) );
  402. die();
  403. }
  404. public function notify_order()
  405. {
  406. $notify_order_list_time = S('notify_order_list_time2');
  407. $now_time = time();
  408. if( isset($notify_order_list_time) && $notify_order_list_time >0 && $now_time - $notify_order_list_time < 3600 )
  409. {
  410. $result_list = S('notify_order_list');
  411. if( !isset($result_list) || empty($result_list) )
  412. {
  413. echo json_encode( array('code' => 1) );
  414. die();
  415. }else{
  416. $result_key = array_rand($result_list,1);
  417. $result = $result_list[$result_key];
  418. echo json_encode( $result );
  419. die();
  420. }
  421. }else{
  422. $notify_order_list = M('lionfish_comshop_notify_order')->order('rand()')->group('member_id')->limit(100)->select();
  423. $result = array();
  424. if(!empty($notify_order_list) )
  425. {
  426. $need_data = array();
  427. foreach($notify_order_list as $notify_order)
  428. {
  429. $miao = (time() -$notify_order['order_time']) % 60;
  430. $result_data = array();
  431. $result_data['code'] = 0;
  432. $result_data['username'] = $notify_order['username'];
  433. $result_data['avatar'] = $notify_order['avatar'];
  434. $result_data['order_id'] = $notify_order['order_id'];
  435. $result_data['order_url'] = $notify_order['order_url'];
  436. $result_data['miao'] = $miao;
  437. $need_data[] = $result_data;
  438. }
  439. S('notify_order_list_time2', time() );
  440. S('notify_order_list', $need_data );
  441. $result_key = array_rand($need_data,1);
  442. $result = $need_data[$result_key];
  443. }
  444. if( empty($result) )
  445. {
  446. echo json_encode( array('code' => 1) );
  447. die();
  448. }else{
  449. echo json_encode( $result);
  450. die();
  451. }
  452. }
  453. die();
  454. //
  455. $notify_order = M('lionfish_comshop_notify_order')->order('state asc , id asc')->find();
  456. $result = array('code' => 1);
  457. if(empty($notify_order))
  458. {
  459. echo json_encode($result);
  460. die();
  461. }
  462. M()->execute("update ".C('DB_PREFIX')."lionfish_comshop_notify_order set state =state+1 where id=".$notify_order['id'] );
  463. //->save( array('state' => 1) );
  464. echo json_encode($result);
  465. die();
  466. }
  467. public function load_buy_recordlist()
  468. {
  469. $gpc = I('request.');
  470. $goods_id = $gpc['goods_id'];
  471. $pageNum = $gpc['pageNum'];
  472. $per_page = 10;
  473. $offset = ($pageNum -1) * $per_page;
  474. $limit = "{$offset}, {$per_page}";
  475. $list = D('Home/Frontorder')->get_goods_buy_record($goods_id,$limit);
  476. if(!empty($list['list']))
  477. {
  478. echo json_encode( array('code' =>0, 'data' => $list['list']) );
  479. die();
  480. }else{
  481. echo json_encode( array('code' => 1) );
  482. die();
  483. }
  484. }
  485. public function get_goods_detail() {
  486. $gpc = I('request.');
  487. $id = $gpc['id'];
  488. $pin_id = isset($gpc['pin_id']) ? $gpc['pin_id'] : 0;
  489. $token = $gpc['token'];
  490. $head_id = $gpc['community_id'];
  491. $needauth = false;
  492. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  493. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  494. {
  495. $needauth = true;
  496. }
  497. $member_id = $weprogram_token['member_id'];
  498. $need_data = array();
  499. $sql = "select g.*,gd.content,gd.begin_time,gd.end_time,gd.video,gd.is_take_fullreduction,gd.goods_share_image,gd.share_title,gd.quality,gd.pick_up_type,gd.pick_up_modify,gd.one_limit_count,gd.total_limit_count,gd.seven,gd.repair,gd.labelname,gd.share_title,gd.relative_goods_list,gd.is_show_arrive,gd.is_modify_sendscore,gd.send_socre,gd.diy_arrive_switch,gd.diy_arrive_details,gd.is_only_hexiao,gd.supply_id,gd.oneday_limit_count,gd.total_limit_count,gd.one_limit_count,gd.goods_start_count
  500. from " . C('DB_PREFIX') . "lionfish_comshop_goods g," . C('DB_PREFIX') . "lionfish_comshop_good_common gd
  501. where g.id=gd.goods_id and g.id=" . $id;
  502. $goods_arr = M()->query($sql);
  503. $goods = $goods_arr[0];
  504. $is_only_hexiao = $goods['is_only_hexiao'];
  505. $goods['nogoods'] = false;
  506. if(empty($goods_arr[0])) { $goods['nogoods'] = true; }
  507. $goods['goods_id'] = $id;
  508. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  509. $full_money = D('Home/Front')->get_config_by_name('full_money');
  510. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  511. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  512. {
  513. $is_open_fullreduction = 0;
  514. }
  515. if($is_open_fullreduction == 0)
  516. {
  517. $goods['is_take_fullreduction'] = 0;
  518. }
  519. $goods['full_money'] = $full_money;
  520. $goods['full_reducemoney'] = $full_reducemoney;
  521. $goods['is_video'] = 0;
  522. $goods['video_size_width'] = 0;
  523. $goods['vedio_size_height'] = 0;
  524. $goods['video_src'] = '';
  525. //goods_share_image
  526. if( !empty($goods['goods_share_image']) )
  527. {
  528. $goods['goods_share_image'] = tomedia($goods['goods_share_image']);
  529. }
  530. //video
  531. if( !empty($goods['video']) )
  532. {
  533. $goods['video'] = tomedia($goods['video']);
  534. }
  535. $goods['goodsname'] = htmlspecialchars_decode($goods['goodsname']);
  536. $goods['description'] = htmlspecialchars_decode($goods['content']);
  537. $goods['description'] = htmlspecialchars_decode($goods['description']);
  538. $qian = array(
  539. "\r\n"
  540. );
  541. $hou = array(
  542. "<br/>"
  543. );
  544. $goods['subtitle'] = str_replace($qian, $hou, $goods['subtitle']);
  545. $hou = array(
  546. "@EOF@"
  547. );
  548. $today_time = strtotime( date('Y-m-d').' 00:00:00' );
  549. //pick_up_type
  550. //1、当日达,2、次日达,3隔日达,4 自定义
  551. if($goods['pick_up_type'] == 0)
  552. {
  553. $goods['pick_up_modify'] = date('Y-m-d', $today_time);
  554. }else if( $goods['pick_up_type'] == 1 ){
  555. $goods['pick_up_modify'] = date('Y-m-d', $today_time+86400);
  556. }else if( $goods['pick_up_type'] == 2 )
  557. {
  558. $goods['pick_up_modify'] = date('Y-m-d', $today_time+86400*2);
  559. }
  560. //gd.begin_time,gd.end_time,
  561. //over_type =0 未开始,over_type =2已结束,over_type =1距结束
  562. $now_time = time();
  563. if($goods['begin_time'] > $now_time)
  564. {
  565. $goods['over_type'] = 0;
  566. }else if( $goods['begin_time'] <= $now_time && $goods['end_time'] > $now_time ){
  567. $goods['over_type'] = 1;
  568. }else if($goods['end_time'] < $now_time){
  569. $goods['over_type'] = 2;
  570. $goods['end_date'] = date('m/d H:i', $goods['end_time']);
  571. }
  572. $goods['activity_summary'] = '';
  573. $onegood_image = D('Home/Pingoods')->get_goods_images($id);
  574. if( !empty($onegood_image) )
  575. {
  576. $goods['image_thumb'] = tomedia($onegood_image['image']);
  577. $goods['image'] = tomedia($onegood_image['image']);
  578. }
  579. $buy_record_arr = D('Home/Frontorder')->get_goods_buy_record($id,9);
  580. $goods_image = D('Home/Pingoods')->get_goods_images($id, 10);
  581. if (isset($goods_image)) {
  582. foreach ($goods_image as $k => $v) {
  583. $goods_image[$k]['image'] = tomedia($v['image']);
  584. }
  585. }
  586. $goods['seller_count']+= $goods['sales'];
  587. $goods_price_arr = D('Home/Pingoods')->get_goods_price($id ,$member_id);
  588. $goods['danprice'] = $goods_price_arr['danprice'];
  589. $goods['card_price'] = $goods_price_arr['card_price'];//会员卡价格
  590. $goods['levelprice'] = $goods_price_arr['levelprice']; // 会员等级价格
  591. $goods['is_mb_level_buy'] = $goods_price_arr['is_mb_level_buy']; //是否 会员等级 可享受
  592. if($goods['type'] == 'integral')
  593. {
  594. $goods['price'] = round($goods_price_arr['price'], 0);
  595. $goods['productprice'] = round($goods['productprice'], 0);
  596. $price_dol = explode(' ', $goods_price_arr['price']);
  597. $price_dol[0] = round($price_dol[0], 0);
  598. }else{
  599. $goods['price'] = $goods_price_arr['price'];
  600. $price_dol = explode('.', $goods_price_arr['price']);
  601. }
  602. $open_buy_send_score = D('Home/Front')->get_config_by_name('open_buy_send_score');
  603. if( !isset($open_buy_send_score) || $open_buy_send_score == 0 )
  604. {
  605. $open_buy_send_score = 0;
  606. }
  607. $goods['open_buy_send_score'] = $open_buy_send_score;
  608. //open_buy_send_score send_socre
  609. if( $goods['is_modify_sendscore'] != 1 )
  610. {
  611. $open_buy_send_score = D('Home/Front')->get_config_by_name('open_buy_send_score');
  612. if( isset($open_buy_send_score) && $open_buy_send_score == 1 )
  613. {
  614. $money_for_score = D('Home/Front')->get_config_by_name('money_for_score');
  615. if( isset($money_for_score) && $money_for_score > 0 )
  616. {
  617. $goods['is_modify_sendscore'] = 1;
  618. $goods['send_socre'] = round($money_for_score*$goods['price'], 2);
  619. }
  620. }
  621. }
  622. $goods['price_front'] = $price_dol[0];
  623. $goods['price_after'] = isset($price_dol[1]) ? $price_dol[1] : '';
  624. $labelname_arr = unserialize( $goods['labelname'] );
  625. $tag_arr = array();
  626. if( !empty($labelname_arr) )
  627. {
  628. $goods['tag'] = $labelname_arr;
  629. }else{
  630. if( $goods['quality'] == 1)
  631. {
  632. $tag_arr[] = '正品保证';
  633. }
  634. if( $goods['seven'] == 1)
  635. {
  636. $tag_arr[] = '7天无理由退换';
  637. }
  638. if( $goods['repair'] == 1)
  639. {
  640. $tag_arr[] = '保修';
  641. }
  642. $goods['tag'] = $tag_arr;
  643. }
  644. $goods['fan_image'] = $goods['image'];
  645. $one_image = D('Home/Pingoods')->get_goods_images($id, 1);
  646. $goods['one_image'] = tomedia($one_image['image']);
  647. $pin_info = array();
  648. $user_favgoods = D('Home/Pingoods')->fav_goods_state($id, $member_id);
  649. if( !empty($user_favgoods) )
  650. {
  651. $goods['favgoods'] = 2;
  652. }else{
  653. $goods['favgoods'] = 1;
  654. }
  655. $price = $goods['danprice'];
  656. $lottery_info = array();
  657. $need_data['lottery_info'] = $lottery_info;
  658. //$goods['share_title'] = $price.'元 '.$goods['goodsname'];
  659. if(empty($goods['share_title'])) {
  660. if($goods['type']=='integral') {
  661. $goods['share_title'] = intval($price).'积分 '.$goods['goodsname'];
  662. } else {
  663. $goods['share_title'] = $price.'元 '.$goods['goodsname'];
  664. }
  665. $is_login_showprice = D('Home/Front')->get_config_by_name('is_login_showprice');
  666. if( !empty($is_login_showprice) && $is_login_showprice == 1 )
  667. {
  668. $member_info = M('lionfish_comshop_member')->where(array('member_id' => $member_id))->find();
  669. if( empty($member_id) || $member_id <= 0 || $member_info['is_apply_state'] == 0 )
  670. {
  671. if($goods['type']=='integral') {
  672. $goods['share_title'] = '---积分 '.$goods['goodsname'];
  673. } else {
  674. $goods['share_title'] = '---元 '.$goods['goodsname'];
  675. }
  676. }
  677. }
  678. }
  679. /** 商品会员折扣begin **/
  680. $is_show_member_disc = 0;
  681. $member_disc = 100;
  682. /** 商品会员折扣end **/
  683. $goods['memberprice'] = sprintf('%.2f', round( ($goods['danprice'] * $member_disc) / 100 ,2));
  684. $max_get_dan_money = round( ($goods['danprice'] * (100 - $max_member_level['discount']) ) / 100 ,2);
  685. $max_get_money = $max_get_dan_money;
  686. if(!empty($pin_info))
  687. {
  688. $pin_info['member_pin_price'] = sprintf('%.2f',round( ($pin_info['pin_price'] * $member_disc) / 100 ,2));
  689. $max_get_pin_money = round( ($pin_info['pin_price'] * (100 - $max_member_level['discount']) ) / 100 ,2);
  690. $max_get_money = $max_get_pin_money;
  691. }
  692. // 商品角标
  693. $label_id = unserialize($goods['labelname']);
  694. if($label_id){
  695. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  696. if($label_info){
  697. if($label_info['type'] == 1){
  698. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  699. } else {
  700. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  701. }
  702. }
  703. $goods['label_info'] = $label_info;
  704. }
  705. //查看会员身份,是否有佣金显示到商品详细页begin
  706. $is_commiss_mb = 0;
  707. $commiss_mb_money = 0;
  708. $is_goods_head_mb = 0;
  709. $goods_head_money = 0;
  710. $is_show_goodsdetails_commiss_money = D('Home/Front')->get_config_by_name('is_show_goodsdetails_commiss_money');
  711. if( !empty($is_show_goodsdetails_commiss_money) && $is_show_goodsdetails_commiss_money == 1 && $member_id > 0 )
  712. {
  713. //先判断是否有分销的佣金
  714. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  715. if( !empty($commiss_level) && $commiss_level > 0)
  716. {
  717. $mb_info = M('lionfish_comshop_member')->field('comsiss_flag')->where( array('member_id' => $member_id ) )->find();
  718. //判断是否分销 =1
  719. if( $mb_info['comsiss_flag'] == 1 )
  720. {
  721. $commission_info = D('Home/Pingoods')->get_goods_commission_info($id,$member_id );
  722. if( $commission_info['commiss_one']['type'] == 2 )
  723. {
  724. $commiss_one_money = $commission_info['commiss_one']['money'];
  725. }else{
  726. $commiss_one_money = round( ($commission_info['commiss_one']['fen'] * $goods['price'] )/100 , 2);
  727. }
  728. $is_commiss_mb = 1;
  729. $commiss_mb_money = $commiss_one_money;
  730. }
  731. }
  732. $is_community_hd = M('lionfish_community_head')->field('id')->where( array('member_id' => $member_id ) )->find();
  733. if( !empty($is_community_hd) )
  734. {
  735. //说明是团长,但是要确定是否这个商品的团长
  736. $is_commu_sale = D('Seller/Communityhead')->check_goods_can_community($id, $is_community_hd['id']);
  737. $community_money_type = D('Home/Front')->get_config_by_name('community_money_type');
  738. if( $is_commu_sale )
  739. {
  740. //计算团长佣金
  741. $head_commission_info = D('Home/Front')->get_goods_common_field($id , 'community_head_commission');
  742. $head_level_arr = D('Seller/Communityhead')->get_goods_head_level_bili( $id );
  743. $community_info = M('lionfish_community_head')->where( array('id' => $is_community_hd['id'] ) )->find();
  744. if( $community_info['state'] == 1 && $community_info['enable'] == 1 )
  745. {
  746. $level = $community_info['level_id'];
  747. $is_head_takegoods = D('Home/Front')->get_config_by_name('is_head_takegoods');
  748. $is_head_takegoods = isset($is_head_takegoods) && $is_head_takegoods == 1 ? 1 : 0;
  749. //启用时 1,上方和商品中的“团长提成比例”失效,使用“团长等级”对应提成比例。不启用时 0,上方和商品中的“团长提成比例有效”。
  750. if($is_head_takegoods == 1)
  751. {
  752. //开启 团长等级
  753. //是否设置了团长等级
  754. $head_level = M('lionfish_comshop_community_head_level')->find();
  755. $is_modify_head_commission = M('lionfish_comshop_good_common')->field('is_modify_head_commission,is_community_head_commission,community_head_commission')->where( array('goods_id' => $goods['goods_id'] ) )->find();
  756. if(!empty($head_level) && $is_modify_head_commission["is_modify_head_commission"] == 1 ){
  757. //有等级 按商品或者等级比例
  758. $head_commission_info['community_head_commission'] = $head_level_arr['head_level'.$level];
  759. }elseif(!empty($head_level) && $is_modify_head_commission["is_modify_head_commission"] == 0 ){
  760. if($level == 0 ){
  761. $head_commission_info['community_head_commission'] = D('Home/Front')->get_config_by_name('default_comunity_money');
  762. }else{
  763. $community_head_level = M('lionfish_comshop_community_head_level')->where(array('id' => $level ) )->find();
  764. $head_commission_info['community_head_commission'] =$community_head_level['commission'];
  765. }
  766. }else{
  767. if($is_modify_head_commission['is_community_head_commission'] == 1){
  768. $head_commission_info['community_head_commission'] = $is_modify_head_commission['community_head_commission'];
  769. }else{
  770. $head_commission_info['community_head_commission'] = D('Home/Front')->get_config_by_name('default_comunity_money');
  771. }
  772. }
  773. }else{
  774. $is_community_head_commission = M('lionfish_comshop_good_common')->field('is_community_head_commission,community_head_commission')->where( array('goods_id' => $goods['goods_id'] ) )->find();
  775. if($is_community_head_commission['is_community_head_commission'] == 1){
  776. //商品单独设置
  777. $head_commission_info['community_head_commission'] = $is_community_head_commission['community_head_commission'];
  778. }else{
  779. $head_commission_info['community_head_commission'] = D('Home/Front')->get_config_by_name('default_comunity_money');
  780. }
  781. }
  782. if( $community_money_type == 1 )
  783. {
  784. $goods_head_money = round( $head_commission_info['community_head_commission'] ,2);
  785. }else{
  786. $goods_head_money = round( ($head_commission_info['community_head_commission'] * $goods['price'] )/100,2);
  787. }
  788. $is_commiss_mb = 0;
  789. $commiss_mb_money = 0;
  790. $is_goods_head_mb = 1;
  791. }
  792. }
  793. }
  794. }
  795. //end
  796. $need_data['pin_info'] = $pin_info;
  797. $need_data['is_commiss_mb'] = $is_commiss_mb;//是否显示 会员分销 佣金 1 是,0否
  798. $need_data['commiss_mb_money'] = $commiss_mb_money;// 会员分销佣金 是多少
  799. $need_data['is_goods_head_mb'] = $is_goods_head_mb;// 是否团长 佣金, 1 是,0否
  800. $need_data['goods_head_money'] = $goods_head_money;// 团长佣金 金额
  801. /**
  802. if(!empty($member_id) && $member_id > 0 && $goods[0]['type'] == 'integral')
  803. {
  804. $member_info = M('member')->field('score')->where( array('member_id' => $member_id) )->find();
  805. if($member_info['score'] < $goods[0]['score'])
  806. {
  807. $goods[0]['score_enough'] = 0;
  808. }else{
  809. $goods[0]['score_enough'] = 1;
  810. }
  811. }
  812. **/
  813. $need_data['member_level_info'] = $member_level_info;
  814. $need_data['member_level_list'] = $member_level_list;
  815. $need_data['max_member_level'] = $max_member_level;
  816. $need_data['max_get_money'] = sprintf('%.2f',$max_get_money);
  817. $need_data['max_get_pin_money'] = $max_get_pin_money;
  818. $need_data['max_get_dan_money'] = $max_get_dan_money;
  819. $need_data['buy_record_arr'] = $buy_record_arr;
  820. $need_data['is_show_max_level'] = $is_show_max_level;
  821. $goods['actPrice'] = explode('.', $goods['price']);
  822. $goods['marketPrice'] = explode('.', $goods['productprice']);
  823. $relative_goods_list = array();
  824. $is_open_goods_relative_goods = D('Home/Front')->get_config_by_name('is_open_goods_relative_goods');
  825. if( !empty($is_open_goods_relative_goods) && $is_open_goods_relative_goods == 1 )
  826. {
  827. $rel_unser = unserialize($goods['relative_goods_list']);
  828. if( !empty($rel_unser) )
  829. {
  830. $relative_goods_list_str = implode(',', $rel_unser);
  831. $now_time = time();
  832. $s_where = " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  833. $limit_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 ', ' g.id in('.$relative_goods_list_str.') and grounding =1 '.$s_where,0,100);
  834. $last_community_info = array();
  835. if( !empty($member_id) && $member_id > 0 )
  836. {
  837. $last_community_info = D('Home/Front')->get_history_community($member_id);
  838. }
  839. $cart= D('Home/Car');
  840. foreach($limit_goods as $kk => $val)
  841. {
  842. if( !empty($last_community_info) )
  843. {
  844. //communityId
  845. $is_canshow = D('Seller/Communityhead')->check_goods_can_community($val['id'], $last_community_info['communityId']);
  846. if( !$is_canshow )
  847. {
  848. continue;
  849. }
  850. }
  851. $tmp_data = array();
  852. $tmp_data['actId'] = $val['id'];
  853. $tmp_data['spuName'] = $val['goodsname'];
  854. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  855. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  856. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  857. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  858. $tmp_data['spuCanBuyNum'] = $val['total'];
  859. $tmp_data['spuDescribe'] = $val['subtitle'];
  860. $tmp_data['end_time'] = $val['end_time'];
  861. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  862. $productprice = $val['productprice'];
  863. $tmp_data['marketPrice'] = explode('.', $productprice);
  864. if( !empty($val['big_img']) )
  865. {
  866. $tmp_data['bigImg'] = tomedia($val['big_img']);
  867. }
  868. $good_image_tp = D('Home/Pingoods')->get_goods_images($val['id']);
  869. if( !empty($good_image_tp) )
  870. {
  871. $tmp_data['skuImage'] = tomedia($good_image_tp['image']);
  872. }
  873. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  874. $price = $price_arr['price'];
  875. if( $pageNum == 1 )
  876. {
  877. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  878. }
  879. $tmp_data['actPrice'] = explode('.', $price);
  880. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  881. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $head_id ,$token);
  882. if( !empty($tmp_data['skuList']) )
  883. {
  884. $tmp_data['car_count'] = 0;
  885. }else{
  886. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  887. if( empty($car_count) )
  888. {
  889. $tmp_data['car_count'] = 0;
  890. }else{
  891. $tmp_data['car_count'] = $car_count;
  892. }
  893. }
  894. if($is_open_fullreduction == 0)
  895. {
  896. $tmp_data['is_take_fullreduction'] = 0;
  897. }else if($is_open_fullreduction == 1){
  898. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  899. }
  900. // 商品角标
  901. $label_id = unserialize($val['labelname']);
  902. if($label_id){
  903. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  904. if($label_info){
  905. if($label_info['type'] == 1){
  906. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  907. } else {
  908. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  909. }
  910. }
  911. $tmp_data['label_info'] = $label_info;
  912. }
  913. $relative_goods_list[$kk] = $tmp_data;
  914. }
  915. }
  916. }
  917. unset($goods['relative_goods_list']);
  918. $need_data['relative_goods_list'] = $relative_goods_list;
  919. $show_goods_subtitle = D('Home/Front')->get_config_by_name('show_goods_subtitle');
  920. if($show_goods_subtitle!=1) $goods['subtitle'] = '';
  921. if(empty($relative_goods_list)){
  922. $goods['cart_quantity'] = D('Home/Car')->get_wecart_goods($goods['id'],"",$head_id ,$token);
  923. }
  924. $need_data['goods'] = $goods;
  925. $need_data['goods_image'] = $goods_image;
  926. /**
  927. $seller_info = M('seller')->field('s_id,s_true_name,s_logo,s_qq,certification')->where(array(
  928. 's_id' => $goods[0]['store_id']
  929. ))->find();
  930. $seller_model = D('Home/Seller');
  931. $seller_info['seller_count'] = $seller_model->getStoreSellerCount($goods[0]['store_id']);
  932. $seller_goods_count = M('goods')->where(array(
  933. 'store_id' => $goods[0]['store_id']
  934. ))->count();
  935. $seller_info['goods_count'] = $seller_goods_count;
  936. $seller_info['s_logo'] = C('SITE_URL') . 'Uploads/image/' . $seller_info['s_logo'];
  937. $need_data['seller_info'] = $seller_info;
  938. **/
  939. $need_data['site_name'] = D('Home/Front')->get_config_by_name('shoname');
  940. //$need_data['options'] = D('Home/Pingoods')->get_goods_options($id, $member_id); // $goods_model->get_goods_options($id);
  941. $need_data['options'] = D('Home/Pingoods')->get_goods_options_carquantity($id, $member_id, $head_id ,$token);
  942. $order_comment_count = M('lionfish_comshop_order_comment')->where( array('state' => 1, 'goods_id' => $id) )->count();
  943. $comment_list = array();
  944. if($order_comment_count > 0)
  945. {
  946. $sql = "select o.*,m.username as name2,m.avatar as avatar2 from ".C('DB_PREFIX')."lionfish_comshop_order_comment as o left join ".C('DB_PREFIX')."lionfish_comshop_member as m
  947. on o.member_id=m.member_id
  948. where o.state = 1 and o.goods_id = {$id} order by o.add_time desc limit 1";
  949. $comment_list= M()->query($sql);
  950. $order_comment_images = array();
  951. foreach($comment_list as $key => $val)
  952. {
  953. //user_name
  954. if( empty($val['user_name']) )
  955. {
  956. $val['name'] = $val['name2'];
  957. $val['avatar'] = tomedia($val['avatar2']);
  958. }else{
  959. $val['name'] = $val['user_name'];
  960. $val['avatar'] = tomedia($val['avatar']);
  961. }
  962. if($val['type'] == 0)
  963. {
  964. $order_goods_info = M('lionfish_comshop_order_goods')->field('order_goods_id')->where( array('goods_id' => $id,'order_id' => $val['order_id']) )->find();
  965. $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_goods_id' => $order_goods_info['order_goods_id'],'order_id' => $val['order_id']) )->select();
  966. $option_arr = array();
  967. foreach($order_option_info as $option)
  968. {
  969. $option_arr[] = $option['value'];
  970. }
  971. $option_str = implode(',', $option_arr);
  972. }else{
  973. $option_str = '';
  974. }
  975. $img_str = unserialize($val['images']);
  976. if( !empty($img_str) && $img_str != 'undefined' )
  977. {
  978. //$img_str = unserialize($val['images']);
  979. $img_list = explode(',', $img_str);
  980. $need_img_list = array();
  981. foreach($img_list as $kk => $vv)
  982. {
  983. if(!empty($vv) )
  984. {
  985. // $vv = tomedia(resize($vv,400,400));
  986. $vv = tomedia($vv);
  987. $img_list[$kk] = $vv;
  988. $need_img_list[$kk] = $vv;
  989. if(count($order_comment_images) <= 4)
  990. $order_comment_images[] = $vv;
  991. }
  992. }
  993. $val['images'] = $need_img_list ;
  994. } else {
  995. $val['images'] = array();
  996. }
  997. $val['option_str'] = $option_str;
  998. $val['add_time'] = date('Y-m-d', $val['add_time']) ;
  999. $comment_list[$key] = $val;
  1000. }
  1001. //$this->comment_list = $comment_list;
  1002. }
  1003. $need_data['cur_time'] = time();
  1004. $need_data['pin_id'] = $pin_id;
  1005. $need_data['is_show_arrive'] = $goods['is_show_arrive'];
  1006. $need_data['diy_arrive_switch'] = $goods['diy_arrive_switch'];
  1007. $need_data['diy_arrive_details'] = $goods['diy_arrive_details'];
  1008. $need_data['is_can_headsales'] = 1;
  1009. //团长休息
  1010. $community_id = $gpc['community_id'];
  1011. if( isset($community_id) && $community_id > 0 )
  1012. {
  1013. $is_can_buy = D('Seller/Communityhead')-> check_goods_can_community($id, $community_id);
  1014. if( !$is_can_buy )
  1015. {
  1016. $need_data['is_can_headsales'] = 0;
  1017. }
  1018. // is_all_sale
  1019. }
  1020. $is_comunity_rest = D('Seller/Communityhead')->is_community_rest($community_id);
  1021. $open_man_orderbuy = D('Home/Front')->get_config_by_name('open_man_orderbuy');
  1022. $man_orderbuy_money = D('Home/Front')->get_config_by_name('man_orderbuy_money');
  1023. //同城配送商品的起卖价格
  1024. $goods_supply_info = M('lionfish_comshop_good_common')->where( array('goods_id' => $goods['id'] ) )->find();
  1025. $supply_id = $goods_supply_info["supply_id"];
  1026. $is_only_distribution = $goods_supply_info["is_only_distribution"];
  1027. //达到金额免配送费
  1028. $localtown_moneytype_fixed_freemoney = 0;
  1029. if($supply_id == 0){
  1030. //配送费类型:0、固定金额,1、按距离收取
  1031. $localtown_delivery_moneytype = D('Home/Front')->get_config_by_name('localtown_delivery_moneytype');
  1032. if($localtown_delivery_moneytype == 0){
  1033. $localtown_moneytype_fixed_freemoney = D('Home/Front')->get_config_by_name('localtown_moneytype_fixed_deliverymoney');
  1034. }
  1035. }else{
  1036. $isopen_localtown_delivery = D('Home/Front')->get_supply_config_by_name('isopen_localtown_delivery',$supply_id);
  1037. //配送费类型:0、固定金额,1、按距离收取
  1038. $localtown_delivery_moneytype = D('Home/Front')->get_supply_config_by_name('localtown_delivery_moneytype',$supply_id);
  1039. if($isopen_localtown_delivery == 1 && $localtown_delivery_moneytype == 0){
  1040. $localtown_moneytype_fixed_freemoney = D('Home/Front')->get_supply_config_by_name('localtown_moneytype_fixed_deliverymoney',$supply_id);
  1041. }
  1042. }
  1043. $goodsdetails_addcart_bg_color = D('Home/Front')->get_config_by_name('goodsdetails_addcart_bg_color');
  1044. $goodsdetails_buy_bg_color = D('Home/Front')->get_config_by_name('goodsdetails_buy_bg_color');
  1045. $is_close_details_time = D('Home/Front')->get_config_by_name('is_close_details_time');
  1046. $isopen_community_group_share = D('Home/Front')->get_config_by_name('isopen_community_group_share');
  1047. $group_share_info = '';
  1048. if($isopen_community_group_share == 1) {
  1049. $head_commiss_info = M('lionfish_community_head_commiss')->where( array('head_id' => $community_id ) )->find();
  1050. if( !empty($head_commiss_info) )
  1051. {
  1052. $group_share_info = array();
  1053. $group_share_info['share_wxcode'] = $head_commiss_info['share_wxcode'] ? tomedia($head_commiss_info['share_wxcode']) : '';
  1054. $share_avatar = D('Home/Front')->get_config_by_name('group_share_avatar');
  1055. $group_share_info['share_avatar'] = tomedia($share_avatar);
  1056. $group_share_info['share_title'] = D('Home/Front')->get_config_by_name('group_share_title');
  1057. $group_share_info['share_desc'] = D('Home/Front')->get_config_by_name('group_share_desc');
  1058. }
  1059. }
  1060. //.... card_price
  1061. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1062. $modify_vipcard_name = D('Home/Front')->get_config_by_name('modify_vipcard_name');
  1063. $modify_vipcard_logo = D('Home/Front')->get_config_by_name('modify_vipcard_logo');
  1064. $modify_vipcard_name = empty($modify_vipcard_name) ? '天机会员': $modify_vipcard_name;
  1065. $is_open_vipcard_buy = !empty($is_open_vipcard_buy) && $is_open_vipcard_buy ==1 ? 1:0;
  1066. if( !empty($modify_vipcard_logo) )
  1067. {
  1068. $modify_vipcard_logo = tomedia($modify_vipcard_logo);
  1069. }
  1070. $goods_details_title_bg = D('Home/Front')->get_config_by_name('goods_details_title_bg');
  1071. if( !empty($goods_details_title_bg) )
  1072. {
  1073. $goods_details_title_bg = tomedia($goods_details_title_bg);
  1074. }
  1075. $is_vip_card_member = 0;
  1076. $is_member_level_buy = 0;
  1077. //member_id
  1078. if( $member_id > 0 )
  1079. {
  1080. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  1081. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1082. {
  1083. $now_time = time();
  1084. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1085. {
  1086. $is_vip_card_member = 1;//还是会员
  1087. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1088. $is_vip_card_member = 2;//已过期
  1089. }
  1090. }
  1091. if( ($goods['is_take_vipcard'] != 1 ) && $member_info['level_id'] >0 && $goods['is_mb_level_buy'] == 1 )
  1092. {
  1093. $is_member_level_buy = 1;
  1094. }
  1095. }
  1096. //$goods['type'] == 'pin' $member_id
  1097. $is_need_subscript = 0;
  1098. $need_subscript_template = array();
  1099. if( $member_id >0 && $goods['type'] == 'pin')
  1100. {
  1101. //'pay_order','send_order','hexiao_success','apply_community','open_tuan','take_tuan','pin_tuansuccess','apply_tixian'
  1102. $open_tuan_info = M('lionfish_comshop_subscribe')->where( array('member_id' => $member_id, 'type' => 'open_tuan') )->find();
  1103. if( empty($open_tuan_info) )
  1104. {
  1105. $weprogram_subtemplate_open_tuan = D('Home/Front')->get_config_by_name('weprogram_subtemplate_open_tuan');
  1106. if( !empty($weprogram_subtemplate_open_tuan) )
  1107. {
  1108. $need_subscript_template['open_tuan'] = $weprogram_subtemplate_open_tuan;
  1109. }
  1110. }
  1111. $take_tuan_info = M('lionfish_comshop_subscribe')->where( array('member_id' => $member_id, 'type' => 'take_tuan' ) )->find();
  1112. if( empty($take_tuan_info) )
  1113. {
  1114. $weprogram_subtemplate_take_tuan = D('Home/Front')->get_config_by_name('weprogram_subtemplate_take_tuan');
  1115. if( !empty($weprogram_subtemplate_take_tuan) )
  1116. {
  1117. $need_subscript_template['take_tuan'] = $weprogram_subtemplate_take_tuan;
  1118. }
  1119. }
  1120. if( !empty($need_subscript_template) )
  1121. {
  1122. $is_need_subscript = 1;
  1123. }
  1124. }
  1125. // 销量开关
  1126. $is_hide_details_count = D('Home/Front')->get_config_by_name('is_hide_details_count');
  1127. $is_open_goods_full_video = D('Home/Front')->get_config_by_name('is_open_goods_full_video');
  1128. $ishide_details_desc = D('Home/Front')->get_config_by_name('ishide_details_desc');
  1129. $delivery_type_ziti = D('Home/Front')->get_config_by_name('delivery_type_ziti');
  1130. $show_goods_preview = D('Home/Front')->get_config_by_name('show_goods_preview');
  1131. //核销门店
  1132. $hx_salesroom_list = array();
  1133. if($is_only_hexiao == 1){
  1134. $hx_salesroom_list = D('Home/Salesroom')->get_goods_salesroom($id,$supply_id,'id,room_name,room_address');
  1135. }
  1136. //判断是否预售 begin
  1137. $need_data['presale_goods_info'] = ['is_presale_goods' => 0 ];
  1138. if($goods['type'] == 'presale')
  1139. {
  1140. $presale_goods_info = [];
  1141. $goods_presale = M('lionfish_comshop_goods_presale')->where(['goods_id' => $id ])->find();
  1142. $presale_goods_info['presale_type'] = $goods_presale['presale_type'];//0 定金, 1 全款支付
  1143. $presale_goods_info['presale_ding_money'] = $goods_presale['presale_ding_money'];//定金金额
  1144. $presale_goods_info['presale_deduction_money'] = $goods_presale['presale_deduction_money'];//定金抵扣金额
  1145. $presale_goods_info['presale_ding_time_start'] = $goods_presale['presale_ding_time_start'];//定金开始支付时间
  1146. $presale_goods_info['presale_ding_time_start_date'] = date('m月d日 H:i', $goods_presale['presale_ding_time_start'] );//定金支付格式化 开始时间
  1147. $presale_goods_info['presale_ding_time_start_date'] = date('m月d日 H:i', $goods_presale['presale_ding_time_start'] );//定金支付格式化 开始时间
  1148. $presale_goods_info['presale_ding_time_end'] = $goods_presale['presale_ding_time_end'] ;//定金支付结束时间
  1149. $presale_goods_info['presale_ding_time_end_date'] = date('m月d日 H:i', $goods_presale['presale_ding_time_end'] );//定金支付格式化 结束时间
  1150. $presale_goods_info['presale_limit_balancepaytime'] = $goods_presale['presale_limit_balancepaytime'] ;//限制尾款支付时间,0不限制,1限制
  1151. $presale_goods_info['presale_balance_paytime'] = intval($goods_presale['presale_balance_paytime']);//限制尾款支付时间, 几天内
  1152. $presale_goods_info['presale_sendorder_type'] = ($goods_presale['presale_sendorder_type']);//预计发货时间,0 固定发货时间, 1购买后几日发货
  1153. $presale_goods_info['presale_sendorder_datetime'] = date('Y-m-d',$goods_presale['presale_sendorder_datetime'] );//固定发货时间 ,具体的固定日期
  1154. $presale_goods_info['presale_sendorder_afterday'] = intval( $goods_presale['presale_sendorder_afterday'] );//购买后几日发货
  1155. $presale_goods_info['is_presale_goods'] = 1;
  1156. $need_subscript_template = [];
  1157. $weprogram_subtemplate_send_order = D('Home/Front')->get_config_by_name('weprogram_subtemplate_presale_ordercan_continuepay');
  1158. if( !empty($weprogram_subtemplate_send_order) )
  1159. {
  1160. $need_subscript_template['presale_ordercan_continuepay'] = $weprogram_subtemplate_send_order;
  1161. $is_need_subscript = 1;
  1162. }
  1163. $presale_goods_info['need_subscript_template'] = $need_subscript_template;//预售订阅消息
  1164. $need_data['presale_goods_info'] = $presale_goods_info;
  1165. }
  1166. //预售end..
  1167. $need_data['virtualcard_goods_info'] = ['is_virtualcard_goods' => 0 ];
  1168. if($goods['type'] == 'virtualcard')
  1169. {
  1170. $goods_virturalcard = D('Seller/VirtualCard')->getGoodsVirtualCardInfoByGoodsId( $id );
  1171. $virturalcard_info = D('Seller/VirtualCard')->getCodeInfoByCodeId( $goods_virturalcard['code_id'] );
  1172. $code_money = $virturalcard_info['code_money'];
  1173. $need_data['virtualcard_goods_info']['is_virtualcard_goods'] = 1; //是否礼品卡商品
  1174. $need_data['virtualcard_goods_info']['code_money'] = round($code_money, 2); //兑换金额
  1175. }
  1176. //判断是否礼品卡 begin
  1177. //礼品卡end
  1178. echo json_encode(array(
  1179. 'code' => 1,
  1180. 'comment_list' => $comment_list,
  1181. 'is_only_hexiao' => $is_only_hexiao,
  1182. 'hexiao_arr' => $hx_salesroom_list,
  1183. 'order_comment_images' => $order_comment_images,
  1184. 'order_comment_count' => $order_comment_count,
  1185. 'data' => $need_data,
  1186. 'is_comunity_rest' => $is_comunity_rest,
  1187. 'open_man_orderbuy' => $open_man_orderbuy,
  1188. 'man_orderbuy_money' => $man_orderbuy_money,
  1189. 'localtown_moneytype_fixed_freemoney' => $localtown_moneytype_fixed_freemoney,
  1190. 'is_only_distribution' => $is_only_distribution,
  1191. 'goodsdetails_buy_bg_color' => $goodsdetails_buy_bg_color,
  1192. 'goodsdetails_addcart_bg_color' => $goodsdetails_addcart_bg_color,
  1193. 'isopen_community_group_share' => $isopen_community_group_share,
  1194. 'group_share_info' => $group_share_info,
  1195. 'is_close_details_time' => $is_close_details_time,
  1196. 'is_open_vipcard_buy' => $is_open_vipcard_buy,//是否开启会员卡
  1197. 'modify_vipcard_name' => $modify_vipcard_name,//会员卡名称
  1198. 'modify_vipcard_logo' => $modify_vipcard_logo,//会员卡图标
  1199. 'is_vip_card_member' => $is_vip_card_member,//是否会员卡会员, 0 不是,1是会员,2已过期的会员
  1200. 'is_member_level_buy' => $is_member_level_buy,
  1201. 'is_need_subscript' => $is_need_subscript,
  1202. 'need_subscript_template' => $need_subscript_template,
  1203. 'is_hide_details_count' => $is_hide_details_count,
  1204. 'is_open_goods_full_video' => $is_open_goods_full_video,
  1205. 'goods_details_title_bg' => $goods_details_title_bg,
  1206. 'needauth' => $needauth,
  1207. 'ishide_details_desc' => $ishide_details_desc,
  1208. 'delivery_type_ziti' => $delivery_type_ziti,
  1209. 'show_goods_preview' => $show_goods_preview
  1210. ));
  1211. die();
  1212. }
  1213. /**
  1214. * 获取服务说明
  1215. */
  1216. public function get_instructions()
  1217. {
  1218. $_GPC = I('request.');
  1219. $list = M('lionfish_comshop_config')->field('value')->where( array('name' => 'instructions') )->find();
  1220. $goods_id = isset($_GPC['goods_id']) ? $_GPC['goods_id'] : '';
  1221. if(!empty($list['value']))
  1222. $list['value'] = htmlspecialchars_decode($list['value']);
  1223. $index_bottom_image = D('Home/Front')->get_config_by_name('index_bottom_image');
  1224. if(!empty($index_bottom_image)) $index_bottom_image = tomedia($index_bottom_image);
  1225. $goods_details_middle_image = D('Home/Front')->get_config_by_name('goods_details_middle_image');
  1226. if(!empty($goods_details_middle_image)) $goods_details_middle_image = tomedia($goods_details_middle_image);
  1227. $is_show_buy_record = D('Home/Front')->get_config_by_name('is_show_buy_record');
  1228. $is_show_comment_list = D('Home/Front')->get_config_by_name('is_show_comment_list');
  1229. $order_notify_switch = D('Home/Front')->get_config_by_name('order_notify_switch');
  1230. $goods_details_price_bg = D('Home/Front')->get_config_by_name('goods_details_price_bg');
  1231. if(!empty($goods_details_price_bg)) $goods_details_price_bg = tomedia($goods_details_price_bg);
  1232. $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
  1233. $goods_industrial_switch = D('Home/Front')->get_config_by_name('goods_industrial_switch');
  1234. $goods_industrial = D('Home/Front')->get_config_by_name('goods_industrial');
  1235. if(!empty($goods_industrial)) {
  1236. $goods_industrial = unserialize($goods_industrial) ;//tomedia($goods_industrial);
  1237. foreach( $goods_industrial as $key => $val )
  1238. {
  1239. $goods_industrial[$key] = tomedia($val);
  1240. }
  1241. }
  1242. //supply_id
  1243. if( $goods_id > 0 )
  1244. {
  1245. $gd_info = M('lionfish_comshop_good_common')->field('supply_id')->where( array('goods_id' => $goods_id ) )->find();
  1246. if( !empty($gd_info) && $gd_info['supply_id'] > 0 )
  1247. {
  1248. $su_info = M('lionfish_comshop_supply')->field('qualifications')->where( array('id' => $gd_info['supply_id'] ) )->find();
  1249. $qualifications = unserialize($su_info['qualifications']);
  1250. if(!empty($qualifications)) {
  1251. foreach ($qualifications as $key => $cval) {
  1252. $qualifications[$key] = tomedia($cval);
  1253. }
  1254. }
  1255. $goods_industrial = $qualifications;
  1256. }
  1257. }
  1258. $list['value'] = htmlspecialchars_decode(htmlspecialchars_decode($list['value']));
  1259. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  1260. $list['index_bottom_image'] = $index_bottom_image;
  1261. $list['goods_details_middle_image'] = $goods_details_middle_image;
  1262. $list['goods_details_price_bg'] = $goods_details_price_bg;
  1263. $list['is_show_buy_record'] = $is_show_buy_record;
  1264. $list['is_show_comment_list'] = $is_show_comment_list;
  1265. $list['order_notify_switch'] = $order_notify_switch;
  1266. $list['index_service_switch'] = $user_service_switch;
  1267. $list['goods_industrial_switch'] = $goods_industrial_switch;
  1268. $list['goods_industrial'] = $goods_industrial;
  1269. $list['is_show_ziti_time'] = D('Home/Front')->get_config_by_name('is_show_ziti_time');
  1270. $list['is_show_goodsdetails_communityinfo'] = D('Home/Front')->get_config_by_name('is_show_goodsdetails_communityinfo');
  1271. $list['hide_community_change_btn'] = $hide_community_change_btn;
  1272. $result = array('code' =>0,'data' => $list);
  1273. echo json_encode($result);
  1274. die();
  1275. }
  1276. /**
  1277. * 获取分类列表
  1278. * @return [type] [description]
  1279. */
  1280. public function get_category_list()
  1281. {
  1282. $is_type_show = I('request.is_type_show', 0);
  1283. $is_show = I('request.is_show', 0);
  1284. $category_list = D('Home/GoodsCategory')->get_index_goods_category(0,'normal', $is_show, $is_type_show);
  1285. $result = array('code' =>0,'data' => $category_list);
  1286. echo json_encode($result);
  1287. die();
  1288. }
  1289. /**
  1290. * 首页3*3布局列表
  1291. * @return [josn] [description]
  1292. */
  1293. public function get_category_col_list()
  1294. {
  1295. $_GPC = I('request.');
  1296. $head_id = $_GPC['head_id'];
  1297. if($head_id == 'undefined') $head_id = '';
  1298. $result = array();
  1299. $result['code'] = 1;
  1300. $cate_list = M('lionfish_comshop_goods_category')->field('id,name,banner')->where( "is_show = 1 and is_show_topic = 1 and cate_type='normal' " )->order('sort_order desc')->select();
  1301. if(empty($cate_list)) {
  1302. $result['msg'] = '无数据';
  1303. } else {
  1304. foreach ($cate_list as $key => &$val) {
  1305. if( !empty($val['banner']) )
  1306. {
  1307. $val['banner'] = tomedia($val['banner']);
  1308. }
  1309. $item = $this->get_category_col_list_item($val['id'], $head_id);
  1310. if($item){
  1311. $val['list'] = empty($item['list']) ? array() : $item['list'];
  1312. $val['full_reducemoney'] = $item['full_reducemoney'];
  1313. $val['full_money'] = $item['full_money'];
  1314. $val['is_open_fullreduction'] = $item['is_open_fullreduction'];
  1315. }
  1316. }
  1317. $result['code'] = 0;
  1318. $result['data'] = $cate_list;
  1319. }
  1320. echo json_encode($result);
  1321. die();
  1322. }
  1323. /**
  1324. * 获取3*3分类列表项目
  1325. * @return [type] [description]
  1326. */
  1327. private function get_category_col_list_item($gid, $head_id, $is_random=0){
  1328. $_GPC = I('request.');
  1329. $token = $_GPC['token'];
  1330. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1331. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1332. {
  1333. $member_id = 0;
  1334. }else{
  1335. $member_id = $weprogram_token['member_id'];
  1336. }
  1337. $now_time = time();
  1338. $where = " g.grounding =1 ";
  1339. $gids = D('Home/GoodsCategory')->get_index_goods_category($gid);
  1340. $gidArr = array();
  1341. $gidArr[] = $gid;
  1342. foreach ($gids as $key => $val) { $gidArr[] = $val['id']; }
  1343. $gid = implode(',', $gidArr);
  1344. if( !empty($head_id) && $head_id >0 )
  1345. {
  1346. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg," .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.goods_id = g.goods_id and g.cate_id in ({$gid}) and pg.head_id = {$head_id} order by pg.id desc ";
  1347. $goods_ids_arr = M()->query($sql_goods_ids);
  1348. $ids_arr = array();
  1349. foreach($goods_ids_arr as $val){ $ids_arr[] = $val['goods_id']; }
  1350. $goods_ids_nolimit_sql = "select pg.id from ".C('DB_PREFIX')."lionfish_comshop_goods as pg," .C('DB_PREFIX')."lionfish_comshop_goods_to_category as g where pg.id = g.goods_id and g.cate_id in ({$gid}) and pg.is_all_sale=1 ";
  1351. $goods_ids_nolimit_arr = M()->query($goods_ids_nolimit_sql);
  1352. if( !empty($goods_ids_nolimit_arr) )
  1353. {
  1354. foreach($goods_ids_nolimit_arr as $val){
  1355. $ids_arr[] = $val['id'];
  1356. }
  1357. }
  1358. $ids_str = implode(',',$ids_arr);
  1359. if( !empty($ids_str) )
  1360. {
  1361. $where .= " and g.id in ({$ids_str})";
  1362. } else{
  1363. $where .= " and 0 ";
  1364. }
  1365. }else{
  1366. $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 where pg.id = g.goods_id and g.cate_id in ({$gid}) ";
  1367. $goods_ids_nohead_arr = M()->query($goods_ids_nohead_sql);
  1368. $ids_arr = array();
  1369. if( !empty($goods_ids_nohead_arr) )
  1370. {
  1371. foreach($goods_ids_nohead_arr as $val){
  1372. $ids_arr[] = $val['id'];
  1373. }
  1374. }
  1375. $ids_str = implode(',',$ids_arr);
  1376. if( !empty($ids_str) )
  1377. {
  1378. $where .= " and g.id in ({$ids_str})";
  1379. } else{
  1380. $where .= " and 0 ";
  1381. }
  1382. }
  1383. // $where .= " and gc.begin_time <={$now_time} and gc.end_time > {$now_time} ";
  1384. $where .= " and gc.begin_time <={$now_time} ";
  1385. $where .= " and gc.is_new_buy=0 and gc.is_spike_buy = 0 and g.is_seckill = 0 ";
  1386. if($is_random == 1)
  1387. {
  1388. $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, 9,' rand() ');
  1389. }else{
  1390. $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, 9);
  1391. }
  1392. if( !empty($community_goods) )
  1393. {
  1394. $is_open_fullreduction = D('Home/Front')->get_config_by_name('is_open_fullreduction');
  1395. $full_money = D('Home/Front')->get_config_by_name('full_money');
  1396. $full_reducemoney = D('Home/Front')->get_config_by_name('full_reducemoney');
  1397. if(empty($full_reducemoney) || $full_reducemoney <= 0)
  1398. {
  1399. $is_open_fullreduction = 0;
  1400. }
  1401. $cart= D('Home/Car');
  1402. $list = array();
  1403. foreach($community_goods as $val)
  1404. {
  1405. $tmp_data = array();
  1406. $tmp_data['actId'] = $val['id'];
  1407. $goodsname = htmlspecialchars_decode($val['goodsname']);
  1408. $tmp_data['spuName'] = $goodsname;
  1409. $tmp_data['spuCanBuyNum'] = $val['total'];
  1410. $tmp_data['spuDescribe'] = $val['subtitle'];
  1411. $tmp_data['end_time'] = $val['end_time'];
  1412. $tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  1413. $tmp_data['actEnd'] = time()>$val['end_time'];
  1414. $tmp_data['oneday_limit_count'] = $val['oneday_limit_count'];
  1415. $tmp_data['total_limit_count'] = $val['total_limit_count'];
  1416. $tmp_data['one_limit_count'] = $val['one_limit_count'];
  1417. $tmp_data['goods_start_count'] = $val['goods_start_count'];
  1418. $productprice = $val['productprice'];
  1419. $tmp_data['marketPrice'] = explode('.', $productprice);
  1420. if( !empty($val['big_img']) )
  1421. {
  1422. $tmp_data['bigImg'] = tomedia($val['big_img']);
  1423. }
  1424. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  1425. if( !empty($good_image) )
  1426. {
  1427. $tmp_data['skuImage'] = tomedia($good_image['image']);
  1428. }
  1429. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'], $member_id);
  1430. $price = $price_arr['price'];
  1431. $tmp_data['actPrice'] = explode('.', $price);
  1432. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1433. if( !empty($tmp_data['skuList']) )
  1434. {
  1435. $tmp_data['car_count'] = 0;
  1436. }else{
  1437. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1438. if( empty($car_count) )
  1439. {
  1440. $tmp_data['car_count'] = 0;
  1441. }else{
  1442. $tmp_data['car_count'] = $car_count;
  1443. }
  1444. }
  1445. if($is_open_fullreduction == 0)
  1446. {
  1447. $tmp_data['is_take_fullreduction'] = 0;
  1448. }else if($is_open_fullreduction == 1){
  1449. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1450. }
  1451. // 商品角标
  1452. $label_id = unserialize($val['labelname']);
  1453. if($label_id){
  1454. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1455. if($label_info){
  1456. if($label_info['type'] == 1){
  1457. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1458. } else {
  1459. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1460. }
  1461. }
  1462. $tmp_data['label_info'] = $label_info;
  1463. }
  1464. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1465. $list[] = $tmp_data;
  1466. }
  1467. $res = array();
  1468. $res['list'] = $list;
  1469. $res['full_reducemoney'] = $full_reducemoney;
  1470. $res['full_money'] = $full_money;
  1471. $res['is_open_fullreduction'] = $is_open_fullreduction;
  1472. return $res;
  1473. } else {
  1474. return false;
  1475. }
  1476. }
  1477. public function check_goods_community_canbuy()
  1478. {
  1479. $_GPC = I('request.');
  1480. $goods_id = $_GPC['goods_id'];
  1481. $community_id = $_GPC['community_id'];
  1482. $is_canshow = D('Seller/Communityhead')->check_goods_can_community($goods_id, $community_id);
  1483. if( $is_canshow )
  1484. {
  1485. echo json_encode( array('code' => 0) );
  1486. die();
  1487. }else{
  1488. echo json_encode( array('code' => 1) );
  1489. die();
  1490. }
  1491. }
  1492. //猜你喜欢
  1493. public function goods_guess_like()
  1494. {
  1495. $_GPC = I('request.');
  1496. //猜你喜欢开关
  1497. $show_goods_guess_like= D('Home/Front')->get_config_by_name('show_goods_guess_like' );
  1498. if( empty($show_goods_guess_like) )
  1499. {
  1500. $show_goods_guess_like = 0;
  1501. }
  1502. $token = $_GPC['token'];
  1503. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1504. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1505. {
  1506. $member_id = 0;
  1507. }else{
  1508. $member_id = $weprogram_token['member_id'];
  1509. }
  1510. //显示数量
  1511. $num_guess_like= D('Home/Front')->get_config_by_name('num_guess_like' );
  1512. if( empty($num_guess_like) )
  1513. {
  1514. $num_guess_like = 8;
  1515. }
  1516. $goods_id = $_GPC['id'];
  1517. $community_id = $_GPC['head_id'];
  1518. $token = $_GPC['token'];
  1519. $now_time = time();
  1520. if(!empty($community_id)){
  1521. //有社区
  1522. $head_info = M('lionfish_community_head')->field('id')->where( array('id' => $community_id ) )->find();
  1523. //团长商品和全部可售
  1524. //lionfish_community_head_goods
  1525. //&head_id=303&id=317
  1526. $head_goods= M('lionfish_community_head_goods')->field('goods_id')->where( array('head_id' => $head_info['id'] ) )->select();
  1527. foreach ($head_goods as $hg) {
  1528. $hg = join(",",$hg);
  1529. $temp_array[] = $hg;
  1530. }
  1531. //团长商品id
  1532. $goods_id_list = implode(",", $temp_array);
  1533. $likegoods_list = array();
  1534. if( !empty($goods_id_list) )
  1535. {
  1536. $sql_likegoods = "select g.*,gc.end_time,gc.begin_time,gc.oneday_limit_count,gc.total_limit_count,gc.one_limit_count,gc.goods_start_count from ".C('DB_PREFIX')."lionfish_comshop_goods as g,".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  1537. where g.id = gc.goods_id and gc.begin_time <={$now_time} and gc.end_time > {$now_time} and (g.grounding =1 or g.id in (".$goods_id_list.") and g.id <> ".$goods_id." ) and g.type = 'normal' and g.is_all_sale = 1 order by rand() limit ".$num_guess_like;
  1538. $likegoods_list = M()->query($sql_likegoods);
  1539. }else{
  1540. $sql_likegoods = "select g.*,gc.end_time,gc.begin_time,gc.oneday_limit_count,gc.total_limit_count,gc.one_limit_count,gc.goods_start_count from ".C('DB_PREFIX')."lionfish_comshop_goods as g,".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  1541. where g.id = gc.goods_id and gc.begin_time <={$now_time} and gc.end_time > {$now_time} and (g.grounding =1 and g.id <> ".$goods_id." ) and g.type = 'normal' and g.is_all_sale = 1 order by rand() limit ".$num_guess_like;
  1542. $likegoods_list = M()->query($sql_likegoods);
  1543. }
  1544. }else{
  1545. //无社区
  1546. $sql_likegoods = "select g.*,gc.end_time,gc.begin_time,gc.oneday_limit_count,gc.total_limit_count,gc.one_limit_count,gc.goods_start_count from ".C('DB_PREFIX')."lionfish_comshop_goods as g,".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  1547. where g.id = gc.goods_id and gc.begin_time <={$now_time} and gc.end_time > {$now_time} and g.grounding =1 and g.type = 'normal' and g.id <> ".$goods_id." order by rand() limit ".$num_guess_like;
  1548. $likegoods_list = M()->query($sql_likegoods);
  1549. }
  1550. if( !empty($likegoods_list) )
  1551. {
  1552. $list = array();
  1553. foreach($likegoods_list as $val)
  1554. {
  1555. $tmp_data = array();
  1556. $tmp_data['actId'] = $val['id'];
  1557. $tmp_data['spuName'] = $val['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. if( $pageNum == 1 )
  1580. {
  1581. $copy_text_arr[] = array('goods_name' => $val['goodsname'], 'price' => $price);
  1582. }
  1583. $tmp_data['actPrice'] = explode('.', $price);
  1584. $tmp_data['danPrice'] = $price_arr['danprice'];
  1585. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'],$member_id);
  1586. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($val['id'], $member_id, $community_id ,$token);
  1587. if( !empty($tmp_data['skuList']) )
  1588. {
  1589. $tmp_data['car_count'] = 0;
  1590. }else{
  1591. //$car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  1592. $car_count = 0;
  1593. if( empty($car_count) )
  1594. {
  1595. $tmp_data['car_count'] = 0;
  1596. }else{
  1597. $tmp_data['car_count'] = $car_count;
  1598. }
  1599. }
  1600. if($is_open_fullreduction == 0)
  1601. {
  1602. $tmp_data['is_take_fullreduction'] = 0;
  1603. }else if($is_open_fullreduction == 1){
  1604. $tmp_data['is_take_fullreduction'] = $val['is_take_fullreduction'];
  1605. }
  1606. // 商品角标
  1607. $label_id = unserialize($val['labelname']);
  1608. if($label_id){
  1609. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  1610. if($label_info){
  1611. if($label_info['type'] == 1){
  1612. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  1613. } else {
  1614. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  1615. }
  1616. }
  1617. $tmp_data['label_info'] = $label_info;
  1618. }
  1619. $tmp_data['is_video'] = empty($val['video']) ? false : true;
  1620. $list[] = $tmp_data;
  1621. }
  1622. }
  1623. echo json_encode(array('code'=>0,
  1624. 'show_goods_guess_like' => $show_goods_guess_like,
  1625. 'list' => $list,
  1626. )
  1627. );
  1628. die();
  1629. }
  1630. /**
  1631. * 视频列表分享信息
  1632. * @return [type] [description]
  1633. */
  1634. public function get_video_list_share()
  1635. {
  1636. $_GPC = I('request.');
  1637. $res = array();
  1638. $res['nav_title'] = D('Home/Front')->get_config_by_name('videolist_nav_title');
  1639. $res['share_title'] = D('Home/Front')->get_config_by_name('videolist_share_title');
  1640. $res['share_poster'] = '';
  1641. $videolist_share_poster = D('Home/Front')->get_config_by_name('videolist_share_poster');
  1642. if($videolist_share_poster)
  1643. $res['share_poster'] = tomedia($videolist_share_poster);
  1644. echo json_encode(array('code'=>0, 'data' => $res));
  1645. die();
  1646. }
  1647. }