From a7887cb999ea1705c2ed48b6926c9422bfc6e447 Mon Sep 17 00:00:00 2001 From: xuanchen120 <122383162@qq.com> Date: Thu, 10 Feb 2022 16:51:05 +0800 Subject: [PATCH] tiaobug --- app/Admin/Imports/SettleCouponImport.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Admin/Imports/SettleCouponImport.php b/app/Admin/Imports/SettleCouponImport.php index c903c4c..22042a6 100644 --- a/app/Admin/Imports/SettleCouponImport.php +++ b/app/Admin/Imports/SettleCouponImport.php @@ -29,16 +29,20 @@ class SettleCouponImport implements ToModel, WithStartRow, WithChunkReading, Wit try { $order_id = trim($row[0]); $exists = Coupon::query()->where('pa_order_id', $order_id)->exists(); - if (! $exists) { - CouponPaCheck::create([ - 'pa_order_id' => $order_id - ]); - } else { + if ($exists) { Coupon::query()->where('pa_order_id', $order_id)->update([ 'is_settle' => 1 ]); + } else { + $exists = CouponPaCheck::query()->where('pa_order_id', $order_id)->exists(); + if (! $exists) { + CouponPaCheck::create([ + 'pa_order_id' => $order_id + ]); + } } + } catch (\Exception $e) { throw new \Exception($e->getMessage()); }