<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Faka\Job; use Carbon\Carbon; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Job\BaseJob; use Module\Faka\Type\ProductOrderProcessStatus; use Module\Faka\Type\ProductStockStatus; use Module\Vendor\Job\MailSendJob; class ProductOrderProcessorJob extends BaseJob { public $processorId = 0; public static function create($fwbR5) { goto e8WDN; DvqvL: $QJc0N->processorId = $fwbR5; goto AkZ1X; e8WDN: $QJc0N = new static(); goto DvqvL; AkZ1X: app('Illuminate\\Contracts\\Bus\\Dispatcher')->dispatch($QJc0N); goto eOKAb; eOKAb: } public function handle() { goto SdKjc; zxwyg: if ($kUoDZ > 0) { goto bLnjs; Bdwj4: $MDFmY = array_merge($MDFmY, $wWBoC); goto n10oo; bLnjs: $wWBoC = ModelUtil::model('faka_product_stock')->where(array('productId' => $MZHZc['productId'], 'status' => ProductStockStatus::NOT_USED))->limit($kUoDZ)->lockForUpdate()->get()->toArray(); goto YhVy4; YhVy4: foreach ($wWBoC as $rpflm) { ModelUtil::update('faka_product_stock', $rpflm['id'], array('orderId' => $MZHZc['id'], 'status' => ProductStockStatus::USED)); } goto Bdwj4; n10oo: } goto ZPFIN; ZPFIN: MailSendJob::create($MZHZc['email'], '发卡通知', 'fakaNotice', array('stocks' => $MDFmY, 'product' => $Wmda_), null, array(), 0, 'Faka'); goto Sfmzh; Sfmzh: ModelUtil::update('faka_product_order_processor', $this->processorId, array('endTime' => Carbon::now(), 'processStatus' => ProductOrderProcessStatus::PROCESSED)); goto tf_ix; tf_ix: ModelUtil::transactionCommit(); goto rw6G4; Vodvf: $kUoDZ = $MZHZc['amount'] - count($MDFmY); goto zxwyg; blLoH: $Wmda_ = ModelUtil::get('faka_product', $MZHZc['productId']); goto Y23bo; Ypw2u: if (empty($jGqlN)) { ModelUtil::transactionCommit(); return; } goto JZryV; PcawE: $jGqlN = ModelUtil::getWithLock('faka_product_order_processor', $this->processorId); goto Ypw2u; Y23bo: $MDFmY = ModelUtil::model('faka_product_stock')->where(array('orderId' => $MZHZc['id']))->get()->toArray(); goto Vodvf; menCQ: ModelUtil::update('faka_product_order_processor', $this->processorId, array('startTime' => Carbon::now())); goto VLyvX; JZryV: if ($jGqlN['processStatus'] != ProductOrderProcessStatus::WAIT_PROCESS) { ModelUtil::transactionCommit(); return; } goto menCQ; VLyvX: $MZHZc = ModelUtil::get('faka_product_order', $jGqlN['orderId']); goto blLoH; SdKjc: ModelUtil::transactionBegin(); goto PcawE; rw6G4: } }