GoodsController.class.php 72 KB

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