浏览代码

Merge branch 'main' of http://124.222.171.90:10880/Southeast-Asia/API-Tou-Biao

Jason 1 年之前
父节点
当前提交
03639023c5

+ 73 - 33
application/admin/controller/user/User.php

@@ -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)
     {

+ 3 - 1
application/admin/lang/vn/user/user.php

@@ -48,5 +48,7 @@ return [
     '抢单开关'               => 'Lấy công tắc đặt hàng',
     '卡单开关'               => 'Công tắc đơn thẻ',
     '累计收益'               => 'Thu nhập tích lũy',
-    'Append'                => 'Nối thêm'
+    'Append'                => 'Nối thêm',
+    '不存在上级ID'           => 'Không tồn tại ID cấp trên',
+    'Mobile already exist'  => 'Số điện thoại di động đã tồn tại'
 ];

+ 1 - 1
application/admin/lang/zh-cn.php

@@ -229,5 +229,5 @@ return [
     'Balance'                                               => '余额',
     'Card slip'                                             => '卡单',
     'Collection'                                            => '收款',
-    '多次卡单时'                                              => '多次卡单时,不同单数之间用英文逗号(,)隔开',
+    '多次卡单时'                                             => '多次卡单时,不同单数之间用英文逗号(,)隔开',
 ];

+ 3 - 1
application/admin/lang/zh-cn/user/user.php

@@ -51,5 +51,7 @@ return [
     'Task num'              => '当前任务数',
     'Pwd title'             => '留空则不修改',
     '一键清空'               => '一键清空',
-    'Append'                => '追加'
+    'Append'                => '追加',
+    '不存在上级ID'           => '不存在上级ID',
+    'Mobile already exist'  => '手机号已存在'
 ];

+ 11 - 0
application/admin/model/Users.php

@@ -124,4 +124,15 @@ class Users extends Model
         return $this->belongsTo('UserGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0);
     }
 
+
+    /**
+     * @param $code     //国际区号
+     * @param $mobile   //手机号
+     * @return array
+     */
+    public static function getByParentInfo($user_id)
+    {
+        return self::where('id', $user_id)->where('is_delete', 0)->find();
+    }
+
 }

+ 38 - 0
application/admin/view/user/user/add.html

@@ -0,0 +1,38 @@
+<form id="add-form" class="" role="form" data-toggle="validator" method="POST" action="">
+    <div class="form-horizontal">
+    {:token()}
+
+    <div class="form-group">
+        <label for="c-code" class="control-label col-xs-12 col-sm-2">{:__('Code')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-code" data-rule="required" class="form-control" name="row[code]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mobile" data-rule="required" class="form-control" name="row[mobile]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="login_pwd" class="control-label col-xs-12 col-sm-2">{:__('Login pwd')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-login_pwd" data-rule="required" class="form-control" name="row[login_pwd]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-parent_id" class="control-label col-xs-12 col-sm-2">{:__('Parent_id')}ID:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-parent_id" class="form-control" name="row[parent_id]" type="parent_id" value="">
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+    </div>
+</form>

+ 1 - 1
application/admin/view/user/user/index.html

@@ -6,7 +6,7 @@
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
-                        {:build_toolbar('refresh')}
+                        {:build_toolbar('refresh,add')}
                         <a href="javascript:;" class="btn btn-success btn-balance btn-disabled disabled {:$auth->check('user/user/balance')?'':'hide'}" title="{:__('Balance')}" >
                             {:__('Balance')}
                         </a>

+ 0 - 1
application/api/controller/User.php

@@ -69,7 +69,6 @@ class User extends Api
         $code = $this->request->post('code');
         $mobile = $this->request->post('mobile');
         $pwd = $this->request->post('pwd');
-
         if (!$code || !$mobile || !$pwd) {
             $this->error(__('Invalid parameters'));
         }

+ 1 - 0
public/assets/js/backend/index.js

@@ -104,6 +104,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
                     type: 'POST',
                     success: function(response) {
                         $("#information span").text(response.data)
+                        $("#information").attr("href", "/eUmZFWDnVH.php/trade/money_out/index?ref=addtabs")
                     },
                 })
             },60000); 

+ 4 - 0
public/assets/js/backend/user/user.js

@@ -6,6 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Table.api.init({
                 extend: {
                     index_url: 'user/user/index',
+                    add_url: 'user/user/add',
                     edit_url: 'user/user/edit',
                     del_url: 'user/user/del',
                     multi_url: 'user/user/multi',
@@ -131,6 +132,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             //收款
             Controller.api.bindevent();
         },
+        add: function () {
+            Controller.api.bindevent();
+        },
         edit: function () {
             Controller.api.bindevent();
         },