User.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php
  2. namespace app\cmgadm\controller\user;
  3. use app\common\controller\Backend;
  4. use fast\Random;
  5. use think\Db;
  6. /**
  7. * 会员管理
  8. *
  9. * @icon fa fa-user
  10. */
  11. class User extends Backend
  12. {
  13. protected $relationSearch = true;
  14. /**
  15. * @var \app\cmgadm\model\User
  16. */
  17. protected $model = null;
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = model('User');
  22. }
  23. /**
  24. * 查看
  25. */
  26. public function index()
  27. {
  28. //设置过滤方法
  29. $this->request->filter(['strip_tags']);
  30. if ($this->request->isAjax()) {
  31. //如果发送的来源是Selectpage,则转发到Selectpage
  32. if ($this->request->request('keyField')) {
  33. return $this->selectpage();
  34. }
  35. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  36. $total = $this->model
  37. ->with('group')
  38. ->where($where)
  39. ->where(['ct_user.status' => ['neq', 0]])
  40. ->order($sort, $order)
  41. ->count();
  42. $list = $this->model
  43. ->with('group')
  44. ->where($where)
  45. ->where(['ct_user.status' => ['neq', 0]])
  46. ->order($sort, $order)
  47. ->limit($offset, $limit)
  48. ->select();
  49. $result = array("total" => $total, "rows" => $list);
  50. return json($result);
  51. }
  52. return $this->view->fetch();
  53. }
  54. function showprc()
  55. {
  56. $ids = input('ids');
  57. $user = get_user_data($ids);
  58. $this->view->assign("info", $user);
  59. return $this->view->fetch();
  60. }
  61. public function reallist()
  62. {
  63. //当前是否为关联查询
  64. $this->relationSearch = false;
  65. //设置过滤方法
  66. $this->request->filter(['strip_tags']);
  67. if ($this->request->isAjax()) {
  68. //如果发送的来源是Selectpage,则转发到Selectpage
  69. if ($this->request->request('keyField')) {
  70. return $this->selectpage();
  71. }
  72. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  73. $total = $this->model
  74. ->where($where)
  75. ->where(['isreal' => ['gt', 0]])
  76. ->order($sort, $order)
  77. ->count();
  78. $list = $this->model
  79. ->where($where)
  80. ->where(['isreal' => ['gt', 0]])
  81. ->order($sort, $order)
  82. ->limit($offset, $limit)
  83. ->select();
  84. $result = array("total" => $total, "rows" => $list, "where" => $order);
  85. return json($result);
  86. }
  87. return $this->view->fetch('index');
  88. }
  89. function viewauto()
  90. {
  91. $ids = input('ids');
  92. $status = input('status');
  93. $info = $this->model->where(['id' => $ids, 'status' => 1])->find();
  94. if (!$info) {
  95. $this->error("信息不存在,或已审核");
  96. } else {
  97. if ($status == 1) {
  98. $res = db('user')->where(['id' => $ids])->update(['isreal' => 2]);
  99. } elseif ($status == -1) {
  100. $data = [
  101. 'isreal' => 0,
  102. 'idcard' => '',
  103. 'realname' => '',
  104. 'idprc1' => '',
  105. 'idprc2' => '',
  106. ];
  107. $res = db('user')->where(['id' => $ids])->update($data);
  108. }
  109. if ($res) {
  110. $this->success('审核通过');
  111. } else {
  112. $this->error('审核失败');
  113. }
  114. }
  115. }
  116. public function noactivelist()
  117. {
  118. //当前是否为关联查询
  119. $this->relationSearch = false;
  120. //设置过滤方法
  121. $this->request->filter(['strip_tags']);
  122. if ($this->request->isAjax()) {
  123. //如果发送的来源是Selectpage,则转发到Selectpage
  124. if ($this->request->request('keyField')) {
  125. return $this->selectpage();
  126. }
  127. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  128. $total = $this->model
  129. ->where($where)
  130. ->where(['status' => 0])
  131. ->order($sort, $order)
  132. ->count();
  133. $list = $this->model
  134. ->where($where)
  135. ->where(['status' => 0])
  136. ->order($sort, $order)
  137. ->limit($offset, $limit)
  138. ->select();
  139. $result = array("total" => $total, "rows" => $list, "where" => $order);
  140. return json($result);
  141. }
  142. return $this->view->fetch('index');
  143. }
  144. function updatepwd()
  145. {
  146. if ($this->request->isPost()) {
  147. $ids = $this->request->post('id');
  148. $password = $this->request->post('password');
  149. $password2 = $this->request->post('password2');
  150. if (empty($password) && empty($password2)) {
  151. $this->error('请输入要充值得密码');
  152. }
  153. $user = db('user')->where(['id' => $ids])->find();
  154. if ($password) {
  155. $data['password'] = getEncryptPassword($password, $user['salt']);
  156. }
  157. if ($password2) {
  158. $data['password2'] = getEncryptPassword($password2, $user['salt']);
  159. }
  160. $data['updatetime'] = time();
  161. $res = db('user')->where(['id' => $ids])->update($data);
  162. if ($res) {
  163. $this->success('重置成功');
  164. } else {
  165. $this->error('重置失败');
  166. }
  167. }
  168. $ids = input('ids');
  169. $user = db('user')->where(['id' => $ids])->find();
  170. if (empty($user)) {
  171. $this->error('用户不存在,或不可用');
  172. }
  173. $this->view->assign('user', $user);
  174. return $this->view->fetch('updatepwd');
  175. }
  176. /* 充值
  177. * */
  178. function chongzhi()
  179. {
  180. if ($this->request->isPost()) {
  181. $ids = $this->request->post('id');
  182. $money = $this->request->post('money');
  183. if (empty($money)) {
  184. $this->error('请输入充值金额');
  185. }
  186. if ($money <= 0) {
  187. $this->error('充值金额不正确');
  188. }
  189. $money_type = $this->request->post('money_type');
  190. if (empty($money_type)) {
  191. $this->error('请选择要充值的币种');
  192. }
  193. $remark = $this->request->post('remark');
  194. $changedata = [
  195. 'type' => 2,
  196. 'money' => $money,
  197. 'userid' => $ids,
  198. 'relevant_userid' => -1,
  199. 'remark' => $remark == '' ? '' : $remark,
  200. ];
  201. $res = caiwu($changedata, $money_type);
  202. if ($res) {
  203. $this->success('充值成功');
  204. } else {
  205. $this->error('充值失败');
  206. }
  207. }
  208. #人,币种,备注
  209. $ids = input('ids');
  210. $user = db('user')->where(['id' => $ids, 'status' => 1])->field('id,username')->find();
  211. if (empty($user)) {
  212. $this->error('用户不存在,或不可用');
  213. }
  214. $this->view->assign('user', $user);
  215. #币种
  216. $money_type_list = db('money_type')->where(['status' => 1])->field('identification,name')->select();
  217. $this->view->assign('moneytype', list_to_arr($money_type_list, 'identification', 'name'));
  218. return $this->view->fetch('chongzhi');
  219. }
  220. /* 扣费
  221. * */
  222. function koufei()
  223. {
  224. if ($this->request->isPost()) {
  225. $ids = $this->request->post('id');
  226. $money = $this->request->post('money');
  227. if (empty($money)) {
  228. $this->error('请输入充值金额');
  229. }
  230. if ($money <= 0) {
  231. $this->error('充值金额不正确');
  232. }
  233. $money_type = $this->request->post('money_type');
  234. if (empty($money_type)) {
  235. $this->error('请选择要充值的币种');
  236. }
  237. $remark = $this->request->post('remark');
  238. $changedata = [
  239. 'type' => 3,
  240. 'money' => 0 - $money,
  241. 'userid' => $ids,
  242. 'relevant_userid' => -1,
  243. 'remark' => $remark == '' ? '' : $remark,
  244. ];
  245. $res = caiwu($changedata, $money_type);
  246. if ($res) {
  247. $this->success('扣除成功');
  248. } else {
  249. $this->error('扣除失败');
  250. }
  251. }
  252. #人,币种,备注
  253. $ids = input('ids');
  254. $user = db('user')->where(['id' => $ids, 'status' => 1])->field('id,username')->find();
  255. if (empty($user)) {
  256. $this->error('用户不存在,或不可用');
  257. }
  258. $this->view->assign('user', $user);
  259. #币种
  260. $money_type_list = db('money_type')->where(['status' => 1])->field('identification,name')->select();
  261. $this->view->assign('moneytype', list_to_arr($money_type_list, 'identification', 'name'));
  262. return $this->view->fetch('chongzhi');
  263. }
  264. /* 冻结解冻
  265. * */
  266. function setStatus()
  267. {
  268. $ids = input('ids');
  269. $status = input('status');
  270. $info = $this->model->where(['id' => $ids])->find();
  271. if (empty($info)) {
  272. $this->error('用户不存在,或不可用');
  273. }
  274. $res = $this->model->where(['id' => $ids])->update(['status' => $status]);
  275. if ($res) {
  276. $this->success('设置完成');
  277. } else {
  278. $this->error('设置失败');
  279. }
  280. }
  281. public function usermessage()
  282. {
  283. //设置过滤方法
  284. //当前是否为关联查询
  285. $this->relationSearch = false;
  286. $this->request->filter(['strip_tags']);
  287. if ($this->request->isAjax()) {
  288. //如果发送的来源是Selectpage,则转发到Selectpage
  289. if ($this->request->request('keyField')) {
  290. return $this->selectpage();
  291. }
  292. $ids = db('user_message')->where(['to_uid' => 0, 'isread' => 0])->group('userid')->column('userid');
  293. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  294. if (count($ids) > 0) {
  295. $total = $this->model
  296. ->where($where)
  297. ->where(['status' => 1, 'id' => ['in', $ids]])
  298. ->order($sort, $order)
  299. ->count();
  300. $list = $this->model
  301. ->where($where)
  302. ->where(['status' => 1, 'id' => ['in', $ids]])
  303. ->order($sort, $order)
  304. ->limit($offset, $limit)
  305. ->select();
  306. } else {
  307. $total = $this->model
  308. ->where($where)
  309. ->where(['status' => 1])
  310. ->order($sort, $order)
  311. ->count();
  312. $list = $this->model
  313. ->where($where)
  314. ->where(['status' => 1])
  315. ->order($sort, $order)
  316. ->limit($offset, $limit)
  317. ->select();
  318. }
  319. $result = array("total" => $total, "rows" => $list, "where" => $order);
  320. return json($result);
  321. }
  322. return $this->view->fetch('index');
  323. }
  324. function viewmsg()
  325. {
  326. $ids = input('ids');
  327. $user = db('user')->where('id', $ids)->find();
  328. $map['from_uid|to_uid'] = 0;
  329. $map['userid'] = $ids;
  330. $data_list = db('user_message')->where($map)->select();
  331. foreach ($data_list as $k => $v) {
  332. if ($v['from_uid'] === 0) {
  333. $data_list[$k]['fromuser'] = '系统';
  334. $data_list[$k]['flag'] = 0;
  335. } else {
  336. $data_list[$k]['flag'] = 1;
  337. $data_list[$k]['fromuser'] = $user['username'];
  338. }
  339. }
  340. $this->view->assign("uid", $ids);
  341. db('user_message')->where(['to_uid' => 0])->update(['isread' => 1]);
  342. $this->view->assign("list", $data_list);
  343. return $this->view->fetch('viewmsg');
  344. }
  345. function usertree()
  346. {
  347. $keyword = input('keyword');
  348. if (!empty($keyword)) {
  349. $user = $this->model->where(['username' => $keyword])->find();
  350. if (empty($user)) {
  351. $this->error("会员不存在");
  352. } else {
  353. $uid = $user['id'];
  354. }
  355. } else {
  356. $uid = 1;
  357. }
  358. $this->view->assign('rootid', $uid);
  359. $this->view->assign('uid', 0);
  360. $this->view->assign('keyword', $keyword);
  361. return $this->view->fetch('usertree');
  362. }
  363. /* 接点图 */
  364. function dottree()
  365. {
  366. $keyword = input('keyword');
  367. if (!empty($keyword)) {
  368. $user_info = db("user")->where(['username' => $keyword])->find();
  369. if (!empty($user_info)) {
  370. $node_info = db("user_parent")->where(['userid' => $user_info['id']])->find();
  371. } else {
  372. $this->error("要查询的会员不存在");
  373. }
  374. }
  375. if (empty($node_info)) {//没有搜索显示网头
  376. $node_info = db("user_parent")->where(['id' => 1])->find();
  377. }
  378. $datascource['id'] = strval($node_info['id']);//这里要用字符串
  379. $datascource['name'] = $node_info['username'];
  380. $datascource['title'] = $node_info['nickname'];
  381. $datascource['nums'] = $node_info['cnum'];
  382. $datascource['relationship']['children_num'] = $node_info['cnum'];
  383. $datascource['relationship']['parent_num'] = $node_info['pid'] > 0 ? $node_info['pid'] : 0;
  384. $datascource_json = json_encode($datascource);
  385. $this->view->assign('datascource', $datascource_json);
  386. return $this->view->fetch('dottree');
  387. }
  388. function childrendot()
  389. {
  390. $res = [];
  391. $nid = input('nid');
  392. $children_list = db("user_parent")->where(['pid' => $nid])->order('distance asc')->select();
  393. foreach ($children_list as $clv) {
  394. $datascource['id'] = strval($clv['id']);//这里要用字符串
  395. $datascource['name'] = $clv['username'];
  396. $datascource['title'] = $clv['nickname'];
  397. $datascource['nums'] = $clv['cnum'];
  398. $datascource['relationship']['children_num'] = $clv['cnum'];
  399. $datascource['relationship']['parent_num'] = $clv['pid'] > 0 ? $clv['pid'] : 0;
  400. $res['children'][] = $datascource;
  401. }
  402. return $res;
  403. }
  404. function parentdot()
  405. {
  406. $res = [];
  407. $nid = input('nid');
  408. $userinfo = db("user_parent")->where(['id' => $nid])->find();
  409. $parentinfo = db("user_parent")->where(['id' => $userinfo['pid']])->find();
  410. $datascource['id'] = strval($parentinfo['id']);//这里要用字符串
  411. $datascource['name'] = $parentinfo['username'];
  412. $datascource['title'] = $parentinfo['nickname'];
  413. $datascource['nums'] = $parentinfo['cnum'];
  414. $datascource['relationship']['children_num'] = $parentinfo['cnum'];
  415. $datascource['relationship']['parent_num'] = $parentinfo['pid'] > 0 ? $parentinfo['pid'] : 0;
  416. return $datascource;
  417. }
  418. /* 激活数据 */
  419. function jihuo()
  420. {
  421. $ids = input('ids');
  422. $info = $this->model->where(['id' => $ids, 'status' => 0])->find();
  423. if ($info) {
  424. db()->startTrans();
  425. $res1 = $this->model->where('id', $ids)->update(['status' => 1]);
  426. if ($info['refereeid'] > 0) {
  427. $res2 = $this->model->where('id', $info['refereeid'])->setInc('referee_number', 1);
  428. } else {
  429. $res2 = 1;
  430. }
  431. $bonusconfig = db('bonus_config')->where(['config_type' => 1, 'user_level' => $info['level']])->find();
  432. $res3 = db('user_account')->insertGetId(['userid' => $ids, 'username' => $info['username'], 'reg_money' => $bonusconfig['value']]);
  433. if ($res1 && $res2 && $res3) {
  434. finance(1, $bonusconfig['value']);
  435. $count = db('user')->count();
  436. if ($count > 1) {
  437. #activeuser($ids);
  438. }
  439. db()->commit();
  440. $this->success("激活成功");
  441. } else {
  442. db()->rollback();
  443. $this->error("激活失败");
  444. }
  445. } else {
  446. $this->error("要操作的数据不存在,或已激活");
  447. }
  448. }
  449. /* 新增 */
  450. function add()
  451. {
  452. if ($this->request->isPost()) {
  453. $params = $this->request->post("row/a");
  454. $flag = $this->request->post('flag');
  455. if (empty($params['username'])) {
  456. $this->error("用户名不能为空");
  457. } else {
  458. $usernameinfo = $this->model->where('username', $params['username'])->find();
  459. if ($usernameinfo) {
  460. $this->error("此用户名已注册,请更换");
  461. }
  462. }
  463. if (empty($params['nickname'])) {
  464. $this->error("昵称不能为空");
  465. }
  466. if (empty($params['mobile'])) {
  467. $this->error("手机号不能为空");
  468. } else {
  469. if (!preg_match('/^1\d{10}$/', $params['mobile'])) {
  470. $this->error('手机号格式不正确');
  471. }
  472. $mobileinfo = db('user')->where('mobile', $params['mobile'])->find();
  473. if ($mobileinfo) {
  474. $this->error("此手机号已注册,请更换");
  475. }
  476. }
  477. $data = [
  478. 'username' => $params['username'],
  479. 'nickname' => $params['nickname'],
  480. 'mobile' => $params['mobile'],
  481. 'level' => 0,
  482. 'salt' => Random::alnum(),
  483. 'createtime' => time(),
  484. 'joinip' => request()->ip(),
  485. 'status' => '1',
  486. ];
  487. $data['password'] = getEncryptPassword($params['password'], $data['salt']);
  488. $data['password2'] = getEncryptPassword($params['password2'], $data['salt']);
  489. if ($flag == 0) {
  490. $data['refereeid'] = 0;
  491. $data['referee_name'] = '';
  492. $data['refereeids'] = '0,';
  493. $data['tdeep'] = 0;
  494. $data['pid'] = 0;
  495. $data['parent_name'] = '';
  496. } else {
  497. $referee = $this->model->where(['username|mobile' => $params['referee'], 'status' => 1])->find();
  498. if ($referee) {
  499. $data['refereeid'] = $referee['id'];
  500. $data['referee_name'] = $referee['username'];
  501. $data['refereeids'] = $referee['refereeids'] . $referee['id'] . ',';
  502. $data['tdeep'] = $referee['tdeep'] + 1;
  503. } else {
  504. $this->error("推荐人不可用或输入的推荐编号有误");
  505. }
  506. if (config('dot_mode') == 1) {
  507. $parent = $this->model->where(['username' => $params['parent'], 'status' => 1])->find();
  508. if ($parent) {
  509. $data['pid'] = $parent['id'];
  510. $data['parent_name'] = $parent['username'];
  511. $pos = $params['pos'];
  512. } else {
  513. $this->error("结点人不可用或输入的或输入的编号有误");
  514. }
  515. } else {
  516. $data['pid'] = 0;
  517. $data['parent_name'] = '';
  518. $pos = 0;
  519. }
  520. }
  521. $ids = $this->model->insertGetId($data);
  522. if ($ids) {
  523. if (config('dot_mode') == 1) {
  524. if ($flag == 0) {
  525. $updata['userid'] = $ids;
  526. $updata['username'] = $data['username'];
  527. $updata['nickname'] = $data['nickname'];
  528. $updata['pid'] = 0;
  529. $updata['distance'] = 1;
  530. $updata['position'] = 0;
  531. $updata['pids'] = '0,';
  532. $updata['system'] = 1;
  533. db('user_parent')->insertGetId($updata);
  534. } else {
  535. $upinfo = db('user_parent')->where(['userid' => $data['pid']])->find();
  536. $updata['userid'] = $ids;
  537. $updata['username'] = $data['username'];
  538. $updata['pid'] = $upinfo['id'];
  539. $updata['distance'] = $upinfo['distance'] + 1;
  540. $updata['position'] = $pos;
  541. $updata['nickname'] = $data['nickname'];
  542. $updata['pids'] = $upinfo['pids'] . $upinfo['id'] . ',';
  543. $updata['system'] = 1;
  544. db('user_parent')->insertGetId($updata);
  545. db('user_parent')->where('id', $upinfo['id'])->setInc('cnum', 1);
  546. }
  547. }
  548. if ($data['refereeid'] > 0) {
  549. $res2 = $this->model->where('id', $data['refereeid'])->setInc('referee_number', 1);
  550. }
  551. $this->success("注册成功");
  552. } else {
  553. $this->error("注册失败");
  554. }
  555. }
  556. #检测推荐人
  557. $info = $this->model->where('id', '>=', '1')->find();
  558. if ($info) {
  559. $flag = 1;
  560. } else {
  561. $flag = 0;
  562. }
  563. $this->assign("flag", $flag);
  564. $randStr = str_shuffle('1234567890');
  565. $randZm = str_shuffle('abcdefghijklmnopqrstuvwxyz');
  566. $username = substr($randZm, 0, 2) . substr($randStr, 0, 6);//账号为7位随机数
  567. $this->view->assign('userlevel', build_select('row[level]', \app\cmgadm\model\Userlevel::column('id,name'), '', ['class' => 'form-control selectpicker']));
  568. $this->view->assign("username", $username);
  569. return parent::add();
  570. }
  571. /**
  572. * 编辑
  573. */
  574. public function edit($ids = NULL)
  575. {
  576. $row = $this->model->get($ids);
  577. if (!$row) {
  578. $this->error(__('No Results were found'));
  579. }
  580. $adminIds = $this->getDataLimitAdminIds();
  581. if (is_array($adminIds)) {
  582. if (!in_array($row[$this->dataLimitField], $adminIds)) {
  583. $this->error(__('You have no permission'));
  584. }
  585. }
  586. if ($this->request->isPost()) {
  587. $params = $this->request->post("row/a");
  588. if (empty($params['nickname'])) {
  589. $this->error("昵称不能为空");
  590. }
  591. if (empty($params['mobile'])) {
  592. $this->error("手机号不能为空");
  593. } else {
  594. if (!preg_match('/^1\d{10}$/', $params['mobile'])) {
  595. $this->error('手机号格式不正确');
  596. }
  597. $mobileinfo = db('user')->where('mobile', $params['mobile'])->find();
  598. if ($mobileinfo && $mobileinfo['id'] != $ids) {
  599. $this->error("此手机号已注册,请更换");
  600. }
  601. }
  602. // 有推荐人
  603. $data = [
  604. 'nickname' => $params['nickname'],
  605. 'mobile' => $params['mobile'],
  606. 'updatetime' => time(),
  607. ];
  608. if ($params['referee'] && $params['referee'] != $row['referee_name']) {
  609. $referee = $this->model->where(['username|mobile' => $params['referee'], 'status' => 1])->find();
  610. if ($referee) {
  611. $data['refereeid'] = $referee['id'];
  612. $data['referee_name'] = $referee['username'];
  613. $data['refereeids'] = $referee['refereeids'] . $referee['id'] . ',';
  614. $data['tdeep'] = $referee['tdeep'] + 1;
  615. } else {
  616. $this->error("推荐人不可用或输入的推荐编号有误");
  617. }
  618. }
  619. Db::startTrans();
  620. $refereeid = isset($data['refereeid']) ? $data['refereeid'] : 0;
  621. $result = $this->model->where(['id' => $ids])->update($data);
  622. if ($result === false) {
  623. Db::rollback();
  624. $this->error('修改失败');
  625. }
  626. if ($refereeid > 0) {
  627. if (!$this->model->where('id', $refereeid)->setInc('referee_number', 1)) {
  628. Db::rollback();
  629. $this->error('修改推荐关系失败');
  630. }
  631. if (!$this->model->where('id', $row['refereeid'])->setDec('referee_number', 1)) {
  632. Db::rollback();
  633. $this->error('修改推荐关系失败');
  634. }
  635. }
  636. Db::commit();
  637. $this->success("修改成功");
  638. }
  639. if (!$row)
  640. $this->error(__('No Results were found'));
  641. $this->view->assign('groupList', build_select('row[group_id]', \app\cmgadm\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
  642. return parent::edit($ids);
  643. }
  644. }