User.php 23 KB

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