| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * Created by PhpStorm.
- * Name: 芸众商城系统
- * Author: 广州市芸众信息科技有限公司
- * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
- * Date: 2022/11/18
- * Time: 16:35
- */
- namespace app\common\modules\goods;
- use app\common\modules\goods\queue\GoodsUpdateObserverQueue;
- use app\common\observers\BaseObserver;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Contracts\Bus\Dispatcher;
- /**
- * 不要往这个观察者类加任何业务程序
- * Class GoodsObserverBase
- * @package app\common\modules\goods
- */
- class GoodsObserverBase extends BaseObserver
- {
- public function saving(Model $model)
- {
- }
- public function saved(Model $model)
- {
- //有修改退库存;这库存变动不能放到队列里,原因是再队列里无法区分是否变动
- if ($model->isDirty('stock')) {
- try {
- \Log::debug('<----商品编辑库存变动----'.$model->id);
- $requestData = request()->input();
- event(new \app\common\modules\goods\events\GoodsStockChangeEvent($model,$requestData));
- } catch (\Exception $exception) {
- \Log::debug("----{$model->id}--库存变动-error---". $exception->getMessage(),[$exception->getFile(),$exception->getLine()]);
- }
- }
- }
- public function updating(Model $model)
- {
- (new \app\common\services\operation\GoodsLog($model, 'update'));
- //$event = event(new \app\common\modules\goods\events\GoodsStockChangeEvent($model,request()->input()));
- }
- public function updated(Model $model)
- {
- //$event = event(new \app\common\modules\goods\events\GoodsStockChangeEvent($model,request()->input()));
- }
- }
|