sunhao 5 years ago
parent
commit
a079e61803

+ 38 - 0
app/Http/Controllers/Admin/OrderController.php

@@ -1389,6 +1389,25 @@ class OrderController extends Controller
1389 1389
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1390 1390
                 }
1391 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
+
1392 1411
                 #记录操作日志
1393 1412
                 $self_id = session('admin_id');
1394 1413
                 $self_name = session('real_name');            
@@ -1455,6 +1474,25 @@ class OrderController extends Controller
1455 1474
                     $balance = $cust->balance + $order->receivedAmount;
1456 1475
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1457 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
+                }
1458 1496
                 
1459 1497
                 #记录操作日志
1460 1498
                 $self_id = session('admin_id');

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

@@ -198,7 +198,7 @@
198 198
 
199 199
             <div id='m_gift_div' class="row cl" style="display: none">
200 200
                 <label class="form-label col-xs-4 col-sm-2">
201
-                    <font color='red'> </font>选择会员月赠品</label>
201
+                    <font color='red'> </font>选择会员月赠品</label>
202 202
                 <div class="formControls col-xs-6 col-sm-6">
203 203
                     <span class="select-box">
204 204
                         <select  size="1" name="m_gift_id" id='m_gift'>                           
@@ -826,6 +826,12 @@
826 826
         var is_ok = 1;
827 827
         var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
828 828
         if(payment_type==4){
829
+            //使用充值卡不能使用优惠券验证
830
+            use_coupon = $("input[type='radio'][name='use_coupon']:checked").val();
831
+            if(use_coupon == 1){
832
+                layer.msg('充值卡不能和优惠券同时使用!',{icon:2,time:1500});
833
+                return false;
834
+            }
829 835
             var phone = $("input[name=deposit_phone]").val();
830 836
             if(!phone){
831 837
                 is_ok = 0;
@@ -891,6 +897,14 @@
891 897
                     }
892 898
                 })
893 899
             }
900
+            else{
901
+                $("input[name=use_coupon]").attr('disabled','disabled');
902
+                $("#m_gift").attr('disabled','disabled');
903
+                $("#b_gift").attr('disabled','disabled');
904
+                $("#use_coupon_div").hide();
905
+                $("#m_gift_div").hide();
906
+                $("#b_gift_div").hide();
907
+            }
894 908
         }
895 909
 
896 910
     </script>

+ 9 - 2
resources/views/order/orderedit.blade.php

@@ -54,7 +54,7 @@
54 54
                 <label class="form-label col-xs-4 col-sm-2">
55 55
                     <font color='red'>* </font>是否使用优惠券:</label>
56 56
                 <div class="formControls col-xs-6 col-sm-6">
57
-                    <input type="radio" name="use_coupon"  value="0" >
57
+                    <input type="radio" name="use_coupon"  value="0"  @if($order['use_coupon']=='0') checked @endif>
58 58
                     <label for="status-0" style="margin-right: 27px;">否</label>
59 59
                     <input type="radio" name="use_coupon" value="1" @if($order['use_coupon']=='1') checked @endif>
60 60
                     <label for="status-1">是</label>
@@ -222,7 +222,7 @@
222 222
 
223 223
             <div id='m_gift_div' class="row cl" @if(empty($order_m_gifts) && $cust_info['if_m_gift'] != '1') style="display: none" @endif>
224 224
                 <label class="form-label col-xs-4 col-sm-2">
225
-                    <font color='red'> </font>选择会员月赠品</label>
225
+                    <font color='red'> </font>选择会员月赠品</label>
226 226
                 <div class="formControls col-xs-6 col-sm-6">
227 227
                     <span class="select-box">
228 228
                         <select  size="1" name="m_gift_id" id='m_gift'>                           
@@ -721,6 +721,13 @@
721 721
         var receivedAmount = $("input[name=receivedAmount]").val();
722 722
         var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
723 723
 
724
+        if( payment_type==4 ){
725
+            use_coupon = $("input[type='radio'][name='use_coupon']:checked").val();
726
+            if(use_coupon == 1){
727
+                layer.msg('充值卡不能和优惠券同时使用!',{icon:2,time:1500});
728
+                return false;
729
+            }
730
+        } 
724 731
 
725 732
         if( payment_type==4 && old_payment_type != 4 ){
726 733
             var phone = $("input[name=deposit_phone]").val();