|
|
@@ -5,9 +5,9 @@ namespace app\admin\controller\user;
|
|
|
use think\Db;
|
|
|
use Exception;
|
|
|
use fast\Random;
|
|
|
-use app\admin\model\UsersPath;
|
|
|
+use think\Hook;
|
|
|
+use app\common\model\UsersPath;
|
|
|
use app\common\model\MoneyLog;
|
|
|
-use think\exception\DbException;
|
|
|
use think\exception\PDOException;
|
|
|
use app\common\controller\Backend;
|
|
|
use think\exception\ValidateException;
|
|
|
@@ -72,9 +72,6 @@ class User extends Backend
|
|
|
/**
|
|
|
* 余额
|
|
|
* @param $ids
|
|
|
- * @return string
|
|
|
- * @throws DbException
|
|
|
- * @throws \think\Exception
|
|
|
*/
|
|
|
public function balance($ids = null)
|
|
|
{
|
|
|
@@ -111,10 +108,6 @@ class User extends Backend
|
|
|
|
|
|
/**
|
|
|
* 卡单
|
|
|
- * @param $ids
|
|
|
- * @return string
|
|
|
- * @throws DbException
|
|
|
- * @throws \think\Exception
|
|
|
*/
|
|
|
public function cardslip($ids = null)
|
|
|
{
|
|
|
@@ -127,12 +120,6 @@ class User extends Backend
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
|
if (false === $this->request->isPost()) {
|
|
|
-
|
|
|
- // $task = json_decode($row->limit_task, true);
|
|
|
- // $row->which_start = $task['which_start']??'';
|
|
|
- // $row->min_amount = $task['min_amount']??'';
|
|
|
- // $row->max_amount = $task['max_amount']??'';
|
|
|
- // $row->income_multiple= $task['income_multiple']??'';
|
|
|
$this->view->assign('row', $row);
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
@@ -160,9 +147,6 @@ class User extends Backend
|
|
|
/**
|
|
|
* 收款
|
|
|
* @param $ids
|
|
|
- * @return string
|
|
|
- * @throws DbException
|
|
|
- * @throws \think\Exception
|
|
|
*/
|
|
|
public function collection($ids = null)
|
|
|
{
|
|
|
@@ -208,10 +192,6 @@ class User extends Backend
|
|
|
|
|
|
/**
|
|
|
* 清零
|
|
|
- * @param $ids
|
|
|
- * @return string
|
|
|
- * @throws DbException
|
|
|
- * @throws \think\Exception
|
|
|
*/
|
|
|
public function clear($ids = null)
|
|
|
{
|
|
|
@@ -235,14 +215,80 @@ class User extends Backend
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
+ 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->dataLimit && $this->dataLimitFieldAutoFill) {
|
|
|
+ $params[$this->dataLimitField] = $this->auth->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($params['mobile'] && \app\common\model\Users::getByCodeAndMobile($params['code'], $params['mobile'])) {
|
|
|
+ $this->error(__('Mobile already exist', ''));
|
|
|
+ }
|
|
|
+
|
|
|
+ $parent_info = $this->model::getByParentInfo($params['parent_id']);
|
|
|
+ if(empty($parent_info)) $this->error('不存在上级ID');
|
|
|
+
|
|
|
+ $ip = request()->ip();
|
|
|
+ $time = time();
|
|
|
+ $user_data = [
|
|
|
+ 'mobile' => $params['mobile'],
|
|
|
+ 'code' => $params['code'],
|
|
|
+ 'login_pwd'=> $params['login_pwd'],
|
|
|
+ 'parent_id'=> $params['parent_id'],
|
|
|
+ 'agent_id' => $parent_info['agent_id'],
|
|
|
+ 'user_type'=> 1,//真人
|
|
|
+ ];
|
|
|
+ if($parent_info['is_agent']) $user_data['agent_id'] = $parent_info['id'];
|
|
|
+
|
|
|
+ $user_data = array_merge($user_data, [
|
|
|
+ 'nickname' => preg_match("/^1[3-9]{1}\d{9}$/", $params['mobile']) ? substr_replace($params['mobile'], '****', 3, 4) : $params['mobile'],
|
|
|
+ 'salt' => Random::alnum(),
|
|
|
+ 'join_time' => $time,
|
|
|
+ 'login_ip' => $ip,
|
|
|
+ 'login_time'=> $time,
|
|
|
+ ]);
|
|
|
+ $user_data['login_pwd'] = $this->auth->getEncryptPassword($params['login_pwd'], $user_data['salt']);
|
|
|
+
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $result = $user = $this->model::create($user_data, true);
|
|
|
+ $_user = $this->model::get($user->id);
|
|
|
+
|
|
|
+ // 创建网体
|
|
|
+ (new UsersPath())->createPath($user->id, $parent_info['id']);
|
|
|
+
|
|
|
+ //上级人数+1
|
|
|
+ $this->model->where('id', $parent_info['id'])->setInc('team_num');
|
|
|
+
|
|
|
+ //设置Token
|
|
|
+ //注册成功的事件
|
|
|
+ Hook::listen("user_register_successed", $_user, $user_data);
|
|
|
+ Db::commit();
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($result === false) {
|
|
|
+ $this->error(__('No rows were inserted'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
|
|
- *
|
|
|
- * @param $ids
|
|
|
- * @return string
|
|
|
- * @throws DbException
|
|
|
- * @throws \think\Exception
|
|
|
*/
|
|
|
public function edit($ids = null)
|
|
|
{
|
|
|
@@ -308,12 +354,6 @@ class User extends Backend
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
- *
|
|
|
- * @param $ids
|
|
|
- * @return void
|
|
|
- * @throws DbException
|
|
|
- * @throws DataNotFoundException
|
|
|
- * @throws ModelNotFoundException
|
|
|
*/
|
|
|
public function del($ids = null)
|
|
|
{
|