userinfo.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace WY\app\controller\agent;
  3. use WY\app\libs\Controller;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class userinfo extends CheckUser
  8. {
  9. public function index()
  10. {
  11. $where = array('fields' => 'userid=?', 'values' => array($_SESSION['login_agentid']));
  12. $userinfo = $this->model()->select()->from('userinfo')->where($where)->fetchRow();
  13. $data = array('title' => '基本资料', 'userinfo' => $userinfo);
  14. $this->put('userinfo.php', $data);
  15. }
  16. public function editsave()
  17. {
  18. if ($this->userData['is_state'] == '1') {
  19. echo json_encode(array('status' => 0, 'msg' => '已开通的账号若要修改资料,请联系客服'));
  20. exit;
  21. }
  22. $data = isset($_POST) ? $_POST : false;
  23. if (!$data) {
  24. echo json_encode(array('status' => 0, 'msg' => '选项填写不完整'));
  25. exit;
  26. }
  27. foreach ($data as $key => $val) {
  28. $data[$key] = $this->req->post($key);
  29. }
  30. if ($data['phone'] == '' || $data['qq'] == '' || $data['realname'] == '' || $data['idcard'] == '' || $data['batype'] == '' || $data['baname'] == '' || $data['baaddr'] == '' || $data['sitename'] == '' || $data['siteurl'] == '') {
  31. echo json_encode(array('status' => 0, 'msg' => '选项填写不完整'));
  32. exit;
  33. }
  34. if (!preg_match('/\\d{11}/', $data['phone'])) {
  35. echo json_encode(array('status' => 0, 'msg' => '手机号码格式错误'));
  36. exit;
  37. }
  38. if (!preg_match('/\\d{5,12}/', $data['qq'])) {
  39. echo json_encode(array('status' => 0, 'msg' => 'QQ号码格式错误'));
  40. exit;
  41. }
  42. if (!preg_match('/[0-9X]{18}/', $data['idcard'])) {
  43. echo json_encode(array('status' => 0, 'msg' => '身份证号码格式错误'));
  44. exit;
  45. }
  46. $data['siteurl'] = str_replace('http://', '', $data['siteurl']);
  47. $data['siteurl'] = str_replace('http://', '', $data['siteurl']);
  48. $data['siteurl'] = str_replace('/', '', $data['siteurl']);
  49. if ($this->model()->from('userinfo')->updateSet($data)->where(array('fields' => 'userid=?', 'values' => array($_SESSION['login_agentid'])))->update()) {
  50. echo json_encode(array('status' => 1, 'msg' => '修改已保存,等待审核'));
  51. exit;
  52. }
  53. echo json_encode(array('status' => 0, 'msg' => '保存失败'));
  54. exit;
  55. }
  56. public function addcfo()
  57. {
  58. $this->put('addcfo.php', array());
  59. }
  60. public function savecfo()
  61. {
  62. $bankname = $this->req->post('bankname');
  63. $provice = $this->req->post('provice');
  64. $city = $this->req->post('city');
  65. $branchname = $this->req->post('branchname');
  66. $accountname = $this->req->post('accountname');
  67. $cardno = $this->req->post('cardno');
  68. $sfz = $this->req->post('sfz');
  69. $shouji = $this->req->post('shouji');
  70. if ($bankname == '' || $provice == '' || $city == '' || $branchname == '' || $accountname == '' || $cardno == '' || $sfz == '' || $shouji == '') {
  71. echo json_encode(array('status' => 0));
  72. exit;
  73. }
  74. $data = array('userid' => $this->userData['id'], 'bankname' => $bankname, 'sfz' => $sfz, 'shouji' => $shouji, 'provice' => $provice, 'city' => $city, 'branchname' => $branchname, 'accountname' => $accountname, 'cardno' => $cardno, 'addtime' => time());
  75. if ($this->model()->from('cfo')->insertData($data)->insert()) {
  76. echo json_encode(array('status' => 1));
  77. exit;
  78. }
  79. echo json_encode(array('status' => 0));
  80. }
  81. public function editcfo()
  82. {
  83. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  84. if ($id && ($cfo = $this->model()->select()->from('cfo')->where(array('fields' => 'userid=? and id=?', 'values' => array($this->userData['id'], $id)))->fetchRow())) {
  85. $this->put('editcfo.php', $cfo);
  86. exit;
  87. }
  88. $this->put('woodyapp.php', array('msg' => '出现错误'));
  89. }
  90. public function editsavecfo()
  91. {
  92. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  93. $bankname = $this->req->post('bankname');
  94. $provice = $this->req->post('provice');
  95. $city = $this->req->post('city');
  96. $branchname = $this->req->post('branchname');
  97. $accountname = $this->req->post('accountname');
  98. $cardno = $this->req->post('cardno');
  99. $sfz = $this->req->post('sfz');
  100. $shouji = $this->req->post('shouji');
  101. if ($id == '' && $bankname == '' || $provice == '' || $city == '' || $branchname == '' || $accountname == '' || $cardno == '' || $sfz == '' || $shouji == '') {
  102. echo json_encode(array('status' => 0));
  103. exit;
  104. }
  105. $data = array('bankname' => $bankname, 'sfz' => $sfz, 'shouji' => $shouji, 'provice' => $provice, 'city' => $city, 'branchname' => $branchname, 'accountname' => $accountname, 'cardno' => $cardno);
  106. if ($this->model()->from('cfo')->updateSet($data)->where(array('fields' => 'userid=? and id=?', 'values' => array($this->userData['id'], $id)))->update()) {
  107. echo json_encode(array('status' => 1));
  108. exit;
  109. }
  110. echo json_encode(array('status' => 0));
  111. }
  112. public function delcfo()
  113. {
  114. $id = intval($this->req->post('id'));
  115. if ($id && $this->model()->from('cfo')->where(array('fields' => 'userid=? and id=?', 'values' => array($this->userData['id'], $id)))->delete()) {
  116. echo json_encode(array('status' => 1));
  117. exit;
  118. }
  119. echo json_encode(array('status' => 0));
  120. }
  121. public function getCfo()
  122. {
  123. $str = '';
  124. $cfo = $this->model()->select()->from('cfo')->where(array('fields' => 'userid=?', 'values' => array($this->userData['id'])))->fetchAll();
  125. if ($cfo) {
  126. foreach ($cfo as $key => $val) {
  127. $str .= '<p class="c' . $val['id'] . '"><label><input type="radio" name="cfoid" value="' . $val['id'] . '">&nbsp;' . $val['bankname'] . '/' . $val['cardno'] . '</label>&nbsp&nbsp;<a href="javascript:;" onclick="showContent(\'编辑代收银行\',\'/member/userinfo/editcfo/' . $val['id'] . '\')" style="font-size:12px"><span class="glyphicon glyphicon-edit"></span></a>&nbsp;<a href="javascript:;" onclick="del(' . $val['id'] . ')" style="font-size:12px"><span class="glyphicon glyphicon-trash"></span></a></p>';
  128. }
  129. }
  130. echo $str;
  131. }
  132. }