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()); }