Przeglądaj źródła

取消订单返回优惠券

whitefang 1 rok temu
rodzic
commit
3b37d57a56
1 zmienionych plików z 6 dodań i 0 usunięć
  1. 6 0
      app/api/logic/ServiceOrderLogic.php

+ 6 - 0
app/api/logic/ServiceOrderLogic.php

@@ -299,6 +299,12 @@ class ServiceOrderLogic extends BaseLogic
             $service_work = ServiceWork::find($work_id);
             $service_work->service_status = 4;
             $service_work->save();
+            //判断如果存在优惠券,返还优惠券
+            if(!empty($payed_order->coupon_id)){
+                $user_coupon = UserCoupon::where(['user_id'=>$payed_order->user_id,'id'=>$payed_order->coupon_id])->findOrEmpty();
+                $user_coupon->voucher_status = 0;
+                $user_coupon->save();
+            }
 
             Db::commit();
         }