MemberModel.class.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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 Admin\Model;
  15. class MemberModel{
  16. /**
  17. *显示分页
  18. */
  19. public function show_member_page($search){
  20. $sql="select * from ".C('DB_PREFIX')."member where 1 ";
  21. if(isset($search['name'])){
  22. $sql.=" and uname like '%".$search['name']."%'";
  23. }
  24. if(isset($search['email'])){
  25. $sql.=" and email='".$search['email']."'";
  26. }
  27. if(isset($search['tel'])){
  28. $sql.=" and telephone='".$search['tel']."'";
  29. }
  30. if(isset($search['level_id'])){
  31. $sql.=" and level_id='".$search['level_id']."'";
  32. }
  33. //level_id
  34. $count=count(M()->query($sql));
  35. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  36. $show = $Page->show();// 分页显示输出
  37. $sql.=' order by member_id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  38. $list=M()->query($sql);
  39. $member_model = D('Home/Member');
  40. $level_data=$this->show_member_level();
  41. $member_default_levelname_info = M('config')->where( array('name' => 'member_default_levelname') )->find();
  42. $member_defualt_discount_info = M('config')->where( array('name' => 'member_defualt_discount') )->find();
  43. $default = array('id'=>'0', 'level' => 0,'levelname' => $member_default_levelname_info['value'],'discount' => $member_defualt_discount_info['value']);
  44. array_unshift($level_data['list'], $default );
  45. $need_level = array();
  46. foreach($level_data['list'] as $vv)
  47. {
  48. $need_level[ $vv['id'] ] = $vv['levelname'];
  49. }
  50. foreach($list as $key => $val)
  51. {
  52. //comsiss_flag
  53. if($val['comsiss_flag'] == 1)
  54. {
  55. $member_commiss = M('member_commiss')->where( array('member_id' => $val['member_id'] ) )->find();
  56. $total_wait_where = array();
  57. $total_wait_where['member_id'] = $val['member_id'];
  58. $total_wait_where['state'] = 0;
  59. $total_wait_commiss = $member_model->sum_member_commiss($total_wait_where);
  60. $all_commiss_money = $total_wait_commiss + $member_commiss['money'] +$member_commiss['getmoney']+$member_commiss['dongmoney'];
  61. $member_commiss['all_commiss_money'] = $all_commiss_money;
  62. $member_commiss['wait_money'] = $total_wait_commiss;
  63. $val['member_commiss'] = $member_commiss;
  64. }
  65. $val['level_name'] = $need_level[ $val['level_id'] ];
  66. //
  67. $list[$key] = $val;
  68. }
  69. return array(
  70. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  71. 'list'=>$list,
  72. 'page'=>$show
  73. );
  74. }
  75. public function levelconfig($data)
  76. {
  77. M('config')->where( array('name' => 'member_level_is_open') )->save( array('value' => $data['member_level_is_open']) );
  78. return array(
  79. 'status'=>'success',
  80. 'message'=>'操作成功',
  81. 'jump'=>U('Member/levelconfig')
  82. );
  83. }
  84. public function check_updategrade( $member_id )
  85. {
  86. $pay_money = M('lionfish_comshop_order')->where("member_id={$member_id} and order_status_id in(6,11)")->sum('total+shipping_fare-voucher_credit-fullreduction_money');
  87. $pay_money = empty($pay_money) ? 0 : $pay_money;
  88. $mb_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  89. if( !empty($mb_info) )
  90. {
  91. $next_level = M('lionfish_comshop_member_level')->where( "id >".$mb_info['level_id']." and is_auto_grade =1 " )->order('id asc')->find();
  92. if( !empty($next_level) && $pay_money >= $next_level['level_money'] )
  93. {
  94. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save( array('level_id' => $next_level['id']) );
  95. }
  96. }
  97. }
  98. /**
  99. 更改会员余额
  100. **/
  101. public function sendMemberMoneyChange($member_id, $num, $changetype, $remark='')
  102. {
  103. $member_info = M('lionfish_comshop_member')->field('account_money')->where( array('member_id' => $member_id) )->find();
  104. $account_money = $member_info['account_money'];
  105. $flow_data = array();
  106. $flow_data['member_id'] = $member_id;
  107. $flow_data['trans_id'] = '';
  108. //0,未支付,1已支付,3余额付款,4退款到余额,5后台充值 6 后台扣款 11兑换卡兑换
  109. //增加 operate_end_yuer
  110. if($changetype == 0)
  111. {
  112. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set account_money = account_money+ ".$num ." where member_id=".$member_id;
  113. $flow_data['state'] = '5';
  114. }
  115. else if($changetype == 1)
  116. {
  117. //减少
  118. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set account_money = account_money - ".$num ." where member_id=".$member_id;
  119. $flow_data['state'] = '8';
  120. }else if($changetype == 2){
  121. //最终积分
  122. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set account_money = ".$num ." where member_id=".$member_id;
  123. if($account_money >= $num)
  124. {
  125. $flow_data['state'] = '8';
  126. $num = $account_money - $num;
  127. }else{
  128. $flow_data['state'] = '5';
  129. $num = $num - $account_money;
  130. }
  131. }else if( $changetype == 9 )
  132. {
  133. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set account_money = account_money+ ".$num ." where member_id=".$member_id;
  134. $flow_data['state'] = '9';
  135. }
  136. else if( $changetype == 10 )
  137. {
  138. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set account_money = account_money+ ".$num ." where member_id=".$member_id;
  139. $flow_data['state'] = '10';
  140. }
  141. else if( $changetype == 20 )
  142. {
  143. //11兑换卡兑换
  144. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set account_money = account_money+ ".$num ." where member_id=".$member_id;
  145. $flow_data['state'] = '20';
  146. }
  147. M()->execute($up_sql);
  148. $member_info = M('lionfish_comshop_member')->field('account_money')->where( array('member_id' => $member_id) )->find();
  149. $account_money = $member_info['account_money'];
  150. $flow_data['money'] = $num;
  151. $flow_data['operate_end_yuer'] = $account_money;
  152. $flow_data['remark'] = $remark;
  153. $flow_data['charge_time'] = time();
  154. $flow_data['add_time'] = time();
  155. M('lionfish_comshop_member_charge_flow')->add($flow_data);
  156. }
  157. /**
  158. 更新会员积分
  159. **/
  160. public function sendMemberPointChange($member_id,$num, $changetype ,$remark ='',$type='system_add', $order_id =0 ,$order_goods_id = 0)
  161. {
  162. //$profile['member_id'], $num, $changetype, $remark
  163. $member_info = M('lionfish_comshop_member')->field('score')->where( array('member_id' => $member_id) )->find();
  164. $member_score = $member_info['score'];
  165. $flow_data = array();
  166. $flow_data['member_id'] = $member_id;
  167. $flow_data['type'] = $type;
  168. $flow_data['order_id'] = $order_id;
  169. $flow_data['order_goods_id'] = $order_goods_id;
  170. //增加
  171. if($changetype == 0)
  172. {
  173. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set score = score+ ".$num ." where member_id=".$member_id;
  174. $flow_data['in_out'] = 'in';
  175. }else if($changetype == 1)
  176. {
  177. //减少
  178. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set score = score - ".$num ." where member_id=".$member_id;
  179. $flow_data['in_out'] = 'out';
  180. }else if($changetype == 2){
  181. //最终积分
  182. $up_sql = "update ".C('DB_PREFIX')."lionfish_comshop_member set score = ".$num ." where member_id=".$member_id;
  183. if($member_score >= $num)
  184. {
  185. $flow_data['in_out'] = 'out';
  186. $num = $member_score - $num;
  187. }else{
  188. $flow_data['in_out'] = 'in';
  189. $num = $num - $member_score;
  190. }
  191. }
  192. $flow_data['score'] = $num;
  193. $flow_data['state'] = 1;
  194. $flow_data['remark'] = $remark;
  195. $flow_data['addtime'] = time();
  196. M()->execute($up_sql);
  197. $member_score_info = M('lionfish_comshop_member')->field('score')->where( array('member_id' => $member_id) )->find();
  198. $flow_data['after_operate_score'] = $member_score_info['score'];
  199. M('lionfish_comshop_member_integral_flow')->add( $flow_data );
  200. }
  201. ///end
  202. public function addlevel($data)
  203. {
  204. //member_level id
  205. /**
  206. array(4) { ["level"]=> string(1) "1" ["levelname"]=> string(7) "等级1" ["discount"]=> string(2) "10" ["send"]=> string(6) "提交" }
  207. **/
  208. // M('member_level')->where()->save();
  209. if( isset($data['id']) && !empty($data['id']) )
  210. {
  211. if($data['id'] == 'default')
  212. {
  213. M('config')->where( array('name' => 'member_default_levelname') )->save( array('value' => $data['levelname']) );
  214. M('config')->where( array('name' => 'member_defualt_discount') )->save( array('value' => $data['discount']) );
  215. }else{
  216. M('member_level')->where( array('id' =>$data['id']) )->save($data);
  217. }
  218. }else{
  219. M('member_level')->add($data);
  220. }
  221. return array(
  222. 'status'=>'success',
  223. 'message'=>'操作成功',
  224. 'jump'=>U('Member/level')
  225. );
  226. }
  227. public function show_member_level()
  228. {
  229. $sql="select * from ".C('DB_PREFIX')."member_level where 1 ";
  230. $count=count(M()->query($sql));
  231. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  232. $show = $Page->show();// 分页显示输出
  233. $sql.=' order by level asc LIMIT '.$Page->firstRow.','.$Page->listRows;
  234. $list=M()->query($sql);
  235. /**
  236. foreach($list as $key => $val)
  237. {
  238. $list[$key] = $val;
  239. }
  240. **/
  241. return array(
  242. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  243. 'list'=>$list,
  244. 'page'=>$show
  245. );
  246. }
  247. public function show_member_charge_page($search)
  248. {
  249. //member_id state
  250. $sql="select * from ".C('DB_PREFIX')."member_charge_flow where 1 ";
  251. if(isset($search['member_id'])){
  252. $sql.=" and member_id='".$search['member_id']."'";
  253. }
  254. if(isset($search['state'])){
  255. $sql.=" and state= ".$search['state'];
  256. }
  257. $count=count(M()->query($sql));
  258. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  259. $show = $Page->show();// 分页显示输出
  260. $sql.=' order by id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  261. $list=M()->query($sql);
  262. foreach( $list as $key =>$val )
  263. {
  264. if($val['state'] == 6)
  265. {
  266. $trans_id = $val['trans_id'];
  267. $flow_info = M('fissionbonus_flow')->where( array('id' => $trans_id) )->find();
  268. //type
  269. if( $flow_info['type'] != 1)
  270. {
  271. //send_member_id
  272. $t_info = M('member')->where( array('member_id' => $flow_info['send_member_id']) )->find();
  273. $val['tip'] = '(好友'.$t_info['uname'].'帮忙签到)';
  274. }
  275. }
  276. $list[$key] = $val;
  277. }
  278. return array(
  279. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  280. 'list'=>$list,
  281. 'page'=>$show
  282. );
  283. }
  284. public function show_member_down_page($search)
  285. {
  286. $member_model = D('Home/Member');
  287. if($search['type'] == 1)
  288. {
  289. $sql="select m.*,a.telephone as tel from ".C('DB_PREFIX')."member as m left join ".C('DB_PREFIX')."address as a
  290. on m .member_id = a.member_id where 1 ";
  291. $sql .= " and m.share_id = ".$search['member_id']."";
  292. $sql .= " group by m.member_id";
  293. $count=count(M()->query($sql));
  294. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  295. $show = $Page->show();// 分页显示输出
  296. $sql.=' order by m.member_id asc LIMIT '.$Page->firstRow.','.$Page->listRows;
  297. $list=M()->query($sql);
  298. }else if( $search['type'] ==2 ){
  299. $sql = 'select member_id from '.C('DB_PREFIX')."member
  300. where share_id = ".$search['member_id'];
  301. $first_list = M()->query($sql);
  302. $list = array();
  303. if( !empty($first_list) )
  304. {
  305. $ids_arr = array();
  306. foreach( $first_list as $val )
  307. {
  308. $ids_arr[] = $val['member_id'];
  309. }
  310. $ids_str = implode(',', $ids_arr);
  311. $sql="select m.*,a.telephone as tel from ".C('DB_PREFIX')."member as m left join ".C('DB_PREFIX')."address as a
  312. on m .member_id = a.member_id where 1 ";
  313. $sql .= " and m.share_id in (".$ids_str.")";
  314. $sql .= " group by m.member_id";
  315. $count=count(M()->query($sql));
  316. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  317. $show = $Page->show();// 分页显示输出
  318. $sql.=' order by m.member_id asc LIMIT '.$Page->firstRow.','.$Page->listRows;
  319. $list=M()->query($sql);
  320. }
  321. } else if( $search['type'] == 3 ){
  322. $sql = 'select member_id from '.C('DB_PREFIX')."member
  323. where share_id = ".$search['member_id'];
  324. $first_list = M()->query($sql);
  325. $list = array();
  326. if( !empty($first_list) )
  327. {
  328. $ids_arr = array();
  329. foreach( $first_list as $val )
  330. {
  331. $ids_arr[] = $val['member_id'];
  332. }
  333. $ids_str = implode(',', $ids_arr);
  334. $sql = 'select member_id from '.C('DB_PREFIX')."member
  335. where share_id in (".$ids_str.") ";
  336. $second_list = M()->query($sql);
  337. if( !empty($second_list) )
  338. {
  339. $ids_arr = array();
  340. foreach( $second_list as $val )
  341. {
  342. $ids_arr[] = $val['member_id'];
  343. }
  344. $ids_str = implode(',', $ids_arr);
  345. $sql="select m.*,a.telephone as tel from ".C('DB_PREFIX')."member as m left join ".C('DB_PREFIX')."address as a
  346. on m .member_id = a.member_id where 1 ";
  347. $sql .= " and m.share_id in (".$ids_str.")";
  348. $sql .= " group by m.member_id";
  349. $count=count(M()->query($sql));
  350. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  351. $show = $Page->show();// 分页显示输出
  352. $sql.=' order by m.member_id asc LIMIT '.$Page->firstRow.','.$Page->listRows;
  353. $list=M()->query($sql);
  354. }
  355. }
  356. }
  357. foreach($list as $key => $val)
  358. {
  359. //comsiss_flag
  360. if($val['comsiss_flag'] == 1)
  361. {
  362. $member_commiss = M('member_commiss')->where( array('member_id' => $val['member_id'] ) )->find();
  363. $total_wait_where = array();
  364. $total_wait_where['member_id'] = $val['member_id'];
  365. $total_wait_where['state'] = 0;
  366. $total_wait_commiss = $member_model->sum_member_commiss($total_wait_where);
  367. $all_commiss_money = $total_wait_commiss + $member_commiss['money'] +$member_commiss['getmoney']+$member_commiss['dongmoney'];
  368. $member_commiss['all_commiss_money'] = $all_commiss_money;
  369. $member_commiss['wait_money'] = $total_wait_commiss;
  370. $val['member_commiss'] = $member_commiss;
  371. }
  372. $list[$key] = $val;
  373. }
  374. return array(
  375. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  376. 'list'=>$list,
  377. 'page'=>$show
  378. );
  379. }
  380. public function show_jiamember_page($search){
  381. $sql="select * from ".C('DB_PREFIX')."jiauser where 1 ";
  382. if(isset($search['name'])){
  383. $sql.=" and username like '%".$search['name']."%'";
  384. }
  385. $count=count(M()->query($sql));
  386. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  387. $show = $Page->show();// 分页显示输出
  388. $sql.=' order by id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  389. $list=M()->query($sql);
  390. return array(
  391. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  392. 'list'=>$list,
  393. 'page'=>$show
  394. );
  395. }
  396. public function show_applymembercomiss_page($search){
  397. $sql="select m.uname,m.member_id,m.create_time,txo.state as state,txo.addtime,txo.money,txo.id from ".C('DB_PREFIX')."member as m,".C('DB_PREFIX')."tixian_order as txo where m.member_id = txo.member_id ";
  398. if(isset($search['name'])){
  399. $sql.=" and m.uname like '%".$search['name']."%'";
  400. }
  401. if(isset($search['email'])){
  402. $sql.=" and m.email='".$search['email']."'";
  403. }
  404. if(isset($search['tel'])){
  405. $sql.=" and m.telephone='".$search['tel']."'";
  406. }
  407. $count=count(M()->query($sql));
  408. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  409. $show = $Page->show();// 分页显示输出
  410. $sql.=' order by txo.state asc, txo.addtime desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  411. $list=M()->query($sql);
  412. return array(
  413. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  414. 'list'=>$list,
  415. 'page'=>$show
  416. );
  417. }
  418. public function show_fen_applymembercomiss_page($search){
  419. $sql="select m.uname,m.member_id,m.create_time,txo.state as state,txo.addtime,txo.money,txo.id from
  420. ".C('DB_PREFIX')."member as m,".C('DB_PREFIX')."fen_tixian_order as txo where m.member_id = txo.member_id ";
  421. if(isset($search['name'])){
  422. $sql.=" and m.uname like '%".$search['name']."%'";
  423. }
  424. if(isset($search['email'])){
  425. $sql.=" and m.email='".$search['email']."'";
  426. }
  427. if(isset($search['tel'])){
  428. $sql.=" and m.telephone='".$search['tel']."'";
  429. }
  430. $count=count(M()->query($sql));
  431. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  432. $show = $Page->show();// 分页显示输出
  433. $sql.=' order by txo.state asc, txo.addtime desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  434. $list=M()->query($sql);
  435. return array(
  436. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  437. 'list'=>$list,
  438. 'page'=>$show
  439. );
  440. }
  441. public function show_applymember_page($search){
  442. $sql="select m.uname,m.member_id,m.create_time,mc.state as state,mc.addtime,mc.id from ".C('DB_PREFIX')."member as m,".C('DB_PREFIX')."member_commiss_apply as mc where 1 and m.member_id = mc.member_id and mc.state =0 ";
  443. if(isset($search['name'])){
  444. $sql.=" and m.uname like '%".$search['name']."%'";
  445. }
  446. if(isset($search['email'])){
  447. $sql.=" and m.email='".$search['email']."'";
  448. }
  449. if(isset($search['tel'])){
  450. $sql.=" and m.telephone='".$search['tel']."'";
  451. }
  452. $count=count(M()->query($sql));
  453. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  454. $show = $Page->show();// 分页显示输出
  455. $sql.=' order by mc.state asc, mc.addtime desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  456. $list=M()->query($sql);
  457. return array(
  458. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  459. 'list'=>$list,
  460. 'page'=>$show
  461. );
  462. }
  463. function add_member($data){
  464. if(empty($data['uname'])){
  465. $error="用户名不能为空!!";
  466. }elseif(M('Member')->getByUname(trim($data['uname']))){
  467. $error="用户名已经存在!!";
  468. }elseif(empty($data['email'])){
  469. $error="邮箱不能为空!!";
  470. }elseif(M('Member')->getByEmail($data['email'])){
  471. $error="邮箱已经存在!!";
  472. }elseif(empty($data['pwd'])){
  473. $error="密码不能为空!!";
  474. }
  475. if($error){
  476. return array(
  477. 'status'=>'back',
  478. 'message'=>$error
  479. );
  480. }
  481. $data['pwd'] =think_ucenter_encrypt($data['pwd'],C('PWD_KEY'));
  482. $data['create_time'] =time();
  483. $data['status'] =1;
  484. if(M('member')->add($data)){
  485. return array(
  486. 'status'=>'success',
  487. 'message'=>'新增成功',
  488. 'jump'=>U('Member/index')
  489. );
  490. }else{
  491. return array(
  492. 'status'=>'back',
  493. 'message'=>'新增失败'
  494. );
  495. }
  496. }
  497. function info($id){
  498. $member=M('member')->find($id);
  499. $address=M('address')->where(array('member_id'=>$id))->select();
  500. return array(
  501. 'info'=>$member,
  502. 'address'=>$address
  503. );
  504. }
  505. function edit_info($d){
  506. $data=$d;
  507. if(empty($d['pwd']))
  508. {
  509. unset($data['pwd']);
  510. }else{
  511. $data['pwd']=think_ucenter_encrypt($d['pwd'],C('PWD_KEY'));
  512. }
  513. $integral_model = D('Seller/Integral');
  514. $member_info = M('member')->field('score')->where(array('member_id'=>$d['member_id']))->find();
  515. if($d['score'] != $member_info['score'])
  516. {
  517. $del_score = $d['score'] - $member_info['score'];
  518. if($del_score < 0)
  519. {
  520. //系统扣除 system_add system_del
  521. //
  522. $integral_model->charge_member_score($d['member_id'], -$del_score,'out', 'system_del');
  523. }else{
  524. //系统奖励
  525. //$integral_model->charge_member_score( $member_id, $score,$in_out, $type, $order_id=0)
  526. $integral_model->charge_member_score($d['member_id'], $del_score,'in', 'system_add');
  527. }
  528. }
  529. unset($d['score']);
  530. $r=M('member')->where(array('member_id'=>$d['member_id']))->save($data);
  531. $http_refer = cookie('http_refer');
  532. if(empty($http_refer))
  533. {
  534. $http_refer = U('Member/index');
  535. }
  536. return array(
  537. 'status'=>'success',
  538. 'message'=>'修改成功',
  539. 'jump'=>$http_refer
  540. );
  541. }
  542. }
  543. ?>