This commit is contained in:
zhouchangcheng 2024-05-27 15:43:40 +08:00
parent e206e87197
commit 6dddb19629
3 changed files with 9 additions and 9 deletions

View File

@ -162,21 +162,21 @@ public function updateGoods(): void
} }
DB::transaction(function () use ($goods, $itemIds, $noticeIdMapItemId) { 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 = []; $notices = [];
foreach ($items as $item) { foreach ($items as $item) {
$item->fill($goods[$item->itemId]); $item->fill($goods[$item->itemid]);
if ($item->isDirty()) { if ($item->isDirty()) {
$item->save(); $item->save();
} }
$item->good_item->fill($goods[$item->itemId]); $item->item->fill($goods[$item->itemid]);
if ($item->good_item->isDirty()) { if ($item->item->isDirty()) {
$item->good_item->save(); $item->item->save();
} }
$notices[] = $noticeIdMapItemId[$item->itemId]; $notices[] = $noticeIdMapItemId[$item->itemid];
} }
\App\Models\Notice::query()->whereIn('notice_id', $notices) \App\Models\Notice::query()->whereIn('notice_id', $notices)
->update(['state', 3]); ->update(['state' => 3]);
}); });

View File

@ -14,7 +14,7 @@ class Good extends Base
'market_price','settlement','category_id', 'category_name' 'market_price','settlement','category_id', 'category_name'
]; ];
public function goodItem(): HasOne public function item(): HasOne
{ {
return $this->hasOne(GoodsItem::class, 'item_id', 'itemid'); return $this->hasOne(GoodsItem::class, 'item_id', 'itemid');
} }

View File

@ -18,7 +18,7 @@ public function up()
$table->integer('notice_id')->unique()->comment('通知id'); $table->integer('notice_id')->unique()->comment('通知id');
$table->integer('notice_type')->comment('通知type'); $table->integer('notice_type')->comment('通知type');
$table->text('raw_content')->comment('原始消息内容'); $table->text('raw_content')->comment('原始消息内容');
$table->tinyInteger('state')->default(1)->comment('消息状态1待消费2消费进行中,3处理完成'); $table->tinyInteger('state')->default(1)->comment('消息状态1待消费,3处理完成');
$table->timestamps(); $table->timestamps();
}); });
} }