|
|
@@ -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];
|
|
|
- }
|
|
|
|
|
|
|
|
|
|