Browse Source

全额退款退券

gorden 5 months ago
parent
commit
399fd2411b
1 changed files with 7 additions and 9 deletions
  1. 7 9
      app/admin/controller/order/RefundController.php

+ 7 - 9
app/admin/controller/order/RefundController.php

@@ -302,25 +302,23 @@ class RefundController extends Curd
         $response = [];
         Db::beginTransaction();
         try {
-            dump("开始退券",sprintf("%.2f", $amount),sprintf("%.2f", $order->order_amount_pay));
             // 全额退款,检查优惠券,恢复可使用
             if (sprintf("%.2f", $amount) == sprintf("%.2f", $order->order_amount_pay)) {
                 if (!empty($order->order_discount_json)) {
-                    dump("有优惠");
                     $discountJson = json_decode($order->order_discount_json, true);
                     foreach ($discountJson as $item){
                         if (empty($item['coupon_id'])){
                             continue;
                         }
-
-                        dump("检查是否有拆单");
                         // 是否有其他订单一起使用优惠券
                         if(!Order::where('order_groupby',$order->order_groupby)->where('order_id','<>',$order->order_id)->where('order_is_complete','<>','R')->exists()){
-                            dump("没有没退的");
-                            CouponDetail::where('coupon_detail_id',$item['coupon_id'])->update([
-                                'coupon_detail_status'=>'ACTIVED',
-                                'coupon_detail_used_datetime'=>''
-                            ]);
+                            foreach ($item['coupon_detail_id'] as $detailId){
+                                CouponDetail::where('coupon_detail_id',$detailId)->update([
+                                    'coupon_detail_status'=>'ACTIVED',
+                                    'coupon_detail_used_datetime'=>''
+                                ]);
+                            }
+
                         }
                     }
                 }