Merge pull request !222 from 赵世界/feat/2024
This commit is contained in:
赵世界 2024-03-23 03:29:36 +00:00 committed by Gitee
commit a9f5b39ce9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 5 deletions

View File

@ -3,15 +3,16 @@
namespace App\Listeners;
use App\Events\BatchStockUpdateEvent;
use App\Jobs\BusinessGoodsSkuIncrQuantity;
use App\Models\BusinessGoodsSku;
use App\Models\Shop;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use App\Services\Business\BusinessFactory;
class BatchStockUpdateListener
class BatchStockUpdateListener implements ShouldQueue
{
use InteractsWithQueue;
/**
* Create the event listener.
*
@ -32,7 +33,7 @@ class BatchStockUpdateListener
{
$shops = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP])->get(['id', 'plat_id']);
if (empty($shops)) {
return false;
return;
}
foreach ($shops as $shop) {
foreach ($event->goodsSkus as $goodsSku) {

View File

@ -9,8 +9,10 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use App\Services\Business\BusinessFactory;
class StockUpdateListener
class StockUpdateListener implements ShouldQueue
{
use InteractsWithQueue;
/**
* Create the event listener.
*
@ -31,7 +33,7 @@ class StockUpdateListener
{
$shops = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP])->get(['id', 'plat_id']);
if (empty($shops)) {
return false;
return;
}
foreach ($shops as $shop) {
$num = $event->goodsSku->stock;