User.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Active\Lib;
  3. use Dever;
  4. class User
  5. {
  6. # 获取代理商信息
  7. public function agent($user, $type = 'mobile')
  8. {
  9. if ($user && $user[$type]) {
  10. $col = $type;
  11. if ($type == 'mid') {
  12. $col = 'id';
  13. }
  14. $member = Dever::db('agent/member')->find(array($col => $user[$type], 'status' => 2));
  15. if ($member) {
  16. return $member;
  17. }
  18. }
  19. return array();
  20. }
  21. #获取代理商信息更新user
  22. public function upUser($mobile,$data){
  23. $member = Dever::load('active/lib/user')->agent(array('mobile' => $mobile));
  24. if ($member) {
  25. $insert['name'] = $member['name'];
  26. $insert['mobile'] = $member['mobile'];
  27. $insert['idcard'] = $member['idcard'];
  28. $insert['pass'] = $member['password'];
  29. $insert['old_pwd'] = $member['old_pwd'];
  30. $insert['old_salt'] = $member['old_salt'];
  31. $uid = Dever::db('active/user')->insert($insert);
  32. } else {
  33. $uid = Dever::db('active/user')->insert($data);
  34. }
  35. return $uid;
  36. }
  37. }