浏览代码

uid修改

afa 4 月之前
父节点
当前提交
1fa69f6dcd

+ 53 - 36
application/admin/controller/user/User.php

@@ -9,7 +9,8 @@ use app\common\model\LedgerFrozenChangeModel;
 use Exception;
 use fast\GoogleAuthenticator;
 use fast\Asset;
-use app\common\model\ProductOrder;
+use think\exception\PDOException;
+use think\exception\ValidateException;
 use app\common\model\LedgerTeacChangeModel;
 use think\Db;
 use think\exception\DbException;
@@ -72,6 +73,57 @@ class User extends Backend
         return json($result);
     }
 
+    
+    /**
+     * 编辑
+     *
+     * @param $ids
+     * @return string
+     * @throws DbException
+     * @throws \think\Exception
+     */
+    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) && !in_array($row[$this->dataLimitField], $adminIds)) {
+            $this->error(__('You have no permission'));
+        }
+        if (false === $this->request->isPost()) {
+            $this->view->assign('row', $row);
+            return $this->view->fetch();
+        }
+        $params = $this->request->post('row/a');
+        if (empty($params)) {
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        $params = $this->preExcludeFields($params);
+        if($this->model::where('nickname', $params['nickname'])->count() > 0) $this->error(__('UID已存在', ''));
+        $result = false;
+        Db::startTrans();
+        try {
+            //是否采用模型验证
+            if ($this->modelValidate) {
+                $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                $row->validateFailException()->validate($validate);
+            }
+            $result = $row->allowField(true)->save($params);
+            Db::commit();
+        } catch (ValidateException|PDOException|Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if (false === $result) {
+            $this->error(__('No rows were updated'));
+        }
+        $this->success();
+    }
+
+
 
     /**
      * 茶宝调整
@@ -136,41 +188,6 @@ class User extends Backend
         $this->success('调整成功');
     }
 
-    //搜索条件
-    private function _where(array $filter): array
-    {
-        $map = [];
-        $pid = 0;
-        $algebra = 0;
-
-        if (isset($filter['id'])) $map['a.id'] = ['=', $filter['id']];
-        if (isset($filter['address'])) $map['a.address'] = ['like', $filter['address']];
-        if (isset($filter['parent_id'])) $map['parent_id'] = ['=', $filter['parent_id']];
-        if (isset($filter['create_time'])) {
-            $arr = explode(' - ', $filter['create_time']);
-            $map['a.create_time']= ['between time',[$arr[0], $arr[1]]];
-        }
-        //团队等级
-        if (isset($filter['team_level_id'])) $map['a.team_level_id'] = ['=', $filter['team_level_id']];
-        //人数
-        if (isset($filter['team_num'])) $map['a.team_num'] = ['=', $filter['team_num']];
-        //直推
-        if (isset($filter['direct_num'])) $map['a.direct_num'] = ['=', $filter['direct_num']];
-        
-        
-        //代数
-        if(isset($filter['parent_id'])) {
-            if(isset($filter['algebra']) && $filter['algebra'] > 0){
-                $pid = $filter['parent_id'];
-                $algebra = $filter['algebra'];
-            }else{
-                $pid = $filter['parent_id'];
-                $algebra = -1;
-            }
-        }
-
-        return [$map, $pid, $algebra];
-    }
 
 
 

+ 2 - 2
application/admin/view/user/user/edit.html

@@ -15,9 +15,9 @@
     </div>
 
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">昵称:</label>
+        <label class="control-label col-xs-12 col-sm-2">UID:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-nickname" class="form-control"  name="row[nickname]" type="text" value="{$row.nickname|htmlentities}" />
+            <input id="c-nickname" class="form-control" data-rule="required;length(10~13)" name="row[nickname]" type="text" value="{$row.nickname|htmlentities}" />
         </div>
     </div>
 

+ 0 - 7
application/api/controller/Offline.php

@@ -3,8 +3,6 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-use app\common\library\EthSign;
-use app\common\library\Token;
 use app\common\model\LedgerWalletModel;
 use app\common\model\OfflineRechargeRecordModel;
 use app\common\model\OfflineWithdrawRecordModel;
@@ -16,11 +14,6 @@ use fast\Random;
 use think\Config;
 use think\Db;
 use Exception;
-use think\Env;
-use think\Hook;
-use think\Log;
-use think\Model;
-use think\Validate;
 
 /**
  * 会员接口