main
Jing Li 2024-05-20 10:13:19 +08:00
parent a1b8e5468a
commit 8a317876e0
1 changed files with 7 additions and 3 deletions

View File

@ -42,8 +42,14 @@ class TaskLedgerGenerateCommand extends Command
protected function generateTasks(Carbon $datetime): void
{
$stores = Store::with(['master'])->get();
if ($stores->isEmpty()) {
return;
}
/** @var \App\Models\PlanLedger */
$planable = DB::transaction(function () use ($datetime) {
$planable = DB::transaction(function () use ($datetime, $stores) {
/** @var \App\Models\PlanLedger */
$planable = PlanLedger::firstOrNew([
'date' => $datetime->format('Y-m-d'),
@ -63,8 +69,6 @@ class TaskLedgerGenerateCommand extends Command
return $planable->setRelation('plan', $plan);
});
$stores = Store::with(['master'])->get();
/** @var \App\Models\Store */
foreach ($stores as $store) {
DB::transaction(function () use ($store, $planable) {