|
|
|
|
@ -141,6 +141,7 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
|
{
|
|
|
|
|
$threshold = 100;
|
|
|
|
|
$last_id = cache("last_auto_checkout_order_item_id", 0);
|
|
|
|
|
Log::channel("daily_auto_checkout")->info("Last id:" . $last_id);
|
|
|
|
|
|
|
|
|
|
$unpaid_order_items = (new OrderItems())
|
|
|
|
|
->whereHas("order", function ($query) {
|
|
|
|
|
@ -159,9 +160,7 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log::channel("daily_auto_checkout")->info("Last id:" . $last_id);
|
|
|
|
|
foreach ($unpaid_order_items as $item) {
|
|
|
|
|
cache(['last_auto_checkout_order_item_id' => $item->id], now()->addSeconds(90));
|
|
|
|
|
$customer = $item->customer;
|
|
|
|
|
if ($customer->balance < $item->total || $item->total == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
@ -181,6 +180,7 @@ class OrderItems extends SoftDeletesModel
|
|
|
|
|
|
|
|
|
|
$customer->update(["balance" => $balance]);
|
|
|
|
|
}
|
|
|
|
|
cache(['last_auto_checkout_order_item_id' => $unpaid_order_items->last()->id], now()->addSeconds(90));
|
|
|
|
|
Log::channel("daily_auto_checkout")->info("From " . $unpaid_order_items->first()->id . " to " . $unpaid_order_items->last()->id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|