SolitaireController.class.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  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. $need_data['head_id_list'] = array($head_id);
  302. $res = D('Seller/Solitaire')->updatedo($need_data, $_W['uniacid'] ,$addtype , $appstate );
  303. echo json_encode( array('code' => 0) );
  304. die();
  305. }
  306. /**
  307. 获取用户查看 团长群接龙的列表
  308. **/
  309. public function get_head_index_solitairelist()
  310. {
  311. $_GPC = I('request.');
  312. $head_id = $_GPC['head_id'];
  313. $community_info = M('lionfish_community_head')->where( array('id' => $head_id ) )->find();
  314. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $community_info['member_id']) )->find();
  315. //$community_info = load_model_class('front')->get_member_community_info($member_id);
  316. if( empty($community_info) || $community_info['state'] != 1 )
  317. {
  318. echo json_encode( array('code' => 3 , 'msg' => '团长不存在' ) );
  319. die();
  320. }
  321. $community_info['avatar'] = $member_info['avatar'];
  322. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  323. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  324. $offset = ($page - 1)* $size;
  325. //
  326. $where = " and state = 1 and appstate = 1 and head_id = {$head_id} ";
  327. $keyword = isset($_GPC['keyword']) ? addslashes($_GPC['keyword']) : '';
  328. if( !empty($keyword) )
  329. {
  330. $where .= " and solitaire_name like '%{$keyword}%' ";
  331. }
  332. $sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_solitaire
  333. where 1 {$where}
  334. order by id desc limit {$offset},{$size}";
  335. $list = M()->query($sql);
  336. $head_data = array();
  337. $head_data['head_id'] = $head_id;//绑定小区
  338. $head_data['community_name'] = $community_info['community_name'];//绑定小区
  339. $head_data['head_name'] = $community_info['head_name'];//团长昵称
  340. $head_data['avatar'] = $community_info['avatar'];//头像
  341. $showTabbar = false;
  342. $tabbar_out_type = D('Home/Front')->get_config_by_name('tabbar_out_type');
  343. $tabbar_out_link = D('Home/Front')->get_config_by_name('tabbar_out_link');
  344. if($tabbar_out_type==6 || ($tabbar_out_type==1 && $tabbar_out_link == '/lionfish_comshop/moduleA/solitaire/index'))
  345. $showTabbar = true;
  346. if( !empty( $list ) )
  347. {
  348. $need_data = array();
  349. $now_time = time();
  350. foreach( $list as $key => $val )
  351. {
  352. $tmp_arr = array();
  353. $tmp_arr['id'] = $val['id'];
  354. $tmp_arr['solitaire_name'] = $val['solitaire_name'];
  355. $tmp_arr['begin_time'] = date('Y-m-d', $val['begin_time']);
  356. $tmp_arr['end_time'] = date('Y-m-d', $val['end_time']);
  357. $state_str = '';
  358. $state = 0;
  359. if($val['end']==0){
  360. if( $val['begin_time'] > $now_time )
  361. {
  362. $state_str = '未开始';
  363. }else if( $val['begin_time'] <= $now_time && $val['end_time'] > $now_time )
  364. {
  365. $state = 1;
  366. $state_str = '进行中';
  367. }else if( $val['end_time'] < $now_time ){
  368. $state_str = '已结束';
  369. $state = 2;
  370. }
  371. } else {
  372. $state_str = '已结束';
  373. $state = 2;
  374. }
  375. $tmp_arr['state'] = $state;
  376. $tmp_arr['state_str'] = $state_str;
  377. //接龙图片
  378. $images_list = unserialize($val['images_list']);
  379. if( empty($images_list) )
  380. {
  381. $images_list = array();
  382. }
  383. if( !empty($images_list) && is_array($images_list) )
  384. {
  385. foreach( $images_list as $kk => $vv )
  386. {
  387. $vv = tomedia( $vv );
  388. $images_list[$kk] = $vv;
  389. }
  390. }
  391. $tmp_arr['images_list'] = $images_list;
  392. //几人看过 //几人参加
  393. $order_count = $invite_count = 0;
  394. $invite_list = array();
  395. if($state!==0) {
  396. $order_count = M('lionfish_comshop_solitaire_order')->where( array('soli_id' => $val['id'] ) )->count();
  397. $invite_count = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $val['id'] ) )->count();
  398. //访问人头像列表
  399. $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";
  400. $invite_list = M()->query($avatar_sql);
  401. }
  402. $tmp_arr['order_count'] = $order_count;
  403. $tmp_arr['invite_list'] = $invite_list;
  404. $tmp_arr['invite_count'] = $invite_count;
  405. $need_data[$key] = $tmp_arr;
  406. }
  407. echo json_encode( array('code' => 0,'head_data' => $head_data, 'data' => $need_data, 'showTabbar' => $showTabbar ) );
  408. die();
  409. }else{
  410. echo json_encode( array('code' => 1, 'head_data' => $head_data, 'showTabbar' => $showTabbar ) );
  411. die();
  412. }
  413. }
  414. /**
  415. 接龙详情接口
  416. **/
  417. public function get_solitaire_detail()
  418. {
  419. $_GPC = I('request.');
  420. $id = intval( $_GPC['id'] );
  421. $token = isset( $_GPC['token'] ) ? $_GPC['token']:'';
  422. $is_head = isset( $_GPC['is_head'] ) ? $_GPC['is_head']:0;
  423. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  424. $member_id = $weprogram_token['member_id'];
  425. $is_Login = true;
  426. if(empty($weprogram_token) || empty($member_id)) $is_Login = false;
  427. $soli_info = M('lionfish_comshop_solitaire')->where( array('id' => $id ) )->find();
  428. if( empty($soli_info) || $soli_info['state'] != 1 )
  429. {
  430. echo json_encode( array('code' => 1 , 'msg' => '接龙不存在' ) );
  431. die();
  432. }
  433. if(!empty($soli_info['content']))
  434. $soli_info['content'] = htmlspecialchars_decode($soli_info['content']);
  435. // 团长信息
  436. $head_id = $soli_info['head_id'];
  437. $community_info = M('lionfish_community_head')->where( array('id' => $head_id ) )->find();
  438. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $community_info['member_id'] ) )->find();
  439. //$soli_info['is_involved'] = false; //是否参与
  440. // 团长中心详情
  441. if($is_head==1) {
  442. if(!$is_Login)
  443. {
  444. echo json_encode( array('code' => 2, 'msg'=>"团长未登录") );
  445. die();
  446. }
  447. // 团长访问非本团详情
  448. if(empty($community_info['member_id']) || $community_info['member_id'] != $member_id)
  449. {
  450. echo json_encode( array('code' => 1, 'msg'=>"无权限访问此接龙") );
  451. die();
  452. }
  453. }
  454. /*else {
  455. //是否已参与
  456. //if($is_Login) {
  457. // $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();
  458. // if(!empty($involved)) $soli_info['is_involved'] = true;
  459. //}
  460. }*/
  461. if( empty($soli_info['qrcode_image']))
  462. {
  463. $path = "lionfish_comshop/moduleA/solitaire/details"; // 首页地址测试
  464. $scene = $soli_info['id']."_".$member_id;
  465. $qrcode_image = D('Home/Pingoods')->_get_commmon_wxqrcode($path, $scene);
  466. M('lionfish_comshop_solitaire')->where( array('id' => $soli_info['id'] ) )->save( array('qrcode_image' => $qrcode_image) );
  467. $soli_info['qrcode_image'] = tomedia($qrcode_image);
  468. }else{
  469. $soli_info['qrcode_image'] = tomedia($soli_info['qrcode_image']);
  470. }
  471. $head_data = array();
  472. $head_data['head_id'] = $head_id;//绑定小区
  473. $head_data['community_name'] = $community_info['community_name'];//绑定小区
  474. $head_data['head_name'] = $community_info['head_name'];//团长昵称
  475. $head_data['avatar'] = $member_info['avatar'];//头像
  476. $order_count = M('lionfish_comshop_solitaire_order')->where( array('soli_id' => $id ) )->count();
  477. $invite_count = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $id ) )->count();
  478. //lionfish_comshop_solitaire_order soli_id order_id
  479. //sum(total+shipping_fare-voucher_credit-fullreduction_money) as total
  480. $sql = "select sum(o.total+o.shipping_fare-o.voucher_credit-o.fullreduction_money) as total from
  481. ".C('DB_PREFIX')."lionfish_comshop_solitaire_order as so, ".C('DB_PREFIX')."lionfish_comshop_order as o
  482. where o.order_id = so.order_id and so.soli_id={$id} and o.order_status_id in (1,4,6,7,11,14) ";
  483. $soli_total_money_arr = M()->query($sql);
  484. $soli_total_money = $soli_total_money_arr[0]['total'];
  485. $soli_info['content'] = htmlspecialchars_decode($soli_info['content']);
  486. $soli_info['order_count'] = $order_count;
  487. $soli_info['invite_count'] = $invite_count;
  488. $soli_info['soli_total_money'] = $soli_total_money;
  489. $soli_info['begin_time_str'] = date('Y-m-d H:i:s', $soli_info['begin_time'] );
  490. $soli_info['end_time_str'] = date('Y-m-d H:i:s', $soli_info['end_time'] );
  491. $soli_info['now_time'] = time();
  492. $soli_info['activity_state'] = 0;// 0未开始 ,1进行中,2已过期
  493. $now_time = time();
  494. if( $soli_info['begin_time'] > $now_time )
  495. {
  496. $soli_info['activity_state'] = 0;
  497. }else if( $soli_info['begin_time'] <= $now_time && $soli_info['end_time'] > $now_time )
  498. {
  499. $soli_info['activity_state'] = 1;
  500. }else if( $soli_info['end_time'] < $now_time ){
  501. $soli_info['activity_state'] = 2;
  502. }
  503. //$ims_
  504. $solitaire_goods_arr = M('lionfish_comshop_solitaire_goods')->field('goods_id')->where( array('soli_id' => $id ) )->order('id asc')->select();
  505. // $solitaire_goods_str = "";
  506. $soli_info['goods_list'] = array();
  507. if( !empty( $solitaire_goods_arr ) )
  508. {
  509. $tp_arr = array();
  510. $gd_info_list = array();
  511. foreach( $solitaire_goods_arr as $val )
  512. {
  513. $tp_arr[] = $val['goods_id'];
  514. $gd_info_list[] = M()->query('select g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video,gc.goods_start_count from
  515. '.C('DB_PREFIX')."lionfish_comshop_goods as g ,".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  516. where g.id = {$val['goods_id']} and g.id =gc.goods_id ");
  517. }
  518. // $solitaire_goods_str = implode(',', $tp_arr );
  519. // $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
  520. // '.C('DB_PREFIX')."lionfish_comshop_goods as g ,".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  521. // where g.id in(".$solitaire_goods_str.") and g.id =gc.goods_id ");
  522. $goods_data = array();
  523. $cart = D('Home/Car');
  524. foreach($gd_info_list as $gd_infos )
  525. {
  526. $gd_info = $gd_infos[0];
  527. $tmp_data = array();
  528. $tmp_data['actId'] = $gd_info['id'];
  529. $tmp_data['spuName'] = $gd_info['goodsname'];
  530. $tmp_data['spuCanBuyNum'] = $gd_info['total'];
  531. $tmp_data['spuDescribe'] = $gd_info['subtitle'];
  532. $tmp_data['goods_start_count'] = $gd_info['goods_start_count'];
  533. $tmp_data['is_take_vipcard'] = $gd_info['is_take_vipcard'];
  534. $tmp_data['soldNum'] = $gd_info['seller_count'] + $gd_info['sales'];
  535. $productprice = $gd_info['productprice'];
  536. $tmp_data['marketPrice'] = explode('.', $productprice);
  537. if( !empty($gd_info['big_img']) )
  538. {
  539. $tmp_data['bigImg'] = tomedia($gd_info['big_img']);
  540. }
  541. $good_image = D('Home/Pingoods')->get_goods_images($gd_info['id']);
  542. if( !empty($good_image) )
  543. {
  544. $tmp_data['skuImage'] = tomedia($good_image['image']);
  545. }
  546. $price_arr = D('Home/Pingoods')->get_goods_price($gd_info['id'], $member_id);
  547. $price = $price_arr['price'];
  548. if( $pageNum == 1 )
  549. {
  550. $copy_text_arr[] = array('goods_name' => $gd_info['goodsname'], 'price' => $price);
  551. }
  552. $tmp_data['actPrice'] = explode('.', $price);
  553. $tmp_data['card_price'] = $price_arr['card_price'];
  554. //card_price $id
  555. $tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($gd_info['id'],$member_id);
  556. if( !empty($tmp_data['skuList']) )
  557. {
  558. $tmp_data['car_count'] = 0;
  559. }else{
  560. $car_count = $cart->get_wecart_goods($gd_info['id'],"",$head_id ,$token);
  561. if( empty($car_count) )
  562. {
  563. $tmp_data['car_count'] = 0;
  564. }else{
  565. $tmp_data['car_count'] = $car_count;
  566. }
  567. }
  568. $goods_total_count = $cart->get_wecart_goods_solicount($gd_info['id'], $head_id,$token, $id );
  569. $tmp_data['goods_total_count'] = $goods_total_count;
  570. if($is_open_fullreduction == 0)
  571. {
  572. $tmp_data['is_take_fullreduction'] = 0;
  573. }else if($is_open_fullreduction == 1){
  574. $tmp_data['is_take_fullreduction'] = $gd_info['is_take_fullreduction'];
  575. }
  576. // 商品角标
  577. $label_id = unserialize($gd_info['labelname']);
  578. if($label_id){
  579. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  580. if($label_info){
  581. if($label_info['type'] == 1){
  582. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  583. } else {
  584. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  585. }
  586. }
  587. $tmp_data['label_info'] = $label_info;
  588. }
  589. $tmp_data['is_video'] = false;
  590. $goods_data[] = $tmp_data;
  591. }
  592. $soli_info['goods_list'] = $goods_data;
  593. }
  594. //接龙图片
  595. $images_list = unserialize($soli_info['images_list']);
  596. if( empty($images_list) )
  597. {
  598. $images_list = array();
  599. }
  600. if( !empty($images_list) )
  601. {
  602. foreach( $images_list as $kk => $vv )
  603. {
  604. $vv = tomedia( $vv );
  605. $images_list[$kk] = $vv;
  606. }
  607. }
  608. $soli_info['images_list'] = $images_list;
  609. //
  610. $solitaire_target = D('Home/Front')->get_config_by_name('solitaire_target');
  611. if( empty($solitaire_target) )
  612. {
  613. $solitaire_target = 0; //是否开启目标
  614. }
  615. $solitaire_target_type = D('Home/Front')->get_config_by_name('solitaire_target_type');
  616. if( empty($solitaire_target_type) )
  617. {
  618. $solitaire_target_type = 0;
  619. }//0 参与人数, 1接龙金额
  620. $solitaire_target_takemember = D('Home/Front')->get_config_by_name('solitaire_target_takemember');
  621. if( empty($solitaire_target_takemember) )
  622. {
  623. $solitaire_target_takemember = 0;
  624. }
  625. // 参与人数
  626. //solitaire_target_takemoney 接龙金额
  627. $solitaire_target_takemoney = D('Home/Front')->get_config_by_name('solitaire_target_takemoney');
  628. if( empty($solitaire_target_takemoney) )
  629. {
  630. $solitaire_target_takemoney =0;
  631. }
  632. $solitaire_notice = D('Home/Front')->get_config_by_name('solitaire_notice');
  633. $solitaire_notice = htmlspecialchars_decode( $solitaire_notice );
  634. $soli_info['comment_total'] = M('lionfish_comshop_solitaire_post')->where( array('soli_id' => $id, 'pid' => 0 ) )->count();
  635. //群接龙留言功能是否开启
  636. $solitaire_is_message = D('Home/Front')->get_config_by_name('solitaire_is_message');
  637. if( empty($solitaire_is_message) )
  638. {
  639. $solitaire_is_message = 0;
  640. }
  641. echo json_encode( array('code' => 0,
  642. 'head_data' => $head_data,
  643. 'solitaire_target' => $solitaire_target,
  644. 'solitaire_target_type' => $solitaire_target_type,
  645. 'solitaire_target_takemoney' => $solitaire_target_takemoney,
  646. 'solitaire_target_takemember' => $solitaire_target_takemember,
  647. 'solitaire_is_message' => $solitaire_is_message,
  648. 'solitaire_notice' => $solitaire_notice,
  649. 'soli_info' => $soli_info
  650. ) );
  651. die();
  652. }
  653. /**
  654. 增加访问量接口
  655. **/
  656. public function send_visite_record()
  657. {
  658. $_GPC = I('request.');
  659. $token = $_GPC['token'];
  660. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  661. $member_id = $weprogram_token['member_id'];
  662. if( empty($member_id) )
  663. {
  664. // 未登录
  665. echo json_encode( array('code' => 1) );
  666. die();
  667. }
  668. $soli_id = $_GPC['soli_id'];
  669. $ck_info = M('lionfish_comshop_solitaire_invite')->where( array('soli_id' => $soli_id, 'member_id' => $member_id ) )->find();
  670. if( !empty($ck_info) )
  671. {
  672. echo json_encode( array('code' => 1, 'msg' => '已加入') );
  673. die();
  674. }
  675. $ins_data = array();
  676. $ins_data['uniacid'] = 0;
  677. $ins_data['soli_id'] = $soli_id;
  678. $ins_data['member_id'] = $member_id;
  679. $ins_data['addtime'] = time();
  680. M('lionfish_comshop_solitaire_invite')->add($ins_data);
  681. echo json_encode( array('code' => 0) );
  682. die();
  683. }
  684. /**
  685. 评价群接龙
  686. **/
  687. public function sub_solipost()
  688. {
  689. $_GPC = I('request.');
  690. $token = $_GPC['token'];
  691. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  692. $member_id = $weprogram_token['member_id'];
  693. if( empty($member_id) )
  694. {
  695. // 未登录
  696. echo json_encode( array('code' => 1) );
  697. die();
  698. }
  699. $soli_id = isset($_GPC['soli_id']) ? intval($_GPC['soli_id']) : 0 ;
  700. $pid = isset($_GPC['pid']) ? intval($_GPC['pid']) : 0;
  701. $content = isset($_GPC['content']) ? htmlspecialchars($_GPC['content']) : '';
  702. if( empty($soli_id) || $soli_id <=0 )
  703. {
  704. echo json_encode( array('code' => 2, 'msg' => '非法请求') );
  705. die();
  706. }
  707. if( empty($content) )
  708. {
  709. echo json_encode( array('code' => 2, 'msg' => '评价内容不能为空') );
  710. die();
  711. }
  712. $end_time = time();
  713. $begin_time = $end_time - 30;
  714. //20 member_id
  715. $total = M('lionfish_comshop_solitaire_post')->where( "member_id={$member_id} and addtime>={$begin_time} and addtime <={$end_time} " )->count();
  716. if( $total >= 20)
  717. {
  718. echo json_encode( array('code' => 2, 'msg' => '评论太过频繁') );
  719. die();
  720. }
  721. $ins_data = array();
  722. $ins_data['uniacid'] = 0;
  723. $ins_data['soli_id'] = $soli_id;
  724. $ins_data['member_id'] = $member_id;
  725. $ins_data['pid'] = $pid;
  726. $ins_data['fav_count'] = 0;
  727. $ins_data['content'] = $content;
  728. $ins_data['addtime'] = time();
  729. $id = M('lionfish_comshop_solitaire_post')->add( $ins_data );
  730. echo json_encode( array( 'code' =>0, 'post_id' => $id, 'cur_time' => date('Y-m-d H:i:s', time()) ) );
  731. die();
  732. }
  733. /**
  734. 点赞评论
  735. **/
  736. public function fav_soli_post()
  737. {
  738. $_GPC = I('request.');
  739. $token = $_GPC['token'];
  740. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  741. $member_id = $weprogram_token['member_id'];
  742. if( empty($member_id) )
  743. {
  744. // 未登录
  745. echo json_encode( array('code' => 1) );
  746. die();
  747. }
  748. $soli_id = isset($_GPC['soli_id']) ? intval($_GPC['soli_id']) : 0 ;
  749. $post_id = isset($_GPC['post_id']) ? intval($_GPC['post_id']) : 0 ;
  750. if( empty($post_id) )
  751. {
  752. echo json_encode( array('code' => 2, 'msg' => '未选择需要点赞的评论') );
  753. die();
  754. }
  755. if( empty($soli_id) )
  756. {
  757. echo json_encode( array('code' => 2, 'msg' => '未选择需要点赞的群接龙') );
  758. die();
  759. }
  760. $fav_info = M('lionfish_comshop_solitaire_post_fav')->where( array('member_id' =>$member_id,'post_id' => $post_id ) )->find();
  761. if( empty($fav_info) )
  762. {
  763. //增加
  764. M('lionfish_comshop_solitaire_post')->where( array('id' => $post_id ) )->setInc('fav_count',1);
  765. $ins_data = array();
  766. $ins_data['uniacid'] = 0;
  767. $ins_data['member_id'] = $member_id;
  768. $ins_data['soli_id'] = $soli_id;
  769. $ins_data['post_id'] = $post_id;
  770. $ins_data['addtime'] = time();
  771. M('lionfish_comshop_solitaire_post_fav')->add( $ins_data );
  772. echo json_encode( array('code' => 0,'do' => 1) );
  773. die();
  774. }else{
  775. //减少
  776. $result = M('lionfish_comshop_solitaire_post_fav')->where( array('id' => $fav_info['id']) )->delete();
  777. if (!empty($result)) {
  778. M('lionfish_comshop_solitaire_post')->where( array('id' => $post_id ) )->setInc('fav_count', -1);
  779. echo json_encode( array('code' => 0,'do' => 2) );
  780. die();
  781. } else {
  782. echo json_encode( array('code' => 2, 'msg' => '取消点赞失败') );
  783. die();
  784. }
  785. }
  786. }
  787. /**
  788. *接龙规则
  789. **/
  790. public function get_rule()
  791. {
  792. $_GPC = I('request.');
  793. $solitaire_notice = D('Home/Front')->get_config_by_name('solitaire_notice');
  794. $solitaire_notice = htmlspecialchars_decode( $solitaire_notice );
  795. echo json_encode( array('code' => 0, 'solitaire_notice'=>$solitaire_notice) );
  796. die();
  797. }
  798. /**
  799. 接龙海报
  800. **/
  801. public function get_haibao()
  802. {
  803. $_GPC = I('request.');
  804. $soli_id = $_GPC['soli_id'];
  805. $solitaire_info = M('lionfish_comshop_solitaire')->where( array('id' => $soli_id ) )->find();
  806. $head_id = $solitaire_info['head_id'];
  807. if( !empty($solitaire_info['qrcode_image'] ) )
  808. {
  809. $image = tomedia( $solitaire_info['qrcode_image'] );
  810. echo json_encode( array('code' =>0, 'image' => $image ) );
  811. die();
  812. }else{
  813. }
  814. }
  815. /**
  816. *获取用户群接龙的列表,分页
  817. **/
  818. public function get_member_solitairelist()
  819. {
  820. $_GPC = I('request.');
  821. $token = $_GPC['token'];
  822. $head_id = $_GPC['head_id'];
  823. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  824. $member_id = $weprogram_token['member_id'];
  825. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  826. if( empty($member_info) )
  827. {
  828. // 未登录
  829. echo json_encode( array('code' => 2) );
  830. die();
  831. }
  832. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  833. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  834. $offset = ($page - 1)* $size;
  835. $list = M()->query('select gc.* from '.C('DB_PREFIX')."lionfish_comshop_order as g ,".C('DB_PREFIX')."lionfish_comshop_solitaire as gc
  836. where g.member_id={$member_id} and g.soli_id>0 and g.soli_id = gc.id and gc.head_id={$head_id} order by g.order_id desc limit {$offset}, {$size} " );
  837. if( !empty( $list ) )
  838. {
  839. $need_data = array();
  840. $now_time = time();
  841. foreach( $list as $key => $val )
  842. {
  843. $tmp_arr = array();
  844. $tmp_arr['id'] = $val['id'];
  845. $tmp_arr['solitaire_name'] = $val['solitaire_name'];
  846. $tmp_arr['begin_time'] = date('Y-m-d', $val['begin_time']);
  847. $tmp_arr['end_time'] = date('Y-m-d', $val['end_time']);
  848. $state_str = '';
  849. if($val['end']==0) {
  850. if( $val['begin_time'] > $now_time )
  851. {
  852. $state_str = '未开始';
  853. }else if( $val['begin_time'] <= $now_time && $val['end_time'] > $now_time )
  854. {
  855. $state_str = '进行中';
  856. }else if( $val['end_time'] < $now_time ){
  857. $state_str = '已结束';
  858. }
  859. } else {
  860. $state_str = '已结束';
  861. }
  862. $tmp_arr['state_str'] = $state_str;
  863. //接龙图片
  864. $images_list = unserialize($val['images_list']);
  865. if( empty($images_list) )
  866. {
  867. $images_list = array();
  868. }
  869. if( !empty($images_list) && is_array($images_list) )
  870. {
  871. foreach( $images_list as $kk => $vv )
  872. {
  873. $vv = tomedia( $vv );
  874. $images_list[$kk] = $vv;
  875. }
  876. }
  877. $tmp_arr['images_list'] = $images_list;
  878. $need_data[$key] = $tmp_arr;
  879. }
  880. echo json_encode( array('code' => 0, 'data' => $need_data ) );
  881. die();
  882. }else{
  883. echo json_encode( array('code' => 1) );
  884. die();
  885. }
  886. }
  887. /**
  888. *获取接龙详情留言列表,分页
  889. **/
  890. public function get_comment_list()
  891. {
  892. $_GPC = I('request.');
  893. $id = intval( $_GPC['id'] );
  894. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  895. $member_id = $weprogram_token['member_id'];
  896. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  897. $is_login = true;
  898. if( empty($member_info) )
  899. {
  900. // 未登录
  901. $is_login = false;
  902. // echo json_encode( array('code' => 2) );
  903. // die();
  904. }
  905. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  906. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  907. $offset = ($page - 1)* $size;
  908. $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
  909. where g.soli_id={$id} and g.pid=0 and g.member_id = gc.member_id order by g.id desc limit {$offset}, {$size} " );
  910. if(!empty($list))
  911. {
  912. $need_data = array();
  913. foreach( $list as $key => $val )
  914. {
  915. $tmp_arr = array();
  916. $tmp_arr['id'] = $val['id'];
  917. $tmp_arr['soli_id'] = $val['soli_id'];
  918. $tmp_arr['pid'] = $val['pid'];
  919. $tmp_arr['username'] = $val['username'];
  920. $tmp_arr['avatar'] = $val['avatar'];
  921. $tmp_arr['fav_count'] = $val['fav_count'];
  922. $tmp_arr['content'] = $val['content'];
  923. $tmp_arr['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  924. //查询回复
  925. $reply = M('lionfish_comshop_solitaire_post')->field('id,content')->where( array('pid' => $val['id'], 'soli_id' => $val['soli_id'] ) )->find();
  926. if(empty($reply)) {
  927. $tmp_arr['reply'] = array();
  928. } else {
  929. $tmp_arr['reply'][] = $reply;
  930. }
  931. //是否点赞
  932. $is_agree = false;
  933. if($is_login) {
  934. $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();
  935. if(!empty($agree)) $is_agree = true;
  936. }
  937. $tmp_arr['is_agree'] = $is_agree;
  938. $need_data[$key] = $tmp_arr;
  939. }
  940. echo json_encode( array('code' => 0, 'data' => $need_data ) );
  941. die();
  942. }else{
  943. echo json_encode( array('code' => 1) );
  944. die();
  945. }
  946. }
  947. /**
  948. * 删除留言
  949. * @return [json] [status]
  950. */
  951. public function delete_comment()
  952. {
  953. $_GPC = I('request.');
  954. $id = intval( $_GPC['id'] );
  955. $token = $_GPC['token'];
  956. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  957. $member_id = $weprogram_token['member_id'];
  958. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  959. if( empty($member_info) )
  960. {
  961. // 未登录
  962. echo json_encode( array('code' => 2) );
  963. die();
  964. }
  965. $result = M('lionfish_comshop_solitaire_post')->where( array('id' => $id ) )->delete();
  966. if (!empty($result)) {
  967. echo json_encode( array('code' => 0, 'msg' => '删除成功') );
  968. die();
  969. } else {
  970. echo json_encode( array('code' => 1, 'msg' => '删除失败') );
  971. die();
  972. }
  973. }
  974. /**
  975. * 团长手动结束
  976. * @return [json] [status]
  977. */
  978. public function end_solitaire()
  979. {
  980. $_GPC = I('request.');
  981. $id = intval( $_GPC['id'] );
  982. $token = $_GPC['token'];
  983. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token ) )->find();
  984. $member_id = $weprogram_token['member_id'];
  985. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  986. if( empty($member_info) )
  987. {
  988. // 未登录
  989. echo json_encode( array('code' => 2) );
  990. die();
  991. }
  992. $soli_info = M('lionfish_comshop_solitaire')->where( array('id' => $id ) )->find();
  993. if( empty($soli_info) || $soli_info['state'] != 1 )
  994. {
  995. echo json_encode( array('code' => 1 , 'msg' => '接龙不存在' ) );
  996. die();
  997. }
  998. // 团长信息
  999. $head_id = $soli_info['head_id'];
  1000. $community_info = M('lionfish_community_head')->where( array('id' => $head_id ) )->find();
  1001. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $community_info['member_id'] ) )->find();
  1002. // 团长访问非本团详情
  1003. if(empty($community_info['member_id']) || $community_info['member_id'] != $member_id)
  1004. {
  1005. echo json_encode( array('code' => 1, 'msg'=>"接龙不存在") );
  1006. die();
  1007. }
  1008. $result = M('lionfish_comshop_solitaire')->where( array('id' => $id) )->save( array( 'end' => 1 ) );
  1009. if (!empty($result)) {
  1010. echo json_encode( array('code' => 0, 'msg' => '操作成功') );
  1011. die();
  1012. } else {
  1013. echo json_encode( array('code' => 1, 'msg' => '操作失败') );
  1014. die();
  1015. }
  1016. }
  1017. /**
  1018. *获取接龙详情订单列表,分页
  1019. **/
  1020. public function get_soli_order_list()
  1021. {
  1022. $_GPC = I('request.');
  1023. $id = intval( $_GPC['id'] );
  1024. $page = isset($_GPC['page']) ? $_GPC['page']:'1';
  1025. $size = isset($_GPC['size']) ? $_GPC['size']:'20';
  1026. $offset = ($page - 1)* $size;
  1027. $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
  1028. 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} ";
  1029. $list = M()->query($sql);
  1030. if(!empty($list))
  1031. {
  1032. $need_data = array();
  1033. foreach( $list as $key => &$val )
  1034. {
  1035. $val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  1036. $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();
  1037. foreach($goods_list as $kk => $vv){
  1038. $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' => $vv['order_goods_id'] ) )->select();
  1039. if( !empty($vv['goods_images']))
  1040. {
  1041. $goods_images = $vv['goods_images'];
  1042. if(is_array($goods_images))
  1043. {
  1044. $vv['goods_images'] = $vv['goods_images'];
  1045. }else{
  1046. $vv['goods_images']= tomedia( $vv['goods_images'] );
  1047. }
  1048. }else{
  1049. $vv['goods_images']= '';
  1050. }
  1051. $goods_filed = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $vv['goods_id'] ) )->find();
  1052. $vv['orign_price'] = $goods_filed['price'];
  1053. $quantity += $vv['quantity'];
  1054. foreach($order_option_list as $option)
  1055. {
  1056. $vv['option_str'][] = $option['value'];
  1057. }
  1058. if( !isset($vv['option_str']) )
  1059. {
  1060. $vv['option_str'] = '';
  1061. }else{
  1062. $vv['option_str'] = implode(',', $vv['option_str']);
  1063. }
  1064. $vv['price'] = sprintf("%.2f",$vv['price']);
  1065. $vv['orign_price'] = sprintf("%.2f",$vv['orign_price']);
  1066. $vv['total'] = sprintf("%.2f",$vv['total']);
  1067. $goods_list[$kk] = $vv;
  1068. }
  1069. $val['goodslist'] = $goods_list;
  1070. $val['goodsnum'] = count($goods_list);
  1071. }
  1072. echo json_encode( array('code' => 0, 'data' => $list ) );
  1073. die();
  1074. }else{
  1075. echo json_encode( array('code' => 1) );
  1076. die();
  1077. }
  1078. }
  1079. }