<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Shop\Jobs; use Illuminate\Support\Facades\Event; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Job\BaseJob; use ModStart\Core\Util\EventUtil; use ModStart\Core\Util\SerializeUtil; use Module\Shop\Events\ShopOrderExpireEvent; use Illuminate\Support\Facades\Log; use Module\Vendor\Type\OrderStatus; class OrderCancelJob extends BaseJob { public $orderId; public $param; public static function create($E24Va, $w6bW5 = array(), $fr4BE = 0) { goto D2NQ8; AVYTP: $owZYb->orderId = $E24Va; goto jFT7r; D2NQ8: $owZYb = new OrderCancelJob(); goto AVYTP; E1DWz: if ($fr4BE > 0) { $owZYb->delay($fr4BE); } goto YIxsI; YIxsI: app('Illuminate\\Contracts\\Bus\\Dispatcher')->dispatch($owZYb); goto YS2Oy; jFT7r: $owZYb->param = $w6bW5; goto E1DWz; YS2Oy: } public function handle() { goto l3yPp; FFuQ5: if (!ShopLockUtil::checkoutLockBegin()) { self::create($this->orderId, 5); return; } goto iLmbt; DuCOO: if (empty($v9Xk2)) { goto WqZRn; gPiKA: ShopLockUtil::checkoutLockEnd(); goto u9Z33; WqZRn: ModelUtil::transactionCommit(); goto gPiKA; u9Z33: return; goto LFxYR; LFxYR: } goto dxPqR; EVYZz: $jiVEb = ModelUtil::model('order_goods')->where(array('orderId' => $this->orderId))->lockForUpdate()->get()->toArray(); goto MkD5K; iLmbt: $v9Xk2 = ModelUtil::getWithLock('order', array('id' => $this->orderId)); goto DuCOO; A790M: foreach ($jiVEb as $RkS5H) { if ($RkS5H['_goodsSnapshot']['specSpec']) { ModelUtil::change('goods_spec', array('goodsId' => $RkS5H['goodsId'], 'spec' => $RkS5H['_goodsSnapshot']['specSpec']), 'stock', +$RkS5H['amount']); Log::info('Shop.goods.' . $RkS5H['goodsId'] . '.' . $RkS5H['_goodsSnapshot']['specSpec'] . ' stock +' . $RkS5H['amount']); } else { ModelUtil::change('goods', array('id' => $RkS5H['goodsId']), 'stock', +$RkS5H['amount']); Log::info('Shop.Shop.goods.' . $RkS5H['goodsId'] . ' stock +' . $RkS5H['amount']); } } goto sSzk5; SLK3W: ModelUtil::transactionCommit(); goto HiP0m; sSzk5: if (!empty($this->param['expire'])) { ModelUtil::update('order', array('id' => $this->orderId), array('status' => OrderStatus::CANCEL_EXPIRED)); } else { ModelUtil::update('order', array('id' => $this->orderId), array('status' => OrderStatus::CANCEL)); } goto SLK3W; HiP0m: ShopLockUtil::checkoutLockEnd(); goto OALM_; dxPqR: if ($v9Xk2['status'] != OrderStatus::CANCEL_QUEUE) { goto pgBZy; W1P2U: return; goto YqYv5; pgBZy: ModelUtil::transactionCommit(); goto YxDXr; YxDXr: ShopLockUtil::checkoutLockEnd(); goto W1P2U; YqYv5: } goto EVYZz; l3yPp: Log::info('Shop.OrderCancelJob.' . sprintf('%05d', getmypid()) . '.Execute ->' . $this->orderId . ' -> ' . SerializeUtil::jsonEncode($this->param)); goto W9YrU; OALM_: EventUtil::fire(new ShopOrderExpireEvent($this->orderId)); goto VJdWP; W9YrU: ModelUtil::transactionBegin(); goto FFuQ5; MkD5K: ModelUtil::join($jiVEb, 'goodsSnapshotId', '_goodsSnapshot', 'goods_snapshot', 'id'); goto A790M; VJdWP: } }