This commit is contained in:
2022-02-10 16:51:05 +08:00
parent 8be61629f6
commit a7887cb999

View File

@@ -29,15 +29,19 @@ 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) {
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
]);
} else {
Coupon::query()->where('pa_order_id', $order_id)->update([
'is_settle' => 1
]);
}
}
} catch (\Exception $e) {
throw new \Exception($e->getMessage());