UserController.class.php 42 KB

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