SolitaireController.class.php 39 KB

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