sunhao 5 years ago
parent
commit
726743c740

+ 18 - 0
app/CustomerCoupons.php

@@ -0,0 +1,18 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: shensong
5
+ * Date: 2019/11/27
6
+ * Time: 17:07
7
+ */
8
+
9
+namespace App;
10
+
11
+
12
+use Illuminate\Database\Eloquent\Model;
13
+
14
+class CustomerCoupons extends Model
15
+{
16
+    protected $table = 'customer_coupons';
17
+    public $timestamps = false;
18
+}

+ 18 - 0
app/CustomerMonthGift.php

@@ -0,0 +1,18 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: shensong
5
+ * Date: 2019/11/28
6
+ * Time: 17:28
7
+ */
8
+
9
+namespace App;
10
+
11
+
12
+use Illuminate\Database\Eloquent\Model;
13
+
14
+class CustomerMonthGift extends Model
15
+{
16
+    public $timestamps = false;
17
+    protected $table = 'customer_month_gift';
18
+}

+ 18 - 0
app/CustomerVip.php

@@ -0,0 +1,18 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: shensong
5
+ * Date: 2019/11/27
6
+ * Time: 17:06
7
+ */
8
+
9
+namespace App;
10
+
11
+
12
+use Illuminate\Database\Eloquent\Model;
13
+
14
+class CustomerVip extends Model
15
+{
16
+    public $timestamps = false;
17
+    protected $table = 'customer_vip';
18
+}

+ 2 - 0
app/Error.php

@@ -12,6 +12,7 @@ class Error
12 12
      */
13 13
     public static $errCodes = [
14 14
 
15
+
15 16
         0    => "成功",
16 17
         200  =>'请求成功',
17 18
         1001 => '未分配销售',
@@ -19,6 +20,7 @@ class Error
19 20
         2000 =>'请求参数不合法',
20 21
         2001 =>'未查询到有效数据',
21 22
         2002 =>'密码错误',
23
+        2003 =>'充值卡余额不足',
22 24
     ];
23 25
     /**
24 26
      * 返回错误码

+ 367 - 0
app/Http/Controllers/Admin/CustomerDepositController.php

@@ -6,8 +6,14 @@
6 6
  * Time: 上午11:20
7 7
  */
8 8
 namespace  App\Http\Controllers\Admin;
9
+use App\CustomerCoupons;
10
+use App\CustomerMonthGift;
11
+use App\CustomerVip;
12
+use App\Goods;
13
+use App\GoodsSkus;
9 14
 use App\Http\Controllers\Controller;
10 15
 use App\Admin;
16
+use function GuzzleHttp\Psr7\str;
11 17
 use Illuminate\Http\Request;
12 18
 use App\CustomerInfo;
13 19
 use App\CustomerDeposit;
@@ -334,4 +340,365 @@ class CustomerDepositController extends Controller
334 340
         return 1;
335 341
     }
336 342
 
343
+    /**
344
+     * vip用户列表
345
+     * @param Request $request
346
+     */
347
+    public function vipCustomerList(Request $request) {
348
+        $page = (int)$request->input('page');
349
+        $name = $request->input('name');
350
+        $phone = $request->input('phone');
351
+
352
+        $admin_id = (int)$request->input('admin_id');
353
+        $team_id = (int)$request->input('team_id');
354
+
355
+        $self_role = session('role_name');
356
+
357
+        if($self_role == '管理员'){
358
+            //只能看自己团队的
359
+            $self_id = session('admin_id');
360
+            $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
361
+        }
362
+
363
+        //假如有团队筛选,检索销售队员
364
+        $saler_ids = null;
365
+
366
+        if($team_id>0 && !$admin_id){
367
+            $saler_ids = DB::table('admin')->where('team_id', $team_id)->lists('id');
368
+        }
369
+
370
+        $pageSize = 20;
371
+        if($page<=0){
372
+            $page = 1;
373
+        }
374
+
375
+        $offset = ($page-1) * $pageSize;
376
+        $count = CustomerVip::where(function($query) use ($name,$phone,$admin_id,$saler_ids) {
377
+            if($phone) $query->where('phone', $phone);
378
+            if($name) $query->where('name', 'like', '%'. $name. '%');
379
+            if($admin_id) $query->where('admin_id', $admin_id);
380
+            if( !empty($saler_ids) ) $query->whereIn('admin_id', $saler_ids);
381
+        })->count();
382
+        if ($count > 1) {
383
+            // 总页数
384
+            $pages = ceil($count/$pageSize);
385
+        }else{
386
+            // 总页数
387
+            $pages = 1;
388
+        }
389
+        $result = CustomerVip::where(function($query) use($phone, $name, $admin_id, $saler_ids){
390
+            if($phone) $query->where('phone', $phone);
391
+            if($name) $query->where('name', 'like', '%'. $name. '%');
392
+            if($admin_id) $query->where('admin_id', $admin_id);
393
+            if( !empty($saler_ids) ) $query->whereIn('admin_id', $saler_ids);
394
+        })->orderBy('id','desc')->offset($offset)->limit($pageSize)->get();
395
+        $result = json_decode(json_encode($result),true);
396
+
397
+
398
+        $teamList = DB::table('teams')->select('id', 'name')->where(function($query) use($team_id, $self_role){
399
+            if($self_role == '管理员') $query->where('id', $team_id);
400
+        })->where('type', 1)->get();
401
+        $teamList = json_decode(json_encode($teamList), true);
402
+
403
+        $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
404
+            if($self_role == '管理员') $query->where('team_id', $team_id);
405
+        })->where('id','>', 1)->get();
406
+        $adminList = json_decode(json_encode($adminList), true);
407
+
408
+        return view('customer/vipCustomerList', [
409
+            'result' =>$result,
410
+            'page'              =>$page,
411
+            'count'             =>$count,
412
+            'pages'             =>$pages,
413
+            'phone'             =>$phone,
414
+            'name'              =>$name,
415
+            'teamlist'          =>$teamList,
416
+            'adminlist'         =>$adminList,
417
+            'team_id'           =>$team_id,
418
+            'admin_id'          =>$admin_id,
419
+            'self_role'         =>$self_role,
420
+        ]);
421
+    }
422
+
423
+    /**
424
+     * 添加vip用户页面
425
+     * @param Request $request
426
+     */
427
+    public function addVipCustomer(Request $request) {
428
+        $self_role = session('role_name');
429
+        $team_id = null;
430
+        if($self_role == '管理员'){
431
+            //只能看自己团队的
432
+            $self_id = session('admin_id');
433
+            $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
434
+        }
435
+        $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
436
+            if($self_role == '管理员') $query->where('team_id', $team_id);
437
+        })->where('id','>', 1)->get();
438
+        $adminList = json_decode(json_encode($adminList), true);
439
+        return view('customer/vipCustomerCreate',[
440
+            'adminlist' => $adminList,
441
+        ]);
442
+    }
443
+
444
+    /**
445
+     * 添加vip用户信息
446
+     * @param Request $request
447
+     */
448
+    public function storeVipCustomer(Request $request) {
449
+
450
+        $this->validate($request, [
451
+            'phone' => 'required',
452
+            'birthday' => 'required',
453
+        ], [
454
+            'phone.required' => '手机号不能为空',
455
+            'birthday.required' => '必须填写用户生日',
456
+        ]);
457
+
458
+        //添加vip用户
459
+        $customerVip = new CustomerVip();
460
+        $customerVip->phone = $request->input('phone');
461
+        $customerVip->name = $request->input('name');
462
+        $customerVip->admin_id = $request->input('admin_id');
463
+        $customerVip->level = 1;
464
+        $customerVip->discount = 95;
465
+        $customerVip->create_time = date('Y-m-d H:i:s',time());
466
+        $customerVip->vip_end_time = date('Y-m-d H:i:s',strtotime('+1 year'));
467
+        $customerVip->birthday = $request->input('birthday');
468
+        $customerVip->is_del = 0;
469
+
470
+        if($customerVip->save()) {
471
+            //添加优惠券
472
+            for($i=1;$i<=6;$i++){
473
+                $customerCoupons = new CustomerCoupons();
474
+                $customerCoupons->phone = $request->input('phone');
475
+                $customerCoupons->coupon_price = 30;
476
+                $customerCoupons->create_time = date('Y-m-d H:i:s',time());
477
+                $customerCoupons->end_time = date('Y-m-d',strtotime('+3 months'));
478
+                $customerCoupons->is_use = 0;
479
+                $customerCoupons->save();
480
+            }
481
+        }
482
+
483
+        return redirect('/admin/customer/vipList')->with('info', '添加成功');
484
+    }
485
+
486
+    /**
487
+     * 编辑vip用户页面
488
+     * @param Request $request
489
+     */
490
+    public function editVipCustomer(Request $request) {
491
+        $id = $request->input('id');
492
+        $self_role = session('role_name');
493
+        $team_id = null;
494
+        if($self_role == '管理员'){
495
+            //只能看自己团队的
496
+            $self_id = session('admin_id');
497
+            $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
498
+        }
499
+        $customer = CustomerVip::findOrFail($id);
500
+        $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
501
+            if($self_role == '管理员') $query->where('team_id', $team_id);
502
+        })->where('id','>', 1)->get();
503
+        $adminList = json_decode(json_encode($adminList), true);
504
+        return view('customer/vipCustomerEdit',[
505
+            'info'=>$customer,
506
+            'adminlist' => $adminList,
507
+            ]);
508
+    }
509
+
510
+    /**
511
+     * 编辑vip用户信息
512
+     * @param Request $request
513
+     */
514
+    public function updateVipCustomer(Request $request) {
515
+        $id = $request->input('id');
516
+        //修改vip用户信息
517
+        $customerVip = CustomerVip::findOrFail($id);
518
+        $customerVip->name = $request->input('name');
519
+        $customerVip->birthday = $request->input('birthday');
520
+        $customerVip->admin_id = $request->input('admin_id');
521
+        if($customerVip->save()){
522
+            return redirect('/admin/customer/vipList')->with('info', '编辑成功');
523
+        } else {
524
+            return redirect('/admin/customer/vipUpdate?id='.$id)->with('info', '编辑失败');
525
+        }
526
+
527
+    }
528
+
529
+    /**
530
+     * 启用vip用户
531
+     * @param Request $request
532
+     */
533
+    public function vipUp(Request $request) {
534
+        $id = $request->input('id');
535
+        $res = CustomerVip::where('id',$id)->update(['is_del'=>0]);
536
+        if($res) exit('1');
537
+        exit('0');
538
+    }
539
+
540
+    /**
541
+     * 禁用vip用户
542
+     * @param Request $request
543
+     */
544
+    public function vipDel(Request $request) {
545
+        $id = $request->input('id');
546
+        $res = CustomerVip::where('id',$id)->update(['is_del'=>1]);
547
+        if($res) exit('1');
548
+        exit('0');
549
+    }
550
+
551
+    /**
552
+     * 会员用户礼品列表
553
+     * @param Request $request
554
+     */
555
+    public function monthGiftList(Request $request) {
556
+        $page = $request->input('page',1);
557
+        $type = $request->input('type');
558
+        $pageSize = 20;
559
+        if($page<=0){
560
+            $page = 1;
561
+        }
562
+
563
+        $offset = ($page-1) * $pageSize;
564
+        $count = CustomerMonthGift::where(function($query) use ($type) {
565
+            if($type && ($type != '-1')) $query->where('type',$type);
566
+        })->count();
567
+        if ($count > 1) {
568
+            // 总页数
569
+            $pages = ceil($count/$pageSize);
570
+        }else{
571
+            // 总页数
572
+            $pages = 1;
573
+        }
574
+        $result = CustomerMonthGift::where(function($query) use ($type) {
575
+            if($type && ($type != '-1')) $query->where('type',$type);
576
+        })->orderBy('id','desc')->offset($offset)->limit($pageSize)->get();
577
+        $result = json_decode(json_encode($result),true);
578
+        $result = array_map(function($value){
579
+            $item = $value;
580
+            $sku = GoodsSkus::select('propsName','price','is_white','quantity','is_weigh')->where('id', $value['sku_id'])->where('is_del', 0)->first();
581
+            $goods = Goods::select('name','picUrl','goodsCategoryName')->where('is_del', 0)->where('id', $value['goods_id'])->first();
582
+            $item['sku'] = $sku;
583
+            $item['goods'] = $goods;
584
+            return $item;
585
+        },$result);
586
+
587
+        return view('customer/customerGiftList',[
588
+            'page'  => $page,
589
+            'pages' => $pages,
590
+            'count' => $count,
591
+            'result'=> $result,
592
+            'type'  => $type,
593
+        ]);
594
+    }
595
+
596
+
597
+    /**
598
+     * 添加礼品页面
599
+     */
600
+    public function addMonthGift() {
601
+        return view('customer/customerGiftAdd');
602
+    }
603
+
604
+    /**
605
+     * 编辑礼品页面
606
+     * @param Request $request
607
+     */
608
+    public function editMonthGift(Request $request) {
609
+        $id = $request->input('id');
610
+        $gift = CustomerMonthGift::findOrFail($id);
611
+        $goods = Goods::select('gs.id as sku_id', 'goods.id as goods_id', 'goods.name', 'gs.propsName as props_name', 'gs.price', 'gs.is_weigh')->leftJoin('goods_skus as gs', 'gs.goodsCode', '=', 'goods.id')->where('gs.id', $gift->sku_id)->orderBy('goods.id', 'desc')->first();
612
+        return view('customer/customerGiftEdit',[
613
+            'info'  => $gift,
614
+            'good' => $goods,
615
+        ]);
616
+    }
617
+
618
+    /**
619
+     * 添加礼品信息
620
+     * @param Request $request
621
+     */
622
+    public function monthGiftStore(Request $request) {
623
+        #数据校验
624
+        $this->validate( $request ,[
625
+                'mtime' => 'required',
626
+            ],[
627
+                'mtime.required' => '日期必填',
628
+            ]
629
+        );
630
+
631
+        #数据处理
632
+        $type = $request->input('type');
633
+        $mtime = date('Y-m-01',strtotime($request->input('mtime')));
634
+        $skus = $request->input('skus');
635
+        $sku_id = $skus[0];
636
+        $gnum = $request->input('gnum');
637
+        $num = $gnum[0];
638
+
639
+        //根据规格id反向查询商品goods_id
640
+        $sku = GoodsSkus::find($sku_id);
641
+        $goods_id = $sku['goodsCode'];
642
+
643
+        #数据存储
644
+        $gift = new CustomerMonthGift();
645
+        $gift->mtime = $mtime;
646
+        $gift->goods_id = $goods_id;
647
+        $gift->sku_id = $sku_id;
648
+        $gift->type = $type;
649
+        $gift->num = $num;
650
+        $gift->create_time = date('Y-m-d H:i:s',time());
651
+        $res = $gift->save();
652
+
653
+        #结果返回
654
+        if($res){
655
+            return redirect('/admin/customer/giftList')->with('info','添加成功');
656
+        } else {
657
+            return back()->with('info','添加失败');
658
+        }
659
+    }
660
+
661
+    /**
662
+     * 编辑礼品信息
663
+     * @param Request $request
664
+     */
665
+    public function monthGiftUpdate(Request $request) {
666
+        #数据校验
667
+        $this->validate( $request ,[
668
+            'mtime' => 'required',
669
+        ],[
670
+                'mtime.required' => '日期必填',
671
+            ]
672
+        );
673
+
674
+        #数据处理
675
+        $type = $request->input('type');
676
+        $id = $request->input('id');
677
+        $mtime = date('Y-m-01',strtotime($request->input('mtime')));
678
+        $skus = $request->input('skus');
679
+        $sku_id = $skus[0];
680
+        $gnum = $request->input('gnum');
681
+        $num = $gnum[0];
682
+
683
+        //根据规格id反向查询商品goods_id
684
+        $sku = GoodsSkus::find($sku_id);
685
+        $goods_id = $sku['goodsCode'];
686
+
687
+        #数据存储
688
+        $gift = CustomerMonthGift::findOrFail($id);
689
+        $gift->mtime = $mtime;
690
+        $gift->goods_id = $goods_id;
691
+        $gift->sku_id = $sku_id;
692
+        $gift->type = $type;
693
+        $gift->num = $num;
694
+        $res = $gift->save();
695
+
696
+        #结果返回
697
+        if($res){
698
+            return redirect('/admin/customer/giftList')->with('info','修改成功');
699
+        } else {
700
+            return back()->with('info','修改失败');
701
+        }
702
+    }
703
+
337 704
 }

+ 345 - 3
app/Http/Controllers/Admin/OrderController.php

@@ -485,7 +485,29 @@ class OrderController extends Controller
485 485
         $self_role = session('role_name');
486 486
         $createTime = date('Y-m-d H:i:s');
487 487
 
488
-        return view('order/ordercreate', ['categorylist' => $catelist, 'adminlist'=>$adminList, 'teamlist'=>$teamList, 'self_role'=>$self_role, 'createTime'=>$createTime, 'last_url' => $_SERVER['HTTP_REFERER']]);
488
+        //当月礼品
489
+        $mtime = date('Y-m-01');
490
+        $gift_info = DB::table('customer_month_gift')->where('mtime', $mtime)->get();
491
+        $gift_info = json_decode(json_encode($gift_info), true);
492
+        $m_gift=array();
493
+        $b_gift=array();
494
+        foreach($gift_info as $k=>$v){
495
+            //获取礼品信息
496
+            $goods_name = Goods::where('id', $v['goods_id'])->pluck('name');
497
+            $sku = GoodsSkus::where('id', $v['sku_id'])->first();
498
+            $data = array();
499
+            $data['id'] = $v['id'];
500
+            $data['goods_name'] = $goods_name;
501
+            $data['propsName'] = $sku['propsName'];
502
+            $data['price'] = $sku['price'];
503
+            if($v['type'] == 0){
504
+                $m_gift[] = $data;
505
+            }else{
506
+                $b_gift[] = $data;
507
+            }
508
+        }
509
+
510
+        return view('order/ordercreate', ['categorylist' => $catelist, 'adminlist'=>$adminList, 'teamlist'=>$teamList, 'self_role'=>$self_role, 'createTime'=>$createTime, 'last_url' => $_SERVER['HTTP_REFERER'], 'm_gift'=>$m_gift, 'b_gift'=>$b_gift]);
489 511
     }
490 512
     /**
491 513
      * 分组管理-进行添加操作
@@ -498,6 +520,7 @@ class OrderController extends Controller
498 520
             'customerName'           => 'required|between:1,6', 
499 521
             'receiverName'           => 'required|between:1,6', 
500 522
             'receiverMobile'           => 'required|regex:/^1[3456789]\d{9}$/',  
523
+            'buyer_phone'           => 'required|regex:/^1[3456789]\d{9}$/',  
501 524
             'fanTime'           => 'required|date', 
502 525
             'receiverState'           => 'required|between:1,5', 
503 526
             'receiverCity'           => 'required|between:1,10', 
@@ -514,6 +537,7 @@ class OrderController extends Controller
514 537
             'receiverName.required'           => '收货人不能为空', 
515 538
             'receiverName.between'           => '收货人不能超过6个字符',                  
516 539
             'receiverMobile.required'           => '收货人手机号不能为空',                   
540
+            'buyer_phone.required'           => '买家手机号不能为空',                   
517 541
             'receiverMobile.regex'           => '收货人手机号格式有误',                   
518 542
             'fanTime.required'           => '加粉时间不能为空',              
519 543
             'receiverState.required'           => '省不能为空',   
@@ -625,6 +649,13 @@ class OrderController extends Controller
625 649
         $order['delivery_date'] = !empty($request->input('delivery_date')) ? $request->input('delivery_date') : date('Y-m-d'); //发货日期
626 650
         $order['order_status'] = (int)$request->input('order_status');
627 651
         $order['payment_type'] = (int)$request->input('payment_type'); //支付方式
652
+        $order['buyer_phone'] = $request->input('buyer_phone'); 
653
+        $order['use_coupon'] = (int)$request->input('use_coupon'); 
654
+        $order['use_b_gift'] = (int)$request->input('use_b_gift'); 
655
+        $m_gift_id = (int)$request->input('m_gift_id');
656
+        if($m_gift_id>0){
657
+            $order['use_m_gift'] = 1;
658
+        }
628 659
        
629 660
         //充值卡验证余额
630 661
         if($order['payment_type'] == 4){
@@ -698,6 +729,63 @@ class OrderController extends Controller
698 729
                     $order_skus_insert = DB::table('order_goods_skus')->insert($order_skus);
699 730
                 }
700 731
 
732
+                #加赠品逻辑
733
+                $use_coupon = (int)$request->input('use_coupon');
734
+                $use_b_gift = (int)$request->input('use_b_gift');
735
+                if($use_coupon == 1){
736
+                    $coupon = DB::table('customer_coupons')->where('phone', $order['buyer_phone'])->where('is_use',0)->orderBy('id', 'desc')->first();
737
+                    if(!empty($coupon)){
738
+                        $cup = array();
739
+                        $cup['is_use'] = 1;
740
+                        $cup['use_time'] = date('Y-m-d H:i:s');
741
+                        $cup['order_id'] = $res;
742
+                        DB::table('customer_coupons')->where('id', $coupon->id)->update($cup);
743
+                    }
744
+                }
745
+                if($m_gift_id>0){
746
+                    $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
747
+                    $order_m_gift = array();
748
+                    $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
749
+                    $order_m_gift['sku_id'] = $m_gift->sku_id;
750
+                    $order_m_gift['order_id'] = $res;
751
+                    $order_m_gift['goods_id'] = $m_sku->goodsCode;
752
+                    $order_m_gift['num'] = $m_gift->num;
753
+                    $order_m_gift['price'] = $m_sku->price;
754
+                    $order_m_gift['gift_id'] = $m_gift_id;
755
+                    $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
756
+                    #记录领取
757
+                    $receive_gift = array();
758
+                    $receive_gift['phone'] = $order['buyer_phone'];
759
+                    $receive_gift['dtime'] = date('Y-m-d');
760
+                    $receive_gift['order_id'] = $res;
761
+                    $receive_gift['gift_id'] = $m_gift_id;
762
+                    $receive_gift['gift_type'] = 0;
763
+                    DB::table('customer_gift_receives')->insert($receive_gift);
764
+                }
765
+                $mdate = date('Y-m-01');
766
+                if($use_b_gift>0){
767
+                    $b_gifts = DB::table('customer_month_gift')->where('mtime', $mdate)->where('type', 1)->get();
768
+                    $b_gifts = json_decode(json_encode($b_gifts),true);
769
+                    foreach($b_gifts as $b_gift){
770
+                        $order_b_gift = array();
771
+                        $b_sku = GoodsSkus::where('id', $b_gift['sku_id'])->first();
772
+                        $order_b_gift['sku_id'] = $b_gift['sku_id'];
773
+                        $order_b_gift['order_id'] = $res;
774
+                        $order_b_gift['goods_id'] = $b_sku->goodsCode;
775
+                        $order_b_gift['num'] = $b_gift['num'];
776
+                        $order_b_gift['price'] = $b_sku->price;
777
+                        $order_b_gift['gift_id'] = $b_gift['id'];
778
+                        $order_gift_insert = DB::table('order_goods_skus')->insert($order_b_gift);
779
+                    }
780
+                    #记录领取
781
+                    $receive_gift = array();
782
+                    $receive_gift['phone'] = $order['buyer_phone'];
783
+                    $receive_gift['dtime'] = date('Y-m-d');
784
+                    $receive_gift['order_id'] = $res;
785
+                    $receive_gift['gift_type'] = 1;
786
+                    DB::table('customer_gift_receives')->insert($receive_gift);
787
+                }
788
+
701 789
                 #新加逻辑,若付款方式为充值卡/消费记录
702 790
                 if($order['payment_type'] == 4){
703 791
                     $consum = new CustomerConsum();
@@ -763,7 +851,7 @@ class OrderController extends Controller
763 851
         //$order['deposit_phone'] = $order['receiverMobile'];
764 852
         $order['receiverMobile'] = substr($order['receiverMobile'], 0, 3).'****'.substr($order['receiverMobile'], 7);
765 853
         $order['goods'] = '';
766
-        $order_skus = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->lists('num','sku_id');
854
+        $order_skus = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->whereNull('gift_id')->lists('num','sku_id');
767 855
 
768 856
         $skus = array_keys($order_skus);
769 857
         if(!empty($skus)){
@@ -783,6 +871,71 @@ class OrderController extends Controller
783 871
             $consum = CustomerConsum::select('phone')->where('order_id', $id)->first();
784 872
             $deposit_phone = isset($consum->phone) ? $consum->phone : '';
785 873
         }
874
+
875
+        //下单当月礼品
876
+        $mtime = date('Y-m-01', strtotime($order['create_time']));
877
+        $gift_info = DB::table('customer_month_gift')->where('mtime', $mtime)->get();
878
+        $gift_info = json_decode(json_encode($gift_info), true);
879
+        $m_gift=array();
880
+        $b_gift=array();
881
+        foreach($gift_info as $k=>$val){
882
+            //获取礼品信息
883
+            $goods_name = Goods::where('id', $val['goods_id'])->pluck('name');
884
+            $sku = GoodsSkus::where('id', $val['sku_id'])->first();
885
+            $data = array();
886
+            $data['id'] = $val['id'];
887
+            $data['goods_name'] = $goods_name;
888
+            $data['propsName'] = $sku['propsName'];
889
+            $data['price'] = $sku['price'];
890
+            if($val['type'] == 0){
891
+                $m_gift[] = $data;
892
+            }else{
893
+                $b_gift[] = $data;
894
+            }
895
+        }
896
+
897
+        #获取赠品信息
898
+        $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
899
+        $order_m_gifts = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->lists('id');
900
+        $order_b_gifts = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->lists('id');
901
+
902
+        #查询用户会员信息
903
+        $cust_info = array();
904
+        $cust_info['coupons'] = 0;
905
+        $cust_info['if_m_gift'] = 0;
906
+        $cust_info['if_b_gift'] = 0;
907
+
908
+        $phone = $order['buyer_phone'];
909
+        $time = date('Y-m-d H:i:s');
910
+        $customer_info = DB::table('customer_vip')->where('phone', $phone)->where('is_del', 0)->first();
911
+        if(!empty($customer_info) && $order['create_time']>'2019-11-28'){
912
+            //判断是否过期
913
+            if($customer_info->vip_end_time > $time){
914
+                //未过期,1.获取优惠券,获取当月礼,获取生日礼,判断领取
915
+                $coupons = DB::table('customer_coupons')->where('phone', $phone)->where('is_use', 0)->where('end_time', '>', $time)->first();
916
+                $cust_info['coupons'] = !empty($coupons) ? 1:0;
917
+                //判断是否领取当月礼
918
+                $if_m_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 0)->where('dtime', '>=', $mtime)->first();
919
+                if(empty($if_m_gift)){
920
+                    $cust_info['if_m_gift'] = 1;
921
+                }
922
+                          
923
+                //判断生日礼
924
+                $birth_stime = date('m-d', strtotime($customer_info->birthday.' -3 day'));               
925
+                $birth_etime = date('m-d', strtotime($customer_info->birthday.' +3 day'));      
926
+                $today = date('m-d'); 
927
+                if($today>=$birth_stime && $today<=$birth_etime){
928
+                    //生日期内,判断是否已领
929
+                    $if_b_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 1)->where('dtime', '>=', $mtime)->first();
930
+                    if(empty($if_b_gift)){
931
+                        $cust_info['if_b_gift'] = 1;
932
+                    }
933
+                }
934
+
935
+            }
936
+
937
+        }
938
+
786 939
         return view('order/orderedit', [       
787 940
             'order' => $order,
788 941
             //'categorylist' => $catelist,
@@ -792,6 +945,11 @@ class OrderController extends Controller
792 945
             'str_query'=> 'page='.$page.'&admin_id='.$admin_id.'&stime='.$stime.'&etime='.$etime.'&receiverName='.$receiverName.'&receiverMobile='.$receiverMobile,
793 946
             'last_url' => $last_url,
794 947
             'deposit_phone' => $deposit_phone,
948
+            'm_gift' => $m_gift,
949
+            'b_gift' => $b_gift,
950
+            'order_m_gifts' => $order_m_gifts,
951
+            'order_b_gifts' => $order_b_gifts,
952
+            'cust_info' => $cust_info,
795 953
         ]);
796 954
 
797 955
     }
@@ -869,6 +1027,14 @@ class OrderController extends Controller
869 1027
         //if(!empty($request->input('createTime'))) $order['createTime'] = $request->input('createTime'); // 订单创建时间
870 1028
         $order['order_status'] = (int)$request->input('order_status');
871 1029
         $order['payment_type'] = (int)$request->input('payment_type'); //支付方式
1030
+        $order['use_coupon'] = (int)$request->input('use_coupon');
1031
+        $order['buyer_phone'] = $request->input('buyer_phone');
1032
+        $order['use_b_gift'] = (int)$request->input('use_b_gift');
1033
+
1034
+        $m_gift_id = (int)$request->input('m_gift_id');
1035
+        if($m_gift_id>0){
1036
+            $order['use_m_gift'] = 1;
1037
+        }
872 1038
 
873 1039
         //$order['status'] = (int)$request->input('status');
874 1040
         $order['should_amount'] = $request->input('should_amount');
@@ -971,7 +1137,7 @@ class OrderController extends Controller
971 1137
             $gnum = $request->input('gnum');
972 1138
             if(empty($skus)) $skus = [];
973 1139
             //先删除
974
-            $del_re = DB::table('order_goods_skus')->where('order_id', $id)->whereNotIn('sku_id', $skus)->update(['is_del'=>1]);
1140
+            $del_re = DB::table('order_goods_skus')->where('order_id', $id)->whereNull('gift_id')->whereNotIn('sku_id', $skus)->update(['is_del'=>1]);
975 1141
             if(!empty($skus)){            
976 1142
                 //再同步
977 1143
                 foreach($skus as $k=>$sku_id){
@@ -1076,6 +1242,100 @@ class OrderController extends Controller
1076 1242
                 Oplog::addLog($self_id, $self_name, $context, $type, $tables, $data_id);
1077 1243
             }  
1078 1244
 
1245
+            #新加逻辑,使用优惠券,赠礼
1246
+            $use_coupon = (int)$request->input('use_coupon');
1247
+            $use_b_gift = (int)$request->input('use_b_gift');
1248
+
1249
+            if($use_coupon == 1 && $old_order->use_coupon != 1){
1250
+                $coupon = DB::table('customer_coupons')->where('phone', $order['buyer_phone'])->where('is_use',0)->orderBy('id', 'desc')->first();
1251
+                if(!empty($coupon)){
1252
+                    $cup = array();
1253
+                    $cup['is_use'] = 1;
1254
+                    $cup['use_time'] = date('Y-m-d H:i:s');
1255
+                    $cup['order_id'] = $id;
1256
+                    DB::table('customer_coupons')->where('id', $coupon->id)->update($cup);
1257
+                }
1258
+            }elseif($use_coupon == 0 && $old_order->use_coupon == 1){
1259
+                DB::table('customer_coupons')->where('order_id', $id)->update(['is_use'=>0]);
1260
+            }
1261
+             #查询本单使用赠礼
1262
+            $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
1263
+            $order_m_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->pluck('id');
1264
+            $order_b_gift_ids = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->lists('id');
1265
+
1266
+            if($m_gift_id>0 && empty($order_m_gift_id) ){
1267
+                $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
1268
+                $order_m_gift = array();
1269
+                $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
1270
+                $order_m_gift['sku_id'] = $m_gift->sku_id;
1271
+                $order_m_gift['order_id'] = $id;
1272
+                $order_m_gift['goods_id'] = $m_sku->goodsCode;
1273
+                $order_m_gift['num'] = $m_gift->num;
1274
+                $order_m_gift['price'] = $m_sku->price;
1275
+                $order_m_gift['gift_id'] = $m_gift_id;
1276
+                $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
1277
+                #记录领取
1278
+                $receive_gift = array();
1279
+                $receive_gift['phone'] = $order['buyer_phone'];
1280
+                $receive_gift['dtime'] = date('Y-m-d');
1281
+                $receive_gift['order_id'] = $id;
1282
+                $receive_gift['gift_id'] = $m_gift_id;
1283
+                $receive_gift['gift_type'] = 0;
1284
+                DB::table('customer_gift_receives')->insert($receive_gift);
1285
+            }elseif($m_gift_id>0 && $m_gift_id != $order_m_gift_id){
1286
+                DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
1287
+                DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
1288
+
1289
+                $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
1290
+                $order_m_gift = array();
1291
+                $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
1292
+                $order_m_gift['sku_id'] = $m_gift->sku_id;
1293
+                $order_m_gift['order_id'] = $id;
1294
+                $order_m_gift['goods_id'] = $m_sku->goodsCode;
1295
+                $order_m_gift['num'] = $m_gift->num;
1296
+                $order_m_gift['price'] = $m_sku->price;
1297
+                $order_m_gift['gift_id'] = $m_gift_id;
1298
+                $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
1299
+                #记录领取
1300
+                $receive_gift = array();
1301
+                $receive_gift['phone'] = $order['buyer_phone'];
1302
+                $receive_gift['dtime'] = date('Y-m-d');
1303
+                $receive_gift['order_id'] = $id;
1304
+                $receive_gift['gift_id'] = $m_gift_id;
1305
+                $receive_gift['gift_type'] = 0;
1306
+                DB::table('customer_gift_receives')->insert($receive_gift);
1307
+            }elseif($m_gift_id==0 && $order_m_gift_id>0){
1308
+                DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
1309
+                DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
1310
+            }
1311
+
1312
+            $mdate = date('Y-m-01', strtotime($old_order->create_time));
1313
+            if($use_b_gift>0 && empty($order_b_gift_ids) ){
1314
+                $b_gifts = DB::table('customer_month_gift')->where('mtime', $mdate)->where('type', 1)->get();
1315
+                $b_gifts = json_decode(json_encode($b_gifts),true);
1316
+                foreach($b_gifts as $b_gift){
1317
+                    $order_b_gift = array();
1318
+                    $b_sku = GoodsSkus::where('id', $b_gift['sku_id'])->first();
1319
+                    $order_b_gift['sku_id'] = $b_gift['sku_id'];
1320
+                    $order_b_gift['order_id'] = $id;
1321
+                    $order_b_gift['goods_id'] = $b_sku->goodsCode;
1322
+                    $order_b_gift['num'] = $b_gift['num'];
1323
+                    $order_b_gift['price'] = $b_sku->price;
1324
+                    $order_b_gift['gift_id'] = $b_gift['id'];
1325
+                    $order_gift_insert = DB::table('order_goods_skus')->insert($order_b_gift);
1326
+                }
1327
+                #记录领取
1328
+                $receive_gift = array();
1329
+                $receive_gift['phone'] = $order['buyer_phone'];
1330
+                $receive_gift['dtime'] = date('Y-m-d');
1331
+                $receive_gift['order_id'] = $id;
1332
+                $receive_gift['gift_type'] = 1;
1333
+                DB::table('customer_gift_receives')->insert($receive_gift);
1334
+            }elseif($use_b_gift==0 && !empty($order_b_gift_ids)){
1335
+                DB::table('order_goods_skus')->whereIn('gift_id', $order_b_gift_ids)->where('order_id', $id)->update(['is_del'=>1]);
1336
+                DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_type', 1)->update(['is_del'=>1]);
1337
+            }
1338
+
1079 1339
             DB::commit();
1080 1340
         }catch (Exception $e){
1081 1341
             DB::rollback();
@@ -1125,11 +1385,31 @@ class OrderController extends Controller
1125 1385
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1126 1386
                 }
1127 1387
 
1388
+
1128 1389
                 #更新order_goods_skus状态
1129 1390
                 $mj_status = array();
1130 1391
                 $mj_status['mj_status'] = 2;
1131 1392
                 OrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
1132 1393
 
1394
+                //假如删除订单使用了优惠券,礼品
1395
+                if($order->use_coupon == 1){
1396
+                    DB::table('customer_coupons')->where('order_id', $id)->update(['is_use'=>0]);
1397
+                }
1398
+                 #查询本单使用赠礼
1399
+                $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
1400
+                if(!empty($order_gifts)){
1401
+                    $order_m_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->pluck('id');
1402
+                    $order_b_gift_ids = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->lists('id');
1403
+                    if($order_m_gift_id>0){
1404
+                        DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
1405
+                        DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
1406
+                    }
1407
+                    if(!empty($order_b_gift_ids)){
1408
+                        DB::table('order_goods_skus')->whereIn('gift_id', $order_b_gift_ids)->where('order_id', $id)->update(['is_del'=>1]);
1409
+                        DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_type', 1)->update(['is_del'=>1]);
1410
+                    }
1411
+                }
1412
+
1133 1413
                 #记录操作日志
1134 1414
                 $self_id = session('admin_id');
1135 1415
                 $self_name = session('real_name');            
@@ -1197,10 +1477,30 @@ class OrderController extends Controller
1197 1477
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1198 1478
                 }
1199 1479
 
1480
+
1200 1481
                 #更新order_goods_skus状态,退回库存
1201 1482
                 $mj_status = array();
1202 1483
                 $mj_status['mj_status'] = 2;
1203 1484
                 OrderGoodsSkus::where('order_id', $id)->where('is_del', 0)->update($mj_status);
1485
+
1486
+                //假如删除订单使用了优惠券,礼品
1487
+                if($order->use_coupon == 1){
1488
+                    DB::table('customer_coupons')->where('order_id', $id)->update(['is_use'=>0]);
1489
+                }
1490
+                 #查询本单使用赠礼
1491
+                $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
1492
+                if(!empty($order_gifts)){
1493
+                    $order_m_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->pluck('id');
1494
+                    $order_b_gift_ids = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->lists('id');
1495
+                    if($order_m_gift_id>0){
1496
+                        DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
1497
+                        DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
1498
+                    }
1499
+                    if(!empty($order_b_gift_ids)){
1500
+                        DB::table('order_goods_skus')->whereIn('gift_id', $order_b_gift_ids)->where('order_id', $id)->update(['is_del'=>1]);
1501
+                        DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_type', 1)->update(['is_del'=>1]);
1502
+                    }
1503
+                }
1204 1504
                 
1205 1505
                 #记录操作日志
1206 1506
                 $self_id = session('admin_id');
@@ -1955,5 +2255,47 @@ class OrderController extends Controller
1955 2255
         return $mjOrder['order'];
1956 2256
     }
1957 2257
 
2258
+    /**
2259
+     * 获取手机号会员信息
2260
+     */
2261
+    public function getVip(Request $request){
2262
+        $phone = $request->input('phone');
2263
+        $time = date('Y-m-d H:i:s');
2264
+        $customer_info = DB::table('customer_vip')->where('phone', $phone)->where('is_del', 0)->first();
2265
+        if(!empty($customer_info)){
2266
+            //判断是否过期
2267
+            if($customer_info->vip_end_time > $time){
2268
+                //未过期,1.获取优惠券,获取当月礼,获取生日礼,判断领取
2269
+                $coupons = DB::table('customer_coupons')->where('phone', $phone)->where('is_use', 0)->where('end_time', '>', $time)->first();
2270
+                $customer_info->coupons = !empty($coupons) ? 1:0;
2271
+                //判断是否领取当月礼
2272
+                $mtime = date('Y-m-01');
2273
+                $if_m_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 0)->where('dtime', '>=', $mtime)->first();
2274
+                $customer_info->if_m_gift = 0;
2275
+                if(empty($if_m_gift)){
2276
+                    $customer_info->if_m_gift = 1;
2277
+                }
2278
+                          
2279
+                //判断生日礼
2280
+                $birth_stime = date('m-d', strtotime($customer_info->birthday.' -3 day'));               
2281
+                $birth_etime = date('m-d', strtotime($customer_info->birthday.' +3 day'));      
2282
+                $today = date('m-d'); 
2283
+                $customer_info->if_b_gift = 0;
2284
+                if($today>=$birth_stime && $today<=$birth_etime){
2285
+                    //生日期内,判断是否已领
2286
+                    $if_b_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 1)->where('dtime', '>=', $mtime)->first();
2287
+                    if(empty($if_b_gift)){
2288
+                        $customer_info->if_b_gift = 1;
2289
+                    }
2290
+                }
2291
+
2292
+                exit(json_encode(['code'=>0, 'data'=>$customer_info]));
2293
+            }
2294
+            exit(json_encode(['code'=>1,'msg'=>'会员过期']));
2295
+        }
2296
+
2297
+        exit(json_encode(['code'=>1,'msg'=>'不是会员']));
2298
+    }
2299
+
1958 2300
 }
1959 2301
 

+ 48 - 15
app/Http/Controllers/Api/GoodsController.php

@@ -1,6 +1,7 @@
1 1
 <?php namespace App\Http\Controllers\Api;
2 2
 
3 3
 use App\Goods;
4
+use App\GoodsSkus;
4 5
 use App\Http\Controllers\Controller;
5 6
 use Illuminate\Http\Request;
6 7
 
@@ -8,19 +9,37 @@ class GoodsController extends Controller {
8 9
 
9 10
 	public function index()
10 11
 	{
11
-        $result = Goods::select('gs.id as sku_id', 'goods.id as goods_id', 'goods.name', 'gs.propsName', 'gs.price', 'gs.is_weigh', 'gs.quantity', 'gs.is_white','goods.picUrl','goods.goodsCategoryName')->leftJoin('goods_skus as gs', 'gs.goodsCode', '=', 'goods.id')->where('goods.is_del', 0)->where('gs.is_del', 0)->orderBy('goods.id', 'desc')->get();
12
+        $result = Goods::select('id as goods_id', 'name','picUrl','goodsCategoryName')->where('is_del', 0)->orderBy('goods.id', 'desc')->get();
12 13
         $result = json_decode(json_encode($result), true);
13 14
 
14 15
         $data = array();
15 16
         foreach($result as $value){
16
-            if($value['is_white'] == 0 && $value['quantity'] <= 0){
17
-                $value['stock'] = 0;
17
+            # 获取sku
18
+            $skuList = GoodsSkus::select('id as sku_id','propsName','price','is_white','quantity','is_weigh')->where('goodsCode', $value['goods_id'])->where('is_del', 0)->get();
19
+            $skuList = json_decode(json_encode($skuList),true);
20
+            $sku = array();
21
+            foreach($skuList as $v){
22
+                if($v['is_white'] == 0 && $v['quantity'] <= 0){
23
+                    $v['stock'] = 0;
24
+                } else {
25
+                    $v['stock'] = 1;
26
+                }
27
+                unset($v['is_white']);
28
+                unset($v['quantity']);
29
+                $sku[] = $v;
30
+            }
31
+            $value['sku_num'] = count($sku);
32
+            if(1 == $value['sku_num']){
33
+                $value['stock'] = $sku[0]['stock'];
34
+                $value['is_weigh'] = $sku[0]['is_weigh'];
35
+            }
36
+            $value['sku_list'] = $sku;
37
+
38
+            if('0' == $value['goodsCategoryName']) {
39
+                $data['其它'][] = $value;
18 40
             } else {
19
-                $value['stock'] = 1;
41
+                $data[$value['goodsCategoryName']][] = $value;
20 42
             }
21
-            unset($value['is_white']);
22
-            unset($value['quantity']);
23
-            $data[$value['goodsCategoryName']][] = $value;
24 43
         }
25 44
 
26 45
         return self::returnValue($data,200);
@@ -29,17 +48,31 @@ class GoodsController extends Controller {
29 48
 	public function searchGoods(Request $request)
30 49
     {
31 50
         $name = trim($request->input('name'));
32
-        $result = Goods::select('gs.id as sku_id', 'goods.id as goods_id', 'goods.name', 'gs.propsName', 'gs.price', 'gs.is_weigh', 'gs.quantity', 'gs.is_white','goods.picUrl')->leftJoin('goods_skus as gs', 'gs.goodsCode', '=', 'goods.id')->where('goods.name', 'like', '%'.$name.'%')->where('goods.is_del', 0)->where('gs.is_del', 0)->orderBy('goods.id', 'desc')->get();
51
+        $result = Goods::select('id as goods_id', 'name','picUrl','goodsCategoryName')->where('name', 'like', '%'.$name.'%')->where('is_del', 0)->orderBy('id', 'desc')->get();
33 52
         $result = json_decode(json_encode($result), true);
34 53
         $data = array();
35
-        foreach ($result as $value) {
36
-            if($value['is_white'] == 0 && $value['quantity'] <= 0){
37
-                $value['stock'] = 0;
38
-            } else {
39
-                $value['stock'] = 1;
54
+        foreach($result as $value){
55
+            # 获取sku
56
+            $skuList = GoodsSkus::select('id as sku_id','propsName','price','is_white','quantity','is_weigh')->where('goodsCode', $value['goods_id'])->where('is_del', 0)->get();
57
+            $skuList = json_decode(json_encode($skuList),true);
58
+            $sku = array();
59
+            foreach($skuList as $v){
60
+                if($v['is_white'] == 0 && $v['quantity'] <= 0){
61
+                    $v['stock'] = 0;
62
+                } else {
63
+                    $v['stock'] = 1;
64
+                }
65
+                unset($v['is_white']);
66
+                unset($v['quantity']);
67
+                $sku[] = $v;
68
+            }
69
+            $value['sku_num'] = count($sku);
70
+            if(1 == $value['sku_num']){
71
+                $value['stock'] = $sku[0]['stock'];
72
+                $value['is_weigh'] = $sku[0]['is_weigh'];
40 73
             }
41
-            unset($value['is_white']);
42
-            unset($value['quantity']);
74
+            $value['sku_list'] = $sku;
75
+
43 76
             $data[] = $value;
44 77
         }
45 78
 

+ 5 - 2
app/Http/Controllers/Api/LoginController.php

@@ -36,9 +36,12 @@ class LoginController extends Controller
36 36
         }
37 37
 
38 38
         if($res = Hash::check($password, $admin->password)){
39
-            return self::returnValue(['admin_id'=>$admin->id],200);
39
+            #角色
40
+            $role = AdminRole::where('user_id', '=', $admin->id)->first();
41
+            return self::returnValue(['admin_id'=>$admin->id,'role'=>$role->role_name],200);
40 42
         }else{
41 43
             return self::returnValue('密码错误',2002);
42 44
         }
45
+
43 46
     }
44
-}
47
+}

File diff suppressed because it is too large
+ 670 - 0
app/Http/Controllers/Api/OrderController.php


+ 4 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -17,4 +17,8 @@ class VerifyCsrfToken extends BaseVerifier {
17 17
 		return parent::handle($request, $next);
18 18
 	}
19 19
 
20
+	protected $except = [
21
+	    'api/*'
22
+    ];
23
+
20 24
 }

+ 24 - 5
app/Http/routes.php

@@ -88,6 +88,7 @@ Route::group(['prefix' => 'admin'], function(){
88 88
         Route::post('/order/setrefundinfo', 'Admin\OrderController@set_refund');  //设为退货 用于c仓同步到卖家取消订单,不删除单子
89 89
         Route::get('/order/setverify/{id}', 'Admin\OrderController@setverify');  //设为已审核
90 90
         Route::get('/order/setverifymore', 'Admin\OrderController@setverifymore');  //设为已审核
91
+        Route::get('/order/getVip', 'Admin\OrderController@getVip');  //获取会员信息
91 92
 
92 93
         //分销订单管理
93 94
         Route::get('/fxorder/index', 'Admin\FxOrderController@orderindex');
@@ -297,9 +298,24 @@ Route::group(['prefix' => 'admin'], function(){
297 298
         //编辑充值方式
298 299
         Route::get('deposit/editPayType', 'Admin\CustomerDepositController@editPayType');
299 300
 
300
-        //用户订单统计
301
+        //用户盈利模型
301 302
         Route::get('statistics/customerOrder','Admin\StatisticsController@customerOrder');
302 303
 
304
+        //会员录入管理
305
+        Route::get('customer/vipList','Admin\CustomerDepositController@vipCustomerList');
306
+        Route::get('customer/vipCreate','Admin\CustomerDepositController@addVipCustomer');
307
+        Route::get('customer/vipUpdate','Admin\CustomerDepositController@editVipCustomer');
308
+        Route::post('customer/addVip','Admin\CustomerDepositController@storeVipCustomer');
309
+        Route::post('customer/editVip','Admin\CustomerDepositController@updateVipCustomer');
310
+        Route::get('customer/vipUp','Admin\CustomerDepositController@vipUp');
311
+        Route::get('customer/vipDel','Admin\CustomerDepositController@vipDel');
312
+
313
+        //会员礼品管理
314
+        Route::get('customer/giftList','Admin\CustomerDepositController@monthGiftList');
315
+        Route::get('customer/giftAdd','Admin\CustomerDepositController@addMonthGift');
316
+        Route::get('customer/giftEdit','Admin\CustomerDepositController@editMonthGift');
317
+        Route::post('customer/giftStore','Admin\CustomerDepositController@monthGiftStore');
318
+        Route::post('customer/giftUpdate','Admin\CustomerDepositController@monthGiftUpdate');
303 319
     });
304 320
     
305 321
 });
@@ -310,10 +326,6 @@ Route::group(['prefix' => 'api'], function() {
310 326
     Route::get('/template/qrcode', 'Api\TemplateController@salerQrcode');
311 327
     Route::get('/template/addLongLog', 'Api\TemplateController@addLongLog');
312 328
     Route::get('/dayGrandTotal', 'Api\TemplateController@dayGrandTotal');
313
-
314
-});
315
-
316
-Route::group(['prefix' => 'api'], function(){
317 329
     #h5登录
318 330
     Route::post('/login','Api\LoginController@doLogin');
319 331
 
@@ -321,4 +333,11 @@ Route::group(['prefix' => 'api'], function(){
321 333
     Route::get('/goodsList','Api\GoodsController@index');
322 334
     #添加商品-商品搜索
323 335
     Route::post('/searchGoods','Api\GoodsController@searchGoods');
336
+
337
+    Route::get('/order/orderList', 'Api\OrderController@orderList');
338
+    Route::post('/order/orderstore', 'Api\OrderController@orderstore');
339
+    Route::post('/order/orderupdate', 'Api\OrderController@orderupdate');
340
+    Route::get('/order/getAddress', 'Api\OrderController@getAddress');
341
+    Route::get('/order/getBalance', 'Api\OrderController@getBalance');
342
+    Route::post('/order/setverify', 'Api\OrderController@setverify');
324 343
 });

+ 1 - 1
app/Oplog.php

@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
12 12
 class Oplog extends Model
13 13
 {
14 14
     public $timestamps = false;
15
-    protected $table = "Oplog";
15
+    protected $table = "oplog";
16 16
  
17 17
  	/**
18 18
  	 * 记录操作

+ 3 - 2
resources/views/admin/index.blade.php

@@ -1,4 +1,3 @@
1
-
2 1
 @extends('admin/master')
3 2
 @section('content')
4 3
     <header class="navbar-wrapper">
@@ -27,6 +26,7 @@
27 26
                         <li @if(!isset($res['admin/all'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/admin/all')}}" data-title="用户列表" href="javascript:void(0)">用户列表</a></li>
28 27
                         <li @if(!isset($res['admin/teamSalers'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/admin/teamSalers')}}" data-title="团队用户列表" href="javascript:void(0)">团队用户列表</a></li>
29 28
                         <li @if(!isset($res['admin/all'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/admin/teamindex')}}" data-title="团队列表" href="javascript:void(0)">团队列表</a></li>
29
+                        <li @if(!isset($res['customer/monthGift'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/customer/giftList')}}" data-title="会员赠礼管理" href="javascript:void(0)">会员赠礼管理</a></li>
30 30
                     </ul>
31 31
                 </dd>
32 32
             </dl>
@@ -74,7 +74,8 @@
74 74
                         <li @if(!isset($res['custreport/total'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/custreport/totalindex')}}" data-title="运营上报投放数据" href="javascript:void(0)">运营上报投放数据</a></li>
75 75
                         <li @if(!isset($res['custreport/detail'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/custreport/detailindex')}}" data-title="销售上报加粉数据" href="javascript:void(0)">销售上报加粉数据</a></li>
76 76
                         <li @if(!isset($res['custreport/disCostList'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/custreport/disCostList')}}" data-title="上报地域投入数据" href="javascript:void(0)">上报地域投入数据</a></li>
77
-                        <li @if(!isset($res['admin/qrcode'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/admin/uploadQrcodeEdit')}}" data-title="微信二维码上传" href="javascript:void(0)">微信二维码上传</a></li>                        
77
+                        <li @if(!isset($res['admin/qrcode'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/admin/uploadQrcodeEdit')}}" data-title="微信二维码上传" href="javascript:void(0)">微信二维码上传</a></li>
78
+                        <li @if(!isset($res['customer/vipList'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/customer/vipList')}}" data-title="会员用户录入" href="javascript:void(0)">会员用户录入</a></li>
78 79
                     </ul>
79 80
                 </dd>
80 81
             </dl>

File diff suppressed because it is too large
+ 339 - 0
resources/views/customer/customerGiftAdd.blade.php


File diff suppressed because it is too large
+ 339 - 0
resources/views/customer/customerGiftEdit.blade.php


+ 98 - 0
resources/views/customer/customerGiftList.blade.php

@@ -0,0 +1,98 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    @if(session('info'))
5
+        <div class="Huialert Huialert-info" onclick="$(this).remove()" id="info">
6
+            {{session('info')}}
7
+        </div>
8
+    @endif
9
+    <div class="page-container">
10
+        <div>
11
+            <input class="input-text" style="width:5%;text-align:center" type="text" value="赠礼类型"/>
12
+            <select style="width:6%;text-align:center" id='type' name="type" class="select-box">
13
+                <option value="-1" @if($type=='-1') selected @endif>-- 请选择--</option>
14
+                <option value="1" @if($type==1) selected @endif>生日赠礼</option>
15
+                <option value="0" @if($type==0) selected @endif>12月赠礼</option>
16
+            </select>
17
+            <a class="btn btn-primary radius" onclick="gift_search()" href="javascript:;">搜索</a>
18
+            <a class="btn btn-primary radius" onclick="gift_add('新增')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加礼品</a>
19
+        </div>
20
+        <div class="mt-20">
21
+            <table class="table table-border table-bordered table-bg table-hover table-sort">
22
+                <thead>
23
+                <tr class="text-c">
24
+                    <th width="10%">ID</th>
25
+                    <th width="10%">商品名称</th>
26
+                    <th width="10%">商品图片</th>
27
+                    <th width="10%">商品规格</th>
28
+                    <th width="10%">商品数量</th>
29
+                    <th width="10%">类型</th>
30
+                    <th width="10%">日期</th>
31
+                    <th width="10%">操作</th>
32
+                </tr>
33
+                </thead>
34
+                <tbody>
35
+                @if($result)
36
+                    @foreach($result as $a)
37
+                        <tr class="text-c">
38
+                            <td class="text-c">{{$a['id']}}</td>
39
+                            <td class="text-c">{{$a['goods']['name']}}</td>
40
+                            <td class="text-c"><img style="width:100px;" src="{{$a['goods']['picUrl']}}"/></td>
41
+                            <td class="text-c">{{$a['sku']['propsName']}}</td>
42
+                            <td class="text-c">{{$a['num']}}</td>
43
+                            <td class="text-c">{{$a['type'] == 0 ? '12月赠礼' : '生日赠礼'}}</td>
44
+                            <td class="text-c">{{$a['mtime']}}</td>
45
+                            <td class="f-14 product-brand-manage">
46
+                                <a style="text-decoration:none" onClick='gift_edit("{{$a['id']}}")' href="javascript:;" title="编辑"><span class="btn btn-primary radius">编辑</span></a>
47
+                            </td>
48
+                        </tr>
49
+                    @endforeach
50
+                @endif
51
+                </tbody>
52
+            </table>
53
+        </div>
54
+        <div id="page" class="page_div"></div>
55
+    </div>
56
+
57
+    <!--_footer 作为公共模版分离出去-->
58
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
59
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
60
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
61
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
62
+    <script type="text/javascript" src="/admin/lib/page/paging.js"></script>
63
+    <!--/_footer 作为公共模版分离出去-->
64
+    <!--/_footer 作为公共模版分离出去-->
65
+
66
+    <script type="text/javascript">
67
+        $(function(){
68
+            setTimeout("$('#info').hide()",3000);
69
+        });
70
+        /*管理员-添加*/
71
+        function gift_add(){
72
+            location.href = '/admin/customer/giftAdd';
73
+        }
74
+        /*管理员-编辑*/
75
+        function gift_edit(id){
76
+            location.href = "/admin/customer/giftEdit?id="+id;
77
+        }
78
+
79
+        function gift_search(){
80
+            var type = $('#type').val();
81
+            location.href='giftList?page='+num+'&type='+type;
82
+        }
83
+
84
+        $("#page").paging({
85
+            pageNo:{{$page}},
86
+            totalPage: {{$pages}},
87
+            totalSize: {{$count}},
88
+            callback: function(num) {
89
+                var type = $('#type').val();
90
+                location.href='giftList?page='+num + '&type='+type;
91
+            }
92
+        })
93
+
94
+
95
+    </script>
96
+    </body>
97
+
98
+@endsection

+ 0 - 0
resources/views/customer/customerInformationQuery.blade.php


+ 76 - 0
resources/views/customer/vipCustomerCreate.blade.php

@@ -0,0 +1,76 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    @if(count($errors) > 0)
5
+        <div class="Huialert Huialert-info" id="error">
6
+            @foreach($errors->all() as $error)
7
+                <li>{{$error}}</li>
8
+            @endforeach
9
+        </div>
10
+    @endif
11
+    <div class="page-container">
12
+        <form action="/admin/customer/addVip" method="post" class="form form-horizontal" enctype="multipart/form-data">
13
+            <input type="hidden" name="_token" value="{{ csrf_token() }}" />
14
+            <div class="row cl">
15
+                <label class="form-label col-xs-4 col-sm-2">
16
+                    姓名:</label>
17
+                <div class="formControls col-xs-6 col-sm-6">
18
+                    <input type="text" class="input-text" value="{{old('name')}}" placeholder="" name="name">
19
+                </div>
20
+            </div>
21
+            <div class="row cl">
22
+                <label class="form-label col-xs-4 col-sm-2">
23
+                    手机号:</label>
24
+                <div class="formControls col-xs-6 col-sm-6">
25
+                    <input type="text" class="input-text" value="{{old('phone')}}" placeholder="" name="phone">
26
+                    <br>
27
+                </div>
28
+            </div>
29
+            <div class="row cl">
30
+                <label class="form-label col-xs-4 col-sm-2">
31
+                    生日:</label>
32
+                <div class="formControls col-xs-6 col-sm-6">
33
+                    <input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" autocomplete="off" class="input-text Wdate" name="birthday" value="{{old('birthday')}}">
34
+                    <br>
35
+                </div>
36
+            </div>
37
+            <div class="row cl">
38
+                <label for="" class="form-label col-xs-4 col-sm-2">选择销售:</label>
39
+                <div class="formControls col-xs-6 col-sm-6">
40
+                    <select style="text-align:center" id='admin_id' class="select-box" name="admin_id">
41
+                        <option value="0" selected class="select-option">-- 选择销售 --</option>
42
+                        @foreach($adminlist as $v)
43
+                            <option value="{{$v['id']}}" @if(old('admin_id')==$v['id']) selected @endif class="select-option">{{$v['realname']}}</option>
44
+                        @endforeach
45
+                    </select>
46
+                </div>
47
+            </div>
48
+            <div class="row cl">
49
+                <div class="col-9 col-offset-2">
50
+                    <button class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>&nbsp;
51
+                    <button class="btn btn-default" type="reset" onclick="return_index();">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>&nbsp;
52
+                    {{--<a href="javascript:void(0)" class="btn btn-default radius" onclick="redirect('{{url('/admin/admin/all')}}')">返回并查看结果</a>--}}
53
+                </div>
54
+            </div>
55
+        </form>
56
+    </div>
57
+    <!--_footer 作为公共模版分离出去-->
58
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
59
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
60
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
61
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
62
+    <!--/_footer 作为公共模版分离出去-->
63
+
64
+    <!--请在下方写此页面业务相关的脚本-->
65
+    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
66
+    <script type="text/javascript">
67
+        $(function(){
68
+            setTimeout("$('#error').hide()",3000);
69
+        });
70
+        /*返回*/
71
+        function return_index(){
72
+            location.href='/admin/customer/vipList';
73
+        }
74
+    </script>
75
+    </body>
76
+@endsection

+ 84 - 0
resources/views/customer/vipCustomerEdit.blade.php

@@ -0,0 +1,84 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    @if(count($errors) > 0)
5
+        <div class="Huialert Huialert-info" id="error">
6
+            @foreach($errors->all() as $error)
7
+                <li>{{$error}}</li>
8
+            @endforeach
9
+        </div>
10
+    @endif
11
+    <style type="text/css">
12
+        #good_sku{
13
+            position: absolute;
14
+            z-index: 9;
15
+            background: #ffffff;
16
+            box-shadow: 1px 1px 1px 1px #ccc;
17
+            width: calc(100% - 30px);
18
+        }
19
+        #good_sku li{
20
+            font-size: 12px;
21
+            line-height: 24px;
22
+            cursor: pointer;
23
+            padding: 5px 10px;
24
+        }
25
+        #good_sku li:hover{
26
+            background: #eaeaea;
27
+        }
28
+    </style>
29
+    <div class="page-container">
30
+        <form id='order-form' action="/admin/customer/editVip" method="post" class="form form-horizontal" enctype="multipart/form-data">
31
+            <input type="hidden" name="_token" value="{{ csrf_token() }}" />
32
+                <input type="hidden" name="id" value="{{$info['id']}}" />
33
+                <div class="row cl">
34
+                    <label class="form-label col-xs-4 col-sm-2">
35
+                        姓名:</label>
36
+                    <div class="formControls col-xs-6 col-sm-6">
37
+                        <input type="text" class="input-text" value="{{$info['name']}}" placeholder="请输入用户姓名" name="name">
38
+                    </div>
39
+                </div>
40
+                <div class="row cl">
41
+                    <label class="form-label col-xs-4 col-sm-2">
42
+                        生日:</label>
43
+                    <div class="formControls col-xs-6 col-sm-6">
44
+                        <input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" autocomplete="off" class="input-text Wdate" name="birthday" value="{{$info['birthday']}}">
45
+                    </div>
46
+                </div>
47
+            <div class="row cl">
48
+                <label for="" class="form-label col-xs-4 col-sm-2">选择销售:</label>
49
+                <div class="formControls col-xs-6 col-sm-6">
50
+                    <select style="text-align:center" id='admin_id' class="select-box" name="admin_id">
51
+                        @foreach($adminlist as $v)
52
+                            <option value="{{$v['id']}}" @if($info['admin_id'] == $v['id']) selected @endif class="select-option">{{$v['realname']}}</option>
53
+                        @endforeach
54
+                    </select>
55
+                </div>
56
+            </div>
57
+            <div class="row cl">
58
+                <div class="col-9 col-offset-2">
59
+                    <button class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>&nbsp;
60
+                    <button class="btn btn-default" type="reset" onclick="return_index();">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>&nbsp;
61
+                </div>
62
+            </div>
63
+        </form>
64
+    </div>
65
+    <!--_footer 作为公共模版分离出去-->
66
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
67
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
68
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
69
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
70
+    <!--/_footer 作为公共模版分离出去-->
71
+
72
+    <!--请在下方写此页面业务相关的脚本-->
73
+    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
74
+    <script type="text/javascript">
75
+        $(function() {
76
+            setTimeout("$('#error').hide()", 3000);
77
+        })
78
+        /*返回*/
79
+        function return_index(){
80
+            location.href='/admin/customer/vipList';
81
+        }
82
+    </script>
83
+    </body>
84
+@endsection

+ 152 - 0
resources/views/customer/vipCustomerList.blade.php

@@ -0,0 +1,152 @@
1
+@extends('admin/master')
2
+@section('content')
3
+<body>
4
+@if(session('info'))
5
+<div class="Huialert Huialert-info" onclick="$(this).remove()" id="info">
6
+    {{session('info')}}
7
+</div>
8
+@endif
9
+<div class="page-container">
10
+    <div>
11
+        @if($self_role != '销售')
12
+            <input class="input-text" style="width:6%;text-align:center" type="text" value="所属团队"/>
13
+            <select style="width:10%;text-align:center" class="select-box" id='team_id' name="team_id">
14
+                <option value="0" @if($team_id=='') selected @endif class="select-option">-- 选择团队 --</option>
15
+                @foreach($teamlist as $v)
16
+                    <option value="{{$v['id']}}" @if($team_id==$v['id']) selected @endif class="select-option">{{$v['name']}}</option>
17
+                @endforeach
18
+            </select>
19
+            <input class="input-text" style="width:6%;text-align:center" type="text" value="所属销售"/>
20
+            <select style="width:8%;text-align:center" id='admin_id' class="select-box" name="admin_id">
21
+                <option value="0" @if($admin_id=='') selected @endif class="select-option">-- 选择销售 --</option>
22
+                @foreach($adminlist as $v)
23
+                    <option value="{{$v['id']}}" @if($admin_id==$v['id']) selected @endif class="select-option">{{$v['realname']}}</option>
24
+                @endforeach
25
+            </select>
26
+        @endif
27
+        <input class="input-text" style="width:6%;text-align:center" type="text" value="客户名"/>
28
+        <input id="name" type="text"  class="input-text" style="width:10%;text-align:center" name="name" value="{{$name?$name:''}}">
29
+        <input class="input-text" style="width:6%;text-align:center" type="text" value="手机号"/>
30
+        <input id="phone" type="text"  class="input-text" style="width:10%;text-align:center" name="phone" value="{{$phone?$phone:''}}">
31
+        <a class="btn btn-primary radius" onclick="user_search()" href="javascript:;">搜索</a>
32
+        <a class="btn btn-primary radius" onclick="user_add('新增')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 新增vip用户</a>
33
+    </div>
34
+    <div class="mt-20">
35
+        <table class="table table-border table-bordered table-bg table-hover table-sort">
36
+            <thead>
37
+            <tr class="text-c">
38
+                <th width="10%">姓名</th>
39
+                <th width="10%">手机号</th>
40
+                <th width="10%">到期时间</th>
41
+                <th width="10%">生日</th>
42
+                <th width="10%">状态</th>
43
+                <th width="10%">操作</th>
44
+            </tr>
45
+            </thead>
46
+            <tbody>
47
+            @if($result)
48
+            @foreach($result as $a)
49
+            <tr class="text-c">
50
+                <td class="text-c">{{$a['name']}}</td>
51
+                <td class="text-c">{{$a['phone']}}</td>
52
+                <td class="text-c">{{$a['vip_end_time']}}</td>
53
+                <td class="text-c">{{$a['birthday']}}</td>
54
+                <td class="text-c">{{$a['is_del'] == 0 ? '启用' : '禁用'}}</td>
55
+                <td class="f-14 product-brand-manage">
56
+                    <a style="text-decoration:none" onClick='user_edit("{{$a['id']}}")' href="javascript:;" title="编辑"><span class="btn btn-primary radius">编辑</span></a>
57
+                    @if($a['is_del']==0)
58
+                        <a style="text-decoration:none" class="ml-5" onClick="user_del(this, '{{$a["id"]}}')" href="javascript:;" title="禁用"><span class="btn btn-danger radius">禁用</span></a>
59
+                    @elseif($a['is_del']==1)
60
+                        <a style="text-decoration:none" class="ml-5" onClick="user_up(this, '{{$a['id']}}')" href="javascript:;" title="启用"><span class="btn btn-success radius">启用</span></a>
61
+                    @endif
62
+                </td>
63
+            </tr>
64
+            @endforeach
65
+            @endif
66
+            </tbody>
67
+        </table>
68
+    </div>
69
+    <div id="page" class="page_div"></div>
70
+</div>
71
+
72
+<!--_footer 作为公共模版分离出去-->
73
+<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
74
+<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
75
+<script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
76
+<script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
77
+<script type="text/javascript" src="/admin/lib/page/paging.js"></script>
78
+<!--/_footer 作为公共模版分离出去-->
79
+<!--/_footer 作为公共模版分离出去-->
80
+
81
+<script type="text/javascript">
82
+    $(function(){
83
+        setTimeout("$('#info').hide()",3000);
84
+    });
85
+    /*管理员-添加*/
86
+    function user_add(){
87
+        location.href = '/admin/customer/vipCreate';
88
+    }
89
+    /*管理员-编辑*/
90
+    function user_edit(id){
91
+        location.href = "/admin/customer/vipUpdate?id="+id;
92
+    }
93
+
94
+    /*vip用户-禁用*/
95
+    function user_del(obj,id){
96
+        layer.confirm('确认要禁用吗?',function(index){
97
+            $.ajax({
98
+                type: 'GET',
99
+                url: '/admin/customer/vipDel?id='+id,
100
+                dataType: 'json',
101
+                success: function(data){
102
+                    if(data == 1){
103
+                        location.reload();
104
+                    }
105
+                }
106
+            });
107
+        });
108
+    }
109
+
110
+    /*vip用户-启用*/
111
+    function user_up(obj,id){
112
+        layer.confirm('确认要启用吗?',function(index){
113
+            $.ajax({
114
+                type: 'GET',
115
+                url: '/admin/customer/vipUp?id='+id,
116
+                dataType: 'json',
117
+                success: function(data){
118
+                    if(data == 1){
119
+                        location.reload();
120
+                    }
121
+                }
122
+            });
123
+        });
124
+    }
125
+
126
+
127
+    function user_search(){
128
+        var phone = $('#phone').val();
129
+        var name = $('#name').val();
130
+        var team_id = $('#team_id').val();
131
+        var admin_id = $('#admin_id').val();
132
+        location.href='vipList?page='+num + '&name='+name + '&phone='+phone + '&team_id=' + team_id + '&admin_id=' + admin_id;
133
+    }
134
+
135
+    $("#page").paging({
136
+        pageNo:{{$page}},
137
+        totalPage: {{$pages}},
138
+        totalSize: {{$count}},
139
+    callback: function(num) {
140
+        var phone = $('#phone').val();
141
+        var name = $('#name').val();
142
+        var team_id = $('#team_id').val();
143
+        var admin_id = $('#admin_id').val();
144
+        location.href='vipList?page='+num + '&name='+name + '&phone='+phone+ '&team_id=' + team_id + '&admin_id=' + admin_id;
145
+    }
146
+    })
147
+
148
+
149
+</script>
150
+</body>
151
+
152
+@endsection

+ 98 - 1
resources/views/order/ordercreate.blade.php

@@ -40,6 +40,24 @@
40 40
                 </div>
41 41
             </div>
42 42
             
43
+            <div class="row cl">
44
+                <label class="form-label col-xs-4 col-sm-2">
45
+                    <font color='red'>* </font>买家手机号:</label>
46
+                <div class="formControls col-xs-6 col-sm-6">
47
+                    <input type="text" class="input-text" value="{{old('buyer_phone')}}" placeholder="" onkeyup="getVip()" name="buyer_phone">
48
+                </div>
49
+            </div>
50
+
51
+             <div id='use_coupon_div' class="row cl" style="display: none">
52
+                <label class="form-label col-xs-4 col-sm-2">
53
+                    <font color='red'>* </font>是否使用优惠券:</label>
54
+                <div class="formControls col-xs-6 col-sm-6">
55
+                    <input type="radio" name="use_coupon"  value="0" checked disabled>
56
+                    <label for="status-0" style="margin-right: 27px;">否</label>
57
+                    <input id='use_coupon_1' type="radio" name="use_coupon" value="1"  disabled>
58
+                    <label for="status-1">是</label>
59
+                </div>
60
+            </div>
43 61
             
44 62
             <div class="row cl">
45 63
                 <label class="form-label col-xs-4 col-sm-2">
@@ -177,7 +195,33 @@
177 195
                     
178 196
                 </div>
179 197
                
180
-            </div><br>       
198
+            </div><br>   
199
+
200
+            <div id='m_gift_div' class="row cl" style="display: none">
201
+                <label class="form-label col-xs-4 col-sm-2">
202
+                    <font color='red'> </font>选择会员当月赠品</label>
203
+                <div class="formControls col-xs-6 col-sm-6">
204
+                    <span class="select-box">
205
+                        <select  size="1" name="m_gift_id" id='m_gift'>                           
206
+                            <option value="0" @if(old('m_gift_id')=='0') selected @endif>- 请选择 -</option>
207
+                            @foreach($m_gift as $item)
208
+                                <option value="{{$item['id']}}" @if(old('m_gift_id')==$item['id']) selected @endif>{{$item['goods_name']}}【{{$item['propsName']}} ¥{{$item['price']}}】</option>
209
+                            @endforeach                                        
210
+                        </select>
211
+                    </span>
212
+                </div>
213
+            </div> 
214
+
215
+            <div id='b_gift_div' class="row cl" style="display: none">
216
+                <label class="form-label col-xs-4 col-sm-2">
217
+                    <font color='red'> </font>是否使用生日赠品</label>
218
+                <div class="formControls col-xs-6 col-sm-6">
219
+                    <input type="radio" name="use_b_gift"  value="0" checked disabled >
220
+                    <label for="status-0" style="margin-right: 27px;">否</label>
221
+                    <input id='use_b_gift_1' type="radio" name="use_b_gift" value="1" disabled>
222
+                    <label for="status-1">是</label>
223
+                </div>
224
+            </div>    
181 225
 
182 226
             <div class="row cl">
183 227
                 <label class="form-label col-xs-4 col-sm-2">
@@ -791,6 +835,12 @@
791 835
         var is_ok = 1;
792 836
         var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
793 837
         if(payment_type==4){
838
+            //使用充值卡不能使用优惠券验证
839
+            use_coupon = $("input[type='radio'][name='use_coupon']:checked").val();
840
+            if(use_coupon == 1){
841
+                layer.msg('充值卡不能和优惠券同时使用!',{icon:2,time:1500});
842
+                return false;
843
+            }
794 844
             var phone = $("input[name=deposit_phone]").val();
795 845
             if(!phone){
796 846
                 is_ok = 0;
@@ -821,6 +871,53 @@
821 871
 
822 872
      }
823 873
 
874
+     function getVip(){
875
+            var phone = $('input[name=buyer_phone]').val();
876
+            var reg = /^1\d{10}$/
877
+            if(reg.test(phone)){
878
+                $.ajax({
879
+                    'url': '/admin/order/getVip?phone='+phone,
880
+                    'type': 'get',
881
+                    'dateType': 'json',
882
+                    success:function(data){
883
+                        data = eval("("+data+")");
884
+                        if(data.code==0){
885
+                            if(data.data.coupons == 1){
886
+                                $("input[name=use_coupon]").removeAttr('disabled');
887
+                                $("#use_coupon_1").attr("checked","checked");
888
+                                $("#use_coupon_div").show();                              
889
+                            }
890
+                            if(data.data.if_m_gift == 1){
891
+                                $("#m_gift").removeAttr('disabled');
892
+                                $("#m_gift_div").show();
893
+                            }
894
+                            if(data.data.if_b_gift == 1){
895
+                                $("input[name=use_b_gift]").removeAttr('disabled');
896
+                                $("#use_b_gift_1").attr("checked","checked");
897
+                                $("#b_gift_div").show();
898
+                            }
899
+                        }else{
900
+                            $("input[name=use_coupon]").attr('disabled','disabled');
901
+                            $("#m_gift").attr('disabled','disabled');
902
+                            $("input[name=use_b_gift]").attr('disabled','disabled');
903
+                            $("#use_coupon_div").hide();
904
+                            $("#m_gift_div").hide();
905
+                            $("#b_gift_div").hide();
906
+                        }
907
+                       
908
+                    }
909
+                })
910
+            }
911
+            else{
912
+                $("input[name=use_coupon]").attr('disabled','disabled');
913
+                $("#m_gift").attr('disabled','disabled');
914
+                $("input[name=use_b_gift]").attr('disabled','disabled');
915
+                $("#use_coupon_div").hide();
916
+                $("#m_gift_div").hide();
917
+                $("#b_gift_div").hide();
918
+            }
919
+        }
920
+
824 921
     </script>
825 922
     </body>
826 923
 @endsection

+ 52 - 0
resources/views/order/orderedit.blade.php

@@ -41,6 +41,25 @@
41 41
                 </div>
42 42
             </div>
43 43
             
44
+            <div class="row cl">
45
+                <label class="form-label col-xs-4 col-sm-2">
46
+                    <font color='red'>* </font>买家手机号:</label>
47
+                <div class="formControls col-xs-6 col-sm-6">
48
+                    {{$order['buyer_phone']}}
49
+                    <input type="hidden" class="input-text" value="{{$order['buyer_phone']}}" placeholder="" name="buyer_phone">
50
+                </div>
51
+            </div>
52
+
53
+             <div id='use_coupon_div' class="row cl" @if($order['use_coupon'] !='1' && $cust_info['coupons'] != '1') style="display: none" @endif>
54
+                <label class="form-label col-xs-4 col-sm-2">
55
+                    <font color='red'>* </font>是否使用优惠券:</label>
56
+                <div class="formControls col-xs-6 col-sm-6">
57
+                    <input type="radio" name="use_coupon"  value="0"  @if($order['use_coupon']=='0') checked @endif>
58
+                    <label for="status-0" style="margin-right: 27px;">否</label>
59
+                    <input type="radio" name="use_coupon" value="1" @if($order['use_coupon']=='1') checked @endif>
60
+                    <label for="status-1">是</label>
61
+                </div>
62
+            </div>
44 63
             
45 64
             <div class="row cl">
46 65
                 <label class="form-label col-xs-4 col-sm-2">
@@ -203,6 +222,32 @@
203 222
                 
204 223
             </div><br>
205 224
 
225
+            <div id='m_gift_div' class="row cl" @if(empty($order_m_gifts) && $cust_info['if_m_gift'] != '1') style="display: none" @endif>
226
+                <label class="form-label col-xs-4 col-sm-2">
227
+                    <font color='red'> </font>选择会员当月赠品</label>
228
+                <div class="formControls col-xs-6 col-sm-6">
229
+                    <span class="select-box">
230
+                        <select  size="1" name="m_gift_id" id='m_gift'>                           
231
+                            <option value="0" @if(old('m_gift_id')=='0') selected @endif>- 请选择 -</option>
232
+                            @foreach($m_gift as $item)
233
+                                <option value="{{$item['id']}}" @if( in_array($item['id'], $order_m_gifts) ) selected @endif>{{$item['goods_name']}}【{{$item['propsName']}} ¥{{$item['price']}}】</option>
234
+                            @endforeach                                        
235
+                        </select>
236
+                    </span>
237
+                </div>
238
+            </div> 
239
+
240
+            <div id='b_gift_div' class="row cl"   @if(empty($order_b_gifts) && $cust_info['if_b_gift'] != '1') style="display: none" @endif>
241
+                <label class="form-label col-xs-4 col-sm-2">
242
+                    <font color='red'> </font>是否使用生日赠品</label>
243
+                    <div class="formControls col-xs-6 col-sm-6">
244
+                        <input type="radio" name="use_b_gift"  value="0"  @if($order['use_b_gift']=='0') checked @endif>
245
+                        <label for="status-0" style="margin-right: 27px;">否</label>
246
+                        <input type="radio" name="use_b_gift" value="1" @if($order['use_b_gift']=='1') checked @endif>
247
+                        <label for="status-1">是</label>
248
+                    </div>
249
+            </div> 
250
+
206 251
             <div class="row cl">
207 252
                 <label class="form-label col-xs-4 col-sm-2">
208 253
                    应收金额:</label>
@@ -687,6 +732,13 @@
687 732
         var receivedAmount = $("input[name=receivedAmount]").val();
688 733
         var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
689 734
 
735
+        if( payment_type==4 ){
736
+            use_coupon = $("input[type='radio'][name='use_coupon']:checked").val();
737
+            if(use_coupon == 1){
738
+                layer.msg('充值卡不能和优惠券同时使用!',{icon:2,time:1500});
739
+                return false;
740
+            }
741
+        } 
690 742
 
691 743
         if( payment_type==4 && old_payment_type != 4 ){
692 744
             var phone = $("input[name=deposit_phone]").val();