GroupdoController.class.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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 GroupdoController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. public function get_goods_detail() {
  21. $_GPC = I('request.');
  22. $id = $_GPC['id'];
  23. $pin_id = isset($_GPC['pin_id']) ? $_GPC['pin_id'] : 0;
  24. $token = $_GPC['token'];
  25. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  26. $member_id = $weprogram_token['member_id'];
  27. $pintuan_model_buy = D('Home/Front')->get_config_by_name('pintuan_model_buy');
  28. if( empty($pintuan_model_buy) || $pintuan_model_buy ==0 )
  29. {
  30. $pintuan_model_buy = 0;
  31. }
  32. //团长休息
  33. $community_id = $_GPC['community_id'];
  34. $is_comunity_rest = D('Seller/Communityhead')->is_community_rest($community_id);
  35. $need_data = array();
  36. $sql = "select g.*,gd.content,gd.begin_time,gd.end_time,gd.video,gd.is_take_fullreduction,gd.share_title,gd.quality,gd.pick_up_type,gd.pick_up_modify,gd.one_limit_count,gd.total_limit_count,gd.seven,gd.repair,gd.labelname,gd.share_title,gd.goods_share_image,gd.relative_goods_list,gd.is_show_arrive,gd.diy_arrive_switch,gd.diy_arrive_details from " . C('DB_PREFIX'). "lionfish_comshop_goods as g," . C('DB_PREFIX') . "lionfish_comshop_good_common as gd
  37. where g.id=gd.goods_id and g.id=" . $id;
  38. $goods_arr = M()->query($sql);
  39. $goods = $goods_arr[0];
  40. $goods['goods_id'] = $id;
  41. $goods['is_take_fullreduction'] = 0;
  42. $goods['is_video'] = 0;
  43. $goods['video_size_width'] = 0;
  44. $goods['vedio_size_height'] = 0;
  45. $goods['video_src'] = '';
  46. if( !empty($goods['goods_share_image']) )
  47. {
  48. $goods['goods_share_image'] = tomedia($goods['goods_share_image']);
  49. }
  50. //video
  51. if( !empty($goods['video']) )
  52. {
  53. $goods['video'] = tomedia($goods['video']);
  54. }
  55. $goods['description'] = htmlspecialchars_decode($goods['content']);
  56. $qian = array(
  57. "\r\n"
  58. );
  59. $hou = array(
  60. "<br/>"
  61. );
  62. $goods['subtitle'] = str_replace($qian, $hou, $goods['subtitle']);
  63. $hou = array(
  64. "@EOF@"
  65. );
  66. $today_time = strtotime( date('Y-m-d').' 00:00:00' );
  67. //pick_up_type
  68. //gd.begin_time,gd.end_time,
  69. //over_type =0 未开始,over_type =2已结束,over_type =1距结束
  70. $now_time = time();
  71. if($goods['begin_time'] > $now_time)
  72. {
  73. $goods['over_type'] = 0;
  74. }else if( $goods['begin_time'] <= $now_time && $goods['end_time'] > $now_time ){
  75. $goods['over_type'] = 1;
  76. }else if($goods['end_time'] < $now_time){
  77. $goods['over_type'] = 2;
  78. $goods['end_date'] = date('m/d H:i', $goods['end_time']);
  79. }
  80. $goods['activity_summary'] = '';
  81. $onegood_image = D('Home/Pingoods')->get_goods_images($id);
  82. if( !empty($onegood_image) )
  83. {
  84. $goods['image_thumb'] = tomedia($onegood_image['image']);
  85. $goods['image'] = tomedia($onegood_image['image']);
  86. }
  87. $buy_record_arr = D('Home/Frontorder')->get_goods_buy_record($id,9);
  88. $goods_image = D('Home/Pingoods')->get_goods_images($id, 10);
  89. if (isset($goods_image)) {
  90. foreach ($goods_image as $k => $v) {
  91. $goods_image[$k]['image'] = tomedia($v['image']);
  92. }
  93. }
  94. $goods['seller_count']+= $goods['sales'];
  95. $goods_price_arr = D('Home/Pingoods')->get_goods_price($id, $member_id);
  96. $goods['price'] = $goods_price_arr['price'];
  97. $goods['danprice'] = $goods_price_arr['danprice'];
  98. $price_dol = explode('.', $goods_price_arr['price']);
  99. $goods['price_front'] = $price_dol[0];
  100. $goods['price_after'] = $price_dol[1];
  101. $labelname_arr = unserialize( $goods['labelname'] );
  102. $tag_arr = array();
  103. if( !empty($labelname_arr) )
  104. {
  105. $goods['tag'] = $labelname_arr;
  106. }else{
  107. if( $goods['quality'] == 1)
  108. {
  109. $tag_arr[] = '正品保证';
  110. }
  111. if( $goods['seven'] == 1)
  112. {
  113. $tag_arr[] = '7天无理由退换';
  114. }
  115. if( $goods['repair'] == 1)
  116. {
  117. $tag_arr[] = '保修';
  118. }
  119. $goods['tag'] = $tag_arr;
  120. }
  121. $goods['fan_image'] = $goods['image'];
  122. $one_image = D('Home/Pingoods')->get_goods_images($id, 1);
  123. $goods['one_image'] = tomedia($one_image['image']);
  124. $pin_info = $goods_price_arr;
  125. $pin_goods_info = M('lionfish_comshop_good_pin')->where( array('goods_id' => $id ) )->find();
  126. $user_favgoods = D('Home/Pingoods')->fav_goods_state($id, $member_id);
  127. if( !empty($user_favgoods) )
  128. {
  129. $goods['favgoods'] = 2;
  130. }else{
  131. $goods['favgoods'] = 1;
  132. }
  133. $price = $goods['danprice'];
  134. $lottery_info = array();
  135. $need_data['lottery_info'] = $lottery_info;
  136. if(empty($goods['share_title'])) $goods['share_title'] = $pin_info['pin_price'].'元 '.$goods['goodsname'];
  137. /** 商品会员折扣begin **/
  138. $is_show_member_disc = 0;
  139. $member_disc = 100;
  140. /** 商品会员折扣end **/
  141. $goods['memberprice'] = sprintf('%.2f', round( ($goods['danprice'] * $member_disc) / 100 ,2));
  142. $max_get_dan_money = round( ($goods['danprice'] * (100 - $max_member_level['discount']) ) / 100 ,2);
  143. $max_get_money = $max_get_dan_money;
  144. if(!empty($pin_info))
  145. {
  146. $pin_info['member_pin_price'] = sprintf('%.2f',round( ($pin_info['pin_price'] * $member_disc) / 100 ,2));
  147. $max_get_pin_money = round( ($pin_info['pin_price'] * (100 - $max_member_level['discount']) ) / 100 ,2);
  148. $max_get_money = $max_get_pin_money;
  149. }
  150. // 商品角标
  151. $label_id = unserialize($goods['labelname']);
  152. if($label_id){
  153. $label_info = D('Home/Pingoods')->get_goods_tags($label_id);
  154. if($label_info){
  155. if($label_info['type'] == 1){
  156. $label_info['tagcontent'] = tomedia($label_info['tagcontent']);
  157. } else {
  158. $label_info['len'] = mb_strlen($label_info['tagcontent'], 'utf-8');
  159. }
  160. }
  161. $goods['label_info'] = $label_info;
  162. }
  163. $pintuan_newman_notice = D('Home/Front')->get_config_by_name('pintuan_newman_notice');
  164. if( !empty($pintuan_newman_notice) )
  165. {
  166. $pintuan_newman_notice = htmlspecialchars_decode($pintuan_newman_notice);
  167. $qian = array(
  168. "\r\n"
  169. );
  170. $hou = array(
  171. "<br/>"
  172. );
  173. $pintuan_newman_notice = str_replace($qian, $hou, $pintuan_newman_notice);
  174. }
  175. $pin_info['is_commiss_tuan'] = $pin_goods_info['is_commiss_tuan'];
  176. $pin_info['is_zero_open'] = $pin_goods_info['is_commiss_tuan'] == 1 ? $pin_goods_info['is_zero_open'] : 0;
  177. $pin_info['is_newman'] = $pin_goods_info['is_newman'];
  178. $pin_info['pintuan_newman_notice'] = $pintuan_newman_notice;
  179. $pin_info['commiss_type'] = $pin_goods_info['commiss_type'];
  180. $pin_info['commiss_money'] = $pin_goods_info['commiss_money'];
  181. //拼团返利开启情况:1、开启,0、关闭
  182. $pin_info['is_pintuan_rebate'] = $pin_goods_info['is_pintuan_rebate'];
  183. $need_data['pin_info'] = $pin_info;
  184. /**
  185. if(!empty($member_id) && $member_id > 0 && $goods[0]['type'] == 'integral')
  186. {
  187. $member_info = M('member')->field('score')->where( array('member_id' => $member_id) )->find();
  188. if($member_info['score'] < $goods[0]['score'])
  189. {
  190. $goods[0]['score_enough'] = 0;
  191. }else{
  192. $goods[0]['score_enough'] = 1;
  193. }
  194. }
  195. **/
  196. $need_data['member_level_info'] = $member_level_info;
  197. $need_data['member_level_list'] = $member_level_list;
  198. $need_data['max_member_level'] = $max_member_level;
  199. $need_data['max_get_money'] = sprintf('%.2f',$max_get_money);
  200. $need_data['max_get_pin_money'] = $max_get_pin_money;
  201. $need_data['max_get_dan_money'] = $max_get_dan_money;
  202. $need_data['buy_record_arr'] = $buy_record_arr;
  203. $need_data['is_show_max_level'] = $is_show_max_level;
  204. $goods['actPrice'] = explode('.', $goods['price']);
  205. $goods['marketPrice'] = explode('.', $goods['productprice']);
  206. ///relative_goods_list member_id
  207. $relative_goods_list = array();
  208. unset($goods['relative_goods_list']);
  209. $need_data['relative_goods_list'] = $relative_goods_list;
  210. $need_data['goods'] = $goods;
  211. $need_data['goods_image'] = $goods_image;
  212. $need_data['site_name'] = D('Home/Front')->get_config_by_name('shoname');
  213. $need_data['options'] = D('Home/Pingoods')->get_goods_options($id, $member_id); // $goods_model->get_goods_options($id);
  214. $order_comment_count = M('lionfish_comshop_order_comment')->where( array('state' => 1, 'goods_id' => $id ) )->count();
  215. $comment_list = array();
  216. if($order_comment_count > 0)
  217. {
  218. $sql = "select o.*,m.username as name2,m.avatar as avatar2 from ".C('DB_PREFIX')."lionfish_comshop_order_comment as o left join ".C('DB_PREFIX')."lionfish_comshop_member as m
  219. on o.member_id=m.member_id
  220. where o.state = 1 and o.goods_id = {$id} order by o.add_time desc limit 1";
  221. $comment_list= M()->query($sql);
  222. $order_comment_images = array();
  223. foreach($comment_list as $key => $val)
  224. {
  225. //user_name
  226. if( empty($val['user_name']) )
  227. {
  228. $val['name'] = $val['name2'];
  229. $val['avatar'] = tomedia($val['avatar2']);
  230. }else{
  231. $val['name'] = $val['user_name'];
  232. $val['avatar'] = tomedia($val['avatar']);
  233. }
  234. if($val['type'] == 0)
  235. {
  236. $order_goods_info = M('lionfish_comshop_order_goods')->field('order_goods_id')->where( array('goods_id' => $id,'order_id' => $val['order_id'] ) )->find();
  237. $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_goods_id' => $order_goods_info['order_goods_id'],'order_id' => $val['order_id'] ) )->select();
  238. $option_arr = array();
  239. foreach($order_option_info as $option)
  240. {
  241. $option_arr[] = $option['value'];
  242. }
  243. $option_str = implode(',', $option_arr);
  244. }else{
  245. $option_str = '';
  246. }
  247. $img_str = unserialize($val['images']);
  248. if( !empty($img_str) && $img_str != 'undefined' )
  249. {
  250. // $img_str = unserialize($val['images']);
  251. $img_list = explode(',', $img_str);
  252. $need_img_list = array();
  253. foreach($img_list as $kk => $vv)
  254. {
  255. if(!empty($vv) )
  256. {
  257. $vv = tomedia($vv );
  258. $img_list[$kk] = $vv;
  259. $need_img_list[$kk] = $vv;
  260. if(count($order_comment_images) <= 4)
  261. $order_comment_images[] = $vv;
  262. }
  263. }
  264. $val['images'] = $need_img_list ;
  265. } else {
  266. $val['images'] = array();
  267. }
  268. $val['option_str'] = $option_str;
  269. $val['add_time'] = date('Y-m-d', $val['add_time']) ;
  270. $comment_list[$key] = $val;
  271. }
  272. //$this->comment_list = $comment_list;
  273. }
  274. $need_data['cur_time'] = time();
  275. $need_data['pin_id'] = $pin_id;
  276. $need_data['is_show_arrive'] = $goods['is_show_arrive'];
  277. $need_data['diy_arrive_switch'] = $goods['diy_arrive_switch'];
  278. $need_data['diy_arrive_details'] = $goods['diy_arrive_details'];
  279. //团长休息
  280. $goodsdetails_addcart_bg_color = D('Home/Front')->get_config_by_name('goodsdetails_addcart_bg_color');
  281. $goodsdetails_buy_bg_color = D('Home/Front')->get_config_by_name('goodsdetails_buy_bg_color');
  282. $is_close_details_time = D('Home/Front')->get_config_by_name('is_close_details_time');
  283. $pintuan_close_stranger = D('Home/Front')->get_config_by_name('pintuan_close_stranger');
  284. $isopen_community_group_share = D('Home/Front')->get_config_by_name('isopen_community_group_share');
  285. $group_share_info = '';
  286. $is_need_subscript = 0;
  287. $need_subscript_template = array();
  288. if( $member_id >0 )
  289. {
  290. //'pay_order','send_order','hexiao_success','apply_community','open_tuan','take_tuan','pin_tuansuccess','apply_tixian'
  291. $open_tuan_info = M('lionfish_comshop_subscribe')->where( array('member_id' => $member_id, 'type' => 'open_tuan') )->find();
  292. if( empty($open_tuan_info) )
  293. {
  294. $weprogram_subtemplate_open_tuan = D('Home/Front')->get_config_by_name('weprogram_subtemplate_open_tuan');
  295. if( !empty($weprogram_subtemplate_open_tuan) )
  296. {
  297. $need_subscript_template['open_tuan'] = $weprogram_subtemplate_open_tuan;
  298. }
  299. }
  300. $take_tuan_info = M('lionfish_comshop_subscribe')->where( array('member_id' => $member_id, 'type' => 'take_tuan' ) )->find();
  301. if( empty($take_tuan_info) )
  302. {
  303. $weprogram_subtemplate_take_tuan = D('Home/Front')->get_config_by_name('weprogram_subtemplate_take_tuan');
  304. if( !empty($weprogram_subtemplate_take_tuan) )
  305. {
  306. $need_subscript_template['take_tuan'] = $weprogram_subtemplate_take_tuan;
  307. }
  308. }
  309. if( !empty($need_subscript_template) )
  310. {
  311. $is_need_subscript = 1;
  312. }
  313. }
  314. echo json_encode(array(
  315. 'code' => 1,
  316. 'comment_list' => $comment_list,
  317. 'order_comment_images' => $order_comment_images,
  318. 'order_comment_count' => $order_comment_count,
  319. 'data' => $need_data,
  320. 'is_comunity_rest' => $is_comunity_rest,
  321. 'open_man_orderbuy' => $open_man_orderbuy,
  322. 'man_orderbuy_money' => $man_orderbuy_money,
  323. 'goodsdetails_buy_bg_color' => $goodsdetails_buy_bg_color,
  324. 'goodsdetails_addcart_bg_color' => $goodsdetails_addcart_bg_color,
  325. 'isopen_community_group_share' => $isopen_community_group_share,
  326. 'is_need_subscript' => $is_need_subscript,
  327. 'need_subscript_template' => $need_subscript_template,
  328. 'group_share_info' => $group_share_info,
  329. 'is_close_details_time' => $is_close_details_time,
  330. 'pintuan_model_buy' => $pintuan_model_buy,
  331. 'pintuan_close_stranger' => $pintuan_close_stranger
  332. ));
  333. die();
  334. }
  335. public function get_goods_fujin_tuan()
  336. {
  337. $_GPC = I('request.');
  338. $pintuan_model_buy = D('Home/Front')->get_config_by_name('pintuan_model_buy');
  339. if( empty($pintuan_model_buy) )
  340. {
  341. $pintuan_model_buy = 0;
  342. }
  343. $head_id = isset($_GPC['head_id']) ? $_GPC['head_id']:0;
  344. $goods_id = $_GPC['goods_id'];
  345. $limit = isset($_GPC['limit']) ? $_GPC['limit']:8;
  346. $where = "";
  347. if( $pintuan_model_buy == 1 )
  348. {
  349. //o.order_id head_id
  350. $where .= " and o.head_id = {$head_id} ";
  351. }
  352. $pintuan_stranger_zero = D('Home/Front')->get_config_by_name('pintuan_stranger_zero');
  353. if( !isset($pintuan_stranger_zero) || $pintuan_stranger_zero == 0 )
  354. {
  355. $where .= " and o.type !='ignore' ";
  356. }
  357. $fujin_sql = "select distinct(p.pin_id) as pin_id,p.need_count,o.order_id,p.end_time,m.username,m.avatar from ".C('DB_PREFIX')."lionfish_comshop_pin as p,".C('DB_PREFIX')."lionfish_comshop_order_goods as og,".C('DB_PREFIX')."lionfish_comshop_pin_order as po,
  358. ".C('DB_PREFIX')."lionfish_comshop_order as o,".C('DB_PREFIX')."lionfish_comshop_member as m
  359. where p.pin_id = po.pin_id and po.order_id = o.order_id and og.order_id=o.order_id and o.member_id = m.member_id {$where} and o.order_status_id =2 and og.goods_id={$goods_id} and p.end_time>".time()." group by po.pin_id order by p.end_time asc limit {$limit}";
  360. $fujin_countsql = "select distinct(p.pin_id) as pin_id,p.need_count,o.order_id,p.end_time,m.username,m.avatar from ".C('DB_PREFIX')."lionfish_comshop_pin as p,".C('DB_PREFIX')."lionfish_comshop_order_goods as og,".C('DB_PREFIX')."lionfish_comshop_pin_order as po,
  361. ".C('DB_PREFIX')."lionfish_comshop_order as o,".C('DB_PREFIX')."lionfish_comshop_member as m
  362. where p.pin_id = po.pin_id and po.order_id=o.order_id and og.order_id=o.order_id and o.member_id = m.member_id {$where} and o.order_status_id =2 and og.goods_id={$goods_id} and p.end_time>".time()." group by po.pin_id order by p.end_time asc ";
  363. $fujin_tuan_arr_count = M()->query($fujin_countsql );
  364. $fujin_tuan_count = count($fujin_tuan_arr_count);
  365. $fujin_tuan = M()->query($fujin_sql);
  366. $result = array();
  367. if(!empty($fujin_tuan))
  368. {
  369. foreach($fujin_tuan as $pintuan)
  370. {
  371. $buy_count = $this->get_tuan_buy_count($pintuan['pin_id']);
  372. $pintuan['buy_count'] =$buy_count;
  373. $pintuan['cur_interface_time'] = time();
  374. $pintuan['re_need_count'] = $pintuan['need_count'] - $buy_count;
  375. //shipping_city_id
  376. //$pintuan['area_name'] = $area_info['area_name'];
  377. $order_id = $pintuan['order_id'];
  378. if($buy_count > 0)
  379. {
  380. //存在进行中的
  381. $result[] = $pintuan;
  382. }
  383. }
  384. }
  385. if( empty($result) )
  386. {
  387. echo json_encode( array('code' => 1) );
  388. die();
  389. }else{
  390. echo json_encode( array('code' => 0, 'list' => $result, 'count' => $fujin_tuan_count) );
  391. die();
  392. }
  393. }
  394. /**
  395. * 获取拼团已成功购买价数量
  396. */
  397. public function get_tuan_buy_count($pin_id=0)
  398. {
  399. $buy_count_sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."lionfish_comshop_pin as p,".C('DB_PREFIX')."lionfish_comshop_pin_order as po,"
  400. .C('DB_PREFIX')."lionfish_comshop_order_goods as og,
  401. ".C('DB_PREFIX')."lionfish_comshop_order as o
  402. where p.pin_id = po.pin_id and po.order_id=o.order_id and og.order_id = o.order_id and o.order_status_id =2 and p.pin_id={$pin_id} ";
  403. $count_tuan_arr = M()->query($buy_count_sql );
  404. return $count_tuan_arr[0]['count'];
  405. }
  406. function group_info()
  407. {
  408. $_GPC = I('request.');
  409. $interface_get_time = time();
  410. $token = $_GPC['token'];
  411. $order_id = $_GPC['order_id'];
  412. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  413. $member_id = $weprogram_token['member_id'];
  414. if( empty($member_id) )
  415. {
  416. $member_id = 0;
  417. }
  418. $is_show = 0;
  419. //获取拼团商品信息
  420. $order_goods = M('lionfish_comshop_order_goods')->field('name,goods_id,price,total,goods_images,quantity')->where( array('order_id' => $order_id ) )->find();
  421. if(empty($order_goods))
  422. {
  423. //未找到
  424. echo json_encode( array('code' =>1) );
  425. die();
  426. }
  427. //分享标题为购买价格
  428. //$order_goods['price'] = round($order_goods['price'],2);
  429. $order_goods['total'] = round($order_goods['total'],2);
  430. $order_info = M('lionfish_comshop_order')->field('member_id,type,head_id')->where( array('order_id' =>$order_id ) )->find();
  431. $good_image = D('Home/Pingoods')->get_goods_images($order_goods['goods_id']);
  432. if( !empty($good_image) )
  433. {
  434. //$order_goods['goods_images'] = tomedia($good_image['image']);
  435. }
  436. $goods_info = M('lionfish_comshop_goods')->field('goodsname as name,subtitle,productprice ,seller_count,sales as virtual_count,is_all_sale')->where( array('id' => $order_goods['goods_id'] ) )->find();
  437. $goods_desc = M('lionfish_comshop_good_common')->field('share_title as share_group_title')->where( array('goods_id' => $order_goods['goods_id'] ) )->find();
  438. $goods_info['seller_count'] = $goods_info['seller_count'] + $goods_info['virtual_count'];
  439. if( !empty($good_image) )
  440. {
  441. $goods_info['goods_images'] = tomedia($good_image['image']);
  442. }
  443. unset($goods_info['virtual_count']);
  444. $pin_order = M('lionfish_comshop_pin_order')->where( array('order_id' => $order_id ) )->find();
  445. //获取拼团信息
  446. $pin_info = M('lionfish_comshop_pin')->where( array('pin_id' =>$pin_order['pin_id'] ) )->find();
  447. $pintuan_isvirs_success = D('Home/Front')->get_config_by_name('pintuan_isvirs_success');
  448. if( !empty($pintuan_isvirs_success) && $pintuan_isvirs_success == 1 && $pin_info['state'] == 0 && $pin_info['end_time'] < time() )
  449. {
  450. $res = D('Home/Pin')->jia_over_order( $pin_info['pin_id'] );
  451. $pin_info = M('lionfish_comshop_pin')->where( array('pin_id' =>$pin_order['pin_id'] ) )->find();
  452. }
  453. //拼团状态:0进行中, 1成功, 2 已经过期了
  454. if($pin_info['state'] == 0 && $pin_info['end_time'] < time()){
  455. $pin_info['state'] = 2;
  456. }
  457. if( !empty($pin_info['success_time']) )
  458. {
  459. $pin_info['success_time'] = date('Y-m-d H:i:s', $pin_info['success_time']);
  460. }
  461. $goods_info['pin_count'] = $pin_info['need_count'];
  462. $price_arr = D('Home/Pingoods')->get_goods_price($order_goods['goods_id'], $member_id);
  463. $goods_info['pinprice'] = $price_arr['price'];
  464. //分享标题为规格最低价格
  465. $order_goods['price'] = round($price_arr['price'],2);
  466. $goods_info['danprice'] = $price_arr['danprice'];
  467. //ims_
  468. $tuanzhang_info = M('lionfish_comshop_member')->field('member_id,username,telephone,avatar')->where( array('member_id' => $pin_info['user_id'] ) )->find();
  469. $pin_order_sql = "select po.add_time,m.member_id,m.username as name,m.telephone,m.avatar from ".C('DB_PREFIX')."lionfish_comshop_pin_order as po,".C('DB_PREFIX')."lionfish_comshop_order as o,
  470. ".C('DB_PREFIX')."lionfish_comshop_order_goods as og,".C('DB_PREFIX')."lionfish_comshop_member as m
  471. where po.pin_id = ".$pin_info['pin_id']." and o.order_status_id in(1,2,4,6,7,8,9,10,11,14)
  472. and og.order_id = po.order_id and o.order_id = po.order_id and o.member_id= m.member_id order by po.add_time asc ";
  473. $pin_order_arr = M()->query($pin_order_sql);
  474. $me_take_in = 0;
  475. foreach($pin_order_arr as $key =>$val)
  476. {
  477. if($member_id == $val['member_id'])
  478. {
  479. $me_take_in = 1;
  480. }
  481. $pin_order_arr[$key] = $val;
  482. }
  483. //pin_order_arr
  484. if( $pin_info['is_jiqi'] == 1 )
  485. {
  486. $jiapinorder = M('lionfish_comshop_jiapinorder')->where( array('pin_id' => $pin_info['pin_id'] ) )->order('id asc')->select();
  487. if( !empty($jiapinorder) )
  488. {
  489. foreach( $jiapinorder as $vv )
  490. {
  491. $tp_arr_info = array();
  492. $tp_arr_info['add_time'] = $vv['addtime'];
  493. $tp_arr_info['member_id'] = $vv['id'];
  494. $tp_arr_info['name'] = $vv['uname'];
  495. $tp_arr_info['telephone'] = $vv['mobile'];
  496. $tp_arr_info['avatar'] = tomedia( $vv['avatar']);
  497. $pin_order_arr[] = $tp_arr_info ;
  498. }
  499. }
  500. }
  501. $is_me = 0;
  502. if($order_info['member_id'] == $member_id)
  503. {
  504. $is_me = 1;
  505. }
  506. $share_title = "不要错过~我".round($order_goods['price'],2)."元拼了".$goods_info['name'];
  507. if(!empty($goods_desc['share_group_title']) )
  508. {
  509. $share_title = $goods_desc['share_group_title'];
  510. $share_title = str_replace('{pin_price}',round($order_goods['price'],2),$share_title);
  511. $share_title = str_replace('{name}',$goods_info['name'],$share_title);
  512. }
  513. /* 商品规格begin */
  514. /* 商品规格end */
  515. unset( $tuanzhang_info['reg_type'] );
  516. unset( $tuanzhang_info['openid'] );
  517. unset( $tuanzhang_info['we_openid'] );
  518. unset( $tuanzhang_info['bindmobile'] );
  519. unset( $tuanzhang_info['uname'] );
  520. unset( $tuanzhang_info['email'] );
  521. unset( $tuanzhang_info['pwd'] );
  522. unset( $tuanzhang_info['address_id'] );
  523. unset( $tuanzhang_info['share_id'] );
  524. unset( $tuanzhang_info['comsiss_flag'] );
  525. unset( $tuanzhang_info['bind_seller_id'] );
  526. unset( $tuanzhang_info['bind_seller_pickup'] );
  527. unset( $tuanzhang_info['cart'] );
  528. unset( $tuanzhang_info['wishlist'] );
  529. unset( $tuanzhang_info['id_cardreal_name'] );
  530. unset( $tuanzhang_info['id_card'] );
  531. unset( $tuanzhang_info['login_count'] );
  532. unset( $tuanzhang_info['last_login_ip'] );
  533. unset( $tuanzhang_info['last_ip_region'] );
  534. unset( $tuanzhang_info['create_time'] );
  535. unset( $tuanzhang_info['last_login_time'] );
  536. unset( $tuanzhang_info['status'] );
  537. $options = D('Home/Pingoods')->get_goods_options($order_goods['goods_id']);
  538. $need_data = array();
  539. $need_data['is_me'] = $is_me;
  540. $need_data['goods_info'] = $goods_info;
  541. //$need_data['pin_goods'] = $pin_goods;
  542. //$need_data['pin_order'] = $pin_order;
  543. $need_data['me_take_in'] = $me_take_in;
  544. $need_data['share_title'] = $share_title;
  545. //$need_data['tuanzhang_info'] = $tuanzhang_info;
  546. $need_data['pin_order_arr'] = $pin_order_arr;
  547. $need_data['order_goods'] = $order_goods;
  548. $need_data['order_id'] = $order_id;
  549. $need_data['order_type'] = $order_info['type'];
  550. $need_data['community_id'] = $order_info['head_id'];
  551. $need_data['group_order_id'] = $group_order_id;
  552. $need_data['options'] = $options;
  553. $need_data['interface_get_time'] = $interface_get_time;
  554. $need_data['member_id'] = $member_id;
  555. $need_data['del_count'] = $pin_info['need_count'] - count($pin_order_arr);
  556. if( $need_data['del_count'] <= 0 && $pin_info['state'] != 2 )
  557. {
  558. $pin_info['state'] = 1;
  559. }
  560. $need_data['pin_info'] = $pin_info;
  561. $pintuan_model_buy = D('Home/Front')->get_config_by_name('pintuan_model_buy');
  562. if( empty($pintuan_model_buy) || $pintuan_model_buy ==0 )
  563. {
  564. $pintuan_model_buy = 0;
  565. }
  566. $need_data['pintuan_model_buy'] = $pintuan_model_buy;
  567. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  568. $need_data['hide_community_change_btn'] = $hide_community_change_btn;
  569. $pintuan_show_community_info = D('Home/Front')->get_config_by_name('pintuan_show_community_info');
  570. $need_data['pintuan_show_community_info'] = $pintuan_show_community_info;
  571. $is_need_subscript = 0;
  572. $need_subscript_template = array();
  573. if( $member_id >0 )
  574. {
  575. $take_tuan_info = M('lionfish_comshop_subscribe')->where( array('member_id' => $member_id, 'type' => 'take_tuan' ) )->find();
  576. if( empty($take_tuan_info) )
  577. {
  578. $weprogram_subtemplate_take_tuan = D('Home/Front')->get_config_by_name('weprogram_subtemplate_take_tuan');
  579. if( !empty($weprogram_subtemplate_take_tuan) )
  580. {
  581. $need_subscript_template['take_tuan'] = $weprogram_subtemplate_take_tuan;
  582. }
  583. }
  584. if( !empty($need_subscript_template) )
  585. {
  586. $is_need_subscript = 1;
  587. }
  588. }
  589. $need_data['is_need_subscript'] = $is_need_subscript;
  590. $need_data['need_subscript_template'] = $need_subscript_template;
  591. echo json_encode( array('code' =>0, 'data' => $need_data) );
  592. die();
  593. }
  594. /***
  595. 获取会员佣金团的收益账户金额
  596. **/
  597. public function get_pincommiss_account_info()
  598. {
  599. $_GPC = I('request.');
  600. $token = $_GPC['token'];
  601. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  602. $member_id = $weprogram_token['member_id'];
  603. if( empty($member_id) )
  604. {
  605. $member_id = 0;
  606. }
  607. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  608. if( empty($member_info) )
  609. {
  610. echo json_encode( array('code' => 1,'msg' => '您未登录') );
  611. die();
  612. }
  613. //commission_account($member_id)
  614. D('Home/Pin')->commission_account($member_id);
  615. $pintuan_commiss = M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $member_id ) )->find();
  616. //可提现金额 money
  617. //待结算金额 ims_lionfish_comshop_pintuan_commiss_order
  618. $wait_statements_money = M('lionfish_comshop_pintuan_commiss_order')->where( array('member_id' =>$member_id,'state' => 0 ) )->sum('money');
  619. //已结算金额 has_statements_money
  620. $has_statements_money = M('lionfish_comshop_pintuan_commiss_order')->where( array('member_id' =>$member_id,'state' => 1 ) )->sum('money');
  621. //已提现金额 getmoney
  622. $pintuan_commiss['wait_statements_money'] = empty($wait_statements_money) ? 0:$wait_statements_money;//待结算金额
  623. $pintuan_commiss['has_statements_money'] = empty($has_statements_money) ? 0 :$has_statements_money;//已结算金额
  624. echo json_encode( array('code' => 0, 'data' => $pintuan_commiss ) );
  625. die();
  626. }
  627. /**
  628. 获取佣金订单列表
  629. **/
  630. public function listorder_list()
  631. {
  632. $_GPC = I('request.');
  633. $token = $_GPC['token'];
  634. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  635. $member_id = $weprogram_token['member_id'];
  636. if( empty($member_id) )
  637. {
  638. $member_id = 0;
  639. }
  640. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  641. if( empty($member_info) )
  642. {
  643. echo json_encode( array('code' => 1, 'msg' => '会员不存在') );
  644. die();
  645. }
  646. $per_page = 6;
  647. $page = isset($_GPC['page']) ? $_GPC['page']:1;
  648. $offset = ($page - 1) * $per_page;
  649. $list = array();
  650. $where = '';
  651. $state = isset($_GPC['state']) ? $_GPC['state']: -1;
  652. //state
  653. if($state >=0)
  654. {
  655. $where .= ' and mco.state = '.$state;
  656. }
  657. $sql = 'select mco.money,mco.addtime,mco.statement_time,mco.state,o.order_id,o.order_num_alias,o.order_status_id,
  658. o.order_num_alias,o.total,o.pay_time,o.date_added,og.goods_id,og.quantity,og.name,og.price,og.goods_images,og.order_goods_id,mco.store_id,m.username as uname from '
  659. .C('DB_PREFIX')."lionfish_comshop_pintuan_commiss_order as mco , ".C('DB_PREFIX')."lionfish_comshop_order_goods as og,
  660. ".C('DB_PREFIX')."lionfish_comshop_order as o ,
  661. ".C('DB_PREFIX')."lionfish_comshop_member as m
  662. where mco.order_id=og.order_id and mco.order_id = o.order_id and mco.order_goods_id=og.order_goods_id and m.member_id=o.member_id and mco.member_id=".$member_id." {$where} order by mco.id desc limit {$offset},{$per_page}";
  663. $list = M()->query($sql );
  664. $status_arr = D('Seller/Order')->get_order_status_name();
  665. foreach($list as $key =>$val)
  666. {
  667. $val['total'] = round($val['total'],2);
  668. $val['money'] = round($val['money'],2);
  669. $val['status_name'] = $status_arr[$val['order_status_id']];
  670. //$val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  671. unset($val['addtime']);
  672. $val['pay_time'] = date('Y-m-d H:i:s', $val['pay_time']);
  673. $val['date_added'] = date('Y-m-d H:i:s', $val['date_added']);
  674. if( !empty($val['goods_images']))
  675. {
  676. if(is_array($goods_images))
  677. {
  678. $val['goods_images'] = $val['goods_images'];
  679. }else{
  680. $val['goods_images']= tomedia( $val['goods_images'] );
  681. }
  682. }else{
  683. $val['goods_images']= '';
  684. }
  685. $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' => $val['order_goods_id'] ) )->select();
  686. foreach($order_option_list as $option)
  687. {
  688. $val['option_str'][] = $option['value'];
  689. }
  690. if( !isset($val['option_str']) )
  691. {
  692. $val['option_str'] = '';
  693. }else{
  694. $val['option_str'] = implode(',', $val['option_str']);
  695. }
  696. if( $val['state'] == 1 )
  697. {
  698. $val['statement_time'] = date('Y-m-d H:i:s', $val['statement_time']);
  699. }
  700. $pin_order = M('lionfish_comshop_pin_order')->where( array('order_id' => $val['order_id'] ) )->find();
  701. $pin_info = M('lionfish_comshop_pin')->field('need_count')->where( array('pin_id' => $pin_order['pin_id'] ) )->find();
  702. $val['pin_count'] = $pin_info['need_count'];
  703. $list[$key] = $val;
  704. }
  705. if(empty($list))
  706. {
  707. echo json_encode( array('code' => 1) );
  708. die();
  709. }else {
  710. echo json_encode( array('code' => 0, 'data' => $list) );
  711. die();
  712. }
  713. }
  714. /**
  715. 获取会员拼团佣金基础数据
  716. **/
  717. public function get_commission_info()
  718. {
  719. $_GPC = I('request.');
  720. $token = $_GPC['token'];
  721. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  722. $member_id = $weprogram_token['member_id'];
  723. if( empty($member_id) )
  724. {
  725. $member_id = 0;
  726. }
  727. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  728. if( empty($member_info) )
  729. {
  730. echo json_encode( array('code' => 1, 'msg' => '会员不存在') );
  731. die();
  732. }
  733. //最小提现金额
  734. $commiss_min_tixian_money = D('Home/Front')->get_config_by_name('pintuan_min_tixian_money');
  735. if( empty($commiss_min_tixian_money) )
  736. {
  737. $commiss_min_tixian_money = 0;
  738. }
  739. $commiss_tixian_bili = D('Home/Front')->get_config_by_name('pintuan_tixian_bili');
  740. if( empty($commiss_tixian_bili) )
  741. {
  742. $commiss_tixian_bili = 0;
  743. }
  744. $member_commiss = M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $member_id ) )->find();
  745. $member_commiss['commiss_min_tixian_money'] = $commiss_min_tixian_money;//最小提现金额, 0标识不限制
  746. $member_commiss['commiss_tixian_bili'] = $commiss_tixian_bili;
  747. $member_commiss['total_commiss_money'] = $member_commiss['money'] + $member_commiss['dongmoney'] + $member_commiss['getmoney'];
  748. $commiss_tixianway_yuer = D('Home/Front')->get_config_by_name('pintuan_tixianway_yuer');
  749. $commiss_tixianway_weixin = D('Home/Front')->get_config_by_name('pintuan_tixianway_weixin');
  750. $commiss_tixianway_alipay = D('Home/Front')->get_config_by_name('pintuan_tixianway_alipay');
  751. $commiss_tixianway_bank = D('Home/Front')->get_config_by_name('pintuan_tixianway_bank');
  752. $member_commiss['commiss_tixianway_yuer'] = empty($commiss_tixianway_yuer) ? 1 : ($commiss_tixianway_yuer == 2 ? 1:0);
  753. $member_commiss['commiss_tixianway_weixin'] = empty($commiss_tixianway_weixin) ? 1 : ($commiss_tixianway_weixin == 2 ? 1:0);
  754. $member_commiss['commiss_tixianway_alipay'] = empty($commiss_tixianway_alipay) ? 1 : ($commiss_tixianway_alipay == 2 ? 1:0);
  755. $member_commiss['commiss_tixianway_bank'] = empty($commiss_tixianway_bank) ? 1 : ($commiss_tixianway_bank == 2 ? 1:0);
  756. //上一微信真实姓名
  757. $last_weixin_realname = "";
  758. $last_weixin_info = M('lionfish_comshop_pintuan_tixian_order')->where( array('member_id' => $member_id, 'type' => 2 ) )->find();
  759. if( !empty($last_weixin_info) )
  760. {
  761. $last_weixin_realname = $last_weixin_info['bankusername'];
  762. }
  763. //上一支付宝账号
  764. $last_alipay_name = '';
  765. $last_alipay_account = '';
  766. $last_alipay_info = M('lionfish_comshop_pintuan_tixian_order')->where( array('member_id' => $member_id, 'type' => 3 ) )->find();
  767. if( !empty($last_alipay_info) )
  768. {
  769. $last_alipay_name = $last_alipay_info['bankusername'];
  770. $last_alipay_account = $last_alipay_info['bankaccount'];
  771. }
  772. //上一银行卡信息
  773. $last_bank_bankname = '';
  774. $last_bank_account = '';
  775. $last_bank_name = '';
  776. $last_bank_info = M('lionfish_comshop_pintuan_tixian_order')->where( array('member_id' => $member_id, 'type' => 4 ) )->find();
  777. if( !empty($last_bank_info) )
  778. {
  779. $last_bank_bankname = $last_bank_info['bankname'];
  780. $last_bank_account = $last_bank_info['bankaccount'];
  781. $last_bank_name = $last_bank_info['bankusername'];
  782. }
  783. $member_commiss['last_weixin_realname'] = $last_weixin_realname;
  784. $member_commiss['last_alipay_name'] = $last_alipay_name;
  785. $member_commiss['last_alipay_account'] = $last_alipay_account;
  786. $member_commiss['last_bank_bankname'] = $last_bank_bankname;
  787. $member_commiss['last_bank_account'] = $last_bank_account;
  788. $member_commiss['last_bank_name'] = $last_bank_name;
  789. $commiss_tixian_publish = D('Home/Front')->get_config_by_name('pintuan_tixian_publish');
  790. $member_commiss['commiss_tixian_publish'] = htmlspecialchars_decode( $commiss_tixian_publish );
  791. $member_commiss['total_money'] = sprintf('%.2f', $member_commiss['money'] + $member_commiss['dongmoney'] + $member_commiss['getmoney']);
  792. echo json_encode( array('code' =>0,'data' => $member_commiss) );
  793. die();
  794. }
  795. /**
  796. 会员拼团佣金提现 提交接口
  797. **/
  798. public function tixian_sub()
  799. {
  800. $_GPC = I('request.');
  801. $token = $_GPC['token'];
  802. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  803. $member_id = $weprogram_token['member_id'];
  804. if( empty($member_id) )
  805. {
  806. $member_id = 0;
  807. }
  808. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  809. if( empty($member_info) )
  810. {
  811. echo json_encode( array('code' => 1, 'msg' => '会员不存在') );
  812. die();
  813. }
  814. $result = array('code' => 1,'msg' => '提现失败');
  815. $member_commiss = M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $member_id ) )->find();
  816. $datas = array();
  817. $datas['money'] = $_GPC['money'];
  818. $money = $datas['money'];//I('post.money',0,'floatval');
  819. $type = $_GPC['type'];// 1余额 2 微信 3 支付宝 4 银行
  820. $bankname = isset($_GPC['bankname']) ? $_GPC['bankname'] : ''; //银行名称
  821. $bankaccount = isset($_GPC['bankaccount']) ? $_GPC['bankaccount'] : '';//卡号,支付宝账号 使用该字段
  822. $bankusername = isset($_GPC['bankusername']) ? $_GPC['bankusername'] : '';//持卡人姓名,微信名称,支付宝名称, 使用该字段
  823. $commiss_money_limit = D('Home/Front')->get_config_by_name('pintuan_min_tixian_money');
  824. if(!empty($commiss_money_limit) && $commiss_money_limit >0)
  825. {
  826. if($member_commiss['money'] < $commiss_money_limit)
  827. {
  828. $result['msg'] = '佣金满'.$commiss_money_limit.'才能提现';
  829. echo json_encode($result);
  830. die();
  831. }
  832. }
  833. if($money > 0 && $money <= $member_commiss['money'])
  834. {
  835. //判断提现手续费,+ 判断提现金额免审直接到账
  836. $service_charge = D('Home/Front')->get_config_by_name('pintuan_tixian_bili');
  837. $data = array();
  838. $data['member_id'] = $member_id;
  839. $data['money'] = $money;
  840. $data['service_charge'] = $service_charge;
  841. $data['service_charge_money'] = round( ($money * $service_charge) /100 ,2);
  842. $data['state'] = 0;
  843. $data['shentime'] = 0;
  844. $data['type'] = $type;
  845. $data['bankname'] = $bankname;
  846. $data['bankaccount'] = $bankaccount;
  847. $data['bankusername'] = $bankusername;
  848. $data['addtime'] = time();
  849. M('lionfish_comshop_pintuan_tixian_order')->add($data);
  850. $com_arr = array();
  851. $com_arr['money'] = $member_commiss['money'] - $money;
  852. $com_arr['dongmoney'] = $member_commiss['dongmoney'] + $money;
  853. M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $member_id ) )->setInc('money',-$money);
  854. M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $member_id ) )->setInc('dongmoney',$money);
  855. $result['code'] = 0;
  856. //commiss_tixian_reviewed 0 , 1
  857. $commiss_tixian_reviewed = D('Home/Front')->get_config_by_name('pintuan_tixian_reviewed');
  858. if(empty($commiss_tixian_reviewed) || $commiss_tixian_reviewed == 0)
  859. {
  860. //手动
  861. } else if( !empty($commiss_tixian_reviewed) && $commiss_tixian_reviewed == 1 ){
  862. //自动
  863. }
  864. }
  865. echo json_encode($result);
  866. die();
  867. }
  868. /**
  869. 提现记录
  870. **/
  871. public function tixian_record()
  872. {
  873. $_GPC = I('request.');
  874. $token = $_GPC['token'];
  875. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  876. $member_id = $weprogram_token['member_id'];
  877. if( empty($member_id) )
  878. {
  879. $member_id = 0;
  880. }
  881. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  882. if( empty($member_info) )
  883. {
  884. echo json_encode( array('code' => 1, 'msg' => '会员不存在') );
  885. die();
  886. }
  887. $per_page = 10;
  888. $page = isset($_GPC['page']) ? $_GPC['page']:1;
  889. $offset = ($page - 1) * $per_page;
  890. $list = array();
  891. $list = M('lionfish_comshop_pintuan_tixian_order')->where( array('member_id' =>$member_id ) )->order('addtime desc')->limit($offset,$per_page )->select();
  892. foreach($list as $key => $val)
  893. {
  894. $val['addtime'] = date('Y-m-d H:i', $val['addtime']);
  895. $list[$key] = $val;
  896. }
  897. if( !empty($list) )
  898. {
  899. echo json_encode( array('code' =>0, 'data'=>$list) );
  900. die();
  901. }else{
  902. echo json_encode( array('code' => 1) );
  903. die();
  904. }
  905. }
  906. }