feat: 修改

This commit is contained in:
赵世界 2024-03-23 11:28:58 +08:00
parent 10535b560a
commit afb6886640
2 changed files with 8 additions and 5 deletions

View File

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

View File

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