|
@@ -520,6 +520,7 @@ class OrderController extends Controller
|
520
|
520
|
'customerName' => 'required|between:1,6',
|
521
|
521
|
'receiverName' => 'required|between:1,6',
|
522
|
522
|
'receiverMobile' => 'required|regex:/^1[3456789]\d{9}$/',
|
|
523
|
+ 'buyer_phone' => 'required|regex:/^1[3456789]\d{9}$/',
|
523
|
524
|
'fanTime' => 'required|date',
|
524
|
525
|
'receiverState' => 'required|between:1,5',
|
525
|
526
|
'receiverCity' => 'required|between:1,10',
|
|
@@ -536,6 +537,7 @@ class OrderController extends Controller
|
536
|
537
|
'receiverName.required' => '收货人不能为空',
|
537
|
538
|
'receiverName.between' => '收货人不能超过6个字符',
|
538
|
539
|
'receiverMobile.required' => '收货人手机号不能为空',
|
|
540
|
+ 'buyer_phone.required' => '买家手机号不能为空',
|
539
|
541
|
'receiverMobile.regex' => '收货人手机号格式有误',
|
540
|
542
|
'fanTime.required' => '加粉时间不能为空',
|
541
|
543
|
'receiverState.required' => '省不能为空',
|
|
@@ -647,6 +649,7 @@ class OrderController extends Controller
|
647
|
649
|
$order['delivery_date'] = !empty($request->input('delivery_date')) ? $request->input('delivery_date') : date('Y-m-d'); //发货日期
|
648
|
650
|
$order['order_status'] = (int)$request->input('order_status');
|
649
|
651
|
$order['payment_type'] = (int)$request->input('payment_type'); //支付方式
|
|
652
|
+ $order['buyer_phone'] = $request->input('buyer_phone');
|
650
|
653
|
|
651
|
654
|
//充值卡验证余额
|
652
|
655
|
if($order['payment_type'] == 4){
|
|
@@ -720,6 +723,43 @@ class OrderController extends Controller
|
720
|
723
|
$order_skus_insert = DB::table('order_goods_skus')->insert($order_skus);
|
721
|
724
|
}
|
722
|
725
|
|
|
726
|
+ #加赠品逻辑
|
|
727
|
+ $use_coupon = (int)$request->input('use_coupon');
|
|
728
|
+ $m_gift_id = (int)$request->input('m_gift_id');
|
|
729
|
+ $b_gift_id = (int)$request->input('b_gift_id');
|
|
730
|
+ if($use_coupon == 1){
|
|
731
|
+ $coupon = DB::table('customer_coupons')->where('phone', $order['buyer_phone'])->where('is_use',0)->orderBy('id', 'desc')->first();
|
|
732
|
+ if(!empty($coupon)){
|
|
733
|
+ $cup = array();
|
|
734
|
+ $cup['is_use'] = 1;
|
|
735
|
+ $cup['use_time'] = date('Y-m-d H:i:s');
|
|
736
|
+ $cup['order_id'] = $res;
|
|
737
|
+ DB::table('customer_coupons')->where('id', $coupon->id)->update($cup);
|
|
738
|
+ }
|
|
739
|
+ }
|
|
740
|
+ if($m_gift_id>0){
|
|
741
|
+ $m_gift = DB::table('customer_month_gift')->where('id', $m_gift_id)->where('type', 0)->first();
|
|
742
|
+ $order_m_gift = array();
|
|
743
|
+ $m_sku = GoodsSkus::where('id', $m_gift->sku_id)->first();
|
|
744
|
+ $order_m_gift['sku_id'] = $m_gift->sku_id;
|
|
745
|
+ $order_m_gift['order_id'] = $res;
|
|
746
|
+ $order_m_gift['goods_id'] = $m_sku->goodsCode;
|
|
747
|
+ $order_m_gift['num'] = $m_gift->num;
|
|
748
|
+ $order_m_gift['price'] = $m_sku->price;
|
|
749
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_m_gift);
|
|
750
|
+ }
|
|
751
|
+ if($b_gift_id>0){
|
|
752
|
+ $b_gift = DB::table('customer_month_gift')->where('id', $b_gift_id)->where('type', 1)->first();
|
|
753
|
+ $order_b_gift = array();
|
|
754
|
+ $b_sku = GoodsSkus::where('id', $b_gift->sku_id)->first();
|
|
755
|
+ $order_b_gift['sku_id'] = $b_gift->sku_id;
|
|
756
|
+ $order_b_gift['order_id'] = $res;
|
|
757
|
+ $order_b_gift['goods_id'] = $b_sku->goodsCode;
|
|
758
|
+ $order_b_gift['num'] = $b_gift->num;
|
|
759
|
+ $order_b_gift['price'] = $b_sku->price;
|
|
760
|
+ $order_gift_insert = DB::table('order_goods_skus')->insert($order_b_gift);
|
|
761
|
+ }
|
|
762
|
+
|
723
|
763
|
#新加逻辑,若付款方式为充值卡/消费记录
|
724
|
764
|
if($order['payment_type'] == 4){
|
725
|
765
|
$consum = new CustomerConsum();
|
|
@@ -1972,7 +2012,7 @@ class OrderController extends Controller
|
1972
|
2012
|
if($customer_info->vip_end_time > $time){
|
1973
|
2013
|
//未过期,1.获取优惠券,获取当月礼,获取生日礼,判断领取
|
1974
|
2014
|
$coupons = DB::table('customer_coupons')->where('phone', $phone)->where('is_use', 0)->where('end_time', '>', $time)->first();
|
1975
|
|
- $customer_info->coupons = $coupons;
|
|
2015
|
+ $customer_info->coupons = !empty($coupons) ? 1:0;
|
1976
|
2016
|
//判断是否领取当月礼
|
1977
|
2017
|
$mtime = date('Y-m-01');
|
1978
|
2018
|
$if_m_gift = DB::table('customer_gift_receives')->where('phone', $phone)->where('is_del',0)->where('gift_type', 0)->where('dtime', '>=', $mtime)->first();
|
|
@@ -1994,13 +2034,12 @@ class OrderController extends Controller
|
1994
|
2034
|
}
|
1995
|
2035
|
}
|
1996
|
2036
|
|
1997
|
|
- $customer_info = json_encode($customer_info);
|
1998
|
|
- exit(['code'=>0, 'data'=>$customer_info]);
|
|
2037
|
+ exit(json_encode(['code'=>0, 'data'=>$customer_info]));
|
1999
|
2038
|
}
|
2000
|
|
- exit(['code'=>1,'msg'=>'会员过期']);
|
|
2039
|
+ exit(json_encode(['code'=>1,'msg'=>'会员过期']));
|
2001
|
2040
|
}
|
2002
|
2041
|
|
2003
|
|
- exit(['code'=>1,'msg'=>'不是会员']);
|
|
2042
|
+ exit(json_encode(['code'=>1,'msg'=>'不是会员']));
|
2004
|
2043
|
}
|
2005
|
2044
|
|
2006
|
2045
|
}
|