| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * Created by PhpStorm.
- * Name: 芸众商城系统
- * Author: 广州市芸众信息科技有限公司
- * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
- * Date: 2022/11/18
- * Time: 16:37
- */
- namespace app\common\modules\goods\queue;
- use app\common\models\Goods;
- use app\common\modules\goods\events\GoodsStockChangeEvent;
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- class GoodsUpdateObserverQueue implements ShouldQueue
- {
- use InteractsWithQueue, Queueable, SerializesModels;
- private $uniacid;
- protected $goods;
- protected $requestData;
- protected $type;
- public function __construct($uniacid, Goods $goods, $requestData)
- {
- $this->uniacid = $uniacid;
- \YunShop::app()->uniacid = $uniacid;
- \Setting::$uniqueAccountId = $uniacid;
- $this->requestData = $requestData;
- $this->goods = $goods;
- }
- public function handle()
- {
- \YunShop::app()->uniacid = $this->uniacid;
- \Setting::$uniqueAccountId = $this->uniacid;
- \Log::debug(\YunShop::app()->uniacid.'----库存变动--'.$this->goods->id, $this->goods->getDirty());
- \Log::debug('---库存变动------', $this->goods->getAttributes());
- \Log::debug('---库存变动------', $this->requestData);
- //有修改退库存
- $bool = $this->goods->isDirty('stock');
- if ($bool) {
- \Log::debug('----库存变动--stock'.$bool);
- }
- if ($bool) {
- $event = new GoodsStockChangeEvent($this->goods, $this->requestData);
- \Log::debug('----库存变动--触发--'.get_class($event));
- event($event);
- }
- }
- }
|