Răsfoiți Sursa

Merge remote-tracking branch 'origin/jun' into liuxiangxin

liuxiangxin 4 luni în urmă
părinte
comite
4e0b6980f3
40 a modificat fișierele cu 634 adăugiri și 157 ștergeri
  1. 66 15
      app/Http/Controllers/Admin/AdminUser.php
  2. 17 5
      app/Http/Controllers/Admin/AuthManager.php
  3. 63 39
      app/Http/Controllers/Admin/Business.php
  4. 23 3
      app/Http/Controllers/Admin/Coupon.php
  5. 27 3
      app/Http/Controllers/Admin/CouponActive.php
  6. 31 4
      app/Http/Controllers/Admin/CouponRewardRule.php
  7. 15 2
      app/Http/Controllers/Admin/CustomCoupon.php
  8. 37 40
      app/Http/Controllers/Admin/Login.php
  9. 6 6
      app/Http/Controllers/Admin/Product.php
  10. 27 3
      app/Http/Controllers/Admin/Promo.php
  11. 6 0
      app/Http/Controllers/Admin/PromoProduct.php
  12. 162 0
      app/Models/Company.php
  13. 1 1
      config/hashids.php
  14. 1 1
      config/view.php
  15. 5 5
      public/static/ueditor/dialogs/charts/charts.js
  16. 2 2
      public/static/ueditor/third-party/SyntaxHighlighter/shCore.js
  17. 2 2
      public/static/ueditor/third-party/codemirror/codemirror.js
  18. 2 2
      public/static/ueditor/third-party/highcharts/highcharts.src.js
  19. 1 1
      public/static/ueditor/third-party/highcharts/modules/canvas-tools.src.js
  20. 1 1
      public/static/ueditor/third-party/highcharts/modules/data.src.js
  21. 1 1
      public/static/ueditor/third-party/jquery-1.10.2.js
  22. 4 4
      public/static/ueditor/ueditor.all.js
  23. 11 2
      resources/views/admin/admin_user/add.blade.php
  24. 12 4
      resources/views/admin/admin_user/edit.blade.php
  25. 6 0
      resources/views/admin/admin_user/index.blade.php
  26. 5 1
      resources/views/admin/auth_manager/index.blade.php
  27. 25 9
      resources/views/admin/business/index.blade.php
  28. 8 0
      resources/views/admin/coupon/add.blade.php
  29. 8 0
      resources/views/admin/coupon/edit.blade.php
  30. 3 1
      resources/views/admin/coupon/index.blade.php
  31. 8 0
      resources/views/admin/coupon_active/add.blade.php
  32. 8 0
      resources/views/admin/coupon_active/edit.blade.php
  33. 2 0
      resources/views/admin/coupon_active/index.blade.php
  34. 8 0
      resources/views/admin/coupon_reward_rule/add.blade.php
  35. 8 0
      resources/views/admin/coupon_reward_rule/edit.blade.php
  36. 2 0
      resources/views/admin/coupon_reward_rule/index.blade.php
  37. 2 0
      resources/views/admin/custom_coupon/index.blade.php
  38. 8 0
      resources/views/admin/promo/add.blade.php
  39. 8 0
      resources/views/admin/promo/edit.blade.php
  40. 2 0
      resources/views/admin/promo/index.blade.php

+ 66 - 15
app/Http/Controllers/Admin/AdminUser.php

@@ -3,6 +3,8 @@
 use App\Http\Requests\Admin\AdminUser as Request;
 use App\Models\AdminUser as Model;
 use App\Models\AdminRule;
+use App\Models\Business;
+use App\Models\Company;
 use Illuminate\Support\Facades\DB;
 /**
  * 系统用户
@@ -50,6 +52,38 @@ class AdminUser extends Auth{
 			if (in_array($value['uid'],explode(',',config('administrator')))) $group[] = '超管';
 			// 切成字符串
 			$value['title']		= implode('、', $group);
+            //获取用户角色
+            $rule               = DB::table('admin_rule')->where('admin_uid',$value['uid'])->first();
+            $rule_title         =   '';
+            if ($rule){
+                switch ($rule['menu_type']){
+                    case 1:
+                        $rule_title         =  '商户';
+                        break;
+                    case 2:
+                        $rule_title         =  '店铺';
+                        break;
+                }
+                if ($rule['menu_type'] == 1){
+                    if ($rule['data_type'] == 1){
+                        $rule_title     =   '商户普通员工';
+                    }elseif ($rule['data_type'] == 2){
+                        $rule_title     =   '商户代表';
+                    }
+                }elseif ($rule['menu_type'] == 2){
+                    if ($rule['data_type'] == 1){
+                        $rule_title     =   '店铺普通员工';
+                    }elseif ($rule['data_type'] == 2){
+                        $rule_title     =   '店铺推广员';
+                    }
+                }
+            }
+            $value['rule_title']    =   $rule_title;
+            $value['business_name']         =   '';
+            if ($value['business_id']){
+                $value['business_name']      =  Business::query()->where('id', $value['business_id'])->value('name');
+            }
+            $value['company_name']      =   Company::query()->where('id', $value['company_id'])->value('name');
 			// 重组
 			$list[$key]			= $value;
 		}
@@ -65,6 +99,8 @@ class AdminUser extends Auth{
 	 * 
 	 * */
 	public function add(Request $request,Model $Model,AdminRule $AdminRule){
+        // 当前登录用户角色数据
+        $session							= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
@@ -76,8 +112,6 @@ class AdminUser extends Auth{
             $dataType		        			= request('data_type',1);
 			// 角色数据
             $ruleData               			= ['menu_type'=>1,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
-			// 当前登录用户角色数据
-            $session							= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
 			// 修改数据
 			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
 			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
@@ -130,7 +164,7 @@ class AdminUser extends Auth{
 		$whereGroup = [];
 		// 如果不是超管 查询当前用户所属组
 		$administrator = explode(',', config('administrator'));
-		if(!in_array(admin('uid'),$administrator)){
+		/*if(!in_array(admin('uid'),$administrator)){
 		    //用户所属组
 			$gsGroup = DB::table('auth_group_access')->where(['user_uid'=>admin('uid')])->pluck('group_id')->toArray();
 			//用户所属组 上级
@@ -139,10 +173,17 @@ class AdminUser extends Auth{
 			$groupLower = DB::table('auth_group')->whereIn('group_pid',$gsGroup)->pluck('id')->toArray();
 			//var_dump($groupLower);
 		    $whereGroup = array_merge($upGroup,$gsGroup,$groupLower);
-		}
+		}*/
+        $where  =   [];
+        if(!in_array(admin('uid'),$administrator)){
+            if($session && $session['menu_type'] ) 		    $where['menu_type'] = $session['menu_type'];
+            if($session && $session['company_id'] ) 		$where['company_id'] = $session['company_id'];
+            if($session && $session['business_id'] ) 		$where['business_id'] = $session['business_id'];
+            $where['type']       = 1;
+        }
 		// 查询用户组
 	    $query 						= DB::table('auth_group');
-	    if($whereGroup) 			$query->whereIn('id',$whereGroup);
+	    if($where) 			        $query->where($where);
 		$group						= $query->whereNotIn('id',explode(',',config('CUSTOM_GROUP')))->select(['id','title'])->get()->toArray();
 		// 错误告知
 		if( !$group )				$this->error('请先添加用户组');
@@ -161,7 +202,13 @@ class AdminUser extends Auth{
 		// 接收参数
 		$uid									= request('uid',0);
 		// 查询用户
-		$oldData								= $Model->where(['uid'=>$uid])->first();
+		$oldData								= $Model
+                    ->join('admin_rule','admin_rule.admin_uid','=','admin.uid')
+                    ->where(['uid'=>$uid])
+                    ->select('admin.*','admin_rule.data_type','admin_rule.menu_type')
+                    ->first();
+        // 当前登录用户角色数据
+        $session							    = session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
 		if(request()->isMethod('post')){
 			// 验证参数
 			$request->scene('edit')->validate();
@@ -173,8 +220,6 @@ class AdminUser extends Auth{
             $ruleData               			= $AdminRule::query()->where([['admin_uid','=',$uid]])->first(['id','admin_uid','menu_type','data_type','type','company_id','business_id']);
 			// 如果不存在的话
 			$ruleData							= $ruleData ? $ruleData->toArray() : ['admin_uid'=>$uid,'menu_type'=>1,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
-			// 当前登录用户角色数据
-			$session							= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
 			// 修改数据
 			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
 			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
@@ -234,10 +279,10 @@ class AdminUser extends Auth{
 			// 告知结果
 			return					json_send(['code'=>'success','msg'=>'修改成功','action'=>'edit']);
 		}
-		$whereGroup = [];
+		//$whereGroup = [];
 		// 如果不是超管 查询当前用户所属组
 		$administrator = explode(',', config('administrator'));
-		if(!in_array(admin('uid'),$administrator)){
+		/*if(!in_array(admin('uid'),$administrator)){
 		    // 用户所属组
 			$gsGroup				= DB::table('auth_group_access')->where(['user_uid'=>admin('uid')])->pluck('group_id')->toArray();
 			// 用户所属组 上级
@@ -246,11 +291,17 @@ class AdminUser extends Auth{
 			$groupLower				= DB::table('auth_group')->whereIn('group_pid',$gsGroup)->pluck('id')->toArray();
 			// 下属组
 		    $whereGroup				= array_merge($upGroup,$gsGroup,$groupLower);
-		}
-		// 查询用户组
-	    $query 						= DB::table('auth_group');
-		// 查询组
-	    if($whereGroup)  			$query->whereIn('id',$whereGroup);
+		}*/
+        $where  =   [];
+        if(!in_array(admin('uid'),$administrator)){
+            if($session && $session['menu_type'] ) 		    $where['menu_type'] = $session['menu_type'];
+            if($session && $session['company_id'] ) 		$where['company_id'] = $session['company_id'];
+            if($session && $session['business_id'] ) 		$where['business_id'] = $session['business_id'];
+            $where['type']       = 1;
+        }
+        // 查询用户组
+        $query 						= DB::table('auth_group');
+        if($where) 			        $query->where($where);
 		// 获取
 		$group						= $query->whereNotIn('id',explode(',',config('CUSTOM_GROUP')))->select(['id','title'])->get()->toArray();
 		// 错误告知

+ 17 - 5
app/Http/Controllers/Admin/AuthManager.php

@@ -1,6 +1,7 @@
 <?php namespace App\Http\Controllers\Admin;
 
 use App\Http\Requests\Admin\AuthManager as Request;
+use App\Models\Business;
 use Illuminate\Support\Facades\DB;
 
 /**
@@ -29,17 +30,28 @@ class AuthManager extends Auth{
         $mp                     =   [];
         $session                = session('userRule');
         if ($session){
-            $mp['company_id']	= $session['company_id'];
-            $mp['menu_type']    = $session['menu_type'];
+            $mp['auth_group.company_id']	= $session['company_id'];
+            $mp['auth_group.menu_type']    = $session['menu_type'];
             if ($session['business_id']){
-                $mp['business_id']       = $session['business_id'];
+                $mp['auth_group.business_id']       = $session['business_id'];
             }
         }
         if(!in_array(admin('uid'), explode(',', config('administrator')))){
-            $mp['type']       = 1;
+            $mp['auth_group.type']       = 1;
         }
   		// 查询列表数据
-     	$list = DB::table('auth_group')->where($mp)->select()->paginate(config('page_num',10))->appends(request()->all());
+     	$list = DB::table('auth_group')
+            ->join('company', 'company.id', '=', 'auth_group.company_id')
+            ->where($mp)
+            ->select('auth_group.*', 'company.name as company_name')
+            ->paginate(config('page_num',10))->appends(request()->all());
+        foreach($list as $k=>$v){
+            $v['business_name']         =   '';
+            if ($v['business_id']){
+                $v['business_name']      =  Business::query()->where('id', $v['business_id'])->value('name');
+            }
+            $list[$k] = $v;
+        }
 		// 分配数据
 		$this->assign('list',$list);
 		// 加载模板

+ 63 - 39
app/Http/Controllers/Admin/Business.php

@@ -6,6 +6,8 @@ use App\Models\AdminUser;
 use App\Models\City;
 use App\Models\AuthRule;
 use App\Models\AdminRule;
+use App\Models\Company;
+use App\Models\AdminHistory;
 use Illuminate\Support\Carbon;
 use Illuminate\Support\Facades\DB;
 
@@ -27,7 +29,7 @@ class Business extends Auth{
 	 * 列表页
 	 * 
 	 * */
-    public function index(Model $Model,City $City,AdminUser $AdminUser){
+    public function index(Model $Model,City $City){
  		// 接受参数
 		$code					= request('business_code','');
 		$phone					= request('phone','');
@@ -38,29 +40,52 @@ class Business extends Auth{
 		// 查询条件
 		$map 					= [];
 		// 编码ID
-		if( $id )				$map[] = ['id','=',$id];
-		if( $phone )			$map[] = ['phone','=',$phone];
-		if( $startTime )		$map[] = ['insert_time','>=',Carbon::createFromFormat('Y-m-d',$startTime)->startOfDay()->getTimestamp()];
-		if( $startTime )		$map[] = ['insert_time','<=',Carbon::createFromFormat('Y-m-d',$startTime)->endOfDay()->getTimestamp()];
-		if( !is_null($status) )	$map[] = ['status','=',$status];
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $map[] = ['leader_uid','=',$session['admin_uid']];
+		if( $id )				$map[] = ['business.id','=',$id];
+		if( $phone )			$map[] = ['business.phone','=',$phone];
+		if( $startTime )		$map[] = ['business.insert_time','>=',Carbon::createFromFormat('Y-m-d',$startTime)->startOfDay()->getTimestamp()];
+		if( $startTime )		$map[] = ['business.insert_time','<=',Carbon::createFromFormat('Y-m-d',$startTime)->endOfDay()->getTimestamp()];
+		if( !is_null($status) )	$map[] = ['business.status','=',$status];
+        if(!in_array(admin('uid'), explode(',', config('administrator')))){
+            $session				= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>1,'business_id'=>0];
+            if ($session){
+                $map[] = ['company_id','=',$session['company_id']];
+                if ($session['business_id']){
+                    $map[] = ['business.id','=',$session['business_id']];
+                }
+                if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                    $map[] = ['business.leader_uid','=',$session['admin_uid']];
+                }
             }
         }
 		// 查询数据
-		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
+		$list					= $Model->query()
+            ->join('company','company.id','=','business.company_id')
+            ->join('admin','admin.uid','=','business.admin_uid')
+            ->where($map)
+            ->orderByDesc('business.id')
+            ->select('business.*','company.name as company_name', 'admin.username as username','admin.phone as admin_phone')
+            ->paginate(config('page_num',10));
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// id转编号
 			$value['business_code'] = $Model->idToCode($value['id']);
-            // id转编号
-			$value['leader_name']   = $AdminUser->getOne($value['leader_uid'],'username');
+            $value['logopic']		= $value['logopic'] ? path_compat($value['logopic']) : '';
+            $addHistory             = AdminHistory::query()
+                ->join('admin','admin.uid','=','admin_history.admin_uid')
+                ->where(['admin_history.primary_id'=>$value['id'],'admin_history.notes_type'=>1,'admin_history.table_name'=>$Model->getTable()])
+                ->select('admin_history.insert_time','admin.username as username')
+                ->first();
+            $editHistory            = AdminHistory::query()
+                ->join('admin','admin.uid','=','admin_history.admin_uid')
+                ->where(['admin_history.primary_id'=>$value['id'],'admin_history.notes_type'=>2,'admin_history.table_name'=>$Model->getTable()])
+                ->select('admin_history.update_time','admin.username as username')
+                ->orderByDesc('id')->first();
+            $value['add_history_username']  = $addHistory   ? $addHistory->username : '';
+            $value['add_history_time']      = $addHistory   ? $addHistory->insert_time : 0;
+            $value['edit_history_username'] = $editHistory  ? $editHistory->username : '';
+            $value['edit_history_time']     = $editHistory  ? $editHistory->update_time : 0;
+            $leader                         =   AdminUser::query()->where('uid',$value['leader_uid'])->first();
+            $value['leader_username']        = $leader ? $leader->username : '';
 			// 重组
 			$list[$key]			= $value;
             if( $value['city_ids'] ) {
@@ -89,29 +114,28 @@ class Business extends Auth{
 	 * 
 	 * */
 	public function add(Request $request,Model $Model,City $City,AdminUser $AdminUser,AdminRule $AdminRule){
+        $session				= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
 			// 接收数据
-			$data['name']			            = request('name','');
-			$data['phone']			            = request('phone','');
-			$data['logopic']		            = request('logopic','');
-			$data['desc']			            = request('desc','');
-			$data['leader_uid']		            = request('leader_uid','');
-            $data['address']		            = request('address','');
-            $data['city_ids']		            = request('city_ids','');
-            $data['city_ids']		            = implode(',',$data['city_ids']);
-			$custom_name		                = request('custom_name','');
-			$phone		                        = request('phone','');
-			$custom_password		            = request('custom_password','');
-            // 角色数据
-            $ruleData               			= ['menu_type'=>2,'company_id'=>1,'business_id'=>0];
-			// 当前登录用户角色数据
-            $session							= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
-			// 修改数据
-			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
-			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
-
+			$data['name']			= request('name','');
+			$data['phone']			= request('phone','');
+			$data['logopic']		= request('logopic','');
+			$data['desc']			= request('desc','');
+			$data['leader_uid']		= request('leader_uid','');
+            $data['address']		= request('address','');
+            $data['city_ids']		= request('city_ids','');
+            if ($data['city_ids']){
+                $data['city_ids']		= implode(',',$data['city_ids']);
+            }
+			$custom_name		    = request('custom_name','');
+			$phone		            = request('phone','');
+			$custom_password		= request('custom_password','');
+            if ($session['company_id']){
+                $data['company_id']	        = $session['company_id'];
+                $ruleData['company_id']     = $session['company_id'];
+            }
             $userData['username']		= $custom_name;
             $userData['phone']			= $phone;
             $userData['password']		= md5($custom_password);
@@ -133,7 +157,8 @@ class Business extends Auth{
                     return json_send(['code'=>'error','msg'=>'新增管理员失败']);
                 }
                 $ruleData['admin_uid']      =   $uid;
-                $ruleData['business_id']    =   $id;
+                $ruleData['business_id']        =   $id;
+                $ruleData['menu_type']      =   2;
                 // 写入数据表
                 $ruleUid					=   $AdminRule->add($ruleData);
                 // 如果操作失败
@@ -173,7 +198,6 @@ class Business extends Auth{
 		}
         // 获取列表
         $cityList					= $City->getCityList();
-        $session                    = session('userRule');
         $mp                         =   [];
         if ($session){
             $mp[]                   =   ['admin_rule.company_id','=',$session['company_id']];
@@ -253,7 +277,7 @@ class Business extends Auth{
         $oldData['city_ids']			= explode(',',$oldData['city_ids']);
         // 获取列表
         $cityList					= $City->getCityList();
-        $session                    = session('userRule');
+        $session				= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
         $mp                         =   [];
         if ($session){
             $mp[]                   =   ['admin_rule.company_id','=',$session['company_id']];

+ 23 - 3
app/Http/Controllers/Admin/Coupon.php

@@ -1,6 +1,7 @@
 <?php namespace App\Http\Controllers\Admin;
 
 use App\Http\Requests\Admin\Coupon as Request;
+use App\Models\Business;
 use App\Models\Coupon as Model;
 use App\Models\CouponRebate;
 use App\Models\CustomCoupon;
@@ -41,14 +42,27 @@ class Coupon extends Auth{
 		if( $startTime )		$map[] = ['start_time','>=',strtotime($startTime)];
 		if( $endTime )			$map[] = ['end_time','<=',strtotime($endTime)];
 		if( !is_null($status) )	$map[] = ['status','=',$status];
+        $session                = session('userRule');
+        if ($session){
+            $map[] = ['company_id','=',$session['company_id']];
+            if ($session['business_id']){
+                $map[] = ['business_id','=',$session['business_id']];
+            }
+            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
+            }
+        }
 		// 查询数据
-		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(request('limit',config('page_num',10)))->appends(request()->all());
+		$list					= $Model->query()->where($map);
+        if (isset($shopIds))    $list->whereIn('business_id',$shopIds);
+        $list                   =  $list->orderByDesc('id')->paginate(request('limit',config('page_num',10)))->appends(request()->all());
 		// 计算各个优惠券的数量
 		$customTotal			= $CustomCoupon->whereIn('coupon_id',array_column($list->toArray()['data'],'id'))->groupBy('coupon_id')->select([DB::raw('count(*) as total'),'coupon_id'])->pluck('total','coupon_id')->toArray();
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// id转编号
 			$value['coupon_code']= $Model->idToCode($value['id']);
+			$value['business_name']= Business::query()->where('id',$value['business_id'])->value('name');
 			// 发放类型
 			$value['gant_name']  = $Model->getGrantType($value['grant_type'],'name');
 			// 如果已经到了结束时间。活动结束
@@ -93,7 +107,7 @@ class Coupon extends Auth{
 	 * 添加
 	 * 
 	 * */
-	public function add( Request $request, Model $Model,City $City,CouponRebate $CouponRebate,Product $Product){
+	public function add( Request $request, Model $Model,City $City,CouponRebate $CouponRebate,Product $Product,Business $Business){
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
@@ -108,6 +122,7 @@ class Coupon extends Auth{
 			$data['type_id']		= request('type_id',1);
 			$data['grant_type']		= request('grant_type',1);
 			$data['status']			= request('status',2);
+            $data['business_id']	= request('business_id',0);
 			$cityIds				= request('city_ids',[]);
 			$data['city_ids']		= implode(',',$cityIds);
 			// 转换时间,默认现在现在生效
@@ -174,9 +189,11 @@ class Coupon extends Auth{
 		// 获取列表
 		$cityList					= $City->getCityList();
 		$grantList					= $Model->getGrantTypeList();
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
 		$this->assign('grantList',$grantList);
+		$this->assign('businessList',$businessList);
 		$this->assign('crumbs','新增');
 		// 加载模板
 		return 						$this->fetch();
@@ -186,7 +203,7 @@ class Coupon extends Auth{
 	 * 编辑
 	 * 
 	 * */
-	public function edit( Request $request, Model $Model,City $City,CouponRebate $CouponRebate,Product $Product){
+	public function edit( Request $request, Model $Model,City $City,CouponRebate $CouponRebate,Product $Product,Business $Business){
 		// 接收参数
 		$id							= request('id',0);
 		// 查询数据
@@ -205,6 +222,7 @@ class Coupon extends Auth{
 			$data['end_time'] 		= request('end_time','');
 			$data['type_id']		= request('type_id',1);
 			$data['grant_type']		= request('grant_type',1);
+			$data['business_id']	= request('business_id',1);
 			$cityIds				= request('city_ids',[]);
 			$data['city_ids']		= implode(',',$cityIds);
 			// 转换时间,默认现在现在生效
@@ -288,9 +306,11 @@ class Coupon extends Auth{
 		// 获取列表
 		$cityList					= $City->getCityList();
 		$grantList					= $Model->getGrantTypeList();
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
 		$this->assign('grantList',$grantList);
+		$this->assign('businessList',$businessList);
 		$this->assign('oldData',$oldData);
 		$this->assign('crumbs','修改');
 		// 加载模板

+ 27 - 3
app/Http/Controllers/Admin/CouponActive.php

@@ -2,6 +2,7 @@
 
 use App\Facades\Servers\WechatMini\Mini;
 use App\Http\Requests\Admin\Coupon\Active as Request;
+use App\Models\Business;
 use App\Models\Coupon\Active as Model;
 use App\Models\Coupon\ActiveCoupon as ActiveCoupon;
 use App\Models\City;
@@ -33,12 +34,25 @@ class CouponActive extends Auth{
 		$map 					= [];
 		// 组合条件
 		if( $name )				$map[] = ['name','=',$name];
+        $session                = session('userRule');
+        if ($session){
+            $map[] = ['company_id','=',$session['company_id']];
+            if ($session['business_id']){
+                $map[] = ['business_id','=',$session['business_id']];
+            }
+            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
+            }
+        }
 		// 查询数据
-		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
+		$list					= $Model->query()->where($map);
+        if (isset($shopIds))    $list->whereIn('business_id',$shopIds);
+        $list					= $list->orderByDesc('id')->paginate(config('page_num',10));
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// 小程序链接
 			$value['mp_urllink']= $this->getUrlLink($value['id']);
+            $value['business_name']	= Business::query()->where([['id','=',$value['business_id']]])->value('name');
 			// 重组
 			$list[$key]			= $value;
 		}
@@ -124,7 +138,7 @@ class CouponActive extends Auth{
 	 * 添加
 	 * 
 	 * */
-	public function add(Request $request,Model $Model,City $City,WeiBanTags $WeiBanTags){
+	public function add(Request $request,Model $Model,City $City,WeiBanTags $WeiBanTags,Business $Business){
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
@@ -141,6 +155,11 @@ class CouponActive extends Auth{
 			$data['city_ids']		= implode(',',$cityIds);
 			$data['tag_scope']		= implode(',',$tagScope);
 			$data['status']			= 1;
+            $data['business_id']	= request('business_id',0);
+            $session                = session('userRule');
+            if ($session){
+                $data['company_id'] = $session['company_id'];
+            }
 			// 写入数据表
 			$id						= $Model->add($data);
 			// 如果操作失败
@@ -152,6 +171,7 @@ class CouponActive extends Auth{
 		}
 		// 获取列表
 		$cityList					= $City->getCityList();
+        $businessList 			    = $Business->getList();
 		// 标签列表
 		$tagData					= $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
 		// 标签列表
@@ -163,6 +183,7 @@ class CouponActive extends Auth{
 		// 分配数据
 		$this->assign('cityList',$cityList);
 		$this->assign('tagList',$tagList);
+        $this->assign('businessList',$businessList);
 		$this->assign('crumbs','新增');
 		// 加载模板
 		return						$this->fetch(); 
@@ -172,7 +193,7 @@ class CouponActive extends Auth{
 	 * 修改
 	 * 
 	 * */
-	public function edit(Request $request,Model $Model,City $City,WeiBanTags $WeiBanTags){
+	public function edit(Request $request,Model $Model,City $City,WeiBanTags $WeiBanTags,Business $Business){
 		// 接收参数
 		$id							= request('id',0);
 		// 查询用户
@@ -193,6 +214,7 @@ class CouponActive extends Auth{
 			$tagScope				= request('tag_scope',[]);
 			$data['city_ids']		= implode(',',$cityIds);
 			$data['tag_scope']		= implode(',',$tagScope);
+            $data['business_id']	= request('business_id',0);
 			// 写入数据表
 			$result					= $Model->edit($id,$data);
 			// 如果操作失败
@@ -217,8 +239,10 @@ class CouponActive extends Auth{
 		foreach ($tagData as $value) {
 			$tagList[$value['group']][] = $value['name'];
 		}
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
+        $this->assign('businessList',$businessList);
 		$this->assign('tagList',$tagList);
 		$this->assign('oldData',$oldData);
 		$this->assign('crumbs','修改');

+ 31 - 4
app/Http/Controllers/Admin/CouponRewardRule.php

@@ -1,6 +1,7 @@
 <?php namespace App\Http\Controllers\Admin;
 
 use App\Http\Requests\Admin\CouponRewardRule as Request;
+use App\Models\Business;
 use App\Models\Coupon;
 use App\Models\CouponRewardRule as Model;
 use App\Models\Custom;
@@ -24,15 +25,28 @@ class CouponRewardRule extends Auth{
 	 * 列表页
 	 * 
 	 * */
-    public function index(Model $Model,Coupon $Coupon){
+    public function index(Model $Model,Coupon $Coupon,Business $Business){
 		// 查询条件
 		$map 					= [];
+        $session                = session('userRule');
+        if ($session){
+            $map[] = ['company_id','=',$session['company_id']];
+            if ($session['business_id']){
+                $map[] = ['business_id','=',$session['business_id']];
+            }
+            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
+            }
+        }
 		// 查询数据
-		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
+		$list					= $Model->query()->where($map);
+        if (isset($shopIds))    $list->whereIn('business_id',$shopIds);
+        $list                   = $list->orderByDesc('id')->paginate(config('page_num',10));
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// 优惠券名称
 			$value['coupon_name']	= $Coupon->query()->where([['id','=',$value['coupon_id']]])->value('name');
+			$value['business_name']	= Business::query()->where([['id','=',$value['business_id']]])->value('name');
 			// 重组
 			$list[$key]			= $value;
 		}
@@ -47,7 +61,7 @@ class CouponRewardRule extends Auth{
 	 * 添加
 	 * 
 	 * */
-	public function add(Request $request,Model $Model,Coupon $Coupon,Custom $Custom,City $City){
+	public function add(Request $request,Model $Model,Coupon $Coupon,Custom $Custom,City $City,Business $Business){
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
@@ -61,9 +75,17 @@ class CouponRewardRule extends Auth{
 			$data['start_time']		= $data['start_time'] ? strtotime($data['start_time']) : 0;
 			$data['end_time']		= $data['end_time'] ? strtotime($data['end_time']) : 0;
 			$data['status']			= 1;
+            $data['business_id']	= request('business_id',0);
+            $session                = session('userRule');
+            if ($session){
+                $data['company_id'] = $session['company_id'];
+            }
 			$cityIds				= request('city_ids',[]);
 			$data['city_ids']		= implode(',',$cityIds);
 			$removeCustom			= request('remove_custom','');
+            //店铺优惠卷是否存在
+            $res                    = $Coupon::query()->where(['id'=>$data['coupon_id'],'business_id'=>$data['business_id']])->first();
+            if (!$res)              return json_send(['code'=>'error','msg'=>'新增失败,店铺优惠卷编码错误']);
 			// 循环处理
 			if( $removeCustom )		{
 				// 兼容逗号问题
@@ -97,8 +119,10 @@ class CouponRewardRule extends Auth{
 		}
 		// 获取列表
 		$cityList					= $City->getCityList();
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
+        $this->assign('businessList',$businessList);
 		$this->assign('crumbs','新增');
 		// 加载模板
 		return						$this->fetch(); 
@@ -108,7 +132,7 @@ class CouponRewardRule extends Auth{
 	 * 修改
 	 * 
 	 * */
-	public function edit(Request $request,Model $Model,Coupon $Coupon,Custom $Custom,City $City){
+	public function edit(Request $request,Model $Model,Coupon $Coupon,Custom $Custom,City $City,Business $Business){
 		// 接收参数
 		$id							= request('id',0);
 		// 查询用户
@@ -126,6 +150,7 @@ class CouponRewardRule extends Auth{
 			$data['end_time']		= request('end_time','');
 			$data['start_time']		= $data['start_time'] ? strtotime($data['start_time']) : 0;
 			$data['end_time']		= $data['end_time'] ? strtotime($data['end_time']) : 0;
+            $data['business_id']	= request('business_id',0);
 			$cityIds				= request('city_ids',[]);
 			$data['city_ids']		= implode(',',$cityIds);
 			$removeCustom			= request('remove_custom','');
@@ -180,8 +205,10 @@ class CouponRewardRule extends Auth{
 		$oldData['city_ids']		= explode(',',$oldData['city_ids']);
 		// 获取列表
 		$cityList					= $City->getCityList();
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
+        $this->assign('businessList',$businessList);
 		$this->assign('oldData',$oldData);
 		$this->assign('crumbs','修改');
 		// 加载模板

+ 15 - 2
app/Http/Controllers/Admin/CustomCoupon.php

@@ -1,5 +1,6 @@
 <?php namespace App\Http\Controllers\Admin;
 
+use App\Models\Business;
 use App\Models\Custom;
 use App\Models\CustomCoupon as Model;
 use App\Models\Coupon as Coupon;
@@ -42,10 +43,21 @@ class CustomCoupon extends Auth{
 		if( $startTime )		$map[] = ['custom_coupon.insert_time','>=',strtotime($startTime)];
 		if( $endTime )			$map[] = ['custom_coupon.insert_time','<=',strtotime($endTime)];
 		if( !is_null($status) )	$map[] = ['custom_coupon.status','=',$status];
+        $session                = session('userRule');
+        if ($session){
+            $map[] = ['coupon.company_id','=',$session['company_id']];
+            if ($session['business_id']){
+                $map[] = ['coupon.business_id','=',$session['business_id']];
+            }
+            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
+            }
+        }
 		// 查询数据
 		$list					= $Model
-								->query()->join('coupon','custom_coupon.coupon_id','=','coupon.id')
-								->where($map)
+								->query()->join('coupon','custom_coupon.coupon_id','=','coupon.id');
+        if (isset($shopIds))    $list->whereIn('coupon.business_id',$shopIds);
+        $list                   =   $list->where($map)
 								->orderBy('custom_coupon.status')
 								->orderByDesc('custom_coupon.id')
 								->select(['custom_coupon.*','coupon.name as coupon_name','coupon.type_id','coupon.rebate_type','coupon.std_pay','coupon.rebate','custom_coupon.exp_time'])
@@ -61,6 +73,7 @@ class CustomCoupon extends Auth{
 			$value['custom_name'] = $Custom->getValue($value['custom_uid'],'username');
 			// id转编号
 			$value['admin_name']  = $AdminUser->getOne($value['admin_uid'],'username');
+            $value['business_name']= Business::query()->where('id',$value['business_id'])->value('name');
 			// 如果过期时间
 			if( $value['status'] == 0 && $value['exp_time'] <= time() ) {
 				// 状态设置

+ 37 - 40
app/Http/Controllers/Admin/Login.php

@@ -7,55 +7,52 @@ use Illuminate\Support\Facades\DB;
 
 /**
  * 管理后台登录控制器
- * 
+ *
  * @author 刘相欣
- * 
+ *
  * */
 class Login extends Admin {
 
 	/**
 	 * 登录方法
-	 * 
+	 *
 	 * */
-	public function index(AdminUser $AdminUser,AdminRule $AdminRule){
-		if( request()->isMethod('post') ){
-			// 接收数据
-			$username						= request('username','');
-			// 接收数据
-			$code							= request('code','');
-			// 验证
-			if( !$username || !$code )		return json_send(['code'=>'error','msg'=>'用户名验证码必填']);
-			// 查询用户
-			$admin							= $AdminUser->orWhere('username',$username)->orWhere('phone',$username)->first(['uid','username','phone','status','password','insert_time','update_time']);
-			// 用户不存在
-			if( !$admin ) 					return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
-			// 用户不存在
-			if( $admin['status'] ) 			return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
-			// 获取数据
-			$adminRule						= $AdminRule::query()->where('admin_uid',$admin['uid'])->first();
-			// 用户不存在
-			if( !$admin || $admin['status'] ) return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
-			// 比对密码
-			if( md5($code) != $admin['password'] ) return json_send(['code'=>'error','msg'=>'密码错误或账号不存在']);
-			// 查询用户的组别
-			$group							= DB::table('auth_group_access')->where(['user_uid'=>$admin['uid']])->pluck('group_id')->toArray();
-			// 权限小组
-			$admin['group_id']				= $group;
-			// 删除敏感数据-密码
-			unset($admin['password']);
-			// 存储登录状态
-			session(['userAuth'=>$admin]);
-			session(['userRule'=>$adminRule]);
-			// 表单令牌
-			return							json_send(['code'=>'success','msg'=>'登录成功','path'=>url('admin')]);
-		}
-		// 加载模板
-		return								$this->fetch();
-	}
+    public function index(AdminUser $AdminUser,AdminRule $AdminRule){
+        if( request()->isMethod('post') ){
+            // 接收数据
+            $username						= request('username','');
+            // 接收数据
+            $code							= request('code','');
+            // 验证
+            if( !$username || !$code )		return json_send(['code'=>'error','msg'=>'用户名验证码必填']);
+            // 查询用户
+            $admin							= $AdminUser->orWhere('username',$username)->orWhere('phone',$username)->first(['uid','username','phone','status','password','insert_time','update_time']);
+            // 用户不存在
+            if( !$admin || $admin['status'] ) return json_send(['code'=>'error','msg'=>'用户名不存在或已被停用']);
+            // 比对密码
+            if( md5($code) != $admin['password'] ) return json_send(['code'=>'error','msg'=>'密码错误或账号不存在']);
+            $admin                          =   $admin->toArray();
+            // 获取数据
+            $adminRule						= $AdminRule::query()->where('admin_uid',$admin['uid'])->first();
+            // 查询用户的组别
+            $group							= DB::table('auth_group_access')->where(['user_uid'=>$admin['uid']])->pluck('group_id')->toArray();
+            // 权限小组
+            $admin['group_id']				= $group;
+            // 删除敏感数据-密码
+            unset($admin['password']);
+            // 存储登录状态
+            session(['userAuth'=>$admin]);
+            session(['userRule'=>$adminRule]);
+            // 表单令牌
+            return							json_send(['code'=>'success','msg'=>'登录成功','path'=>url('admin')]);
+        }
+        // 加载模板
+        return								$this->fetch();
+    }
 
 	/**
 	 * 退出登录方法
-	 * 
+	 *
 	 * */
 	public function out(){
 		// 清除
@@ -66,7 +63,7 @@ class Login extends Admin {
 
 	/**
 	 * 发送验证码
-	 * 
+	 *
 	 * */
 	public function send_code(Sms $Sms){
 		if( request()->isMethod('post') ){

+ 6 - 6
app/Http/Controllers/Admin/Product.php

@@ -267,7 +267,7 @@ class Product extends Auth{
 			// 限购提示
 			if( $data['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) 	return json_send(['code'=>'error','msg'=>'限购必填限购时间','data'=>['error'=>'限购必填限购时间']]);
 			// 限购提示
-			if( $data['min_quota'] > $data['quota'] ) 	return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
+			if( $data['quota'] && $data['min_quota'] > $data['quota'] ) 	return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
 			// SKU存在的时候,判断限购数量
 			if( $skuList )			{
 				// 循环处理
@@ -275,7 +275,7 @@ class Product extends Auth{
 					// SKU限购,所以限购时间也必须填
 					if( $value['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'SKU限购时,请填限购时间','data'=>['error'=>'SKU限购时,请填限购时间']]);
 					// 限购提示
-					if( $value['min_quota'] > $value['quota'] ) 	return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
+					if(  $value['quota'] && $value['min_quota'] > $value['quota'] ) 	return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
 					// 提示起购数量异常,如果总起购数量小于SKU起购数量,提示
 					if( $value['min_quota'] && $value['min_quota'] < $data['min_quota'] ) return json_send(['code'=>'error','msg'=>'SKU的起购数量不能小于总起购数量','data'=>['error'=>'SKU的起购数量不能小于总起购数量']]);
 				}
@@ -495,7 +495,7 @@ class Product extends Auth{
 			// 限购提示
 			if( $data['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) 	return json_send(['code'=>'error','msg'=>'限购必填限购时间','data'=>['error'=>'限购必填限购时间']]);
 			// 限购提示
-			if( $data['min_quota'] > $data['quota'] ) 	return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
+			if( $data['quota'] && $data['min_quota'] > $data['quota'] ) 	return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
 			// SKU存在的时候,判断限购数量
 			if( $skuList )			{
 				// 循环处理
@@ -503,7 +503,7 @@ class Product extends Auth{
 					// SKU限购,所以限购时间也必须填
 					if( $value['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) 	return json_send(['code'=>'error','msg'=>'SKU限购时,请填限购时间','data'=>['error'=>'SKU限购时,请填限购时间']]);
 					// 限购提示
-					if( $value['min_quota'] > $value['quota'] ) 	return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
+					if(  $value['quota'] && $value['min_quota'] > $value['quota'] ) 	return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
 					// 提示起购数量异常,如果总起购数量小于SKU起购数量,提示
 					if( $value['min_quota'] && $value['min_quota'] < $data['min_quota'] ) 	return json_send(['code'=>'error','msg'=>'SKU的起购数量不能小于总起购数量','data'=>['error'=>'SKU的起购数量不能小于总起购数量']]);
 				}
@@ -745,7 +745,7 @@ class Product extends Auth{
 			// 限购提示
 			if( $data['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) 	return json_send(['code'=>'error','msg'=>'限购必填限购时间','data'=>['error'=>'限购必填限购时间']]);
 			// 限购提示
-			if( $data['min_quota'] > $data['quota'] ) 	return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
+			if($data['quota'] && $data['min_quota'] > $data['quota'] ) 	return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
 			// 总库存
 			if( $skuList )			$data['stock'] = array_sum(array_column($skuList,'stock'));
 			// SKU存在的时候,判断限购数量
@@ -755,7 +755,7 @@ class Product extends Auth{
 					// SKU限购,所以限购时间也必须填
 					if( $value['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) 	return json_send(['code'=>'error','msg'=>'SKU限购时,请填限购时间','data'=>['error'=>'SKU限购时,请填限购时间']]);
 					// 限购提示
-					if( $value['min_quota'] > $value['quota'] ) 	return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
+					if(  $value['quota'] && $value['min_quota'] > $value['quota'] ) 	return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
 					// 提示起购数量异常,如果总起购数量小于SKU起购数量,提示
 					if( $value['min_quota'] && $value['min_quota'] < $data['min_quota'] ) 	return json_send(['code'=>'error','msg'=>'SKU的起购数量不能小于总起购数量','data'=>['error'=>'SKU的起购数量不能小于总起购数量']]);
 				}

+ 27 - 3
app/Http/Controllers/Admin/Promo.php

@@ -1,6 +1,7 @@
 <?php namespace App\Http\Controllers\Admin;
 
 use App\Http\Requests\Admin\Promo as Request;
+use App\Models\Business;
 use App\Models\Promo as Model;
 use App\Models\PromoRebate;
 use App\Models\Product;
@@ -43,8 +44,20 @@ class Promo extends Auth{
 		if( $startTime )		$map[] = ['start_time','>=',strtotime($startTime)];
 		if( $endTime )			$map[] = ['end_time','<=',strtotime($endTime)];
 		if( !is_null($status) )	$map[] = ['status','=',$status];
+        $session                = session('userRule');
+        if ($session){
+            $map[] = ['company_id','=',$session['company_id']];
+            if ($session['business_id']){
+                $map[] = ['business_id','=',$session['business_id']];
+            }
+            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
+            }
+        }
 		// 查询数据
-		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(request('limit',config('page_num',10)))->appends(request()->all());
+		$list					= $Model->query()->where($map);
+        if (isset($shopIds))    $list->whereIn('business_id',$shopIds);
+        $list                   =    $list->orderByDesc('id')->paginate(request('limit',config('page_num',10)))->appends(request()->all());
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// id转编号
@@ -77,6 +90,7 @@ class Promo extends Auth{
 				// 返回结果
 				$value['rebate'] 	= (string) $PromoRebate->query()->join('product','promo_rebate.product_id','=','product.id')->where([['promo_id','=',$value['id']]])->value('product.name');
 			}
+            $value['business_name']	= Business::query()->where([['id','=',$value['business_id']]])->value('name');
 			// 重组
 			$list[$key]				= $value;
 		}
@@ -91,7 +105,7 @@ class Promo extends Auth{
 	 * 添加
 	 * 
 	 * */
-	public function add( Request $request, Model $Model,City $City,PromoRebate $PromoRebate,Product $Product,WeiBanTags $WeiBanTags){
+	public function add( Request $request, Model $Model,City $City,PromoRebate $PromoRebate,Product $Product,WeiBanTags $WeiBanTags,Business $Business){
 		if( request()->isMethod('post') ){
 			// 验证参数
 			$request->scene('add')->validate();
@@ -127,6 +141,11 @@ class Promo extends Auth{
 				// 设置为0,避免数据异常
 				$data['rebate']     = 0;
 			}
+            $data['business_id']	= request('business_id',0);
+            $session                = session('userRule');
+            if ($session){
+                $data['company_id'] = $session['company_id'];
+            }
 			// 组合数据,写入订单表,子表
 			DB::beginTransaction();
 			try {
@@ -174,10 +193,12 @@ class Promo extends Auth{
             $tagList[$value['group']][] = $value['name'];
         }
 		$grantList					= $Model->getGrantTypeList();
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
 		$this->assign('grantList',$grantList);
 		$this->assign('tagList',$tagList);
+        $this->assign('businessList',$businessList);
 		$this->assign('crumbs','新增');
 		// 加载模板
 		return 						$this->fetch();
@@ -187,7 +208,7 @@ class Promo extends Auth{
 	 * 编辑
 	 * 
 	 * */
-	public function edit( Request $request, Model $Model,City $City,PromoRebate $PromoRebate,Product $Product,WeiBanTags $WeiBanTags){
+	public function edit( Request $request, Model $Model,City $City,PromoRebate $PromoRebate,Product $Product,WeiBanTags $WeiBanTags,Business $Business){
 		// 接收参数
 		$id							= request('id',0);
 		// 查询数据
@@ -206,6 +227,7 @@ class Promo extends Auth{
             $data['type_id']		= request('type_id',1);
 			$cityIds				= request('city_ids',[]);
             $tagScope				= request('tag_scope',[]);
+            $data['business_id']	= request('business_id',0);
             $data['city_ids']		= implode(',',$cityIds);
             $data['tag_scope']		= implode(',',$tagScope);
 			// 转换时间,默认现在现在生效
@@ -293,11 +315,13 @@ class Promo extends Auth{
         foreach ($tagData as $value) {
             $tagList[$value['group']][] = $value['name'];
         }
+        $businessList 			    = $Business->getList();
 		// 分配数据
 		$this->assign('cityList',$cityList);
 		$this->assign('grantList',$grantList);
 		$this->assign('tagList',$tagList);
 		$this->assign('oldData',$oldData);
+        $this->assign('businessList',$businessList);
 		$this->assign('crumbs','修改');
 		// 加载模板
 		return 					$this->fetch();

+ 6 - 0
app/Http/Controllers/Admin/PromoProduct.php

@@ -76,6 +76,12 @@ class PromoProduct extends Auth{
 			$oldId					= $Model->query()->where([['promo_id','=',$data['promo_id']],['product_id','=',$data['product_id']]])->value('id');
 			// 重复提醒
 			if( $oldId ) 			return json_send(['code'=>'error','msg'=>'产品编码已存在']);
+            //查询产品店铺是否与活动一致
+            $productInfo            =   $Product->getOne($data['product_id']);
+            $promoInfo              =   $Promo->getOne($data['promo_id']);
+            if ($productInfo['business_id'] !== $promoInfo['business_id']) {
+                return json_send(['code'=>'error','msg'=>'产品所属店铺不一致']);
+            }
 			// 写入数据表
 			$id						= $Model->add($data);
 			// 如果操作失败

+ 162 - 0
app/Models/Company.php

@@ -0,0 +1,162 @@
+<?php namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 商业公司模型
+ * 
+ */
+class Company extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'company';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $id;
+    }
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function edit($id,$data)
+    {
+        // 更新时间
+        $data['update_time']                = time();
+        // 写入数据表
+        $result						        = $this->query()->where(['id'=>$id])->update($data);
+        // 如果操作失败
+        if( !$result )                      return $result;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $result;
+    }
+
+    /**
+     * 获取列表
+     * @param   Bool    $force  是否强制更新
+     * 
+     */
+    public function getList($force = false)
+    {
+        // 结果数据
+        //$list                  = $force ? [] : cache('admin:business:list');
+        $list                   =   [];
+        // 不存在数据
+        if ( !$list ) {
+            $session           = session('userRule');
+            $map                =   [];
+            $map[] = ['status','=',0];
+            if ($session){
+                $map[] = ['company_id','=',$session['company_id']];
+                if ($session['business_id']){
+                    $map[] = ['id','=',$session['business_id']];
+                }
+                if ($session['menu_type'] == 1 && $session['data_type'] == 2){
+                    $map[] = ['leader_uid','=',$session['admin_uid']];
+                }
+            }
+            // 从数据库获取数据
+            $data              = $this->query()->where($map)->get();
+            // 是否有数据
+            $data              = $data ? $data->toArray() : [];
+            // 循环处理数据
+            $list              = [];
+            // 进行更新
+            foreach ($data as $value) {
+                // 重组数据
+                $list[$value['id']] = $value;
+            }
+            // 存起来
+            cache(['admin:business:list'=>$list]);
+        }
+        // 返回结果
+        return                  $list;
+    }
+
+    /**
+     * 获取配置平台对应的应用数据
+     * 
+     * @param   Array      用户ID
+     * @param   String     指定字段
+     * 
+     */
+    public function getOne($id,$field='')
+    {
+        // 获取列表数据
+        $list                   = $this->getList();
+        // 获取数据
+        $one                    = isset($list[$id]) ? $list[$id] : [];
+        // 返回值
+        return                  empty($field) ? $one : ( isset($one[$field]) ? $one[$field] : null);
+    }
+
+
+    /**
+     * 获取配置平台对应的应用数据
+     * 
+     * @param   Array      用户ID
+     * @param   String     指定字段
+     * 
+     */
+    public function getIdByName($name)
+    {
+        // 获取列表数据
+        $list                               = $this->getList();
+        // 获取数据
+        foreach ($list as $value) {
+            // 如果有名称
+            if( $name == $value['name'] )   return $value['id'];
+        }
+        // 写入数据表
+        $id						            = $this->add(['name'=>$name]);
+        // 返回结果
+        return                              $id;
+    }
+
+
+    /**
+     * 编码转id
+     * 
+     * @param  string $code 编码
+     * 
+     */
+    public function codeToId($code){
+        return intval(str_ireplace('klsj','',$code));
+    }
+ 
+    /**
+     * id转编码
+     * 
+     * @param  int  $id 编码
+     * 
+     */
+    public function idToCode($id){
+         return 'klsj'. str_pad($id, 9, '0', STR_PAD_LEFT);
+    }
+
+}

+ 1 - 1
config/hashids.php

@@ -3,7 +3,7 @@
 /**
  * Copyright (c) Vincent Klaiber.
  *
- * For the full copyright and license information, please view the LICENSE
+ * For the full copyright and license information, please views the LICENSE
  * file that was distributed with this source code.
  *
  * @see https://github.com/vinkla/laravel-hashids

+ 1 - 1
config/view.php

@@ -9,7 +9,7 @@ return [
     |
     | Most templating systems load templates from disk. Here you may specify
     | an array of paths that should be checked for your views. Of course
-    | the usual Laravel view path has already been registered for you.
+    | the usual Laravel views path has already been registered for you.
     |
     */
 

+ 5 - 5
public/static/ueditor/dialogs/charts/charts.js

@@ -25,7 +25,7 @@ window.onload = function () {
     renderTable( editorTable );
     initEvent();
     initUserConfig( editorTable.getAttribute( "data-chart" ) );
-    $( "#scrollBed .view-box:eq("+ currentChartType +")" ).trigger( "click" );
+    $( "#scrollBed .views-box:eq("+ currentChartType +")" ).trigger( "click" );
     updateViewType( currentChartType );
 
     dialog.addListener( "resize", function () {
@@ -52,7 +52,7 @@ function initChartsTypeView () {
 
     for ( var i = 0, len = chartsConfig.length; i<len; i++ ) {
 
-        contents.push( '<div class="view-box" data-chart-type="'+ i +'"><img width="300" src="images/charts'+ i +'.png"></div>' );
+        contents.push( '<div class="views-box" data-chart-type="'+ i +'"><img width="300" src="images/charts'+ i +'.png"></div>' );
 
     }
 
@@ -127,7 +127,7 @@ function initEvent () {
     var cacheValue = null,
         //图表类型数
         typeViewCount = chartsConfig.length- 1,
-        $chartsTypeViewBox = $( '#scrollBed .view-box' );
+        $chartsTypeViewBox = $( '#scrollBed .views-box' );
 
     $( ".charts-format" ).delegate( ".format-ctrl", "change", function () {
 
@@ -135,7 +135,7 @@ function initEvent () {
 
     } )
 
-    $( ".table-view" ).delegate( ".data-item", "focus", function () {
+    $( ".table-views" ).delegate( ".data-item", "focus", function () {
 
         cacheValue = this.value;
 
@@ -172,7 +172,7 @@ function initEvent () {
     } );
 
     //图表类型变化
-    $( '#scrollBed' ).delegate( ".view-box", "click", function (e) {
+    $( '#scrollBed' ).delegate( ".views-box", "click", function (e) {
 
         var index = $( this ).attr( "data-chart-type" );
         $chartsTypeViewBox.removeClass( "selected" );

+ 2 - 2
public/static/ueditor/third-party/SyntaxHighlighter/shCore.js

@@ -714,7 +714,7 @@ if (typeof(SyntaxHighlighter) == 'undefined') var SyntaxHighlighter = function()
             /** Enables quick code copy and paste from double click. */
             'quick-code' : true,
 
-            /** Forces code view to be collapsed. */
+            /** Forces code views to be collapsed. */
             'collapse' : false,
 
             /** Enables or disables automatic links. */
@@ -3537,7 +3537,7 @@ typeof(exports) != 'undefined' ? exports.SyntaxHighlighter = SyntaxHighlighter :
 						'second section select sequence serializable set size smallint static ' +
 						'statistics table temp temporary then time timestamp to top transaction ' +
 						'translation trigger true truncate uncommitted union unique update values ' +
-						'varchar varying view when where with work';
+						'varchar varying views when where with work';
 
 		var operators =	'all and any between cross in join like not null or outer some';
 

+ 2 - 2
public/static/ueditor/third-party/codemirror/codemirror.js

@@ -26,7 +26,7 @@ var CodeMirror = (function() {
                 'autocorrect="off" autocapitalize="off"></textarea></div>' +
                 '<div class="CodeMirror-scroll" tabindex="-1">' +
                 '<div style="position: relative">' + // Set to the height of the text, causes scrolling
-                '<div style="position: relative">' + // Moved around its parent to cover visible view
+                '<div style="position: relative">' + // Moved around its parent to cover visible views
                 '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
                 // Provides positioning relative to (visible) text origin
                 '<div class="CodeMirror-lines"><div style="position: relative">' +
@@ -76,7 +76,7 @@ var CodeMirror = (function() {
         // happened during the operation.
         var updateInput, userSelChange, changes, textChanged, selectionChanged, leaveInputAlone,
             gutterDirty, callbacks;
-        // Current visible range (may be bigger than the view window).
+        // Current visible range (may be bigger than the views window).
         var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0;
         // bracketHighlighted is used to remember that a backet has been
         // marked.

+ 2 - 2
public/static/ueditor/third-party/highcharts/highcharts.src.js

@@ -7830,7 +7830,7 @@ Axis.prototype = {
 			}
 		}
 
-		// In full view, displaying the reset zoom button is not required
+		// In full views, displaying the reset zoom button is not required
 		this.displayBtn = newMin !== UNDEFINED || newMax !== UNDEFINED;
 		
 		// Do it
@@ -13445,7 +13445,7 @@ Series.prototype = {
 		}
 
 		// Hide cropped-away points - this only runs when the number of points is above cropThreshold, or when
-		// swithching view from non-grouped data to grouped data (#637)	
+		// swithching views from non-grouped data to grouped data (#637)
 		if (data && (processedDataLength !== (dataLength = data.length) || hasGroupedData)) {
 			for (i = 0; i < dataLength; i++) {
 				if (i === cropStart && !hasGroupedData) { // when has grouped data, clear all points

+ 1 - 1
public/static/ueditor/third-party/highcharts/modules/canvas-tools.src.js

@@ -1171,7 +1171,7 @@ if(!Array.prototype.indexOf){
 			
 				this.baseSetContext(ctx);
 				
-				// create new view port
+				// create new views port
 				if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) {
 					ctx.translate(this.attribute('x').Length.toPixels('x'), this.attribute('y').Length.toPixels('y'));
 				}

+ 1 - 1
public/static/ueditor/third-party/highcharts/modules/data.src.js

@@ -18,7 +18,7 @@
  *
  * - columns : Array<Array<Mixed>>
  * A two-dimensional array representing the input data on tabular form. This input can
- * be used when the data is already parsed, for example from a grid view component.
+ * be used when the data is already parsed, for example from a grid views component.
  * Each cell can be a string or number. If not switchRowsAndColumns is set, the columns
  * are interpreted as series. See also the rows option.
  *

+ 1 - 1
public/static/ueditor/third-party/jquery-1.10.2.js

@@ -5208,7 +5208,7 @@ jQuery.event = {
 	},
 
 	// Includes some event props shared by KeyEvent and MouseEvent
-	props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+	props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp views which".split(" "),
 
 	fixHooks: {},
 

+ 4 - 4
public/static/ueditor/ueditor.all.js

@@ -7329,10 +7329,10 @@
 					container.style.zIndex = options.zIndex;
 
 					var html = (ie && browser.version < 9 ? '' : '<!DOCTYPE html>') +
-						'<html xmlns=\'http://www.w3.org/1999/xhtml\' class=\'view\' ><head>' +
+						'<html xmlns=\'http://www.w3.org/1999/xhtml\' class=\'views\' ><head>' +
 						'<style type=\'text/css\'>' +
 						//设置四周的留边
-						'.view{padding:0;word-wrap:break-word;cursor:text;height:90%;}\n' +
+						'.views{padding:0;word-wrap:break-word;cursor:text;height:90%;}\n' +
 						//设置默认字体和字号
 						//font-family不能呢随便改,在safari下fillchar会有解析问题
 						'body{margin:8px;font-family:sans-serif;font-size:16px;}' +
@@ -7340,7 +7340,7 @@
 						'p{margin:5px 0;}</style>' +
 						(options.iframeCssUrl ? '<link rel=\'stylesheet\' type=\'text/css\' href=\'' + utils.unhtml(options.iframeCssUrl) + '\'/>' : '') +
 						(options.initialStyle ? '<style>' + options.initialStyle + '</style>' : '') +
-						'</head><body class=\'view\' ></body>' +
+						'</head><body class=\'views\' ></body>' +
 						'<script type=\'text/javascript\' ' + (ie ? 'defer=\'defer\'' : '') + ' id=\'_initialScript\'>' +
 						'setTimeout(function(){editor = window.parent.UE.instants[\'ueditorInstant' + me.uid + '\'];editor._setup(document);},0);' +
 						'var _tmpScript = document.getElementById(\'_initialScript\');_tmpScript.parentNode.removeChild(_tmpScript);</script></html>';
@@ -7681,7 +7681,7 @@
 				}
 				return '<html><head>' + (me.options.charset ? '<meta http-equiv="Content-Type" content="text/html; charset=' + me.options.charset + '"/>' : '') +
 					(headHtmlForIE9 || me.document.getElementsByTagName('head')[0].innerHTML) + headHtml.join('\n') + '</head>' +
-					'<body ' + (ie && browser.version < 9 ? 'class="view"' : '') + '>' + me.getContent(null, null, true) + '</body></html>';
+					'<body ' + (ie && browser.version < 9 ? 'class="views"' : '') + '>' + me.getContent(null, null, true) + '</body></html>';
 			},
 
 			/**

+ 11 - 2
resources/views/admin/admin_user/add.blade.php

@@ -21,11 +21,20 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 		<div class="clearfix">
 			<label class="checkbox-inline">
 				<input type="radio" value="1" name="data_type" checked>
-				普通员工
+				@if(session('userRule.business_id'))
+					店铺普通员工
+				@else
+					商户普通员工
+				@endif
 			</label>
 			<label class="checkbox-inline">
 				<input type="radio" value="2" name="data_type">
-				代表
+				@if(session('userRule.business_id'))
+					推广员
+				@else
+					代表
+				@endif
+
 			</label>
 		</div>
 	</div>

+ 12 - 4
resources/views/admin/admin_user/edit.blade.php

@@ -20,12 +20,20 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 		<label class="control-label">账户角色</label>
 		<div class="clearfix">
 			<label class="checkbox-inline">
-				<input type="checkbox" value="1" name="data_type">
-				普通员工
+				<input type="checkbox" value="1" name="data_type" @if($oldData['data_type'] == 1) checked @endif>
+				@if(session('userRule.business_id'))
+					店铺普通员工
+				@else
+					商户普通员工
+				@endif
 			</label>
 			<label class="checkbox-inline">
-				<input type="checkbox" value="2" name="data_type">
-				代表
+				<input type="checkbox" value="2" name="data_type" @if($oldData['data_type'] == 2) checked @endif>
+				@if(session('userRule.business_id'))
+					推广员
+				@else
+					代表
+				@endif
 			</label>
 		</div>
 	</div>

+ 6 - 0
resources/views/admin/admin_user/index.blade.php

@@ -22,6 +22,9 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 					<tr>
 						<th>序号</th>
 						<th>用户账号</th>
+						<th>商户名称</th>
+						<th>商业公司名称</th>
+						<th>用户角色</th>
 						<th>用户权限</th>
 						<th>创建时间</th>
 						<th>操作</th>									
@@ -33,6 +36,9 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<tr>
 							<th>{{$a['uid']}}</th>
 							<td>{{$a['username']}}</td>
+							<td>{{$a['company_name']}}</td>
+							<td>{{$a['business_name']}}</td>
+							<td>{{$a['rule_title']}}</td>
 							<td>{{$a['title']}}</td>
 							<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
 							<td>

+ 5 - 1
resources/views/admin/auth_manager/index.blade.php

@@ -14,7 +14,9 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 					<tr>											
 						<th>用户组</th> 	
 						<th>描述</th> 	
-						<th>授权</th> 	
+						<th>商户名称</th>
+						<th>商业公司名称</th>
+						<th>授权</th>
 						<th>操作</th>	
 					</tr>
 				</thead>
@@ -23,6 +25,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<tr>
 							<td>{{$a['title']}}</td>
 							<td>{{$a['description']}}</td>
+							<td>{{$a['company_name']}}</td>
+							<td>{{$a['business_name']}}</td>
 							<td>
 								<a href="{{url('admin/auth_manager/access?'.http_build_query(['id'=>$a['id']]))}}">访问授权</a>
 							</td>

+ 25 - 9
resources/views/admin/business/index.blade.php

@@ -38,14 +38,18 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 				<thead>
 					<tr>
 						<th>编码</th>
-						<th>状态</th>
 						<th>商业公司</th>
+						<th>图片</th>
+						<th>状态</th>
 						<th>联系方式</th>
 						<th>城市</th>
 						<th>详细地址</th>
 						<th>上级代表</th>
-						<th>简介说明</th>
-						<th>创建时间</th>
+						<th>管理员登录账号</th>
+						<th>管理员手机号</th>
+						<th>所属平台</th>
+						<th>最后修改人员/时间</th>
+						<th>创建人员/时间</th>
 						<th>操作</th>									
 					</tr>
 				</thead>
@@ -54,23 +58,35 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						@foreach ($list as $a)
 						<tr>
 							<th>{{$a['business_code']}}</th>
-							<td>{{$a['status']?'禁用':'正常'}}</td>
 							<td>{{$a['name']}}</td>
+							<td> <img src="{{$a['logopic']}}" alt="" height="50"> </td>
+							<td>{{$a['status']?'停用':'启用'}}</td>
 							<td>{{$a['phone']}}</td>
 							<td>{{$a['city_ids']}}</td>
 							<td>{{$a['address']}}</td>
-							<td>{{$a['leader_name']}}</td>
-							<td>{{$a['desc']}}</td>
-							<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
+							<td>{{$a['leader_username']}}</td>
+							<td>{{$a['username']}}</td>
+							<td>{{$a['admin_phone']}}</td>
+							<td>{{$a['company_name']}}</td>
+							<td>
+								@if($a['edit_history_time'])
+									{{$a['edit_history_username']}}<br/> {{date('Y/m/d H:i:s',$a['edit_history_time'])}}
+								@endif
+							</td>
+							<td>
+								@if($a['add_history_time'])
+									{{$a['add_history_username']}}<br/> {{date('Y/m/d H:i:s',$a['add_history_time'])}}
+								@endif
+							</td>
 							<td>
 								@if(check_auth('admin/business/edit'))
 								<a href="{{url('admin/business/edit?'.http_build_query(['id'=>$a['id']]))}}" class="btn btn-sm btn-warning" >编辑</a>
 								@endif
 								@if(check_auth('admin/business/set_status'))
 									@if($a['status'])
-									<a data-url="{{url('admin/business/set_status?'.http_build_query(['id'=>$a['id'],'status'=>0]))}}" class="set_status btn btn-sm btn-success" >取消拉黑</a>
+									<a data-url="{{url('admin/business/set_status?'.http_build_query(['id'=>$a['id'],'status'=>0]))}}" class="set_status btn btn-sm btn-success" >启用</a>
 									@else
-									<a data-url="{{url('admin/business/set_status?'.http_build_query(['id'=>$a['id'],'status'=>1]))}}" class="set_status btn btn-sm btn-danger" >拉黑</a>
+									<a data-url="{{url('admin/business/set_status?'.http_build_query(['id'=>$a['id'],'status'=>1]))}}" class="set_status btn btn-sm btn-danger" >停用</a>
 									@endif
 								@endif
 							</td>							

+ 8 - 0
resources/views/admin/coupon/add.blade.php

@@ -88,6 +88,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			@endforeach
 		</select>
 	</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">商业公司</label>
+		<select name="business_id" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" selected >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		@csrf
 		<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />

+ 8 - 0
resources/views/admin/coupon/edit.blade.php

@@ -88,6 +88,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			@endforeach
 		</select>
 	</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">商业公司</label>
+		<select name="business_id" required class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" @if( $value['id'] == $oldData['business_id']) selected @endif >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		@csrf
 		<input type="hidden" name="id" value="{{$oldData['id']}}" />

+ 3 - 1
resources/views/admin/coupon/index.blade.php

@@ -55,6 +55,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>活动城市</th>
 						<th>商品范围</th>
 						<th>发放类型</th>
+						<th>店铺</th>
 						<th>优惠券状态</th>
 						<th>发放时间</th>
 						<th>修改时间</th>
@@ -95,7 +96,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							@endif
 						</td>
 						<td> {{$a['gant_name']}} </td>
-						<td> 
+						<td> {{$a['business_name']}} </td>
+						<td>
 							@if ($a['status'] == 0) 
 
 								@if ( $a['start_time']  > time() ) 

+ 8 - 0
resources/views/admin/coupon_active/add.blade.php

@@ -49,6 +49,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			@endforeach
 		</select>
 	</div>
+	<div class="form-group col-sm-6">
+		<label class="control-label">商业公司</label>
+		<select name="business_id" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" selected >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">活动规则</label>
 		<textarea class="form-control" name="active_rule" rows="10" placeholder="请输入活动规则" maxlength="255" ></textarea>

+ 8 - 0
resources/views/admin/coupon_active/edit.blade.php

@@ -49,6 +49,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			@endforeach
 		</select>
 	</div>
+	<div class="form-group col-sm-6">
+		<label class="control-label">商业公司</label>
+		<select name="business_id" required class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" @if( $value['id'] == $oldData['business_id']) selected @endif >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">活动规则</label>
 		<textarea class="form-control" name="active_rule" rows="10" placeholder="请输入活动规则" >{{$oldData['active_rule']}}</textarea>

+ 2 - 0
resources/views/admin/coupon_active/index.blade.php

@@ -30,6 +30,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>结束时间</th>
 						<th>内部跳转</th>
 						<th>宣发链接</th>
+						<th>店铺</th>
 						<th>活动状态</th>
 						<th>修改时间</th>
 						<th>操作</th>									
@@ -45,6 +46,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<td>{{date('Y/m/d H:i:s',$a['end_time'])}}</td>
 							<td>/pages/coupon/active?id={{$a['id']}}</td>
 							<td>{{$a['mp_urllink']}}</td>
+							<td>{{$a['business_name']}}</td>
 							<td>
 								@if( $a['status'] )
 								停用

+ 8 - 0
resources/views/admin/coupon_reward_rule/add.blade.php

@@ -36,6 +36,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			@endforeach
 		</select>
 	</div>
+	<div class="form-group col-sm-12">
+		<label class="control-label">店铺</label>
+		<select name="business_id" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" selected >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">排除客户</label>
 		<textarea class="form-control" name="remove_custom" rows="10" placeholder="需要排除的客户编码,多个使用换行" ></textarea>

+ 8 - 0
resources/views/admin/coupon_reward_rule/edit.blade.php

@@ -36,6 +36,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			@endforeach
 		</select>
 	</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">商业公司</label>
+		<select name="business_id" required class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" @if( $value['id'] == $oldData['business_id']) selected @endif >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">排除客户</label>
 		<textarea class="form-control" name="remove_custom" rows="10" placeholder="需要排除的客户编码,多个使用换行" >{{$oldData['remove_custom']}}</textarea>

+ 2 - 0
resources/views/admin/coupon_reward_rule/index.blade.php

@@ -30,6 +30,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>开始时间</th>
 						<th>结束时间</th>
 						<th>优惠券</th>
+						<th>店铺</th>
 						<th>配置状态</th>
 						<th>修改时间</th>
 						<th>操作</th>									
@@ -45,6 +46,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<td> {{date('Y/m/d H:i:s',$a['start_time'])}}</td>
 							<td> {{date('Y/m/d H:i:s',$a['end_time'])}}</td>
 							<td>{{$a['coupon_name']}}</td>
+							<td>{{$a['business_name']}}</td>
 							<td>{{$a['status']?'停用':'启用'}}</td>
 							<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
 							<td>

+ 2 - 0
resources/views/admin/custom_coupon/index.blade.php

@@ -50,6 +50,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 					<tr>
 						<th>优惠券编码</th>
 						<th>优惠券名称</th>
+						<th>店铺名称</th>
 						<th>客户编码</th>
 						<th>客户名称</th>
 						<th>商品范围</th>
@@ -67,6 +68,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 					<tr>
 						<td> {{$a['coupon_code']}}</td>
 						<td> {{$a['coupon_name']}}</td>
+						<td> {{$a['business_name']}}</td>
 						<td> {{$a['custom_code']}}</td>
 						<td> {{$a['custom_name']}}</td>
 						<td> 

+ 8 - 0
resources/views/admin/promo/add.blade.php

@@ -72,6 +72,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			</div>
 		</div>
 	</div>
+	<div class="form-group col-sm-6">
+		<label class="control-label">店铺</label>
+		<select name="business_id" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" selected >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		@csrf
 		<input id="send" type="submit" value="提交" class="btn btn-primary btn-block" />

+ 8 - 0
resources/views/admin/promo/edit.blade.php

@@ -72,6 +72,14 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			</div>
 		</div>
 	</div>
+	<div class="form-group col-sm-2">
+		<label class="control-label">店铺</label>
+		<select name="business_id" required class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索商业公司" data-none-results-text="未搜索到 {0}" title="选择商业公司">
+			@foreach ($businessList as $value)
+				<option value="{{$value['id']}}" @if( $value['id'] == $oldData['business_id']) selected @endif >{{$value['name']}}</option>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col-sm-12">
 		@csrf
 		<input type="hidden" name="id" value="{{$oldData['id']}}" />

+ 2 - 0
resources/views/admin/promo/index.blade.php

@@ -54,6 +54,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>活动城市</th>
 						<th>标签范围</th>
 						<th>商品范围</th>
+						<th>店铺</th>
 						<th>状态</th>
 						<th>活动时间</th>
 						<th>修改时间</th>
@@ -91,6 +92,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 								全部商品
 							@endif
 						</td>
+						<td> {{$a['business_name']}}</td>
 						<td> 
 							@if ($a['status'] == 0)