aiyou 4 anni fa
parent
commit
2ad65714cc

+ 30 - 2
application/admin/controller/Dashboard.php

@@ -7,7 +7,7 @@ use app\admin\model\store\StoreProduct;
 use app\common\controller\Backend;
 use think\Config;
 use app\admin\model\Member;
-
+use app\admin\model\ShopUser;
 /**
  * 控制台
  *
@@ -22,6 +22,16 @@ class Dashboard extends Backend
      */
     public function index()
     {
+
+//        $effect_city=$this->auth->effect_city;
+//        $get_suser_id=[];
+//        if (!empty($effect_city)){
+//
+//            $where_suser['effect_city']=['like','%'.$effect_city.'%'];
+//            $get_suser_list=ShopUser::where($where_suser)->field('id')->select();
+//            $get_suser_id=array_column($get_suser_list,'id');
+//
+//        }
         $seventtime = \fast\Date::unixtime('day', -7);
         $paylist = $createlist = [];
         for ($i = 0; $i <= 7; $i++)
@@ -32,10 +42,15 @@ class Dashboard extends Backend
 
 
             $where1['status']=array('in',['1','2','3','0','9']);
-            $get_num_xiadan=StoreOrder::where($where1)->field('count(*) as num')->find();
+            if (count($this->auth->suser_id)>0){
+                $where1['suser_id']=['in',$this->auth->suser_id];
+            }
 
+            $get_num_xiadan=StoreOrder::where($where1)->field('count(*) as num')->find();
+            //dump($get_num_xiadan);exit;
 
             $where1['status']=array('in',['1','2','3']);
+
             $get_num_wancheng=StoreOrder::where($where1)->field('count(*) as num')->find();
 
 
@@ -53,6 +68,10 @@ class Dashboard extends Backend
         $get_member_count=Member::field('count(*) as num')->find();
 
         $order_where['status']=array('in',['3','4']);
+
+        if (count($this->auth->suser_id)>0){
+            $order_where['suser_id']=['in',$this->auth->suser_id];
+        }
         $get_order_count=StoreOrder::where($order_where)->field('count(*) as num,sum(pay_price) as price')->find();
 
         $where_member1['create_time']= ['between', [mktime(0,0,0,date('m'),date('d'),date('Y')), time()]];
@@ -61,10 +80,19 @@ class Dashboard extends Backend
 
         $where1['add_time'] = ['between', [mktime(0,0,0,date('m'),date('d'),date('Y')), time()]];
         $where1['status']=array('in',['1','2','3']);
+        if (count($this->auth->suser_id)>0){
+            $where1['suser_id']=['in',$this->auth->suser_id];
+        }
+
         $get_order1=StoreOrder::where($where1)->field('count(*) as num')->find();
 
         $where2['add_time'] = ['between', [mktime(0,0,0,date('m'),date('d'),date('Y')), time()]];
         $where2['status']=array('in',['1','-1']);
+
+
+        if (count($this->auth->suser_id)>0){
+            $where2['suser_id']=['in',$this->auth->suser_id];
+        }
         $get_order2=StoreOrder::where($where2)->field('count(*) as num')->find();
 
 

+ 18 - 0
application/admin/controller/Index.php

@@ -7,6 +7,7 @@ use app\common\controller\Backend;
 use think\Config;
 use think\Hook;
 use think\Validate;
+use app\admin\model\ShopUser;
 
 /**
  * 后台首页
@@ -87,8 +88,25 @@ class Index extends Backend
             }
             AdminLog::setTitle(__('Login'));
             $result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0);
+
             if ($result === true) {
                 Hook::listen("admin_login_after", $this->request);
+
+
+                //
+//                $effect_city=$this->auth->effect_city;
+//                $get_suser_id=[];
+//                if (!empty($effect_city)){
+//
+//                    $where_suser['effect_city']=['like','%'.$effect_city.'%'];
+//
+//                    $get_suser_list=ShopUser::where($where_suser)->field('id')->select();
+//                    $get_suser_id=array_column($get_suser_list,'id');
+//                    dump($get_suser_id);
+//                }
+//               // dump($this->auth);
+//                $this->auth->suer_id=$get_suser_id;
+               // dump( $this->auth->suer_id);
                 $this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]);
             } else {
                 $msg = $this->auth->getError();

+ 44 - 17
application/admin/controller/MemberExtract.php

@@ -55,23 +55,50 @@ class MemberExtract extends Backend
                 $whre1['type']='1';
                 $whre1['suser_id']=$suser_id;
             }
-            $total = $this->model
-                ->where($where)
-                ->where('is_del','0')
-                ->where('is_system_del','0')
-                ->where($whre1)
-                ->order($sort, $order)
-                ->count();
-
-            $list = $this->model
-                ->where($where)
-                ->where('is_del','0')
-                ->where('is_system_del','0')
-                ->where($whre1)
-                ->with('member')
-                ->order($sort, $order)
-                ->limit($offset, $limit)
-                ->select();
+
+            if (count($this->auth->suser_id)>0) {
+                $where2['suser_id'] = ['in', $this->auth->suser_id];
+                $total = $this->model
+                    ->where($where)
+                    ->where('is_del','0')
+                    ->where('is_system_del','0')
+                    ->where($whre1)
+                    ->where($where2)
+                    ->order($sort, $order)
+                    ->count();
+
+                $list = $this->model
+                    ->where($where)
+                    ->where('is_del','0')
+                    ->where('is_system_del','0')
+                    ->where($whre1)
+                    ->where($where2)
+                    ->with('member')
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+
+            }else{
+                $total = $this->model
+                    ->where($where)
+                    ->where('is_del','0')
+                    ->where('is_system_del','0')
+                    ->where($whre1)
+                    ->order($sort, $order)
+                    ->count();
+
+                $list = $this->model
+                    ->where($where)
+                    ->where('is_del','0')
+                    ->where('is_system_del','0')
+                    ->where($whre1)
+                    ->with('member')
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+            }
+
 
             $list = collection($list)->toArray();
             $result = array("total" => $total, "rows" => $list);

+ 36 - 10
application/admin/controller/ShopUser.php

@@ -53,17 +53,43 @@ class ShopUser extends Backend
 
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
-            $total = $this->model
-                ->where($where)
-                ->order($sort, $order)
-                ->count();
 
-            $list = $this->model
-                ->where($where)
-                ->with('member')
-                ->order($sort, $order)
-                ->limit($offset, $limit)
-                ->select();
+
+
+            if (count($this->auth->suser_id)>0){
+
+                $wherelike['id']=['in',$this->auth->suser_id];
+             //   $wherelike['mid']=['neq',0];
+             //   $wherelike['effect_city']=['like','%'.$effect_city.'%'];
+                $total = $this->model
+                    ->where($where)
+                    ->where($wherelike)
+                    ->order($sort, $order)
+                    ->count();
+
+                $list = $this->model
+                    ->where($where)
+                    ->where($wherelike)
+                    ->with('member')
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            }else{
+                $total = $this->model
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->count();
+
+                $list = $this->model
+                    ->where($where)
+                    ->with('member')
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+            }
+
+
             $list = collection($list)->toArray();
             $result = array("total" => $total, "rows" => $list);
 

+ 40 - 16
application/admin/controller/order/StoreOrder.php

@@ -52,23 +52,47 @@ class StoreOrder extends Backend
             }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
             $where1['status']=['not in',['0','9']];
-            $total = $this->model
-                ->where($where)
-                ->where('is_system_del','0')
-                ->where('is_del','0')
-                ->where($where1)
-                ->order($sort, $order)
-                ->count();
 
-            $list = $this->model
-                ->where($where)
-                ->with(['shopuser','member'])
-                ->where('is_system_del','0')
-                ->where('is_del','0')
-                ->where($where1)
-                ->order($sort, $order)
-                ->limit($offset, $limit)
-                ->select();
+            if (count($this->auth->suser_id)>0) {
+
+                $where1['suser_id'] = ['in', $this->auth->suser_id];
+                $total = $this->model
+                    ->where($where)
+                    ->where('is_system_del','0')
+                    ->where('is_del','0')
+                    ->where($where1)
+                    ->order($sort, $order)
+                    ->count();
+
+                $list = $this->model
+                    ->where($where)
+                    ->with(['shopuser','member'])
+                    ->where('is_system_del','0')
+                    ->where('is_del','0')
+                    ->where($where1)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+            }else{
+                $total = $this->model
+                    ->where($where)
+                    ->where('is_system_del','0')
+                    ->where('is_del','0')
+                    ->where($where1)
+                    ->order($sort, $order)
+                    ->count();
+
+                $list = $this->model
+                    ->where($where)
+                    ->with(['shopuser','member'])
+                    ->where('is_system_del','0')
+                    ->where('is_del','0')
+                    ->where($where1)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            }
 
             $list = collection($list)->toArray();
             foreach ($list as $k=>$v){

+ 20 - 0
application/admin/library/Auth.php

@@ -3,6 +3,7 @@
 namespace app\admin\library;
 
 use app\admin\model\Admin;
+use app\admin\model\ShopUser;
 use fast\Random;
 use fast\Tree;
 use think\Config;
@@ -57,12 +58,31 @@ class Auth extends \fast\Auth
             $this->setError('Password is incorrect');
             return false;
         }
+
+
+
         $admin->loginfailure = 0;
         $admin->logintime = time();
         $admin->loginip = request()->ip();
         $admin->token = Random::uuid();
         $admin->save();
+        $effect_city=$admin['effect_city'];
+        $get_suser_id=[];
+        if (!empty($effect_city)){
+
+            $where_suser['effect_city']=['like','%'.$effect_city.'%'];
+            $where_suser['mid']=['neq','0'];
+            $get_suser_list=ShopUser::where($where_suser)->field('id')->select();
+            $get_suser_id=array_column($get_suser_list,'id');
+
+        }
+        $admin['suser_id']=$get_suser_id;
+
         Session::set("admin", $admin->toArray());
+
+
+
+
         $this->keeplogin($keeptime);
         return true;
     }

+ 7 - 2
application/admin/view/auth/admin/add.html

@@ -36,10 +36,15 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('手机号')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-phone" class="form-control"  data-rule="mobile" data-rule-mobile="[/^1[3-9]\d{9}$/, '请填写有效的手机号']" name="row[phone]" type="text" value="">
+            <input id="c-phone" class="form-control"  data-rule="mobile,required" data-rule-mobile="[/^1[3-9]\d{9}$/, '请填写有效的手机号']" name="row[phone]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('管理省市')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class='control-relative'><input id="c-effect_city" data-rule="required"  data-level="city" class="form-control" data-toggle="city-picker" name="row[effect_city]" type="text" ></div>
         </div>
     </div>
-
 <!--    <div class="form-group">-->
 <!--        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>-->
 <!--        <div class="col-xs-12 col-sm-8">-->

+ 8 - 2
application/admin/view/auth/admin/edit.html

@@ -28,13 +28,19 @@
     <div class="form-group">
         <label for="password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input type="password" class="form-control" id="password" name="row[password]" autocomplete="new-password" value="" data-rule="password" />
+            <input type="password" class="form-control" id="password" name="row[password]" autocomplete="new-password" value="" data-rule="password,required" />
         </div>
     </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('手机号')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-phone" class="form-control"  data-rule="mobile" data-rule-mobile="[/^1[3-9]\d{9}$/, '请填写有效的手机号']" name="row[phone]" type="text" value="{$row.phone|htmlentities}">
+            <input id="c-phone" class="form-control"  data-rule="mobile,required" data-rule-mobile="[/^1[3-9]\d{9}$/, '请填写有效的手机号']" name="row[phone]" type="text" value="{$row.phone|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('管理省市')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class='control-relative'><input id="c-effect_city" data-rule="required"  data-level="city" class="form-control" data-toggle="city-picker" name="row[effect_city]" type="text" value="{$row.effect_city|htmlentities}"></div>
         </div>
     </div>
 <!--    <div class="form-group">-->

+ 2 - 1
public/assets/js/backend/auth/admin.js

@@ -34,7 +34,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'username', title: __('Username')},
                         {field: 'nickname', title: __('Nickname')},
                         {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
-                        {field: 'email', title: __('Email')},
+                        {field: 'phone', title: __('手机号')},
+                        {field: 'effect_city', title: __('管理区域')},
                         {field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
                         {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {