model = new \app\admin\model\User; $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("oldstatusList", $this->model->getOldstatusList()); $this->view->assign("noticeEmailList", $this->model->getNoticeEmailList()); $this->view->assign("noticeWhatsappList", $this->model->getNoticeWhatsappList()); $this->view->assign("noticePhonecallList", $this->model->getNoticePhonecallList()); $this->view->assign("isFirstList", $this->model->getIsFirstList()); } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ /** * 查看 */ public function index() { //当前是否为关联查询 $this->relationSearch = true; //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->with(['userwallet']) ->where($where) ->order($sort, $order) ->paginate($limit); foreach ($list as $row) { $row->getRelation('userwallet')->visible(['score']); } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } return $this->view->fetch(); } /** * 注册会员 */ public function add() { if (!$this->request->isPost()) { return $this->view->fetch(); } $firstname = input('firstname'); $lastname = input('lastname'); $countrycode = input('countrycode',65,'intval'); $mobile = input('mobile',''); $email = input('email'); $password = input('password'); if (!$firstname || !$lastname || !$email || !$password) { $this->error(__('Invalid parameters')); } if ($email && !Validate::is($email, "email")) { $this->error(__('Email is incorrect')); } $fullmobile = $countrycode.$mobile; $extend = [ 'firstname' => $firstname, 'lastname' => $lastname, 'simplemobile' => $mobile, 'birthday' => strtotime(input('birthday','')), 'height' => input('height',''), 'weight' => input('weight',''), 'age' => input('age',''), 'residential' => input('residential',''), 'health' => input('health',''), 'emergency' => input('emergency',''), 'emergency_phone' => input('emergency_phone',''), 'knowus' => input('knowus',''), // 'is_first' => input('is_first',''), 'notice_email' => input('notice_email',0), 'notice_whatsapp' => input('notice_whatsapp',0), 'notice_phonecall' => input('notice_phonecall',0), 'whatsapp' => input('whatsapp',''), ]; $auth = new \app\common\library\Auth; $ret = $auth->register('',$password, $email, $fullmobile, $extend); if ($ret) { $this->success('注册完成'); } else { $this->error($auth->getError()); } } /** * 充值积分 */ public function updatescore(){ $id = input('id'); $info = Db::name('user_wallet') ->where('user_id',$id) ->find(); if ($this->request->isPost()) { $user_id = input('user_id'); $score = input('score'); $remark = input('remark','线下修改'); $remark_en = input('remark_en','Offline modification'); Db::startTrans(); if($score != 0){ $rs = model('wallet')->lockChangeAccountRemain($user_id,'score',$score,1,$remark,'admin',$this->auth->id,$remark_en); if($rs['status'] === false){ Db::rollback(); $this->error($rs['msg']); } } Db::commit(); $this->success('充值完成'); } $this->assign('row',$info); return $this->view->fetch(); } public function selectpagenew() { $this->selectpageFields = 'id,username,nickname,firstname,lastname,email'; return parent::selectpage_user(); } }