feat: #10000 库存同步修改,索引优化

This commit is contained in:
赵世界 2022-08-18 11:08:13 +08:00
parent ed5fd2f5f2
commit 2de3c6b8bf
4 changed files with 5 additions and 3 deletions

View File

@ -29,7 +29,7 @@ class StockUpdateListener
*/ */
public function handle(StockUpdateEvent $event) public function handle(StockUpdateEvent $event)
{ {
$shops = Shop::query()->where('status', 1)->get(['id', 'plat_id']); $shops = Shop::query()->whereNotIn('status', [0, 3])->get(['id', 'plat_id']);
if (empty($shops)) { if (empty($shops)) {
return; return;
} }

View File

@ -45,7 +45,7 @@ class UpdateBusinessGoodsStock implements ShouldQueue
return; return;
} }
$shops = Shop::query()->where('id', '<>', $event->businessOrderItem['shop_id'])->where('status', 1)->get(['id', 'plat_id']); $shops = Shop::query()->where('id', '<>', $event->businessOrderItem['shop_id'])->whereNotIn('status', [0, 3])->get(['id', 'plat_id']);
if (empty($shops)) { if (empty($shops)) {
return; return;
} }

View File

@ -32,7 +32,7 @@ class Goods
$sku['spec_list'] = json_encode($sku['spec_list'], 256); $sku['spec_list'] = json_encode($sku['spec_list'], 256);
$data = array_merge($businessGood, $sku); $data = array_merge($businessGood, $sku);
BusinessGoodsSku::updateOrCreate( BusinessGoodsSku::updateOrCreate(
['shop_id' => $shopId, 'activity_no' => $businessGood['activity_no'], 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']], ['shop_id' => $shopId, 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']],
$data $data
); );
} }

View File

@ -41,6 +41,8 @@ class CreateBusinessGoodsSkusTable extends Migration
$table->string('thumb_url')->nullable(); $table->string('thumb_url')->nullable();
$table->bigInteger('total_quantity')->nullable(); $table->bigInteger('total_quantity')->nullable();
$table->timestamps(); $table->timestamps();
$table->index(['shop_id', 'goods_id', 'sku_id']);
$table->index(['shop_id', 'external_sku_id']);
}); });
} }