|
@@ -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' => '省不能为空',
|
|
@@ -532,7 +556,7 @@ class OrderController extends Controller
|
532
|
556
|
|
533
|
557
|
//redis防重复数据
|
534
|
558
|
$phone = $request->input('receiverMobile');
|
535
|
|
-
|
|
559
|
+ /*
|
536
|
560
|
$redisKey = 'seafood.order_phone_add.'.$phone;
|
537
|
561
|
$res = RedisModel::setnx($redisKey, 1);
|
538
|
562
|
if( $res == 0 ){
|
|
@@ -540,7 +564,7 @@ class OrderController extends Controller
|
540
|
564
|
return redirect('/admin/order/index')->with('info', $msg);
|
541
|
565
|
}
|
542
|
566
|
$res = RedisModel::expire( $redisKey, 60 );
|
543
|
|
-
|
|
567
|
+ */
|
544
|
568
|
$skus = $request->input('skus');
|
545
|
569
|
$warehouse = (int)$request->input('warehouse');
|
546
|
570
|
if($warehouse == 3 && empty($skus)){
|
|
@@ -625,6 +649,8 @@ 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');
|
628
|
654
|
|
629
|
655
|
//充值卡验证余额
|
630
|
656
|
if($order['payment_type'] == 4){
|
|
@@ -698,6 +724,61 @@ class OrderController extends Controller
|
698
|
724
|
$order_skus_insert = DB::table('order_goods_skus')->insert($order_skus);
|
699
|
725
|
}
|
700
|
726
|
|
|
727
|
+ #加赠品逻辑
|
|
728
|
+ $use_coupon = (int)$request->input('use_coupon');
|
|
729
|
+ $m_gift_id = (int)$request->input('m_gift_id');
|
|
730
|
+ $b_gift_id = (int)$request->input('b_gift_id');
|
|
731
|
+ if($use_coupon == 1){
|
|
732
|
+ $coupon = DB::table('customer_coupons')->where('phone', $order['buyer_phone'])->where('is_use',0)->orderBy('id', 'desc')->first();
|
|
733
|
+ if(!empty($coupon)){
|
|
734
|
+ $cup = array();
|
|
735
|
+ $cup['is_use'] = 1;
|
|
736
|
+ $cup['use_time'] = date('Y-m-d H:i:s');
|
|
737
|
+ $cup['order_id'] = $res;
|
|
738
|
+ DB::table('customer_coupons')->where('id', $coupon->id)->update($cup);
|
|
739
|
+ }
|
|
740
|
+ }
|
|
741
|
+ if($m_gift_id>0){
|
|
742
|
+ $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
|
|
743
|
+ $order_m_gift = array();
|
|
744
|
+ $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
|
|
745
|
+ $order_m_gift['sku_id'] = $m_gift->sku_id;
|
|
746
|
+ $order_m_gift['order_id'] = $res;
|
|
747
|
+ $order_m_gift['goods_id'] = $m_sku->goodsCode;
|
|
748
|
+ $order_m_gift['num'] = $m_gift->num;
|
|
749
|
+ $order_m_gift['price'] = $m_sku->price;
|
|
750
|
+ $order_m_gift['gift_id'] = $m_gift_id;
|
|
751
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
|
|
752
|
+ #记录领取
|
|
753
|
+ $receive_gift = array();
|
|
754
|
+ $receive_gift['phone'] = $order['buyer_phone'];
|
|
755
|
+ $receive_gift['dtime'] = date('Y-m-d');
|
|
756
|
+ $receive_gift['order_id'] = $res;
|
|
757
|
+ $receive_gift['gift_id'] = $m_gift_id;
|
|
758
|
+ $receive_gift['gift_type'] = 0;
|
|
759
|
+ DB::table('customer_gift_receives')->insert($receive_gift);
|
|
760
|
+ }
|
|
761
|
+ if($b_gift_id>0){
|
|
762
|
+ $b_gift = DB::table('customer_month_gift')->where('id', $b_gift_id)->where('type', 1)->first();
|
|
763
|
+ $order_b_gift = array();
|
|
764
|
+ $b_sku = GoodsSkus::where('id', $b_gift->sku_id)->first();
|
|
765
|
+ $order_b_gift['sku_id'] = $b_gift->sku_id;
|
|
766
|
+ $order_b_gift['order_id'] = $res;
|
|
767
|
+ $order_b_gift['goods_id'] = $b_sku->goodsCode;
|
|
768
|
+ $order_b_gift['num'] = $b_gift->num;
|
|
769
|
+ $order_b_gift['price'] = $b_sku->price;
|
|
770
|
+ $order_b_gift['gift_id'] = $b_gift_id;
|
|
771
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_b_gift);
|
|
772
|
+ #记录领取
|
|
773
|
+ $receive_gift = array();
|
|
774
|
+ $receive_gift['phone'] = $order['buyer_phone'];
|
|
775
|
+ $receive_gift['dtime'] = date('Y-m-d');
|
|
776
|
+ $receive_gift['order_id'] = $res;
|
|
777
|
+ $receive_gift['gift_id'] = $b_gift_id;
|
|
778
|
+ $receive_gift['gift_type'] = 1;
|
|
779
|
+ DB::table('customer_gift_receives')->insert($receive_gift);
|
|
780
|
+ }
|
|
781
|
+
|
701
|
782
|
#新加逻辑,若付款方式为充值卡/消费记录
|
702
|
783
|
if($order['payment_type'] == 4){
|
703
|
784
|
$consum = new CustomerConsum();
|
|
@@ -763,7 +844,7 @@ class OrderController extends Controller
|
763
|
844
|
$order['deposit_phone'] = $order['receiverMobile'];
|
764
|
845
|
$order['receiverMobile'] = substr($order['receiverMobile'], 0, 3).'****'.substr($order['receiverMobile'], 7);
|
765
|
846
|
$order['goods'] = '';
|
766
|
|
- $order_skus = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->lists('num','sku_id');
|
|
847
|
+ $order_skus = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->whereNull('gift_id')->lists('num','sku_id');
|
767
|
848
|
|
768
|
849
|
$skus = array_keys($order_skus);
|
769
|
850
|
if(!empty($skus)){
|
|
@@ -780,6 +861,71 @@ class OrderController extends Controller
|
780
|
861
|
$consum = CustomerConsum::select('phone')->where('order_id', $id)->first();
|
781
|
862
|
$deposit_phone = isset($consum->phone) ? $consum->phone : '';
|
782
|
863
|
}
|
|
864
|
+
|
|
865
|
+ //下单当月礼品
|
|
866
|
+ $mtime = date('Y-m-01', strtotime($order['create_time']));
|
|
867
|
+ $gift_info = DB::table('customer_month_gift')->where('mtime', $mtime)->get();
|
|
868
|
+ $gift_info = json_decode(json_encode($gift_info), true);
|
|
869
|
+ $m_gift=array();
|
|
870
|
+ $b_gift=array();
|
|
871
|
+ foreach($gift_info as $k=>$val){
|
|
872
|
+ //获取礼品信息
|
|
873
|
+ $goods_name = Goods::where('id', $val['goods_id'])->pluck('name');
|
|
874
|
+ $sku = GoodsSkus::where('id', $val['sku_id'])->first();
|
|
875
|
+ $data = array();
|
|
876
|
+ $data['id'] = $val['id'];
|
|
877
|
+ $data['goods_name'] = $goods_name;
|
|
878
|
+ $data['propsName'] = $sku['propsName'];
|
|
879
|
+ $data['price'] = $sku['price'];
|
|
880
|
+ if($val['type'] == 0){
|
|
881
|
+ $m_gift[] = $data;
|
|
882
|
+ }else{
|
|
883
|
+ $b_gift[] = $data;
|
|
884
|
+ }
|
|
885
|
+ }
|
|
886
|
+
|
|
887
|
+ #获取赠品信息
|
|
888
|
+ $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
|
|
889
|
+ $order_m_gifts = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->lists('id');
|
|
890
|
+ $order_b_gifts = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->lists('id');
|
|
891
|
+
|
|
892
|
+ #查询用户会员信息
|
|
893
|
+ $cust_info = array();
|
|
894
|
+ $cust_info['coupons'] = 0;
|
|
895
|
+ $cust_info['if_m_gift'] = 0;
|
|
896
|
+ $cust_info['if_b_gift'] = 0;
|
|
897
|
+
|
|
898
|
+ $phone = $order['buyer_phone'];
|
|
899
|
+ $time = date('Y-m-d H:i:s');
|
|
900
|
+ $customer_info = DB::table('customer_vip')->where('phone', $phone)->where('is_del', 0)->first();
|
|
901
|
+ if(!empty($customer_info) && $order['create_time']>'2019-11-28'){
|
|
902
|
+ //判断是否过期
|
|
903
|
+ if($customer_info->vip_end_time > $time){
|
|
904
|
+ //未过期,1.获取优惠券,获取当月礼,获取生日礼,判断领取
|
|
905
|
+ $coupons = DB::table('customer_coupons')->where('phone', $phone)->where('is_use', 0)->where('end_time', '>', $time)->first();
|
|
906
|
+ $cust_info['coupons'] = !empty($coupons) ? 1:0;
|
|
907
|
+ //判断是否领取当月礼
|
|
908
|
+ $if_m_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 0)->where('dtime', '>=', $mtime)->first();
|
|
909
|
+ if(empty($if_m_gift)){
|
|
910
|
+ $cust_info['if_m_gift'] = 1;
|
|
911
|
+ }
|
|
912
|
+
|
|
913
|
+ //判断生日礼
|
|
914
|
+ $birth_stime = date('m-d', strtotime($customer_info->birthday.' -3 day'));
|
|
915
|
+ $birth_etime = date('m-d', strtotime($customer_info->birthday.' +3 day'));
|
|
916
|
+ $today = date('m-d');
|
|
917
|
+ if($today>=$birth_stime && $today<=$birth_etime){
|
|
918
|
+ //生日期内,判断是否已领
|
|
919
|
+ $if_b_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 1)->where('dtime', '>=', $mtime)->first();
|
|
920
|
+ if(empty($if_b_gift)){
|
|
921
|
+ $cust_info['if_b_gift'] = 1;
|
|
922
|
+ }
|
|
923
|
+ }
|
|
924
|
+
|
|
925
|
+ }
|
|
926
|
+
|
|
927
|
+ }
|
|
928
|
+
|
783
|
929
|
return view('order/orderedit', [
|
784
|
930
|
'order' => $order,
|
785
|
931
|
//'categorylist' => $catelist,
|
|
@@ -789,6 +935,11 @@ class OrderController extends Controller
|
789
|
935
|
'str_query'=> 'page='.$page.'&admin_id='.$admin_id.'&stime='.$stime.'&etime='.$etime.'&receiverName='.$receiverName.'&receiverMobile='.$receiverMobile,
|
790
|
936
|
'last_url' => $last_url,
|
791
|
937
|
'deposit_phone' => $deposit_phone,
|
|
938
|
+ 'm_gift' => $m_gift,
|
|
939
|
+ 'b_gift' => $b_gift,
|
|
940
|
+ 'order_m_gifts' => $order_m_gifts,
|
|
941
|
+ 'order_b_gifts' => $order_b_gifts,
|
|
942
|
+ 'cust_info' => $cust_info,
|
792
|
943
|
]);
|
793
|
944
|
|
794
|
945
|
}
|
|
@@ -866,6 +1017,8 @@ class OrderController extends Controller
|
866
|
1017
|
//if(!empty($request->input('createTime'))) $order['createTime'] = $request->input('createTime'); // 订单创建时间
|
867
|
1018
|
$order['order_status'] = (int)$request->input('order_status');
|
868
|
1019
|
$order['payment_type'] = (int)$request->input('payment_type'); //支付方式
|
|
1020
|
+ $order['use_coupon'] = (int)$request->input('use_coupon');
|
|
1021
|
+ $order['buyer_phone'] = $request->input('buyer_phone');
|
869
|
1022
|
|
870
|
1023
|
//$order['status'] = (int)$request->input('status');
|
871
|
1024
|
$order['should_amount'] = $request->input('should_amount');
|
|
@@ -968,7 +1121,7 @@ class OrderController extends Controller
|
968
|
1121
|
$gnum = $request->input('gnum');
|
969
|
1122
|
if(empty($skus)) $skus = [];
|
970
|
1123
|
//先删除
|
971
|
|
- $del_re = DB::table('order_goods_skus')->where('order_id', $id)->whereNotIn('sku_id', $skus)->update(['is_del'=>1]);
|
|
1124
|
+ $del_re = DB::table('order_goods_skus')->where('order_id', $id)->whereNull('gift_id')->whereNotIn('sku_id', $skus)->update(['is_del'=>1]);
|
972
|
1125
|
if(!empty($skus)){
|
973
|
1126
|
//再同步
|
974
|
1127
|
foreach($skus as $k=>$sku_id){
|
|
@@ -1073,11 +1226,125 @@ class OrderController extends Controller
|
1073
|
1226
|
Oplog::addLog($self_id, $self_name, $context, $type, $tables, $data_id);
|
1074
|
1227
|
}
|
1075
|
1228
|
|
|
1229
|
+ #新加逻辑,使用优惠券,赠礼
|
|
1230
|
+ $use_coupon = (int)$request->input('use_coupon');
|
|
1231
|
+ $m_gift_id = (int)$request->input('m_gift_id');
|
|
1232
|
+ $b_gift_id = (int)$request->input('b_gift_id');
|
|
1233
|
+ if($use_coupon == 1 && $old_order->use_coupon != 1){
|
|
1234
|
+ $coupon = DB::table('customer_coupons')->where('phone', $order['buyer_phone'])->where('is_use',0)->orderBy('id', 'desc')->first();
|
|
1235
|
+ if(!empty($coupon)){
|
|
1236
|
+ $cup = array();
|
|
1237
|
+ $cup['is_use'] = 1;
|
|
1238
|
+ $cup['use_time'] = date('Y-m-d H:i:s');
|
|
1239
|
+ $cup['order_id'] = $id;
|
|
1240
|
+ DB::table('customer_coupons')->where('id', $coupon->id)->update($cup);
|
|
1241
|
+ }
|
|
1242
|
+ }elseif($use_coupon == 0 && $old_order->use_coupon == 1){
|
|
1243
|
+ DB::table('customer_coupons')->where('order_id', $id)->update(['is_use'=>0]);
|
|
1244
|
+ }
|
|
1245
|
+ #查询本单使用赠礼
|
|
1246
|
+ $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
|
|
1247
|
+ $order_m_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->pluck('id');
|
|
1248
|
+ $order_b_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->pluck('id');
|
|
1249
|
+
|
|
1250
|
+ if($m_gift_id>0 && empty($order_m_gift_id) ){
|
|
1251
|
+ $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
|
|
1252
|
+ $order_m_gift = array();
|
|
1253
|
+ $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
|
|
1254
|
+ $order_m_gift['sku_id'] = $m_gift->sku_id;
|
|
1255
|
+ $order_m_gift['order_id'] = $id;
|
|
1256
|
+ $order_m_gift['goods_id'] = $m_sku->goodsCode;
|
|
1257
|
+ $order_m_gift['num'] = $m_gift->num;
|
|
1258
|
+ $order_m_gift['price'] = $m_sku->price;
|
|
1259
|
+ $order_m_gift['gift_id'] = $m_gift_id;
|
|
1260
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
|
|
1261
|
+ #记录领取
|
|
1262
|
+ $receive_gift = array();
|
|
1263
|
+ $receive_gift['phone'] = $order['buyer_phone'];
|
|
1264
|
+ $receive_gift['dtime'] = date('Y-m-d');
|
|
1265
|
+ $receive_gift['order_id'] = $id;
|
|
1266
|
+ $receive_gift['gift_id'] = $m_gift_id;
|
|
1267
|
+ $receive_gift['gift_type'] = 0;
|
|
1268
|
+ DB::table('customer_gift_receives')->insert($receive_gift);
|
|
1269
|
+ }elseif($m_gift_id>0 && $m_gift_id != $order_m_gift_id){
|
|
1270
|
+ DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1271
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
|
|
1272
|
+
|
|
1273
|
+ $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
|
|
1274
|
+ $order_m_gift = array();
|
|
1275
|
+ $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
|
|
1276
|
+ $order_m_gift['sku_id'] = $m_gift->sku_id;
|
|
1277
|
+ $order_m_gift['order_id'] = $id;
|
|
1278
|
+ $order_m_gift['goods_id'] = $m_sku->goodsCode;
|
|
1279
|
+ $order_m_gift['num'] = $m_gift->num;
|
|
1280
|
+ $order_m_gift['price'] = $m_sku->price;
|
|
1281
|
+ $order_m_gift['gift_id'] = $m_gift_id;
|
|
1282
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
|
|
1283
|
+ #记录领取
|
|
1284
|
+ $receive_gift = array();
|
|
1285
|
+ $receive_gift['phone'] = $order['buyer_phone'];
|
|
1286
|
+ $receive_gift['dtime'] = date('Y-m-d');
|
|
1287
|
+ $receive_gift['order_id'] = $id;
|
|
1288
|
+ $receive_gift['gift_id'] = $m_gift_id;
|
|
1289
|
+ $receive_gift['gift_type'] = 0;
|
|
1290
|
+ DB::table('customer_gift_receives')->insert($receive_gift);
|
|
1291
|
+ }elseif($m_gift_id==0 && $order_m_gift_id>0){
|
|
1292
|
+ DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1293
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
|
|
1294
|
+ }
|
|
1295
|
+ if($b_gift_id>0 && empty($order_b_gift_id) ){
|
|
1296
|
+ $b_gift = DB::table('customer_month_gift')->where('id', $b_gift_id)->where('type', 1)->first();
|
|
1297
|
+ $order_b_gift = array();
|
|
1298
|
+ $b_sku = GoodsSkus::where('id', $b_gift->sku_id)->first();
|
|
1299
|
+ $order_b_gift['sku_id'] = $b_gift->sku_id;
|
|
1300
|
+ $order_b_gift['order_id'] = $id;
|
|
1301
|
+ $order_b_gift['goods_id'] = $b_sku->goodsCode;
|
|
1302
|
+ $order_b_gift['num'] = $b_gift->num;
|
|
1303
|
+ $order_b_gift['price'] = $b_sku->price;
|
|
1304
|
+ $order_b_gift['gift_id'] = $b_gift_id;
|
|
1305
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_b_gift);
|
|
1306
|
+ #记录领取
|
|
1307
|
+ $receive_gift = array();
|
|
1308
|
+ $receive_gift['phone'] = $order['buyer_phone'];
|
|
1309
|
+ $receive_gift['dtime'] = date('Y-m-d');
|
|
1310
|
+ $receive_gift['order_id'] = $id;
|
|
1311
|
+ $receive_gift['gift_id'] = $b_gift_id;
|
|
1312
|
+ $receive_gift['gift_type'] = 1;
|
|
1313
|
+ DB::table('customer_gift_receives')->insert($receive_gift);
|
|
1314
|
+ }elseif($b_gift_id>0 && $b_gift_id != $order_b_gift_id){
|
|
1315
|
+ DB::table('order_goods_skus')->where('gift_id', $order_b_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1316
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_b_gift_id)->update(['is_del'=>1]);
|
|
1317
|
+
|
|
1318
|
+ $b_gift = DB::table('customer_month_gift')->where('id', $b_gift_id)->where('type', 1)->first();
|
|
1319
|
+ $order_b_gift = array();
|
|
1320
|
+ $b_sku = GoodsSkus::where('id', $b_gift->sku_id)->first();
|
|
1321
|
+ $order_b_gift['sku_id'] = $b_gift->sku_id;
|
|
1322
|
+ $order_b_gift['order_id'] = $id;
|
|
1323
|
+ $order_b_gift['goods_id'] = $b_sku->goodsCode;
|
|
1324
|
+ $order_b_gift['num'] = $b_gift->num;
|
|
1325
|
+ $order_b_gift['price'] = $b_sku->price;
|
|
1326
|
+ $order_b_gift['gift_id'] = $b_gift_id;
|
|
1327
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_b_gift);
|
|
1328
|
+ #记录领取
|
|
1329
|
+ $receive_gift = array();
|
|
1330
|
+ $receive_gift['phone'] = $order['buyer_phone'];
|
|
1331
|
+ $receive_gift['dtime'] = date('Y-m-d');
|
|
1332
|
+ $receive_gift['order_id'] = $id;
|
|
1333
|
+ $receive_gift['gift_id'] = $b_gift_id;
|
|
1334
|
+ $receive_gift['gift_type'] = 1;
|
|
1335
|
+ DB::table('customer_gift_receives')->insert($receive_gift);
|
|
1336
|
+
|
|
1337
|
+ }elseif($b_gift_id==0 && $order_b_gift_id>0){
|
|
1338
|
+ DB::table('order_goods_skus')->where('gift_id', $order_b_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1339
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_b_gift_id)->update(['is_del'=>1]);
|
|
1340
|
+ }
|
|
1341
|
+
|
1076
|
1342
|
DB::commit();
|
1077
|
1343
|
}catch (Exception $e){
|
1078
|
1344
|
DB::rollback();
|
1079
|
1345
|
Log::errorLog($request,['error'=>$e->getMessage()],"order/update",0,'');
|
1080
|
|
- return redirect('/admin/order/index?'.$str_query)->with('info', $e->getMessage());
|
|
1346
|
+ var_dump($e->getMessage());
|
|
1347
|
+ //return redirect('/admin/order/index?'.$str_query)->with('info', $e->getMessage());
|
1081
|
1348
|
}
|
1082
|
1349
|
|
1083
|
1350
|
if(!empty($last_url)){
|
|
@@ -1122,6 +1389,25 @@ class OrderController extends Controller
|
1122
|
1389
|
CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
|
1123
|
1390
|
}
|
1124
|
1391
|
|
|
1392
|
+ //假如删除订单使用了优惠券,礼品
|
|
1393
|
+ if($order->use_coupon == 1){
|
|
1394
|
+ DB::table('customer_coupons')->where('order_id', $id)->update(['is_use'=>0]);
|
|
1395
|
+ }
|
|
1396
|
+ #查询本单使用赠礼
|
|
1397
|
+ $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
|
|
1398
|
+ if(!empty($order_gifts)){
|
|
1399
|
+ $order_m_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->pluck('id');
|
|
1400
|
+ $order_b_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->pluck('id');
|
|
1401
|
+ if($order_m_gift_id>0){
|
|
1402
|
+ DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1403
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
|
|
1404
|
+ }
|
|
1405
|
+ if($order_b_gift_id>0){
|
|
1406
|
+ DB::table('order_goods_skus')->where('gift_id', $order_b_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1407
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_b_gift_id)->update(['is_del'=>1]);
|
|
1408
|
+ }
|
|
1409
|
+ }
|
|
1410
|
+
|
1125
|
1411
|
#记录操作日志
|
1126
|
1412
|
$self_id = session('admin_id');
|
1127
|
1413
|
$self_name = session('real_name');
|
|
@@ -1188,6 +1474,25 @@ class OrderController extends Controller
|
1188
|
1474
|
$balance = $cust->balance + $order->receivedAmount;
|
1189
|
1475
|
CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
|
1190
|
1476
|
}
|
|
1477
|
+
|
|
1478
|
+ //假如删除订单使用了优惠券,礼品
|
|
1479
|
+ if($order->use_coupon == 1){
|
|
1480
|
+ DB::table('customer_coupons')->where('order_id', $id)->update(['is_use'=>0]);
|
|
1481
|
+ }
|
|
1482
|
+ #查询本单使用赠礼
|
|
1483
|
+ $order_gifts = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->where('gift_id','>',0)->lists('gift_id');
|
|
1484
|
+ if(!empty($order_gifts)){
|
|
1485
|
+ $order_m_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 0)->pluck('id');
|
|
1486
|
+ $order_b_gift_id = DB::table('customer_month_gift')->whereIn('id', $order_gifts)->where('type', 1)->pluck('id');
|
|
1487
|
+ if($order_m_gift_id>0){
|
|
1488
|
+ DB::table('order_goods_skus')->where('gift_id', $order_m_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1489
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_m_gift_id)->update(['is_del'=>1]);
|
|
1490
|
+ }
|
|
1491
|
+ if($order_b_gift_id>0){
|
|
1492
|
+ DB::table('order_goods_skus')->where('gift_id', $order_b_gift_id)->where('order_id', $id)->update(['is_del'=>1]);
|
|
1493
|
+ DB::table('customer_gift_receives')->where('order_id', $id)->where('gift_id', $order_b_gift_id)->update(['is_del'=>1]);
|
|
1494
|
+ }
|
|
1495
|
+ }
|
1191
|
1496
|
|
1192
|
1497
|
#记录操作日志
|
1193
|
1498
|
$self_id = session('admin_id');
|
|
@@ -1938,5 +2243,47 @@ class OrderController extends Controller
|
1938
|
2243
|
return $mjOrder['order'];
|
1939
|
2244
|
}
|
1940
|
2245
|
|
|
2246
|
+ /**
|
|
2247
|
+ * 获取手机号会员信息
|
|
2248
|
+ */
|
|
2249
|
+ public function getVip(Request $request){
|
|
2250
|
+ $phone = $request->input('phone');
|
|
2251
|
+ $time = date('Y-m-d H:i:s');
|
|
2252
|
+ $customer_info = DB::table('customer_vip')->where('phone', $phone)->where('is_del', 0)->first();
|
|
2253
|
+ if(!empty($customer_info)){
|
|
2254
|
+ //判断是否过期
|
|
2255
|
+ if($customer_info->vip_end_time > $time){
|
|
2256
|
+ //未过期,1.获取优惠券,获取当月礼,获取生日礼,判断领取
|
|
2257
|
+ $coupons = DB::table('customer_coupons')->where('phone', $phone)->where('is_use', 0)->where('end_time', '>', $time)->first();
|
|
2258
|
+ $customer_info->coupons = !empty($coupons) ? 1:0;
|
|
2259
|
+ //判断是否领取当月礼
|
|
2260
|
+ $mtime = date('Y-m-01');
|
|
2261
|
+ $if_m_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 0)->where('dtime', '>=', $mtime)->first();
|
|
2262
|
+ $customer_info->if_m_gift = 0;
|
|
2263
|
+ if(empty($if_m_gift)){
|
|
2264
|
+ $customer_info->if_m_gift = 1;
|
|
2265
|
+ }
|
|
2266
|
+
|
|
2267
|
+ //判断生日礼
|
|
2268
|
+ $birth_stime = date('m-d', strtotime($customer_info->birthday.' -3 day'));
|
|
2269
|
+ $birth_etime = date('m-d', strtotime($customer_info->birthday.' +3 day'));
|
|
2270
|
+ $today = date('m-d');
|
|
2271
|
+ $customer_info->if_b_gift = 0;
|
|
2272
|
+ if($today>=$birth_stime && $today<=$birth_etime){
|
|
2273
|
+ //生日期内,判断是否已领
|
|
2274
|
+ $if_b_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 1)->where('dtime', '>=', $mtime)->first();
|
|
2275
|
+ if(empty($if_b_gift)){
|
|
2276
|
+ $customer_info->if_b_gift = 1;
|
|
2277
|
+ }
|
|
2278
|
+ }
|
|
2279
|
+
|
|
2280
|
+ exit(json_encode(['code'=>0, 'data'=>$customer_info]));
|
|
2281
|
+ }
|
|
2282
|
+ exit(json_encode(['code'=>1,'msg'=>'会员过期']));
|
|
2283
|
+ }
|
|
2284
|
+
|
|
2285
|
+ exit(json_encode(['code'=>1,'msg'=>'不是会员']));
|
|
2286
|
+ }
|
|
2287
|
+
|
1941
|
2288
|
}
|
1942
|
2289
|
|