zac3533 1 vuosi sitten
vanhempi
sitoutus
19862c6552

+ 115 - 11
application/admin/controller/user/Team.php

@@ -2,8 +2,13 @@
 
 namespace app\admin\controller\user;
 
+use app\admin\model\UserPath;
+use think\Db;
+use Exception;
+use think\exception\DbException;
+use think\exception\PDOException;
 use app\common\controller\Backend;
-use fast\Tree;
+use think\exception\ValidateException;
 
 /**
  * 会员团队
@@ -14,36 +19,135 @@ class Team extends Backend
 {
 
     /**
-     * @var \app\admin\model\UserRule
+     * @var \app\admin\model\UserPath
      */
     protected $model = null;
  
     public function _initialize()
     {
         parent::_initialize();
-        $this->model = model('UserRule');
- 
+        $this->model = model('User');
+        $user_id = $this->request->param('ids/d', 0);
+        $this->assignconfig('user_id', $user_id);
+        $this->view->assign("typeList", UserPath::where('parent_id', $user_id)->order('distance', 'asc')->column('distance'));
+
     }
 
+
     /**
      * 查看
+     * @return string|Json
+     * @throws \think\Exception
+     * @throws DbException
      */
     public function index()
     {
-        if ($this->request->isAjax()) {
-            $list = $this->rulelist;
-            $total = count($this->rulelist);
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+       
+        [, $sort, $order, $offset, $limit] = $this->buildparams();
+
+        $where = self::_where(json_decode($this->request->get("filter"), true));
 
-            $result = array("total" => $total, "rows" => $list);
+        $mapType = []; 
+        $type = $this->request->param('distance/d');
+        if($type > 0) $mapType['distance'] = $type;
+        $user_id = $this->request->param('user_id/d');
 
-            return json($result);
+        $list = $this->model->alias('a')
+            ->join('users b','a.parent_id = b.id', 'LEFT')
+            ->join('users_path c','a.id = c.user_id and c.parent_id ='. $user_id, 'LEFT')
+            ->where('a.id','IN',function($query) use($user_id){
+                $query->table('ta_users_path')->where('parent_id', $user_id)->order('distance', 'desc')->field('user_id');
+            })
+            ->where($where)->where($mapType)
+            ->field('a.id,a.is_lock,a.mobile,a.balance,a.bonus_sum,a.create_time,b.mobile as parent_name,c.distance')
+            ->order($sort, $order)
+            ->paginate($limit);
+        if($list->total() > 0){
+            $in  = model('Mongyin');
+            $out = model('Mongyout');
+            foreach ($list as &$item) {
+                $item->recharge = $in::where('status', 1)->where('user_id', $item->id)->sum('amount');
+                $item->withdraw = $out::where('status', 1)->where('user_id', $item->id)->sum('amount');
+            }  
         }
-        return $this->view->fetch();
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
     }
 
- 
+    /**
+     * 封禁
+     * @param $ids
+     * @return string
+     * @throws DbException
+     * @throws \think\Exception
+     */
+    public function lock($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'));
+        }
+        $result = false;
+        try {
+            $result = $row->allowField(true)->save(['is_lock'=>1]);
+        } catch (ValidateException|PDOException|Exception $e) {
+            $this->error($e->getMessage());
+        }
+        if (false === $result) {
+            $this->error(__('No rows were updated'));
+        }
+        $this->success();
+    }
 
+    /**
+     * 封禁团队
+     * @param $ids
+     * @return string
+     * @throws DbException
+     * @throws \think\Exception
+     */
+    public function lockAll($ids = null)
+    {
+        $rows = UserPath::where('parent_id', $ids)->column('distance');
+        if (!$rows) {
+            $this->error(__('No Results were found'));
+        }
+        $result = false;
+        try {
+            $result = $this->model->where('id', 'in', $rows)->update(['is_lock'=>1]);
+        } catch (ValidateException|PDOException|Exception $e) {
+            $this->error($e->getMessage());
+        }
+        if (false === $result) {
+            $this->error(__('No rows were updated'));
+        }
+        $this->success();
+    }
 
 
+    //搜索条件
+    private static function _where($filter = array()): array
+    {
+        $where = [];
+        if(isset($filter['mobile'])) $where['a.mobile'] = $filter['mobile'];
+        if(isset($filter['create_time'])) {
+            $arr = explode(' - ', $filter['create_time']);
+            $where['a.create_time']= ['between', [strtotime($arr[0]), strtotime($arr[1])]];
+        }
+        return $where;
+    }
 
 }

+ 0 - 19
application/admin/lang/vn/user/rule.php

@@ -1,19 +0,0 @@
-<?php
-
-return [
-    'Pid'             => '父ID',
-    'Name'            => '规则',
-    'Title'           => '标题',
-    'Remark'          => '备注',
-    'Ismenu'          => '是否菜单',
-    'Change password' => '修改密码',
-    'Createtime'      => '创建时间',
-    'Updatetime'      => '更新时间',
-    'Menu tips'       => '规则任意,请不可重复,仅做层级显示,无需匹配控制器和方法',
-    'Node tips'       => '模块/控制器/方法名',
-    'Weigh'           => '权重',
-    'Status'          => '状态',
-    'Toggle all'      => '显示全部',
-    'Toggle menu visible' => '点击切换菜单显示',
-    'Toggle sub menu'     => '点击切换子菜单',
-];

+ 18 - 0
application/admin/lang/vn/user/team.php

@@ -0,0 +1,18 @@
+<?php
+
+return [
+    'Pid'             => '父ID',
+    'Name'            => '规则',
+    'Balance'         => '余额',
+    'Bonus sum'       => '累计佣金',
+    'Parent id'       => '上级用户',
+    'Recharge'        => '充值',
+    'Withdraw'        => '提现',
+    'Level'           => 'mức độ',
+    'Grade'           => 'lớp học',  
+    'Account'         => 'Thay đổi tài khoản', 
+    'Ban team'        => 'đội cấm',
+    'Ban'             => 'lệnh cấm', 
+    'Createtime'      => '注册时间',
+    'Updatetime'      => '更新时间',
+];

+ 0 - 19
application/admin/lang/zh-cn/user/rule.php

@@ -1,19 +0,0 @@
-<?php
-
-return [
-    'Pid'             => '父ID',
-    'Name'            => '规则',
-    'Title'           => '标题',
-    'Remark'          => '备注',
-    'Ismenu'          => '是否菜单',
-    'Change password' => '修改密码',
-    'Createtime'      => '创建时间',
-    'Updatetime'      => '更新时间',
-    'Menu tips'       => '规则任意,请不可重复,仅做层级显示,无需匹配控制器和方法',
-    'Node tips'       => '模块/控制器/方法名',
-    'Weigh'           => '权重',
-    'Status'          => '状态',
-    'Toggle all'      => '显示全部',
-    'Toggle menu visible' => '点击切换菜单显示',
-    'Toggle sub menu'     => '点击切换子菜单',
-];

+ 20 - 0
application/admin/lang/zh-cn/user/team.php

@@ -0,0 +1,20 @@
+<?php
+
+return [
+
+    'Pid'             => '父ID',
+    'Name'            => '规则',
+    'Balance'         => '余额',
+    'Bonus sum'       => '累计佣金',
+    'Parent id'       => '上级用户',
+    'Recharge'        => '充值',
+    'Withdraw'        => '提现',
+    'Level'           => '级别',
+    'Grade'           => '级',  
+    'Ban'             => '封禁',
+    'Ban team'        => '封禁团队',  
+    'Account'         => '帐变', 
+    'Createtime'      => '注册时间',
+    'Updatetime'      => '更新时间',
+
+];

+ 6 - 0
application/admin/model/User.php

@@ -70,6 +70,12 @@ class User extends Model
     }
 
 
+    public function parent()
+    {
+        return $this->hasOne('User','id','parent_id',[],'LEFT')->setEagerlyType(0);
+    }
+
+
     public function getPrevtimeTextAttr($value, $data)
     {
         $value = $value ? $value : ($data['prevtime'] ?? "");

+ 1 - 1
application/admin/model/UserPath.php

@@ -9,7 +9,7 @@ class UserPath extends Model
 {
 
     // 表名
-    protected $name = 'user_path';
+    protected $name = 'users_path';
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = false;
     // 定义时间戳字段名

+ 11 - 12
application/admin/view/user/team/index.html

@@ -1,24 +1,23 @@
 <div class="panel panel-default panel-intro">
-    {:build_heading()}
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs">
+            <li class="active"><a href="#all" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="typeList" item="vo"}
+                <li><a href="#{$vo}" data-toggle="tab">{$vo} {:__('Grade')}</a></li>
+            {/foreach}
+        </ul>
+    </div>
 
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
-                        {:build_toolbar('refresh,add,edit,del')}
-                        <div class="dropdown btn-group {:$auth->check('user/rule/multi')?'':'hide'}">
-                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
-                            <ul class="dropdown-menu text-left" role="menu">
-                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
-                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
-                            </ul>
-                        </div>
-                        <a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a>
+                        {:build_toolbar('refresh')}
+
                     </div>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
-                           data-operate-edit="{:$auth->check('user/rule/edit')}"
-                           data-operate-del="{:$auth->check('user/rule/del')}"
                            width="100%">
                     </table>
                 </div>

+ 0 - 3
application/common/model/Lists.php

@@ -35,9 +35,6 @@ class Lists extends Model
         return $this->hasOne('Types','id','type_id',[],'LEFT')->setEagerlyType(0);
     }
 
-
-
-
     public function getCreateTimeTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');

+ 1 - 0
public/assets/js/backend/news/lists.js

@@ -35,6 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         },
                         {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]

+ 0 - 130
public/assets/js/backend/user/rule.js

@@ -1,130 +0,0 @@
-define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
-
-    var Controller = {
-        index: function () {
-            // 初始化表格参数配置
-            Table.api.init({
-                extend: {
-                    index_url: 'user/rule/index',
-                    add_url: 'user/rule/add',
-                    edit_url: 'user/rule/edit',
-                    del_url: 'user/rule/del',
-                    multi_url: 'user/rule/multi',
-                    table: 'user_rule',
-                }
-            });
-
-            var table = $("#table");
-
-            // 初始化表格
-            table.bootstrapTable({
-                url: $.fn.bootstrapTable.defaults.extend.index_url,
-                pk: 'id',
-                sortName: 'weigh',
-                escape: false,
-                columns: [
-                    [
-                        {checkbox: true},
-                        {field: 'id', title: __('Id')},
-                        {field: 'pid', title: __('Pid'), visible: false},
-                        {field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title},
-                        {field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
-                        {field: 'remark', title: __('Remark')},
-                        // {field: 'ismenu', title: __('Ismenu'), formatter: Table.api.formatter.toggle},
-                        {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
-                        {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
-                        {field: 'weigh', title: __('Weigh')},
-                        {field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
-                    ]
-                ],
-                pagination: false,
-                search: false,
-                commonSearch: false,
-                rowAttributes: function (row, index) {
-                    return row.pid == 0 ? {} : {style: "display:none"};
-                }
-            });
-
-            // 为表格绑定事件
-            Table.api.bindevent(table);
-
-            table.on('post-body.bs.table', function (e, settings, json, xhr) {
-                //显示隐藏子节点
-                $(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
-                    var status = $(this).data("shown") ? true : false;
-                    $("a[data-pid='" + $(this).data("id") + "']").each(function () {
-                        $(this).closest("tr").toggle(!status);
-                    });
-                    if (status) {
-                        $("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
-                    }
-                    $(this).data("shown", !status);
-                    $("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
-                    return false;
-                });
-            });
-
-            //隐藏子节点
-            $(document).on("collapse", ".btn-node-sub", function () {
-                if ($("i", this).length > 0) {
-                    $("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
-                }
-                $("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
-                $(this).data("shown", false);
-                $(this).closest("tr").toggle(false);
-            });
-
-            //展开隐藏一级
-            $(document.body).on("click", ".btn-toggle", function (e) {
-                $("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
-                var that = this;
-                var show = $("i", that).hasClass("fa-chevron-down");
-                $("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
-                $("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
-                $(".btn-node-sub[data-pid=0]").data("shown", show);
-            });
-
-            //展开隐藏全部
-            $(document.body).on("click", ".btn-toggle-all", function (e) {
-                var that = this;
-                var show = $("i", that).hasClass("fa-plus");
-                $("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
-                $(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
-                $(".btn-node-sub").data("shown", show);
-                $(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
-            });
-        },
-        add: function () {
-            Controller.api.bindevent();
-        },
-        edit: function () {
-            Controller.api.bindevent();
-        },
-        api: {
-            formatter: {
-                title: function (value, row, index) {
-                    value = value.toString().replace(/(&|&amp;)nbsp;/g, '&nbsp;');
-                    var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : '';
-                    value = value.indexOf("&nbsp;") > -1 ? value.replace(/(.*)&nbsp;/, "$1" + caret) : caret + value;
-
-                    value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
-                    return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
-                        + (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
-                },
-                name: function (value, row, index) {
-                    return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
-                },
-            },
-            bindevent: function () {
-                $(document).on('click', "input[name='row[ismenu]']", function () {
-                    var name = $("input[name='row[name]']");
-                    name.prop("placeholder", $(this).val() == 1 ? name.data("placeholder-menu") : name.data("placeholder-node"));
-                });
-                $("input[name='row[ismenu]']:checked").trigger("click");
-                Form.api.bindevent($("form[role=form]"));
-            }
-        }
-    };
-    return Controller;
-});

+ 99 - 0
public/assets/js/backend/user/team.js

@@ -0,0 +1,99 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'user/team/index'+ location.search +'&user_id='+Config.user_id,
+                    table: 'user_team',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'a.id',
+                sortName: 'a.id',
+                searchFormVisible: true,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id'), operate: false},
+                        {field: 'mobile', title: __('Mobile'), operate: 'Like'},
+                        {field: 'balance', title: __('Balance'), operate: false},
+                        {field: 'bonus_sum', title: __('Bonus sum'), operate: false},
+                        {field: 'parent_name', title: __('Parent id'),operate: false},
+                        {field: 'recharge', title: __('Recharge'), operate: false},
+                        {field: 'withdraw', title: __('Withdraw'), operate: false},
+
+                        {field: 'distance', title: __('Level'), formatter: function(value, row, index) {
+                            return value + __('Grade');
+                        }, operate: false,cellStyle: function () {
+                            return {css: {"color":"#18bc9c", 'font-weight':'550'}}}
+                        },
+                        {field: 'create_time', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table,
+                            buttons: [
+                                {
+                                    name: "account",
+                                    text:  __('Account'),
+                                    classname: 'btn btn-xs btn-info btn-magic btn-dialog',
+                                    url: function(row){ return 'trade/moneylog/index/ids/'+row.id},
+                                    refresh: true
+                            },{
+                                name: "ban",
+                                text:  __('Ban'),
+                                classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
+                                url: function(row){ return 'user/team/lock/ids/'+row.id},
+                                visible: function (row) {
+                                    if(row.is_lock == 0)  return true;
+                                    return false;
+                                },
+                                refresh: true
+                            },{
+                                name: "banteam",
+                                text:  __('Ban team'),
+                                classname: 'btn btn-xs btn-warning btn-magic btn-ajax',
+                                url: function(row){ return 'user/team/lockAll/ids/'+row.id},
+                                refresh: true
+                            }],
+                            events: Table.api.events.operate, formatter: Table.api.formatter.operate
+                        }]
+                ],
+       
+           
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+                var typeStr = $(this).attr("href").replace('#', '');
+                var options = table.bootstrapTable('getOptions');
+                options.pageNumber = 1;
+                options.queryParams = function (params) {
+                    params.distance = typeStr;
+                    return params;
+                };
+                table.bootstrapTable('refresh', {});
+                return false;
+            });
+   
+        },
+        account: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+ 
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 3 - 5
public/assets/js/backend/user/user.js

@@ -55,8 +55,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     classname: 'btn btn-xs btn-info btn-magic btn-dialog',
                                     url: 'trade/moneylog/index',
                                     refresh: true
-                                },
-                                {
+                            },{
                                 name: "clear",
                                 text:  __('Clear'),
                                 classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
@@ -70,9 +69,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 name: "team",
                                 text:  __('Team'),
                                 classname: 'btn btn-xs btn-success btn-magic btn-dialog',
-                                confirm: __('Confirm review'),
-                                url: 'user/group/Team',
-                
+                                url: 'user/team/index',
+                                extend: 'data-area=\'["80%","80%"]\'',
                                 refresh: true
                             },{
                                 name: "edit",