UserController.class.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605
  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 Seller\Controller;
  15. class UserController extends CommonController{
  16. public function index()
  17. {
  18. $condition = '';
  19. $gpc = I('request.');
  20. $this->gpc = $gpc;
  21. $pindex = I('request.page', 1);
  22. $psize = 20;
  23. $keyword = I('request.keyword');
  24. $this->keyword = $keyword;
  25. if (!empty($keyword)) {
  26. if(is_numeric($keyword)){
  27. $condition .= ' and ( (username like '.'"%' . $keyword . '%") or (telephone like '.'"%' . $keyword . '%") or (member_id = ' . $keyword .'))';
  28. }else{
  29. $condition .= ' and ( (username like '.'"%' . $keyword . '%") or (telephone like '.'"%' . $keyword . '%") )';
  30. }
  31. }
  32. //时间
  33. $starttime_arr = I('request.time');
  34. $starttime = isset($starttime_arr['start']) ? strtotime($starttime_arr['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  35. $endtime = isset($starttime_arr['end']) ? strtotime($starttime_arr['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  36. $sort_starttime = I('request.sort_starttime');
  37. $sort_endtime = I('request.sort_endtime');
  38. if( isset($sort_starttime) && $sort_starttime > 0 )
  39. {
  40. $starttime = $sort_starttime;
  41. }
  42. if( isset($sort_endtime) && $sort_endtime > 0 )
  43. {
  44. $endtime = $sort_endtime;
  45. }
  46. $this->starttime = $starttime;
  47. $this->endtime = $endtime;
  48. $searchtime = I('request.searchtime','');
  49. $this->searchtime = $searchtime;
  50. if( !empty($searchtime) )
  51. {
  52. switch( $searchtime )
  53. {
  54. case 'create':
  55. $condition .= ' AND (create_time >='.$starttime.' and create_time <= '.$endtime.' )';
  56. break;
  57. }
  58. }
  59. //时间 end
  60. //排序
  61. $sortby = I('get.sortby');
  62. $sortfield = I('get.sortfield');
  63. $this->sortfield = $sortfield;
  64. $sortby = (!empty($sortby) ? ($sortby== 'asc' ?'desc':'asc') : ( !empty($sortfield) ? 'desc':'' ) );
  65. $this->sortby = $sortby;
  66. if(!empty($sortfield) && !empty($sortby)){
  67. $orderby = $sortfield.' '.$sortby .',';
  68. }
  69. //排序end
  70. $level_id = I('request.level_id',0);
  71. if( isset($level_id) && !empty($level_id) )
  72. {
  73. if($level_id == 'default')
  74. {
  75. $level_id = 0;
  76. }
  77. $condition .= ' and level_id = '.$level_id;
  78. }
  79. $this->level_id = $level_id;
  80. $groupid = I('request.groupid');
  81. $this->groupid = $groupid;
  82. //groupid/default
  83. if( isset($groupid) && !empty($groupid) && $groupid != 'default' )
  84. {
  85. $condition .= ' and groupid = '.$groupid;
  86. }
  87. $card_id = I('request.card_id');
  88. $this->card_id = $card_id;
  89. if( isset($card_id) && !empty($card_id) && $card_id != 'default' )
  90. {
  91. $condition .= ' and card_id = '.$card_id;
  92. }
  93. if ($gpc['export'] == '1') {
  94. $list = M()->query('SELECT * FROM ' .C('DB_PREFIX') . "lionfish_comshop_member \r\n
  95. WHERE 1=1 " . $condition . ' order by '. $orderby .' member_id desc');
  96. }else{
  97. $list = M()->query('SELECT * FROM ' .C('DB_PREFIX') . "lionfish_comshop_member \r\n
  98. WHERE 1=1 " . $condition . ' order by '. $orderby .' member_id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  99. }
  100. $total = M('lionfish_comshop_member')->where("1=1 ". $condition )->count();
  101. $level_list = M('lionfish_comshop_member_level')->order('level asc')->select();
  102. $keys_level = array();
  103. foreach($level_list as $vv)
  104. {
  105. $keys_level[$vv['id']] = $vv['levelname'];
  106. }
  107. $this->level_list = $level_list;
  108. $group_list = M('lionfish_comshop_member_group')->order('id asc')->select();
  109. $keys_group = array();
  110. if( !empty($group_list) )
  111. {
  112. foreach($group_list as $vv)
  113. {
  114. $keys_group[$vv['id']] = $vv['groupname'];
  115. }
  116. }
  117. $this->group_list = $group_list;
  118. //会员卡 $keys_card
  119. $card_list = M('lionfish_comshop_member_card')->order('id asc')->select();
  120. $keys_card = array();
  121. if( !empty($card_list) )
  122. {
  123. foreach($card_list as $vv)
  124. {
  125. $keys_card[$vv['id']] = $vv['cardname'];
  126. }
  127. }
  128. $this->card_list = $card_list;
  129. foreach( $list as $key => $val )
  130. {
  131. //ims_ lionfish_comshop_order 1 2 4 6 11
  132. $ordercount = M('lionfish_comshop_order')->where( array('order_status_id' => array('in','1,2,4,6,11,14,12,13'),'member_id' => $val['member_id'] ) )->count();
  133. //$ordermoney = M('lionfish_comshop_order')->where( array('order_status_id' => array('in','1,2,4,6,11,14,12,13'),'member_id' => $val['member_id']) )->sum('total');
  134. $ordermoney = M('lionfish_comshop_order')->where( ' type != "integral" and order_status_id in(1,2,4,6,11,14,12,13) and member_id='.$val['member_id'] )->sum('total');
  135. if(empty($val['share_id'] )){
  136. $share_name['username'] = 0 ;
  137. }else{
  138. $share_name = M('lionfish_comshop_member')->where( array('member_id' => $val['share_id'] ) )->find();
  139. }
  140. // lionfish_community_history
  141. $community_history = M('lionfish_community_history')->field('head_id')->where( array('member_id' => $val['member_id'] ) )->order('addtime desc')->find();
  142. if( !empty($community_history) )
  143. {
  144. $cur_community_info = M('lionfish_community_head')->where( array('id' => $community_history['head_id'] ) )->find();
  145. $val['cur_communityname'] = $cur_community_info['community_name'];
  146. } else{
  147. $val['cur_communityname'] = '无';
  148. }
  149. $val['levelname'] = empty($val['level_id']) ? '普通会员':$keys_level[$val['level_id']];
  150. $val['groupname'] = empty($val['groupid']) ? '默认分组':$keys_group[$val['groupid']];
  151. $val['cardname'] = empty($val['card_id']) ? '无会员卡':$keys_card[$val['card_id']];
  152. $has_shopinfo = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $val['member_id']) )->find();
  153. if( !empty($has_shopinfo) )
  154. {
  155. $val['has_shopinfo'] = $has_shopinfo;
  156. }else{
  157. $val['has_shopinfo'] = array();
  158. }
  159. $val['ordercount'] = $ordercount;
  160. $val['ordermoney'] = $ordermoney;
  161. $val['share_name'] = $share_name['username'];
  162. //$val['username'] = base64_decode(''.$val['full_user_name'].'');
  163. $val['form_info'] = unserialize( $val['form_info'] );
  164. $list[$key] = $val;
  165. }
  166. if ($gpc['export'] == '1') {
  167. foreach ($list as &$row) {
  168. //推荐人 总店
  169. $row['share_name'] = $row['share_name'] == '' ? '总店': $row['share_name'];
  170. $row['create_time'] = date('Y-m-d H:i:s', $row['create_time']);
  171. //状态
  172. $row['isblack'] = $row['isblack'] == 1 ? '禁用':'启用';
  173. //分销
  174. $row['comsiss'] = ($row['comsiss_flag'] == 1 && $row['comsiss_state'] == 1) ? '是':'否';
  175. //订单金额
  176. $row['ordermoney'] = $row['ordermoney'] == 0 ? 0 : $row['ordermoney'];
  177. }
  178. //unset($row);
  179. $columns = array(
  180. array('title' => 'ID', 'field' => 'member_id', 'width' => 12),
  181. array('title' => '会员名称', 'field' => 'username', 'width' => 12),
  182. array('title' => '推荐人', 'field' => 'share_name', 'width' => 12),
  183. array('title' => '小区名称', 'field' => 'cur_communityname', 'width' => 24),
  184. array('title' => 'openid', 'field' => 'openid', 'width' => 24),
  185. array('title' => '手机', 'field' => 'telephone', 'width' => 12),
  186. array('title' => '会员等级', 'field' => 'levelname', 'width' => 12),
  187. array('title' => '会员分组', 'field' => 'groupname', 'width' => 12),
  188. array('title' => '积分', 'field' => 'score', 'width' => 12),
  189. array('title' => '余额', 'field' => 'account_money', 'width' => 12),
  190. array('title' => '订单数', 'field' => 'ordercount', 'width' => 12),
  191. array('title' => '订单金额', 'field' => 'ordermoney', 'width' => 12),
  192. array('title' => '是否分销', 'field' => 'comsiss', 'width' => 12),
  193. array('title' => '注册时间', 'field' => 'create_time', 'width' => 24),
  194. array('title' => '状态', 'field' => 'isblack', 'width' => 12)
  195. );
  196. D('Seller/excel')->export($list, array('title' => '会员数据-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  197. }
  198. $is_get_formdata = D('Home/Front')->get_config_by_name('is_get_formdata');
  199. $this->is_get_formdata = $is_get_formdata;
  200. $pager = pagination2($total, $pindex, $psize);
  201. $this->pager = $pager;
  202. $this->list = $list;
  203. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  204. if( empty($commiss_level) )
  205. {
  206. $commiss_level = 0;
  207. }
  208. $this->commiss_level = $commiss_level;
  209. //会员是否需要审核
  210. $is_user_shenhe = D('Home/Front')->get_config_by_name('is_user_shenhe');
  211. if( empty($is_user_shenhe) || $is_user_shenhe == 0 )
  212. {
  213. $is_user_shenhe = 1;
  214. }
  215. $this->is_user_shenhe = $is_user_shenhe;
  216. $this->display();
  217. }
  218. //todo
  219. public function agent_shenhe()
  220. {
  221. $_GPC = I('request.');
  222. $id = intval($_GPC['id']);
  223. if (empty($id)) {
  224. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  225. }
  226. $is_apply_state = intval($_GPC['state']);
  227. $apply_list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member_tixian_order
  228. WHERE id in( ' . $id . ' ) ');
  229. M('lionfish_comshop_member')->where( "member_id in ({$id})" )->save( array('is_apply_state' => $is_apply_state) );
  230. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  231. }
  232. public function agent_unshenhe()
  233. {
  234. $_GPC = I('request.');
  235. $id = intval($_GPC['id']);
  236. if (empty($id)) {
  237. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  238. }
  239. $is_apply_state = intval($_GPC['state']);
  240. $apply_list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member_tixian_order
  241. WHERE id in( ' . $id . ' ) ');
  242. M('lionfish_comshop_member')->where( "member_id in ({$id})" )->save( array('is_apply_state' => 2) );
  243. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  244. }
  245. public function shopinfo()
  246. {
  247. $member_id = I('get.id');
  248. $shop_info = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $member_id ) )->find();
  249. $level_list = M('lionfish_comshop_member_level')->order('level asc ')->select();
  250. if( !empty($shop_info['imggroup']) )
  251. {
  252. $shop_info['imggroup'] = explode(',' , $shop_info['imggroup']);
  253. }
  254. if( !empty($shop_info['otherimggroup']) )
  255. {
  256. $shop_info['otherimggroup'] = explode(',' , $shop_info['otherimggroup']);
  257. }
  258. $this->shop_info = $shop_info;
  259. $this->member_id = $member_id;
  260. $list = array(
  261. array('id' => 'default', 'level_money'=>'0','discount'=>'100' ,'level'=>0,'levelname' => '普通会员',
  262. 'membercount' => $membercount ) );
  263. if( empty($level_list) )
  264. {
  265. $level_list = array();
  266. }
  267. //$level_list = array_merge($list, $level_list);
  268. $this->level_list = $level_list;
  269. $this->display();
  270. }
  271. public function chose_community()
  272. {
  273. $_GPC = I('request.');
  274. $member_id = $_GPC['s_member_id'];
  275. $head_id = $_GPC['head_id'];
  276. D('Seller/community')->in_community_history($member_id, $head_id);
  277. //load_model_class('community')->in_community_history($member_id, $head_id);
  278. echo json_encode( array('code' => 0) );
  279. die();
  280. }
  281. public function lvconfig ()
  282. {
  283. $_GPC = I('request.');
  284. if (IS_POST) {
  285. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  286. D('Seller/Config')->update($data);
  287. show_json(1);
  288. }
  289. $data = D('Seller/Config')->get_all_config();
  290. $this->display();
  291. }
  292. public function recharge_flow ()
  293. {
  294. $_GPC = I('request.');
  295. $member_id = $_GPC['id'];
  296. $condition = ' and member_id='.$member_id.' and state >0 ';
  297. $pindex = max(1, intval($_GPC['page']));
  298. $psize = 20;
  299. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member_charge_flow \r\n
  300. WHERE 1 " . $condition . ' order by id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  301. $total_arr = M()->query('SELECT count(id) as count FROM ' . C('DB_PREFIX') . 'lionfish_comshop_member_charge_flow WHERE 1 ' . $condition );
  302. $total = $total_arr[0]['count'];
  303. foreach( $list as $key => $val )
  304. {
  305. $val['add_time'] = date('Y-m-d H:i:s',$val['add_time'] );
  306. if($val['state'] != 21){
  307. $val['trans_id'] = '--';
  308. }
  309. if($val['state'] == 3 || $val['state'] == 4)
  310. {
  311. $od_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['trans_id'] ) )->find();
  312. if( !empty($od_info) )
  313. {
  314. $val['trans_id'] = $od_info['order_num_alias'];
  315. }
  316. }
  317. $list[$key] = $val;
  318. }
  319. $pager = pagination2($total, $pindex, $psize);
  320. $this->list = $list;
  321. $this->pager = $pager;
  322. $this->display();
  323. }
  324. public function integral_flow ()
  325. {
  326. $_GPC = I('request.');
  327. $member_id = $_GPC['id'];
  328. $condition = ' and member_id='.$member_id.' and type >0 ';
  329. $pindex = max(1, intval($_GPC['page']));
  330. $psize = 20;
  331. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member_integral_flow
  332. WHERE 1 " . $condition . ' order by id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  333. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member_integral_flow WHERE 1 ' . $condition );
  334. $total = $total_arr[0]['count'];
  335. foreach( $list as $key => $val )
  336. {
  337. $val['add_time'] = date('Y-m-d H:i:s',$val['add_time'] );
  338. if($val['type'] == 'goodsbuy' || $val['type'] == 'refundorder' || $val['type'] == 'orderbuy'|| $val['type'] == 'goodscomment')
  339. {
  340. $od_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['order_id'] ) )->find();
  341. if( !empty($od_info) )
  342. {
  343. $val['order_id'] = $od_info['order_num_alias'];
  344. }
  345. }
  346. $list[$key] = $val;
  347. }
  348. $pager = pagination2($total, $pindex, $psize);
  349. $this->list = $list;
  350. $this->pager = $pager;
  351. $this->display();
  352. }
  353. public function editshopinfo()
  354. {
  355. $post_data = I('post.');
  356. $up_data = array();
  357. $up_data['shop_name'] = $post_data['shop_name'];
  358. $up_data['shop_mobile'] = $post_data['shop_mobile'];
  359. $up_data['state'] = $post_data['state'];
  360. M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $post_data['member_id'] ) )->save($up_data);
  361. //oscshop_ lionfish_comshop_member_shopinfo
  362. if($post_data['state'] == 1)
  363. {
  364. M('lionfish_comshop_member')->where( array('member_id' =>$post_data['member_id'] ) )->save( array('level_id' => $post_data['level_id'] ) );
  365. }
  366. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  367. }
  368. //user.changelevel
  369. public function changelevel()
  370. {
  371. $_GPC = I('request.');
  372. $level = $_GPC['level'];
  373. $ids_arr = $_GPC['ids'];
  374. $toggle = $_GPC['toggle'];
  375. $ids = implode(',', $ids_arr);
  376. if($toggle == 'group')
  377. {
  378. M('lionfish_comshop_member')->where( "member_id in ({$ids})" )->save( array('groupid' => $level ) );
  379. }else if($toggle == 'level'){
  380. M('lionfish_comshop_member')->where( "member_id in ({$ids})" )->save( array('level_id' =>$level ) );
  381. }
  382. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  383. }
  384. public function config()
  385. {
  386. if (IS_POST) {
  387. $data = I('request.data');
  388. D('Seller/Config')->update($data);
  389. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  390. }
  391. $data = D('Seller/Config')->get_all_config();
  392. $this->data = $data;
  393. $this->display();
  394. }
  395. public function usergroup()
  396. {
  397. $_GPC = I('request.');
  398. $membercount = M('lionfish_comshop_member')->where( array('groupid' => 0) )->count();
  399. $list = array(
  400. array('id' => 'default', 'groupname' => '默认分组',
  401. 'membercount' => $membercount )
  402. );
  403. $condition = ' ';
  404. $params = array(':uniacid' => $_W['uniacid']);
  405. $keyword= '';
  406. if (!(empty($_GPC['keyword']))) {
  407. $_GPC['keyword'] = trim($_GPC['keyword']);
  408. $condition .= ' and ( groupname like "%'.$_GPC['keyword'].'%")';
  409. $keyword = $_GPC['keyword'];
  410. }
  411. $alllist = M('lionfish_comshop_member_group')->where( '1'. $condition )->order('id asc')->select();
  412. foreach ($alllist as &$row ) {
  413. $membercount_arr = M()->query('select count(*) as count from ' . C('DB_PREFIX') .
  414. 'lionfish_comshop_member where groupid='.$row['id'].' ');
  415. $row['membercount'] = $membercount_arr[0]['count'];
  416. }
  417. unset($row);
  418. if (empty($_GPC['keyword'])) {
  419. $list = array_merge($list, $alllist);
  420. }
  421. else {
  422. $list = $alllist;
  423. }
  424. $this->keyword = $keyword;
  425. $this->list = $list;
  426. $this->display();
  427. }
  428. public function user()
  429. {
  430. }
  431. public function userjia()
  432. {
  433. $_GPC = I('request.');
  434. $condition = '1';
  435. $pindex = max(1, intval($_GPC['page']));
  436. $psize = 20;
  437. if (!empty($_GPC['keyword'])) {
  438. $_GPC['keyword'] = trim($_GPC['keyword']);
  439. $condition .= ' and username like "%' . $_GPC['keyword'] . '%"';
  440. }
  441. $list = M('lionfish_comshop_jiauser')->where( $condition )->order('id desc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  442. $total = M('lionfish_comshop_jiauser')->where($condition)->count();
  443. $pager = pagination2($total, $pindex, $psize);
  444. $this->list = $list;
  445. $this->pager = $pager;
  446. $this->gpc = $_GPC;
  447. $this->display();
  448. }
  449. public function userlevel()
  450. {
  451. $_GPC = I('request.');
  452. $membercount = M('lionfish_comshop_member')->where( array('level_id' => 0) )->count();
  453. $list = array(
  454. array('id' => 'default', 'level_money'=>'0','discount'=>'100' ,'level'=>0,'levelname' => '普通会员',
  455. 'membercount' => $membercount ) );
  456. $condition = ' 1 ';
  457. if (!(empty($_GPC['keyword']))) {
  458. $_GPC['keyword'] = trim($_GPC['keyword']);
  459. $condition .= ' and ( levelname like "%'.$_GPC['keyword'].'%" )';
  460. }
  461. $alllist = M('lionfish_comshop_member_level')->where( $condition )->order('id asc')->select();
  462. foreach ($alllist as &$row ) {
  463. $row['membercount'] = M('lionfish_comshop_member')->where( "find_in_set(".$row['id'].",level_id)" )->count();
  464. }
  465. unset($row);
  466. if (empty($_GPC['keyword'])) {
  467. if( empty($alllist) )
  468. {
  469. $alllist = array();
  470. }
  471. $list = array_merge($list, $alllist);
  472. }
  473. else {
  474. $list = $alllist;
  475. }
  476. $this->gpc = $_GPC;
  477. $this->list = $list;
  478. $this->display();
  479. }
  480. public function adduserlevel()
  481. {
  482. $_GPC = I('request.');
  483. //ims_
  484. $id = intval($_GPC['id']);
  485. $group = M('lionfish_comshop_member_level')->where( array('id' => $id ) )->find();
  486. if (IS_POST) {
  487. $discount = trim($_GPC['discount']);
  488. if(!preg_match("/^[1-9][0-9]*$/" ,$discount) || intval($discount) < 1 || intval($discount) > 100){
  489. show_json(0, array('message' => '请按照提示设置会员等级折扣'));
  490. }
  491. $data = array('logo' => trim($_GPC['logo']),'discount' => trim($_GPC['discount']),'level_money' => trim($_GPC['level_money']),'levelname' => trim($_GPC['levelname']),
  492. 'level' => trim($_GPC['level']), 'is_auto_grade' => $_GPC['is_auto_grade'] );
  493. if (!(empty($id))) {
  494. M('lionfish_comshop_member_level')->where(array('id' => $id))->save( $data );
  495. }
  496. else {
  497. $id = M('lionfish_comshop_member_level')->add( $data );
  498. }
  499. show_json(1, array('url' => U('user/userlevel', array('op' => 'display'))));
  500. }
  501. if(empty($group['discount'])){
  502. $group['discount'] = 100;
  503. }else{
  504. $group['discount'] = floatval($group['discount']);
  505. }
  506. $this->id = $id;
  507. $this->gpc = $_GPC;
  508. $this->group = $group;
  509. $this->display();
  510. }
  511. public function adduserjia()
  512. {
  513. $_GPC = I('request.');
  514. $id = intval($_GPC['id']);
  515. $group = array();
  516. if( $id > 0 )
  517. {
  518. $group = M('lionfish_comshop_jiauser')->where( array('id' => $id) )->find();
  519. }
  520. if (IS_POST) {
  521. $data = array('avatar' => trim($_GPC['avatar']),
  522. 'username' => trim($_GPC['username']),'mobile' => trim($_GPC['mobile']) );
  523. if (!(empty($id))) {
  524. M('lionfish_comshop_jiauser')->where( array('id' => $id) )->save( $data );
  525. }
  526. else {
  527. $id = M('lionfish_comshop_jiauser')->add($data);
  528. }
  529. show_json(1, array('url' => U('user/userjia', array('op' => 'display'))));
  530. }
  531. $this->group = $group;
  532. $this->display();
  533. }
  534. //--begin
  535. public function zhenquery_commission()
  536. {
  537. $_GPC = I('request.');
  538. $kwd = trim($_GPC['keyword']);
  539. $is_not_hexiao = isset($_GPC['is_not_hexiao']) ? intval($_GPC['is_not_hexiao']):0;
  540. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  541. $this->kwd = $kwd;
  542. $this->is_not_hexiao = $is_not_hexiao;
  543. $this->is_ajax = $is_ajax;
  544. $condition = ' and comsiss_flag=1 and comsiss_state=1 ';
  545. if (!empty($kwd)) {
  546. $condition .= ' AND ( `username` LIKE "%'.$kwd.'%" or `telephone` like "%'.$kwd.'%" )';
  547. }
  548. if( $is_not_hexiao == 1 )
  549. {
  550. $condition .= " and pickup_id= 0 ";
  551. }
  552. /**
  553. 分页开始
  554. **/
  555. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  556. $page = max(1, $page);
  557. $page_size = 10;
  558. /**
  559. 分页结束
  560. **/
  561. $ds = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member WHERE 1 ' . $condition .
  562. ' order by member_id asc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size );
  563. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX') .
  564. 'lionfish_comshop_member WHERE 1 ' . $condition );
  565. $total = $total_arr[0]['count'];
  566. foreach ($ds as &$value) {
  567. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  568. $value['id'] = $value['member_id'];
  569. if($is_ajax == 1)
  570. {
  571. $ret_html .= '<tr>';
  572. $ret_html .= ' <td><img src="'.$value['avatar'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />'. $value['nickname'].'</td>';
  573. $ret_html .= ' <td>'.$value['mobile'].'</td>';
  574. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  575. $ret_html .= '</tr>';
  576. }
  577. }
  578. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  579. if( $is_ajax == 1 )
  580. {
  581. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  582. die();
  583. }
  584. unset($value);
  585. if ($_GPC['suggest']) {
  586. exit(json_encode(array('value' => $ds)));
  587. }
  588. $this->pager = $pager;
  589. $this->ds = $ds;
  590. $this->display('User/query_commission');
  591. }
  592. public function zhenquery()
  593. {
  594. $_GPC = I('request.');
  595. $kwd = trim($_GPC['keyword']);
  596. $is_not_hexiao = isset($_GPC['is_not_hexiao']) ? intval($_GPC['is_not_hexiao']):0;
  597. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  598. $limit = isset($_GPC['limit']) ? intval($_GPC['limit']) : 0;
  599. $condition = ' ';
  600. if (!empty($kwd)) {
  601. $condition .= ' AND ( `username` LIKE "%'.$kwd.'%" or `telephone` like "%'.$kwd.'%" )';
  602. }
  603. if( $is_not_hexiao == 1 )
  604. {
  605. $condition .= " and pickup_id= 0 ";
  606. }
  607. /**
  608. 分页开始
  609. **/
  610. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  611. $page = max(1, $page);
  612. $page_size = 10;
  613. /**
  614. 分页结束
  615. **/
  616. $sql ='SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member WHERE 1 ' . $condition .' order by member_id asc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size ;
  617. $ds = M()->query($sql);
  618. $total = M('lionfish_comshop_member')->where( '1 ' . $condition )->count();
  619. foreach ($ds as &$value) {
  620. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  621. $value['nickname'] = str_replace("'",'',$value['username']);
  622. $value['username'] = htmlspecialchars($value['username'], ENT_QUOTES);
  623. $value['username'] = str_replace("'",'',$value['username']);
  624. $value['id'] = $value['member_id'];
  625. //判断该会员是否已经是团长
  626. if($limit == 1)
  627. {
  628. $value['exist'] = M('lionfish_community_head')->where( array('member_id' => $value['id'] ) )->count();
  629. }else{
  630. $value['exist'] = 0;
  631. }
  632. if($is_ajax == 1)
  633. {
  634. $ret_html .= '<tr>';
  635. $ret_html .= ' <td><img src="'.$value['avatar'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />'. $value['nickname'].'</td>';
  636. $ret_html .= ' <td>'.$value['mobile'].'</td>';
  637. if(!empty($value['exist'])){
  638. $ret_html .= '<td style="width:80px;border:#ccc">选择</td>';
  639. }else{
  640. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  641. }
  642. $ret_html .= '</tr>';
  643. }
  644. }
  645. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  646. if( $is_ajax == 1 )
  647. {
  648. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  649. die();
  650. }
  651. unset($value);
  652. if ($_GPC['suggest']) {
  653. exit(json_encode(array('value' => $ds)));
  654. }
  655. $this->ds = $ds;
  656. $this->pager = $pager;
  657. $this->display('User/query');
  658. }
  659. //--end
  660. public function zhenquery_many()
  661. {
  662. $_GPC = I('request.');
  663. $kwd = trim($_GPC['keyword']);
  664. $is_not_hexiao = isset($_GPC['is_not_hexiao']) ? intval($_GPC['is_not_hexiao']):0;
  665. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  666. $this->_GPC = $_GPC;
  667. $this->kwd = $kwd;
  668. $condition = ' ';
  669. if (!empty($kwd)) {
  670. $condition .= ' AND ( `username` LIKE "%'.$kwd.'%" or `telephone` like "%'.$kwd.'%" )';
  671. }
  672. if( $is_not_hexiao == 1 )
  673. {
  674. $condition .= " and pickup_id= 0 ";
  675. }
  676. /**
  677. 分页开始
  678. **/
  679. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  680. $page = max(1, $page);
  681. $page_size = 10;
  682. /**
  683. 分页结束
  684. **/
  685. $ds = M()->query('SELECT * FROM ' . C('DB_PREFIX') . 'lionfish_comshop_member WHERE 1 ' . $condition .
  686. ' order by member_id asc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size );
  687. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX').'lionfish_comshop_member WHERE 1 ' . $condition );
  688. $total = $total_arr[0]['count'];
  689. foreach ($ds as &$value) {
  690. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  691. $value['id'] = $value['member_id'];
  692. if($is_ajax == 1)
  693. {
  694. $ret_html .= '<tr>';
  695. $ret_html .= ' <td><img src="'.$value['avatar'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />'. $value['nickname'].'</td>';
  696. $ret_html .= ' <td>'.$value['mobile'].'</td>';
  697. $value['username'] = str_replace("'", "", $value['username']);
  698. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  699. $ret_html .= '</tr>';
  700. }
  701. }
  702. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  703. if( $is_ajax == 1 )
  704. {
  705. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  706. die();
  707. }
  708. unset($value);
  709. if ($_GPC['suggest']) {
  710. exit(json_encode(array('value' => $ds)));
  711. }
  712. $this->ds = $ds;
  713. $this->pager = $pager;
  714. $this->display();
  715. }
  716. public function query()
  717. {
  718. $kwd = I('request.keyword','');
  719. $condition = ' 1 ';
  720. if (!empty($kwd)) {
  721. $condition .= ' AND ( `username` LIKE '.'"%' . $kwd . '%"'.' )';
  722. }
  723. $ds = M('lionfish_comshop_jiauser')->where( $condition )->select();
  724. $s_html = "";
  725. foreach ($ds as &$value) {
  726. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  727. $value['avatar'] = tomedia($value['avatar']);
  728. $value['member_id'] = ($value['id']);
  729. $s_html .= "<tr><td><img src='".$value['avatar']."' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> {$value[nickname]}</td>";
  730. $s_html .= "<td>{$value['mobile']}</td>";
  731. $s_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td></tr>';
  732. }
  733. unset($value);
  734. if( isset($_GPC['is_ajax']) )
  735. {
  736. echo json_encode( array('code' =>0, 'html' => $s_html) );
  737. die();
  738. }
  739. $url = 'user/query';
  740. $this->url = $url;
  741. $this->ds = $ds;
  742. $this->display();
  743. }
  744. public function addusergroup()
  745. {
  746. $_GPC = I('request.');
  747. $id = intval($_GPC['id']);
  748. if( $id >0 )
  749. {
  750. $group = M('lionfish_comshop_member_group')->where( array('id' => $id ) )->find();
  751. $this->group = $group;
  752. }
  753. if (IS_POST) {
  754. $data = array( 'groupname' => trim($_GPC['groupname']) );
  755. if (!(empty($id))) {
  756. M('lionfish_comshop_member_group')->where( array('id' => $id) )->save($data);
  757. }
  758. else {
  759. $id = M('lionfish_comshop_member_group')->add( $data );
  760. }
  761. show_json(1, array('url' => U('user/usergroup', array('op' => 'display'))));
  762. }
  763. include $this->display();
  764. }
  765. public function recharge()//
  766. {
  767. $_GPC = I('request.');
  768. $type = trim($_GPC['type']);
  769. //dump($_GPC);
  770. //echo 7777;
  771. if( empty($type) )
  772. {
  773. $type = 'score';
  774. }
  775. $id = intval($_GPC['id']);
  776. $profile = M('lionfish_comshop_member')->where( array('member_id' => $id) )->find();
  777. if (IS_POST) {
  778. $typestr = ($type == 'score' ? '积分' : '余额');
  779. $num = floatval($_GPC['num']);
  780. $remark = trim($_GPC['remark']);
  781. if ($num < 0) {
  782. show_json(0, array('message' => '请填写不小于0的数字!'));
  783. }
  784. $changetype = intval($_GPC['changetype']);
  785. if ($type == 'score') {
  786. //0 增加 1 减少 2 最终积分
  787. $ch_type = 'system_add';
  788. if($changetype == 1 )
  789. {
  790. $ch_type = 'system_del';
  791. }
  792. D('Seller/User')->sendMemberPointChange($profile['member_id'], $num, $changetype, $remark, $ch_type);
  793. //D('Seller/User')->sendMemberPointChange($profile['member_id'], $num, $changetype, $remark);
  794. }
  795. if ($type == 'account_money') {
  796. D('Seller/User')->sendMemberMoneyChange($profile['member_id'], $num, $changetype, $remark);
  797. }
  798. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  799. }
  800. $this->profile = $profile;
  801. $this->id = $id;
  802. $this->type = $type;
  803. $this->gpc = $_GPC;
  804. $this->display();
  805. }
  806. public function detail()
  807. {
  808. $id = I('request.id');
  809. $_GPC = I('request.');
  810. $is_showform = I('request.is_showform',0);
  811. $member = M('lionfish_comshop_member')->where( array('member_id' => $id) )->find();
  812. $ordercount = M('lionfish_comshop_order')->where( 'order_status_id in(1,2,4,6,11,14,12,13) and member_id='.$id )->count();
  813. $ordermoney = M('lionfish_comshop_order')->where( ' type != "integral" and order_status_id in(1,2,4,6,11,14,12,13) and member_id='.$id )->sum('total');
  814. $member['self_ordercount'] = $ordercount;
  815. $member['self_ordermoney'] = $ordermoney;
  816. //commiss_formcontent is_writecommiss_form
  817. if( $member['is_writecommiss_form'] == 1 )
  818. {
  819. $member['commiss_formcontent'] = unserialize($member['commiss_formcontent']);
  820. }
  821. if( $member['is_write_form'] == 1 )
  822. {
  823. $member['form_info'] = unserialize( $member['form_info'] );
  824. }
  825. if (IS_POST) {
  826. $data = I('request.data');
  827. if($member['is_writecommiss_form'] == 1)
  828. {
  829. $commiss_formcontent_data = array();
  830. foreach( $member['commiss_formcontent'] as $val )
  831. {
  832. $key = $val['name'].'_'.$val['type'];
  833. if( isset($_GPC[$key]) )
  834. {
  835. $commiss_formcontent_data[] = array('type' => 'text','name' => $val['name'], 'value' => $_GPC[$key] );
  836. }
  837. $data['commiss_formcontent'] = serialize($commiss_formcontent_data);
  838. }
  839. }
  840. //if( $commiss_level > 0 )
  841. // {
  842. if( $id == $data['agentid'] )
  843. {
  844. show_json(0, array('message' => '不能选择自己为上级分销商'));
  845. }
  846. // }
  847. //
  848. if( $data['isblack'] == 1)
  849. {
  850. M('lionfish_comshop_weprogram_token')->where( array('member_id' => $id ) )->delete();
  851. }
  852. M('lionfish_comshop_member')->where( array('member_id' => $id) )->save($data);
  853. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  854. }
  855. if(!empty($member['card_id']) && $member['card_id'] > 0){
  856. $member_card = M('lionfish_comshop_member_card')->where( array('id' => $member['card_id']) )->find();
  857. $member['cardname'] = $member_card['cardname'];
  858. }
  859. $this->member = $member;
  860. $level_list = M('lionfish_comshop_member_level')->order('level asc')->select();
  861. $keys_level = array();
  862. foreach($level_list as $vv)
  863. {
  864. $keys_level[$vv['id']] = $vv['levelname'];
  865. }
  866. $this->level_list = $level_list;
  867. $group_list = M('lionfish_comshop_member_group')->order('id asc')->select();
  868. $keys_group = array();
  869. if( !empty($group_list) )
  870. {
  871. foreach($group_list as $vv)
  872. {
  873. $keys_group[$vv['id']] = $vv['groupname'];
  874. }
  875. }
  876. $this->group_list = $group_list;
  877. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  878. if( empty($commiss_level) )
  879. {
  880. $commiss_level = 0;
  881. }
  882. $this->commiss_level = $commiss_level;
  883. foreach( $list as $key => $val )
  884. {
  885. //ims_ lionfish_comshop_order 1 2 4 6 11
  886. $ordercount = M('lionfish_comshop_order')->where( array('member_id' => $val['member_id'] ) )->count();
  887. $ordermoney = M('lionfish_comshop_order')->where( array('order_status_id' => array('in','1,2,4,6,11,14,12,13'),'member_id' => $val['member_id']) )->sum('total');
  888. $val['levelname'] = empty($val['level_id']) ? '普通会员':$keys_level[$val['level_id']];
  889. $val['groupname'] = empty($val['groupid']) ? '默认分组':$keys_group[$val['groupid']];
  890. $has_shopinfo = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $val['member_id']) )->find();
  891. if( !empty($has_shopinfo) )
  892. {
  893. $val['has_shopinfo'] = $has_shopinfo;
  894. }else{
  895. $val['has_shopinfo'] = array();
  896. }
  897. $val['ordercount'] = $ordercount;
  898. $val['ordermoney'] = $ordermoney;
  899. $list[$key] = $val;
  900. }
  901. $saler = array();
  902. //会员是否需要审核
  903. $is_user_shenhe = D('Home/Front')->get_config_by_name('is_user_shenhe');
  904. if( empty($is_user_shenhe) || $is_user_shenhe == 0 )
  905. {
  906. $is_user_shenhe = 1;
  907. }
  908. $this->is_user_shenhe = $is_user_shenhe;
  909. //会员是否需要收集表单
  910. $is_get_formdata = D('Home/Front')->get_config_by_name('is_get_formdata');
  911. if( empty($is_get_formdata) || $is_get_formdata == 0 )
  912. {
  913. $is_get_formdata = 1;
  914. }
  915. $this->is_get_formdata = $is_get_formdata;
  916. //saler
  917. if( $member['agentid'] > 0 )
  918. {
  919. $saler = M('lionfish_comshop_member')->field('avatar,username as nickname,member_id')->where( array('member_id' => $member['agentid'] ) )->find();
  920. }
  921. $this->saler = $saler;
  922. $this->is_showform = $is_showform;
  923. $this->display();
  924. }
  925. public function deleteuserlevel()
  926. {
  927. $_GPC = I('request.');
  928. $id = intval($_GPC['id']);
  929. if (empty($id)) {
  930. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  931. }
  932. $items = M('lionfish_comshop_member_level')->field('id')->where( ' id in( ' . $id . ' ) ' )->select();
  933. foreach ($items as $item ) {
  934. M('lionfish_comshop_member')->where( array('level_id' => $item['id']) )->save( array('level_id' => 0) );
  935. M('lionfish_comshop_member_level')->where( array('id' => $item['id']) )->delete();
  936. }
  937. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  938. }
  939. public function deleteuser()
  940. {
  941. $id = I('request.id');
  942. if (empty($id)) {
  943. $ids = I('request.ids');
  944. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  945. }
  946. $items = M('lionfish_comshop_member')->field('member_id')->where( array('member_id' => array('in', $id)) )->select();
  947. foreach ($items as $item ) {
  948. M('lionfish_comshop_member')->where( array('member_id' => $item['member_id']) )->delete();
  949. }
  950. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  951. }
  952. public function deleteuserjia()
  953. {
  954. $_GPC = I('request.');
  955. $id = intval($_GPC['id']);
  956. if (empty($id)) {
  957. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  958. }
  959. $items = M('lionfish_comshop_jiauser')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  960. foreach ($items as $item ) {
  961. M('lionfish_comshop_jiauser')->where( array('id' => $item['id']) )->delete();
  962. }
  963. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  964. }
  965. public function deleteusergroup()
  966. {
  967. $_GPC = I('request.');
  968. $id = intval($_GPC['id']);
  969. if (empty($id)) {
  970. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  971. }
  972. $items = M('lionfish_comshop_member_group')->where( "id in (".$id.")" )->select();
  973. foreach ($items as $item ) {
  974. M('lionfish_comshop_member')->where( array('groupid' => $item['id'] ) )->save( array('groupid' => 0) );
  975. M('lionfish_comshop_member_group')->where( array('id' => $item['id']) )->delete();
  976. }
  977. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  978. }
  979. /**
  980. * 修改会员卡到期时间
  981. */
  982. public function edit_expiretime(){
  983. $_GPC = I('request.');
  984. $id = $_GPC['id'];
  985. $is_post = $_GPC['is_post'];
  986. $member = M('lionfish_comshop_member')->where( array('member_id' => $id) )->find();
  987. $this->member = $member;
  988. if($is_post){
  989. $expire_time = strtotime($_GPC['expire_time']);
  990. $days = (strtotime(date('Y-m-d',$expire_time)) - strtotime(date('Y-m-d',$member['card_end_time']))) / 86400;
  991. M('lionfish_comshop_member')->where( array('member_id' => $id) )->save(array('card_end_time'=>$expire_time));
  992. $member_card = M('lionfish_comshop_member_card')->where( array('id' => $member['card_id']) )->find();
  993. $begin_time = time();
  994. $member_charge_flow_data = array();
  995. $member_charge_flow_data['order_sn'] = build_order_no($id);
  996. $member_charge_flow_data['member_id'] = $id;
  997. $member_charge_flow_data['pay_type'] = 'admin';
  998. $member_charge_flow_data['state'] = 1;
  999. $member_charge_flow_data['car_id'] = $member['card_id'];
  1000. $member_charge_flow_data['expire_day'] = $days;
  1001. $member_charge_flow_data['price'] = $member_card['price'];
  1002. $member_charge_flow_data['order_type'] = 5; // 后台修改
  1003. $member_charge_flow_data['begin_time'] = $begin_time;
  1004. $member_charge_flow_data['end_time'] = $expire_time;
  1005. $member_charge_flow_data['pay_time'] = $begin_time;
  1006. $member_charge_flow_data['addtime'] = time();
  1007. $order_id = M('lionfish_comshop_member_card_order')->add( $member_charge_flow_data );
  1008. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1009. }
  1010. $this->display();
  1011. }
  1012. public function query_card(){
  1013. $_GPC = I('request.');
  1014. $id = $_GPC['id'];
  1015. $member = M('lionfish_comshop_member')->where( array('member_id' => $id) )->find();
  1016. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  1017. $kwd = $_GPC['keyword'];
  1018. $condition = ' 1=1 ';
  1019. if (!empty($kwd)) {
  1020. $condition .= ' AND ( `cardname` LIKE '.'"%' . $kwd . '%"'.' )';
  1021. }
  1022. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  1023. $page = max(1, $page);
  1024. $page_size = 10;
  1025. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member_card WHERE ' . $condition .
  1026. ' order by id desc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size );
  1027. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX') .
  1028. 'lionfish_comshop_member_card WHERE ' . $condition );
  1029. $total = $total_arr[0]['count'];
  1030. $s_html = "<tr>"
  1031. . " <th>会员卡名称</th>"
  1032. . " <th>原价</th>"
  1033. . " <th>现价</th>"
  1034. . " <th>有效天数</th>"
  1035. . " <th>操作</th>"
  1036. . " </tr>";
  1037. foreach ($list as &$value) {
  1038. $s_html .= "<td>{$value['cardname']}</td>";
  1039. $s_html .= "<td>{$value['orignprice']}</td>";
  1040. $s_html .= "<td>{$value['price']}</td>";
  1041. $s_html .= "<td>{$value['expire_day']}天</td>";
  1042. $s_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td></tr>';
  1043. }
  1044. unset($value);
  1045. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  1046. if( $is_ajax == 1 )
  1047. {
  1048. echo json_encode( array('code' => 0, 'html' => $s_html,'pager' => $pager) );
  1049. die();
  1050. }
  1051. $url = 'user/query_card';
  1052. $this->url = $url;
  1053. $this->list = $list;
  1054. $this->pager = $pager;
  1055. $this->member = $member;
  1056. $this->display();
  1057. }
  1058. /**
  1059. * 后台开通会员卡
  1060. */
  1061. public function open_ucard(){
  1062. $_GPC = I('request.');
  1063. $card_id = $_GPC['card_id'];
  1064. $id = $_GPC['member_id'];
  1065. if(empty($id) || empty($card_id)){
  1066. show_json(0, array('message' => '会员或会员卡数据错误'));
  1067. }
  1068. $member_card = M('lionfish_comshop_member_card')->where( array('id' => $card_id) )->find();
  1069. $begin_time = time();
  1070. $end_time = $begin_time + 86400 * $member_card['expire_day'];
  1071. $member_charge_flow_data = array();
  1072. $member_charge_flow_data['order_sn'] = build_order_no($id);
  1073. $member_charge_flow_data['member_id'] = $id;
  1074. $member_charge_flow_data['pay_type'] = 'admin';
  1075. $member_charge_flow_data['state'] = 1;
  1076. $member_charge_flow_data['car_id'] = $member_card['id'];
  1077. $member_charge_flow_data['expire_day'] = $member_card['expire_day'];
  1078. $member_charge_flow_data['price'] = $member_card['price'];
  1079. $member_charge_flow_data['order_type'] = 4; // 后台购买
  1080. $member_charge_flow_data['begin_time'] = $begin_time;
  1081. $member_charge_flow_data['end_time'] = $end_time;
  1082. $member_charge_flow_data['pay_time'] = $begin_time;
  1083. $member_charge_flow_data['addtime'] = time();
  1084. $order_id = M('lionfish_comshop_member_card_order')->add( $member_charge_flow_data );
  1085. $mb_up_data = array();
  1086. $mb_up_data['card_id'] = $member_card['id'];
  1087. $mb_up_data['card_begin_time'] = $begin_time;
  1088. $mb_up_data['card_end_time'] = $end_time;
  1089. M('lionfish_comshop_member')->where( array('member_id' => $id ) )->save( $mb_up_data );
  1090. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1091. }
  1092. public function user_shenhe()
  1093. {
  1094. $_GPC = I('request.');
  1095. $member_id = $_GPC['id'];
  1096. $state = $_GPC['state'];
  1097. if( $state == 1 )
  1098. {
  1099. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save( array('is_comsiss_audit' => 1) );
  1100. }else{
  1101. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save( array('is_comsiss_audit' => 0) );
  1102. }
  1103. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  1104. }
  1105. }
  1106. ?>