SolitaireController.class.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  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 SolitaireController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. /**
  21. 获取团长群接龙的列表,分页
  22. **/
  23. public function get_head_solitairelist()
  24. {
  25. $_GPC = I('request.');
  26. $token = $_GPC['token'];
  27. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  28. $member_id = $weprogram_token['member_id'];
  29. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  30. if( empty($member_info) )
  31. {
  32. // 未登录
  33. echo json_encode( array('code' => 2) );
  34. die();
  35. }
  36. $community_info = D('Home/Front')->get_member_community_info($member_id);
  37. if( empty($community_info) || $community_info['state'] != 1 )
  38. {
  39. echo json_encode( array('code' => 3 , 'msg' => '团长不存在' ) );
  40. die();
  41. }
  42. $head_id = $community_info['id'];
  43. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  44. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  45. $offset = ($page - 1)* $size;
  46. //
  47. $where = " and head_id = {$head_id} ";
  48. $keyword = isset($_GPC['keyword']) ? addslashes($_GPC['keyword']) : '';
  49. if( !empty($keyword) )
  50. {
  51. $where .= " and solitaire_name like '%{$keyword}%' ";
  52. }
  53. $sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_solitaire
  54. where 1 {$where}
  55. order by id desc limit {$offset},{$size}";
  56. $list = M()->query($sql);
  57. if( !empty( $list ) )
  58. {
  59. $need_data = array();
  60. $now_time = time();
  61. foreach( $list as $key => $val )
  62. {
  63. $tmp_arr = array();
  64. $tmp_arr['id'] = $val['id'];
  65. $tmp_arr['solitaire_name'] = $val['solitaire_name'];
  66. $tmp_arr['begin_time'] = date('Y-m-d', $val['begin_time']);
  67. $tmp_arr['state'] = $val['state'];
  68. $tmp_arr['appstate'] = $val['appstate'];
  69. $tmp_arr['state_str'] = '';
  70. if( $val['appstate'] == 0 )
  71. {
  72. $tmp_arr['state_str'] = '等待平台审核';
  73. }else if( $val['appstate'] == 1 ){
  74. if( $val['state'] == 0 )
  75. {
  76. $tmp_arr['state_str'] = '已禁用';
  77. }else if( $val['end'] == 1 ){
  78. $tmp_arr['state_str'] = '已终止';
  79. }else if( $val['state'] == 1 ){
  80. if( $val['begin_time'] > $now_time )
  81. {
  82. $tmp_arr['state_str'] = '未开始';
  83. }else if( $val['begin_time'] < $now_time && $val['end_time'] > $now_time )
  84. {
  85. $tmp_arr['state_str'] = '进行中';
  86. }else if( $val['end_time'] < $now_time ){
  87. $tmp_arr['state_str'] = '已结束';
  88. }
  89. }
  90. }else if( $val['appstate'] == 2 ){
  91. $tmp_arr['state_str'] = '平台拒绝';
  92. }
  93. //几人看过 //几人参加
  94. $order_count = M('lionfish_comshop_solitaire_order')->where( array('soli_id' => $val['id'] ) )->count();
  95. $tmp_arr['order_count'] = $order_count;
  96. $invite_count = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $val['id'] ) )->count();
  97. $tmp_arr['invite_count'] = $invite_count;
  98. $need_data[$key] = $tmp_arr;
  99. }
  100. echo json_encode( array('code' => 0, 'data' => $need_data ) );
  101. die();
  102. }else{
  103. echo json_encode( array('code' => 1) );
  104. die();
  105. }
  106. }
  107. /**
  108. 获取团长基本信息
  109. **/
  110. public function get_solitaire_headinfo()
  111. {
  112. $_GPC = I('request.');
  113. $token = $_GPC['token'];
  114. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  115. $member_id = $weprogram_token['member_id'];
  116. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  117. if( empty($member_info) )
  118. {
  119. // 未登录
  120. echo json_encode( array('code' => 1) );
  121. die();
  122. }
  123. $community_info = D('Home/Front')->get_member_community_info($member_id);
  124. if( empty($community_info) || $community_info['state'] != 1 )
  125. {
  126. echo json_encode( array('code' => 3 , 'msg' => '团长不存在' ) );
  127. die();
  128. }
  129. $community_info['avatar'] = $member_info['avatar'];
  130. $need_data = array();
  131. $need_data['community_name'] = $community_info['community_name'];//绑定小区
  132. $need_data['head_name'] = $community_info['head_name'];//团长昵称
  133. $need_data['avatar'] = $community_info['avatar'];//头像
  134. echo json_encode( array('code' =>0, 'data' => $need_data ) );
  135. die();
  136. }
  137. /***
  138. 搜索团长可售 商品
  139. **/
  140. public function search_head_goodslist()
  141. {
  142. $_GPC = I('request.');
  143. $token = $_GPC['token'];
  144. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  145. $member_id = $weprogram_token['member_id'];
  146. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  147. if( empty($member_info) )
  148. {
  149. // 未登录
  150. echo json_encode( array('code' => 2) );
  151. die();
  152. }
  153. $community_info = D('Home/Front')->get_member_community_info($member_id);
  154. if( empty($community_info) || $community_info['state'] != 1 )
  155. {
  156. echo json_encode( array('code' => 3 , 'msg' => '团长不存在' ) );
  157. die();
  158. }
  159. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  160. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  161. $offset = ($page - 1)* $size;
  162. $head_id = $community_info['id'];
  163. $kwd = trim($_GPC['keyword']);
  164. $is_recipe = 0;
  165. $is_only_express = isset($_GPC['is_only_express']) ? intval($_GPC['is_only_express']) : 0;
  166. $is_soli = 1;
  167. $type = 'normal';
  168. $condition = ' and g.type = "'.$type.'" and g.grounding = 1 and g.is_seckill = 0 ';
  169. if( $is_only_express == 1 )
  170. {
  171. $condition .= ' and gc.is_only_express=1 ';
  172. }else{
  173. $condition .= ' and gc.is_only_express=0 ';
  174. }
  175. if (!empty($kwd)) {
  176. $condition .= ' AND `g.goodsname` LIKE "%'.$kwd.'%"';
  177. }
  178. if( $is_soli == 1 )
  179. {
  180. $sql_goods_ids = "select pg.goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods as pg
  181. where pg.head_id = {$head_id} order by pg.id desc ";
  182. $goods_ids_arr = M()->query($sql_goods_ids);
  183. $ids_arr = array();
  184. foreach($goods_ids_arr as $val){
  185. $ids_arr[] = $val['goods_id'];
  186. }
  187. if( !empty($ids_arr) )
  188. {
  189. $ids_str = implode(',',$ids_arr);
  190. $condition .= " and ( g.is_all_sale = 1 or g.id in ({$ids_str}) ) ";
  191. }else{
  192. $condition .= " and ( g.is_all_sale = 1 ) ";
  193. }
  194. //is_all_sale
  195. }
  196. //todo.... g.
  197. $ds = M()->query("SELECT g.id as gid, g.goodsname, g.subtitle, g.price, g.productprice,g.seller_count ,g.sales,g.total,gc.end_time FROM " .
  198. C('DB_PREFIX'). 'lionfish_comshop_goods as g left join '.C('DB_PREFIX').'lionfish_comshop_good_common as gc on g.id =gc.goods_id
  199. WHERE 1 ' . $condition . ' order by g.id desc limit '.$offset.','.$size );
  200. //$tmp_data['soldNum'] = $val['seller_count'] + $val['sales'];
  201. $now_time = time();
  202. foreach ($ds as $key => $d) {
  203. //thumb
  204. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $d['gid']) )->order('id asc')->find();
  205. $d['thumb'] = tomedia($thumb['image']);
  206. $d['seller_count'] = $d['seller_count'] + $d['sales'];
  207. $d['is_over'] = 0;
  208. //end_time
  209. if( $d['end_time'] <= $now_time)
  210. {
  211. $d['is_over'] = 1;
  212. }
  213. unset($d['sales']);
  214. $ds[$key] = $d;
  215. }
  216. if( !empty($ds) )
  217. {
  218. echo json_encode( array('code' => 0, 'data' => $ds ) );
  219. die();
  220. }else{
  221. echo json_encode( array('code' => 1) );
  222. die();
  223. }
  224. }
  225. /**
  226. 团长发布群接龙
  227. **/
  228. public function sub_head_solitaire()
  229. {
  230. $_GPC = I('request.');
  231. $token = $_GPC['token'];
  232. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  233. $member_id = $weprogram_token['member_id'];
  234. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  235. if( empty($member_info) )
  236. {
  237. // 未登录
  238. echo json_encode( array('code' => 2) );
  239. die();
  240. }
  241. $community_info = D('Home/Front')->get_member_community_info($member_id);
  242. $solitaire_is_needexamine = D('Home/Front')->get_config_by_name('solitaire_is_needexamine');
  243. if( empty($solitaire_is_needexamine) )
  244. {
  245. $solitaire_is_needexamine = 0;
  246. }
  247. if( empty($community_info) || $community_info['state'] != 1 )
  248. {
  249. echo json_encode( array('code' => 3 , 'msg' => '团长不存在' ) );
  250. die();
  251. }
  252. $head_id = $community_info['id'];
  253. $solitaire_name = htmlspecialchars( $_GPC['title'] );
  254. $images_list_str = $_GPC['images_list'];
  255. $images_list = explode(',', $images_list_str);
  256. $addtype = 1;
  257. $appstate = $solitaire_is_needexamine == 1 ? 0 : 1;//是否需要审核
  258. $state = 1;//状态
  259. $begin_time = $_GPC['begin_time'];
  260. $end_time = $_GPC['end_time'];
  261. $content = htmlspecialchars( $_GPC['content'] );
  262. $goods_list = $_GPC['goods_list'];//'1,2,3,4'
  263. if( empty($solitaire_name) )
  264. {
  265. echo json_encode( array('code' => 1, 'msg' => '请填写接龙标题') );
  266. die();
  267. }
  268. if( empty($content) )
  269. {
  270. echo json_encode( array('code' => 1, 'msg' => '请填写接龙内容') );
  271. die();
  272. }
  273. if( empty($goods_list) )
  274. {
  275. echo json_encode( array('code' => 1, 'msg' => '请选择商品') );
  276. die();
  277. }
  278. if( empty($begin_time) )
  279. {
  280. echo json_encode( array('code' => 1, 'msg' => '请选择开始时间') );
  281. die();
  282. }
  283. if( empty($end_time) )
  284. {
  285. echo json_encode( array('code' => 1, 'msg' => '请选择结束时间') );
  286. die();
  287. }
  288. $data = array();
  289. $data['id'] = 0;
  290. $data['solitaire_name'] = $solitaire_name;
  291. $data['state'] = $state;
  292. $data['content'] = $content;
  293. $need_data = array();
  294. $need_data['data'] = $data;
  295. $need_data['images_list'] = $images_list;
  296. $need_data['time']['start'] = $begin_time;
  297. $need_data['time']['end'] = $end_time;
  298. $need_data['goods_list'] = $goods_list;
  299. $need_data['head_id'] = $head_id;
  300. $need_data['head_dan_id'] = $head_id;
  301. D('Seller/Solitaire')->updatedo($need_data, $_W['uniacid'] ,$addtype , $appstate );
  302. echo json_encode( array('code' => 0) );
  303. die();
  304. }
  305. /**
  306. 获取用户查看 团长群接龙的列表
  307. **/
  308. public function get_head_index_solitairelist()
  309. {
  310. $_GPC = I('request.');
  311. $head_id = $_GPC['head_id'];
  312. $community_info = M('lionfish_community_head')->where( array('id' => $head_id ) )->find();
  313. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $community_info['member_id']) )->find();
  314. //$community_info = load_model_class('front')->get_member_community_info($member_id);
  315. if( empty($community_info) || $community_info['state'] != 1 )
  316. {
  317. echo json_encode( array('code' => 3 , 'msg' => '团长不存在' ) );
  318. die();
  319. }
  320. $community_info['avatar'] = $member_info['avatar'];
  321. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  322. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  323. $offset = ($page - 1)* $size;
  324. //
  325. $where = " and state = 1 and appstate = 1 and head_id = {$head_id} ";
  326. $keyword = isset($_GPC['keyword']) ? addslashes($_GPC['keyword']) : '';
  327. if( !empty($keyword) )
  328. {
  329. $where .= " and solitaire_name like '%{$keyword}%' ";
  330. }
  331. $sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_solitaire
  332. where 1 {$where}
  333. order by id desc limit {$offset},{$size}";
  334. $list = M()->query($sql);
  335. $head_data = array();
  336. $head_data['head_id'] = $head_id;//绑定小区
  337. $head_data['community_name'] = $community_info['community_name'];//绑定小区
  338. $head_data['head_name'] = $community_info['head_name'];//团长昵称
  339. $head_data['avatar'] = $community_info['avatar'];//头像
  340. $showTabbar = false;
  341. $tabbar_out_type = D('Home/Front')->get_config_by_name('tabbar_out_type');
  342. $tabbar_out_link = D('Home/Front')->get_config_by_name('tabbar_out_link');
  343. if($tabbar_out_type==6 || ($tabbar_out_type==1 && $tabbar_out_link == '/lionfish_comshop/moduleA/solitaire/index'))
  344. $showTabbar = true;
  345. if( !empty( $list ) )
  346. {
  347. $need_data = array();
  348. $now_time = time();
  349. foreach( $list as $key => $val )
  350. {
  351. $tmp_arr = array();
  352. $tmp_arr['id'] = $val['id'];
  353. $tmp_arr['solitaire_name'] = $val['solitaire_name'];
  354. $tmp_arr['begin_time'] = date('Y-m-d', $val['begin_time']);
  355. $tmp_arr['end_time'] = date('Y-m-d', $val['end_time']);
  356. $state_str = '';
  357. $state = 0;
  358. if($val['end']==0){
  359. if( $val['begin_time'] > $now_time )
  360. {
  361. $state_str = '未开始';
  362. }else if( $val['begin_time'] <= $now_time && $val['end_time'] > $now_time )
  363. {
  364. $state = 1;
  365. $state_str = '进行中';
  366. }else if( $val['end_time'] < $now_time ){
  367. $state_str = '已结束';
  368. $state = 2;
  369. }
  370. } else {
  371. $state_str = '已结束';
  372. $state = 2;
  373. }
  374. $tmp_arr['state'] = $state;
  375. $tmp_arr['state_str'] = $state_str;
  376. //接龙图片
  377. $images_list = unserialize($val['images_list']);
  378. if( empty($images_list) )
  379. {
  380. $images_list = array();
  381. }
  382. if( !empty($images_list) && is_array($images_list) )
  383. {
  384. foreach( $images_list as $kk => $vv )
  385. {
  386. $vv = tomedia( $vv );
  387. $images_list[$kk] = $vv;
  388. }
  389. }
  390. $tmp_arr['images_list'] = $images_list;
  391. //几人看过 //几人参加
  392. $order_count = $invite_count = 0;
  393. $invite_list = array();
  394. if($state!==0) {
  395. $order_count = M('lionfish_comshop_solitaire_order')->where( array('soli_id' => $val['id'] ) )->count();
  396. $invite_count = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $val['id'] ) )->count();
  397. //访问人头像列表
  398. $avatar_sql = "select A.id, B.avatar from ".C('DB_PREFIX')."lionfish_comshop_solitaire_invite AS A, ".C('DB_PREFIX')."lionfish_comshop_member AS B where A.soli_id={$val['id']} AND A.member_id=B.member_id group by A.member_id limit 6";
  399. $invite_list = M()->query($avatar_sql);
  400. }
  401. $tmp_arr['order_count'] = $order_count;
  402. $tmp_arr['invite_list'] = $invite_list;
  403. $tmp_arr['invite_count'] = $invite_count;
  404. $need_data[$key] = $tmp_arr;
  405. }
  406. echo json_encode( array('code' => 0,'head_data' => $head_data, 'data' => $need_data, 'showTabbar' => $showTabbar ) );
  407. die();
  408. }else{
  409. echo json_encode( array('code' => 1, 'head_data' => $head_data, 'showTabbar' => $showTabbar ) );
  410. die();
  411. }
  412. }
  413. /**
  414. 接龙详情接口
  415. **/
  416. public function get_solitaire_detail()
  417. {
  418. $_GPC = I('request.');
  419. $id = intval( $_GPC['id'] );
  420. $token = isset( $_GPC['token'] ) ? $_GPC['token']:'';
  421. $is_head = isset( $_GPC['is_head'] ) ? $_GPC['is_head']:0;
  422. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  423. $member_id = $weprogram_token['member_id'];
  424. $is_Login = true;
  425. if(empty($weprogram_token) || empty($member_id)) $is_Login = false;
  426. $soli_info = M('lionfish_comshop_solitaire')->where( array('id' => $id ) )->find();
  427. if( empty($soli_info) || $soli_info['state'] != 1 )
  428. {
  429. echo json_encode( array('code' => 1 , 'msg' => '接龙不存在' ) );
  430. die();
  431. }
  432. if(!empty($soli_info['content']))
  433. $soli_info['content'] = htmlspecialchars_decode($soli_info['content']);
  434. // 团长信息
  435. $head_id = $soli_info['head_id'];
  436. $community_info = M('lionfish_community_head')->where( array('id' => $head_id ) )->find();
  437. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $community_info['member_id'] ) )->find();
  438. //$soli_info['is_involved'] = false; //是否参与
  439. // 团长中心详情
  440. if($is_head==1) {
  441. if(!$is_Login)
  442. {
  443. echo json_encode( array('code' => 2, 'msg'=>"团长未登录") );
  444. die();
  445. }
  446. // 团长访问非本团详情
  447. if(empty($community_info['member_id']) || $community_info['member_id'] != $member_id)
  448. {
  449. echo json_encode( array('code' => 1, 'msg'=>"接龙不存在") );
  450. die();
  451. }
  452. } else {
  453. //是否已参与
  454. //if($is_Login) {
  455. // $involved = M('lionfish_comshop_order')->where( "member_id={$member_id} and soli_id={$id} and order_status_id in (1,4,6,7,11,12,14)" )->find();
  456. // if(!empty($involved)) $soli_info['is_involved'] = true;
  457. //}
  458. }
  459. if( empty($soli_info['qrcode_image']))
  460. {
  461. $path = "lionfish_comshop/moduleA/solitaire/details"; // 首页地址测试
  462. $scene = $soli_info['id']."_".$member_id;
  463. $qrcode_image = D('Home/Pingoods')->_get_commmon_wxqrcode($path, $scene);
  464. M('lionfish_comshop_solitaire')->where( array('id' => $soli_info['id'] ) )->save( array('qrcode_image' => $qrcode_image) );
  465. $soli_info['qrcode_image'] = tomedia($qrcode_image);
  466. }else{
  467. $soli_info['qrcode_image'] = tomedia($soli_info['qrcode_image']);
  468. }
  469. $head_data = array();
  470. $head_data['head_id'] = $head_id;//绑定小区
  471. $head_data['community_name'] = $community_info['community_name'];//绑定小区
  472. $head_data['head_name'] = $community_info['head_name'];//团长昵称
  473. $head_data['avatar'] = $member_info['avatar'];//头像
  474. $order_count = M('lionfish_comshop_solitaire_order')->where( array('soli_id' => $id ) )->count();
  475. $invite_count = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $id ) )->count();
  476. //lionfish_comshop_solitaire_order soli_id order_id
  477. //sum(total+shipping_fare-voucher_credit-fullreduction_money) as total
  478. $sql = "select sum(o.total+o.shipping_fare-o.voucher_credit-o.fullreduction_money) as total from
  479. ".C('DB_PREFIX')."lionfish_comshop_solitaire_order as so, ".C('DB_PREFIX')."lionfish_comshop_order as o
  480. where o.order_id = so.order_id and so.soli_id={$id} and o.order_status_id in (1,4,6,7,11,14) ";
  481. $soli_total_money_arr = M()->query($sql);
  482. $soli_total_money = $soli_total_money_arr[0]['total'];
  483. $soli_info['content'] = htmlspecialchars_decode($soli_info['content']);
  484. $soli_info['order_count'] = $order_count;
  485. $soli_info['invite_count'] = $invite_count;
  486. $soli_info['soli_total_money'] = $soli_total_money;
  487. $soli_info['begin_time_str'] = date('Y-m-d H:i:s', $soli_info['begin_time'] );
  488. $soli_info['end_time_str'] = date('Y-m-d H:i:s', $soli_info['end_time'] );
  489. $soli_info['now_time'] = time();
  490. $soli_info['activity_state'] = 0;// 0未开始 ,1进行中,2已过期
  491. $now_time = time();
  492. if( $soli_info['begin_time'] > $now_time )
  493. {
  494. $soli_info['activity_state'] = 0;
  495. }else if( $soli_info['begin_time'] <= $now_time && $soli_info['end_time'] > $now_time )
  496. {
  497. $soli_info['activity_state'] = 1;
  498. }else if( $soli_info['end_time'] < $now_time ){
  499. $soli_info['activity_state'] = 2;
  500. }
  501. //$ims_
  502. $solitaire_goods_arr = M('lionfish_comshop_solitaire_goods')->field('goods_id')->where( array('soli_id' => $id ) )->order('id asc')->select();
  503. $solitaire_goods_str = "";
  504. $soli_info['goods_list'] = array();
  505. if( !empty( $solitaire_goods_arr ) )
  506. {
  507. $tp_arr = array();
  508. foreach( $solitaire_goods_arr as $val )
  509. {
  510. $tp_arr[] = $val['goods_id'];
  511. }
  512. $solitaire_goods_str = implode(',', $tp_arr );
  513. $gd_info_list = M()->query('select g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video from
  514. '.C('DB_PREFIX')."lionfish_comshop_goods as g ,".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  515. where g.id in(".$solitaire_goods_str.") and g.id =gc.goods_id ");
  516. $goods_data = array();
  517. $cart = D('Home/Car');
  518. foreach($gd_info_list as $gd_info )
  519. {
  520. $tmp_data = array();
  521. $tmp_data['actId'] = $gd_info['id'];
  522. $tmp_data['spuName'] = $gd_info['goodsname'];
  523. $tmp_data['spuCanBuyNum'] = $gd_info['total'];
  524. $tmp_data['spuDescribe'] = $gd_info['subtitle'];
  525. $tmp_data['is_take_vipcard'] = $gd_info['is_take_vipcard'];
  526. $tmp_data['soldNum'] = $gd_info['seller_count'] + $gd_info['sales'];
  527. $productprice = $gd_info['productprice'];
  528. $tmp_data['marketPrice'] = explode('.', $productprice);
  529. if( !empty($gd_info['big_img']) )
  530. {
  531. $tmp_data['bigImg'] = tomedia($gd_info['big_img']);
  532. }
  533. $good_image = D('Home/Pingoods')->get_goods_images($gd_info['id']);
  534. if( !empty($good_image) )
  535. {
  536. $tmp_data['skuImage'] = tomedia($good_image['image']);
  537. }
  538. $price_arr = D('Home/Pingoods')->get_goods_price($gd_info['id'], $member_id);
  539. $price = $price_arr['price'];
  540. if( $pageNum == 1 )
  541. {
  542. $copy_text_arr[] = array('goods_name' => $gd_info['goodsname'], 'price' => $price);
  543. }
  544. $tmp_data['actPrice'] = explode('.', $price);
  545. $tmp_data['card_price'] = $price_arr['card_price'];
  546. //card_price $id
  547. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($gd_info['id'],$member_id);
  548. if( !empty($tmp_data['skuList']) )
  549. {
  550. $tmp_data['car_count'] = 0;
  551. }else{
  552. $car_count = $cart->get_wecart_goods($gd_info['id'],"",$head_id ,$token);
  553. if( empty($car_count) )
  554. {
  555. $tmp_data['car_count'] = 0;
  556. }else{
  557. $tmp_data['car_count'] = $car_count;
  558. }
  559. }
  560. $goods_total_count = $cart->get_wecart_goods_solicount($gd_info['id'], $head_id,$token, $id );
  561. $tmp_data['goods_total_count'] = $goods_total_count;
  562. if($is_open_fullreduction == 0)
  563. {
  564. $tmp_data['is_take_fullreduction'] = 0;
  565. }else if($is_open_fullreduction == 1){
  566. $tmp_data['is_take_fullreduction'] = $gd_info['is_take_fullreduction'];
  567. }
  568. // 商品角标
  569. $label_id = unserialize($gd_info['labelname']);
  570. if($label_id){
  571. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  572. if($label_info){
  573. if($label_info['type'] == 1){
  574. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  575. } else {
  576. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  577. }
  578. }
  579. $tmp_data['label_info'] = $label_info;
  580. }
  581. $tmp_data['is_video'] = false;
  582. $goods_data[] = $tmp_data;
  583. }
  584. $soli_info['goods_list'] = $goods_data;
  585. }
  586. //接龙图片
  587. $images_list = unserialize($soli_info['images_list']);
  588. if( empty($images_list) )
  589. {
  590. $images_list = array();
  591. }
  592. if( !empty($images_list) )
  593. {
  594. foreach( $images_list as $kk => $vv )
  595. {
  596. $vv = tomedia( $vv );
  597. $images_list[$kk] = $vv;
  598. }
  599. }
  600. $soli_info['images_list'] = $images_list;
  601. //
  602. $solitaire_target = D('Home/Front')->get_config_by_name('solitaire_target');
  603. if( empty($solitaire_target) )
  604. {
  605. $solitaire_target = 0; //是否开启目标
  606. }
  607. $solitaire_target_type = D('Home/Front')->get_config_by_name('solitaire_target_type');
  608. if( empty($solitaire_target_type) )
  609. {
  610. $solitaire_target_type = 0;
  611. }//0 参与人数, 1接龙金额
  612. $solitaire_target_takemember = D('Home/Front')->get_config_by_name('solitaire_target_takemember');
  613. if( empty($solitaire_target_takemember) )
  614. {
  615. $solitaire_target_takemember = 0;
  616. }
  617. // 参与人数
  618. //solitaire_target_takemoney 接龙金额
  619. $solitaire_target_takemoney = D('Home/Front')->get_config_by_name('solitaire_target_takemoney');
  620. if( empty($solitaire_target_takemoney) )
  621. {
  622. $solitaire_target_takemoney =0;
  623. }
  624. $solitaire_notice = D('Home/Front')->get_config_by_name('solitaire_notice');
  625. $solitaire_notice = htmlspecialchars_decode( $solitaire_notice );
  626. $soli_info['comment_total'] = M('lionfish_comshop_solitaire_post')->where( array('soli_id' => $id, 'pid' => 0 ) )->count();
  627. echo json_encode( array('code' => 0,
  628. 'head_data' => $head_data,
  629. 'solitaire_target' => $solitaire_target,
  630. 'solitaire_target_type' => $solitaire_target_type,
  631. 'solitaire_target_takemoney' => $solitaire_target_takemoney,
  632. 'solitaire_target_takemember' => $solitaire_target_takemember,
  633. 'solitaire_notice' => $solitaire_notice,
  634. 'soli_info' => $soli_info
  635. ) );
  636. die();
  637. }
  638. /**
  639. 增加访问量接口
  640. **/
  641. public function send_visite_record()
  642. {
  643. $_GPC = I('request.');
  644. $token = $_GPC['token'];
  645. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  646. $member_id = $weprogram_token['member_id'];
  647. if( empty($member_id) )
  648. {
  649. // 未登录
  650. echo json_encode( array('code' => 1) );
  651. die();
  652. }
  653. $soli_id = $_GPC['soli_id'];
  654. $ck_info = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $soli_id, 'member_id' => $member_id ) )->find();
  655. if( !empty($ck_info) )
  656. {
  657. echo json_encode( array('code' => 1, 'msg' => '已加入') );
  658. die();
  659. }
  660. $ins_data = array();
  661. $ins_data['uniacid'] = 0;
  662. $ins_data['soli_id'] = $soli_id;
  663. $ins_data['member_id'] = $member_id;
  664. $ins_data['addtime'] = time();
  665. M('lionfish_comshop_solitaire_invite')->add($ins_data);
  666. echo json_encode( array('code' => 0) );
  667. die();
  668. }
  669. /**
  670. 评价群接龙
  671. **/
  672. public function sub_solipost()
  673. {
  674. $_GPC = I('request.');
  675. $token = $_GPC['token'];
  676. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  677. $member_id = $weprogram_token['member_id'];
  678. if( empty($member_id) )
  679. {
  680. // 未登录
  681. echo json_encode( array('code' => 1) );
  682. die();
  683. }
  684. $soli_id = isset($_GPC['soli_id']) ? intval($_GPC['soli_id']) : 0 ;
  685. $pid = isset($_GPC['pid']) ? intval($_GPC['pid']) : 0;
  686. $content = isset($_GPC['content']) ? htmlspecialchars($_GPC['content']) : '';
  687. if( empty($soli_id) || $soli_id <=0 )
  688. {
  689. echo json_encode( array('code' => 2, 'msg' => '非法请求') );
  690. die();
  691. }
  692. if( empty($content) )
  693. {
  694. echo json_encode( array('code' => 2, 'msg' => '评价内容不能为空') );
  695. die();
  696. }
  697. $end_time = time();
  698. $begin_time = $end_time - 30;
  699. //20 member_id
  700. $total = M('lionfish_comshop_solitaire_post')->where( "member_id={$member_id} and addtime>={$begin_time} and addtime <={$end_time} " )->count();
  701. if( $total >= 20)
  702. {
  703. echo json_encode( array('code' => 2, 'msg' => '评论太过频繁') );
  704. die();
  705. }
  706. $ins_data = array();
  707. $ins_data['uniacid'] = 0;
  708. $ins_data['soli_id'] = $soli_id;
  709. $ins_data['member_id'] = $member_id;
  710. $ins_data['pid'] = $pid;
  711. $ins_data['fav_count'] = 0;
  712. $ins_data['content'] = $content;
  713. $ins_data['addtime'] = time();
  714. $id = M('lionfish_comshop_solitaire_post')->add( $ins_data );
  715. echo json_encode( array( 'code' =>0, 'post_id' => $id, 'cur_time' => date('Y-m-d H:i:s', time()) ) );
  716. die();
  717. }
  718. /**
  719. 点赞评论
  720. **/
  721. public function fav_soli_post()
  722. {
  723. $_GPC = I('request.');
  724. $token = $_GPC['token'];
  725. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  726. $member_id = $weprogram_token['member_id'];
  727. if( empty($member_id) )
  728. {
  729. // 未登录
  730. echo json_encode( array('code' => 1) );
  731. die();
  732. }
  733. $soli_id = isset($_GPC['soli_id']) ? intval($_GPC['soli_id']) : 0 ;
  734. $post_id = isset($_GPC['post_id']) ? intval($_GPC['post_id']) : 0 ;
  735. if( empty($post_id) )
  736. {
  737. echo json_encode( array('code' => 2, 'msg' => '未选择需要点赞的评论') );
  738. die();
  739. }
  740. if( empty($soli_id) )
  741. {
  742. echo json_encode( array('code' => 2, 'msg' => '未选择需要点赞的群接龙') );
  743. die();
  744. }
  745. $fav_info = M('lionfish_comshop_solitaire_post_fav')->where( array('member_id' =>$member_id,'post_id' => $post_id ) )->find();
  746. if( empty($fav_info) )
  747. {
  748. //增加
  749. M('lionfish_comshop_solitaire_post')->where( array('id' => $post_id ) )->setInc('fav_count',1);
  750. $ins_data = array();
  751. $ins_data['uniacid'] = 0;
  752. $ins_data['member_id'] = $member_id;
  753. $ins_data['soli_id'] = $soli_id;
  754. $ins_data['post_id'] = $post_id;
  755. $ins_data['addtime'] = time();
  756. M('lionfish_comshop_solitaire_post_fav')->add( $ins_data );
  757. echo json_encode( array('code' => 0,'do' => 1) );
  758. die();
  759. }else{
  760. //减少
  761. $result = M('lionfish_comshop_solitaire_post_fav')->where( array('id' => $fav_info['id']) )->delete();
  762. if (!empty($result)) {
  763. M('lionfish_comshop_solitaire_post')->where( array('id' => $post_id ) )->setInc('fav_count', -1);
  764. echo json_encode( array('code' => 0,'do' => 2) );
  765. die();
  766. } else {
  767. echo json_encode( array('code' => 2, 'msg' => '取消点赞失败') );
  768. die();
  769. }
  770. }
  771. }
  772. /**
  773. *接龙规则
  774. **/
  775. public function get_rule()
  776. {
  777. $_GPC = I('request.');
  778. $solitaire_notice = D('Home/Front')->get_config_by_name('solitaire_notice');
  779. $solitaire_notice = htmlspecialchars_decode( $solitaire_notice );
  780. echo json_encode( array('code' => 0, 'solitaire_notice'=>$solitaire_notice) );
  781. die();
  782. }
  783. /**
  784. 接龙海报
  785. **/
  786. public function get_haibao()
  787. {
  788. $_GPC = I('request.');
  789. $soli_id = $_GPC['soli_id'];
  790. $solitaire_info = M('lionfish_comshop_solitaire')->where( array('id' => $soli_id ) )->find();
  791. $head_id = $solitaire_info['head_id'];
  792. if( !empty($solitaire_info['qrcode_image'] ) )
  793. {
  794. $image = tomedia( $solitaire_info['qrcode_image'] );
  795. echo json_encode( array('code' =>0, 'image' => $image ) );
  796. die();
  797. }else{
  798. }
  799. }
  800. /**
  801. *获取用户群接龙的列表,分页
  802. **/
  803. public function get_member_solitairelist()
  804. {
  805. $_GPC = I('request.');
  806. $token = $_GPC['token'];
  807. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  808. $member_id = $weprogram_token['member_id'];
  809. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  810. if( empty($member_info) )
  811. {
  812. // 未登录
  813. echo json_encode( array('code' => 2) );
  814. die();
  815. }
  816. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  817. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  818. $offset = ($page - 1)* $size;
  819. $list = M()->query('select gc.* from '.C('DB_PREFIX')."lionfish_comshop_order as g ,".C('DB_PREFIX')."lionfish_comshop_solitaire as gc
  820. where g.member_id={$member_id} and g.soli_id>0 and g.soli_id = gc.id order by g.order_id desc limit {$offset}, {$size} " );
  821. if( !empty( $list ) )
  822. {
  823. $need_data = array();
  824. $now_time = time();
  825. foreach( $list as $key => $val )
  826. {
  827. $tmp_arr = array();
  828. $tmp_arr['id'] = $val['id'];
  829. $tmp_arr['solitaire_name'] = $val['solitaire_name'];
  830. $tmp_arr['begin_time'] = date('Y-m-d', $val['begin_time']);
  831. $tmp_arr['end_time'] = date('Y-m-d', $val['end_time']);
  832. $state_str = '';
  833. if($val['end']==0) {
  834. if( $val['begin_time'] > $now_time )
  835. {
  836. $state_str = '未开始';
  837. }else if( $val['begin_time'] <= $now_time && $val['end_time'] > $now_time )
  838. {
  839. $state_str = '进行中';
  840. }else if( $val['end_time'] < $now_time ){
  841. $state_str = '已结束';
  842. }
  843. } else {
  844. $state_str = '已结束';
  845. }
  846. $tmp_arr['state_str'] = $state_str;
  847. //接龙图片
  848. $images_list = unserialize($val['images_list']);
  849. if( empty($images_list) )
  850. {
  851. $images_list = array();
  852. }
  853. if( !empty($images_list) && is_array($images_list) )
  854. {
  855. foreach( $images_list as $kk => $vv )
  856. {
  857. $vv = tomedia( $vv );
  858. $images_list[$kk] = $vv;
  859. }
  860. }
  861. $tmp_arr['images_list'] = $images_list;
  862. $need_data[$key] = $tmp_arr;
  863. }
  864. echo json_encode( array('code' => 0, 'data' => $need_data ) );
  865. die();
  866. }else{
  867. echo json_encode( array('code' => 1) );
  868. die();
  869. }
  870. }
  871. /**
  872. *获取接龙详情留言列表,分页
  873. **/
  874. public function get_comment_list()
  875. {
  876. $_GPC = I('request.');
  877. $id = intval( $_GPC['id'] );
  878. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  879. $member_id = $weprogram_token['member_id'];
  880. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  881. $is_login = true;
  882. if( empty($member_info) )
  883. {
  884. // 未登录
  885. $is_login = false;
  886. // echo json_encode( array('code' => 2) );
  887. // die();
  888. }
  889. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  890. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  891. $offset = ($page - 1)* $size;
  892. $list = M()->query('select g.*,gc.username,gc.avatar from '.C('DB_PREFIX')."lionfish_comshop_solitaire_post as g ,".C('DB_PREFIX')."lionfish_comshop_member as gc
  893. where g.soli_id={$id} and g.pid=0 and g.member_id = gc.member_id order by g.id desc limit {$offset}, {$size} " );
  894. if(!empty($list))
  895. {
  896. $need_data = array();
  897. foreach( $list as $key => $val )
  898. {
  899. $tmp_arr = array();
  900. $tmp_arr['id'] = $val['id'];
  901. $tmp_arr['soli_id'] = $val['soli_id'];
  902. $tmp_arr['pid'] = $val['pid'];
  903. $tmp_arr['username'] = $val['username'];
  904. $tmp_arr['avatar'] = $val['avatar'];
  905. $tmp_arr['fav_count'] = $val['fav_count'];
  906. $tmp_arr['content'] = $val['content'];
  907. $tmp_arr['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  908. //查询回复
  909. $reply = M('lionfish_comshop_solitaire_post')->field('id,content')->where( array('pid' => $val['id'], 'soli_id' => $val['soli_id'] ) )->find();
  910. if(empty($reply)) {
  911. $tmp_arr['reply'] = array();
  912. } else {
  913. $tmp_arr['reply'][] = $reply;
  914. }
  915. //是否点赞
  916. $is_agree = false;
  917. if($is_login) {
  918. $agree = M('lionfish_comshop_solitaire_post_fav')->field('id')->where( array('post_id' => $val['id'],'soli_id' => $val['soli_id'],'member_id' => $member_id ) )->find();
  919. if(!empty($agree)) $is_agree = true;
  920. }
  921. $tmp_arr['is_agree'] = $is_agree;
  922. $need_data[$key] = $tmp_arr;
  923. }
  924. echo json_encode( array('code' => 0, 'data' => $need_data ) );
  925. die();
  926. }else{
  927. echo json_encode( array('code' => 1) );
  928. die();
  929. }
  930. }
  931. /**
  932. * 删除留言
  933. * @return [json] [status]
  934. */
  935. public function delete_comment()
  936. {
  937. $_GPC = I('request.');
  938. $id = intval( $_GPC['id'] );
  939. $token = $_GPC['token'];
  940. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  941. $member_id = $weprogram_token['member_id'];
  942. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  943. if( empty($member_info) )
  944. {
  945. // 未登录
  946. echo json_encode( array('code' => 2) );
  947. die();
  948. }
  949. $result = M('lionfish_comshop_solitaire_post')->where( array('id' => $id ) )->delete();
  950. if (!empty($result)) {
  951. echo json_encode( array('code' => 0, 'msg' => '删除成功') );
  952. die();
  953. } else {
  954. echo json_encode( array('code' => 1, 'msg' => '删除失败') );
  955. die();
  956. }
  957. }
  958. /**
  959. * 团长手动结束
  960. * @return [json] [status]
  961. */
  962. public function end_solitaire()
  963. {
  964. $_GPC = I('request.');
  965. $id = intval( $_GPC['id'] );
  966. $token = $_GPC['token'];
  967. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  968. $member_id = $weprogram_token['member_id'];
  969. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  970. if( empty($member_info) )
  971. {
  972. // 未登录
  973. echo json_encode( array('code' => 2) );
  974. die();
  975. }
  976. $soli_info = M('lionfish_comshop_solitaire')->where( array('id' => $id ) )->find();
  977. if( empty($soli_info) || $soli_info['state'] != 1 )
  978. {
  979. echo json_encode( array('code' => 1 , 'msg' => '接龙不存在' ) );
  980. die();
  981. }
  982. // 团长信息
  983. $head_id = $soli_info['head_id'];
  984. $community_info = M('lionfish_community_head')->where( array('id' => $head_id ) )->find();
  985. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $community_info['member_id'] ) )->find();
  986. // 团长访问非本团详情
  987. if(empty($community_info['member_id']) || $community_info['member_id'] != $member_id)
  988. {
  989. echo json_encode( array('code' => 1, 'msg'=>"接龙不存在") );
  990. die();
  991. }
  992. $result = M('lionfish_comshop_solitaire')->where( array('id' => $id) )->save( array( 'end' => 1 ) );
  993. if (!empty($result)) {
  994. echo json_encode( array('code' => 0, 'msg' => '操作成功') );
  995. die();
  996. } else {
  997. echo json_encode( array('code' => 1, 'msg' => '操作失败') );
  998. die();
  999. }
  1000. }
  1001. /**
  1002. *获取接龙详情订单列表,分页
  1003. **/
  1004. public function get_soli_order_list()
  1005. {
  1006. $_GPC = I('request.');
  1007. $id = intval( $_GPC['id'] );
  1008. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  1009. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  1010. $offset = ($page - 1)* $size;
  1011. $sql = "select so.order_id,so.addtime,m.username,m.avatar from ".C('DB_PREFIX')."lionfish_comshop_solitaire_order as so, ".C('DB_PREFIX')."lionfish_comshop_order as o, ".C('DB_PREFIX')."lionfish_comshop_member as m
  1012. where o.order_id = so.order_id and so.soli_id={$id} and o.order_status_id in (1,4,6,7,11,14) and o.member_id=m.member_id order by so.id desc limit {$offset}, {$size} ";
  1013. $list = M()->query($sql);
  1014. if(!empty($list))
  1015. {
  1016. $need_data = array();
  1017. foreach( $list as $key => &$val )
  1018. {
  1019. $val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  1020. $goods_list = M('lionfish_comshop_order_goods')->field('order_goods_id,goods_id,name,goods_images,quantity,price,total')->where( array('order_id' => $val['order_id'] ) )->select();
  1021. foreach($goods_list as $kk => $vv){
  1022. $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' => $vv['order_goods_id'] ) )->select();
  1023. if( !empty($vv['goods_images']))
  1024. {
  1025. $goods_images = $vv['goods_images'];
  1026. if(is_array($goods_images))
  1027. {
  1028. $vv['goods_images'] = $vv['goods_images'];
  1029. }else{
  1030. $vv['goods_images']= tomedia( $vv['goods_images'] );
  1031. }
  1032. }else{
  1033. $vv['goods_images']= '';
  1034. }
  1035. $goods_filed = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $vv['goods_id'] ) )->find();
  1036. $vv['orign_price'] = $goods_filed['price'];
  1037. $quantity += $vv['quantity'];
  1038. foreach($order_option_list as $option)
  1039. {
  1040. $vv['option_str'][] = $option['value'];
  1041. }
  1042. if( !isset($vv['option_str']) )
  1043. {
  1044. $vv['option_str'] = '';
  1045. }else{
  1046. $vv['option_str'] = implode(',', $vv['option_str']);
  1047. }
  1048. $vv['price'] = sprintf("%.2f",$vv['price']);
  1049. $vv['orign_price'] = sprintf("%.2f",$vv['orign_price']);
  1050. $vv['total'] = sprintf("%.2f",$vv['total']);
  1051. $goods_list[$kk] = $vv;
  1052. }
  1053. $val['goodslist'] = $goods_list;
  1054. $val['goodsnum'] = count($goods_list);
  1055. }
  1056. echo json_encode( array('code' => 0, 'data' => $list ) );
  1057. die();
  1058. }else{
  1059. echo json_encode( array('code' => 1) );
  1060. die();
  1061. }
  1062. }
  1063. }