Browse Source

过滤已离职员工

shensong 5 years ago
parent
commit
f87743d312
1 changed files with 41 additions and 42 deletions
  1. 41 42
      app/Http/Controllers/Admin/CustomerDepositController.php

+ 41 - 42
app/Http/Controllers/Admin/CustomerDepositController.php

@@ -149,7 +149,7 @@ class CustomerDepositController extends Controller
149 149
         }
150 150
         $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id){
151 151
             if($team_id>0) $query->where('team_id', $team_id);
152
-        })->where('id','>', 1)->get();
152
+        })->where('id','>', 1)->where('is_use',1)->get();
153 153
         $adminList = json_decode(json_encode($adminList), true);
154 154
 
155 155
         return view('deposit/create', ['packages'=>$packages, 'phone'=>$phone, 'phonei'=>$phonei, 'adminlist'=>$adminList, 'self_role'=>$self_role]);
@@ -394,11 +394,25 @@ class CustomerDepositController extends Controller
394 394
             if( !empty($saler_ids) ) $query->whereIn('admin_id', $saler_ids);
395 395
         })->orderBy('id','desc')->offset($offset)->limit($pageSize)->get();
396 396
         $result = json_decode(json_encode($result),true);
397
-        foreach($result as &$value) {
398
-            $admin = Admin::find($value['admin_id']);
399
-            $value['admin_name'] = $admin->realname;
400
-        }
401 397
 
398
+        $result = array_map(function($value){
399
+            $item = $value;
400
+            $birthdayGift = CustomerGiftReceives::getCustomerReceivesLog($value['phone'],1);
401
+            if($birthdayGift){
402
+                $item['birthday_gift'] = $birthdayGift[0]['dtime'].' 领取';
403
+            } else {
404
+                $item['birthday_gift'] = '未使用';
405
+            }
406
+            $monthGift = CustomerGiftReceives::getCustomerReceivesLog($value['phone'],0);
407
+            $monthGiftNum = count($monthGift);
408
+            $item['month_gift'] = '剩余'.(12-$monthGiftNum).'次';
409
+
410
+            $coupons = CustomerCoupons::where('phone',$value['phone'])->where('is_use',0)->count();
411
+            $item['coupon'] = '剩余'.$coupons.'张';
412
+            $admin = Admin::find($value['admin_id']);
413
+            $item['admin_name'] = $admin->realname;
414
+            return $item;
415
+        },$result);
402 416
 
403 417
         $teamList = DB::table('teams')->select('id', 'name')->where(function($query) use($team_id, $self_role){
404 418
             if($self_role == '管理员') $query->where('id', $team_id);
@@ -407,7 +421,7 @@ class CustomerDepositController extends Controller
407 421
 
408 422
         $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
409 423
             if($self_role == '管理员') $query->where('team_id', $team_id);
410
-        })->where('id','>', 1)->get();
424
+        })->where('id','>', 1)->where('is_use',1)->get();
411 425
         $adminList = json_decode(json_encode($adminList), true);
412 426
 
413 427
         return view('customer/vipCustomerList', [
@@ -439,7 +453,7 @@ class CustomerDepositController extends Controller
439 453
         }
440 454
         $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
441 455
             if($self_role == '管理员') $query->where('team_id', $team_id);
442
-        })->where('id','>', 1)->get();
456
+        })->where('id','>', 1)->where('is_use',1)->get();
443 457
         $adminList = json_decode(json_encode($adminList), true);
444 458
         return view('customer/vipCustomerCreate',[
445 459
             'adminlist' => $adminList,
@@ -504,7 +518,7 @@ class CustomerDepositController extends Controller
504 518
         $customer = CustomerVip::findOrFail($id);
505 519
         $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
506 520
             if($self_role == '管理员') $query->where('team_id', $team_id);
507
-        })->where('id','>', 1)->get();
521
+        })->where('id','>', 1)->where('is_use',1)->get();
508 522
         $adminList = json_decode(json_encode($adminList), true);
509 523
         return view('customer/vipCustomerEdit',[
510 524
             'info'=>$customer,
@@ -707,53 +721,38 @@ class CustomerDepositController extends Controller
707 721
     }
708 722
 
709 723
     /**
710
-     * 查询会员信息页面
724
+     * 查询会员每月礼品领取记录
711 725
      * @param Request $request
712 726
      */
713
-    public function queryVipView(Request $request) {
714
-        return view('customer/customerInformationQuery');
727
+    public function monthGiftLog(Request $request) {
728
+        $phone = $request->input('phone');
729
+        echo "month_gift_log";die;
730
+        $monthGiftLog = CustomerGiftReceives::getCustomerReceivesLog($phone,0);
731
+
732
+        return view('customer/monthGiftLog',[]);
715 733
     }
716 734
 
717 735
     /**
718
-     * 查询会员信息操作
736
+     * 查询会员代金券领取记录
719 737
      * @param Request $request
738
+     * @return \Illuminate\View\View
720 739
      */
721
-    public function queryVipInformation(Request $request) {
740
+    public function couponLog(Request $request) {
722 741
         $phone = $request->input('phone');
723 742
 
724
-        #查询数据
725
-        $customer = CustomerVip::where('phone',$phone)->first();
726
-        if(!$customer){
727
-            //不是会员
728
-            $couponsList = null;
729
-            $giftList = null;
730
-        } else {
731
-            $couponsList = CustomerCoupons::where('phone',$phone)->get();
732
-            $giftList = CustomerGiftReceives::where('phone',$phone)->where('is_del',0)->get();
733
-        }
743
+        $couponList = CustomerCoupons::getCustomerCouponsLog($phone);
734 744
 
735
-        #处理数据
736
-        if($couponsList){
737
-            $coupons = array();
738
-            foreach($couponsList as $value) {
739
-                if($value['is_use'] == 1) {
740
-                    $coupons['use']++;
741
-                } else {
742
-                    $coupons['nouse']++;
743
-                }
744
-            }
745
-        }
745
+        return view('customer/customerCouponLog',['list'=>$couponList]);
746
+    }
746 747
 
747
-        if($giftList){
748
-            $gifts = array();
749
-            foreach($giftList as $value) {
750
-                if($value['gift_type'] == 1){
751 748
 
752
-                } else if($value['gift_type'] == 0){
749
+    public function birthdayGiftLog(Request $request) {
750
+        $phone = $request->input('phone');
751
+        $log = CustomerGiftReceives::getCustomerReceivesLog($phone,1);
752
+        $data = array_map(function($value){
753 753
 
754
-                }
755
-            }
756
-        }
754
+        },$log);
755
+        return view('customer/birthdayGiftLog',['list'=>$data]);
757 756
     }
758 757
 
759 758
 }