123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use Think\Db;
- class Userauth extends Backend
- {
-
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Userauth;
- $this->view->assign("statusList", $this->model->getStatusList());
- }
- public function import()
- {
- parent::import();
- }
-
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['user'])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
-
- $row->getRelation('user')->visible(['nickname','mobile']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
-
- public function edit($ids = null)
- {
- $row = $this->model->get($ids);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- $adminIds = $this->getDataLimitAdminIds();
- if (is_array($adminIds)) {
- if (!in_array($row[$this->dataLimitField], $adminIds)) {
- $this->error(__('You have no permission'));
- }
- }
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- if ($params) {
- $params = $this->preExcludeFields($params);
- $result = false;
- if (isset($params['status']) && $params['status'] == 1) {
- $edit_data['status'] = 1;
- } else {
- $edit_data['status'] = 2;
- $edit_data['certify_id'] = '';
- $edit_data['out_trade_no'] = '';
- }
- Db::startTrans();
-
- $result = Db::name('user_auth')->where(['user_id' => $row['user_id'], 'status' => $row['status']])->setField($edit_data);
- if (!$result) {
- Db::rollback();
- $this->error('操作失败');
- }
-
- $rs = Db::name('user')->where(['id' => $row['user_id']])->setField('real_status', $edit_data['status']);
- if (!$rs) {
- Db::rollback();
- $this->error('操作失败');
- }
- if ($edit_data['status'] == 1) {
-
-
- $task_rs = \app\common\model\TaskLog::tofinish($row['user_id'],20);
- if($task_rs === false){
- Db::rollback();
- $this->error('完成任务赠送奖励失败');
- }
-
- $msg_id = \app\common\model\Message::addMessage($row['user_id'],'真人认证','真人认证已经审核通过');
- } else {
-
- $msg_id = \app\common\model\Message::addMessage($row['user_id'],'真人认证','真人认证审核不通过');
- }
- Db::commit();
- $this->success();
-
- }
- $this->error(__('Parameter %s can not be empty', ''));
- }
- $this->view->assign("row", $row);
- return $this->view->fetch();
- }
- }
|