diff --git a/app/Jobs/notice.php b/app/Jobs/notice.php index 5f59935..0d48dde 100644 --- a/app/Jobs/notice.php +++ b/app/Jobs/notice.php @@ -162,21 +162,21 @@ public function updateGoods(): void } DB::transaction(function () use ($goods, $itemIds, $noticeIdMapItemId) { - $items = Good::query()->whereIn('itemid', $itemIds)->with('good_item')->get(); + $items = Good::query()->whereIn('itemid', $itemIds)->with('item')->get(); $notices = []; foreach ($items as $item) { - $item->fill($goods[$item->itemId]); + $item->fill($goods[$item->itemid]); if ($item->isDirty()) { $item->save(); } - $item->good_item->fill($goods[$item->itemId]); - if ($item->good_item->isDirty()) { - $item->good_item->save(); + $item->item->fill($goods[$item->itemid]); + if ($item->item->isDirty()) { + $item->item->save(); } - $notices[] = $noticeIdMapItemId[$item->itemId]; + $notices[] = $noticeIdMapItemId[$item->itemid]; } \App\Models\Notice::query()->whereIn('notice_id', $notices) - ->update(['state', 3]); + ->update(['state' => 3]); }); diff --git a/app/Models/Good.php b/app/Models/Good.php index 4e54431..ead9a6c 100644 --- a/app/Models/Good.php +++ b/app/Models/Good.php @@ -14,7 +14,7 @@ class Good extends Base 'market_price','settlement','category_id', 'category_name' ]; - public function goodItem(): HasOne + public function item(): HasOne { return $this->hasOne(GoodsItem::class, 'item_id', 'itemid'); } diff --git a/database/migrations/2024_05_24_033401_create_notices_table.php b/database/migrations/2024_05_24_033401_create_notices_table.php index 4d304fd..577f209 100644 --- a/database/migrations/2024_05_24_033401_create_notices_table.php +++ b/database/migrations/2024_05_24_033401_create_notices_table.php @@ -18,7 +18,7 @@ public function up() $table->integer('notice_id')->unique()->comment('通知id'); $table->integer('notice_type')->comment('通知type'); $table->text('raw_content')->comment('原始消息内容'); - $table->tinyInteger('state')->default(1)->comment('消息状态,1待消费,2消费进行中,3处理完成'); + $table->tinyInteger('state')->default(1)->comment('消息状态,1待消费,3处理完成'); $table->timestamps(); }); }