hrjy 3 years ago
parent
commit
0867283886
1 changed files with 7 additions and 0 deletions
  1. 7 0
      app/admin/controller/order/StoreOrder.php

+ 7 - 0
app/admin/controller/order/StoreOrder.php

@@ -10,6 +10,7 @@ namespace app\admin\controller\order;
 use app\admin\controller\AuthController;
 use app\admin\model\order\StoreOrderCartInfo;
 use app\admin\model\system\Express;
+use app\admin\model\ump\StoreCouponUser;
 use crmeb\repositories\OrderRepository;
 use crmeb\repositories\ShortLetterRepositories;
 use crmeb\services\{
@@ -525,6 +526,12 @@ class StoreOrder extends AuthController
         $data['refund_price'] = bcadd($data['refund_price'], $product['refund_price'], 2);
         $bj = bccomp((float)$product['pay_price'], (float)$data['refund_price'], 2);
         if ($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额');
+        $coupon = StoreCouponUser::where('order_id',$product['order_id'])->select();
+        if ($coupon){
+            if (!empty(StoreCouponUser::where('order_id',$product['order_id'])->where('status', 1)->find())) return Json::fail('优惠券已使用不能退款');
+            StoreCouponUser::where('order_id',$product['order_id'])->delete();
+        }
+
         if ($data['type'] == 1) {
             $data['refund_status'] = 2;
         } else if ($data['type'] == 2) {