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

View File

@@ -29,16 +29,20 @@ class SettleCouponImport implements ToModel, WithStartRow, WithChunkReading, Wit
try { try {
$order_id = trim($row[0]); $order_id = trim($row[0]);
$exists = Coupon::query()->where('pa_order_id', $order_id)->exists(); $exists = Coupon::query()->where('pa_order_id', $order_id)->exists();
if (! $exists) { if ($exists) {
CouponPaCheck::create([
'pa_order_id' => $order_id
]);
} else {
Coupon::query()->where('pa_order_id', $order_id)->update([ Coupon::query()->where('pa_order_id', $order_id)->update([
'is_settle' => 1 '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) { } catch (\Exception $e) {
throw new \Exception($e->getMessage()); throw new \Exception($e->getMessage());
} }