<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\PayCenter\Web\Controller; use Illuminate\Support\Facades\Session; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Module\ModuleBaseController; use Module\PayCenter\Biz\PayCenterBiz; use Module\PayCenter\Support\PayCenterPerform; use Module\PayCenter\Type\PayOrderQuickStatus; use Module\PayCenter\Type\PayOrderStatus; use Module\PayCenter\Util\PayOrderUtil; class PayController extends ModuleBaseController { private $api; public function __construct() { $this->api = app(\Module\PayCenter\Api\Controller\PayController::class); } public function index() { goto HGLJy; bNCuu: if (Request::isPost()) { return Response::jsonFromGenerate($this->api->submit($v9Xk2, $TaEmZ['orderSecretId'])); } goto sbKFJ; oAzed: Session::forget('autoClickPayType'); goto NTIOy; HGLJy: $TaEmZ = Response::tryGetData($this->api->info()); goto t391q; t391q: $v9Xk2 = $TaEmZ['order']; goto bNCuu; sbKFJ: $C8kl2 = floatval($TaEmZ['order']['feeTotal']); goto ayV0d; NTIOy: return $this->view('pay.index', array('order' => $v9Xk2, 'autoClickPayType' => $u7EZL)); goto llo9b; ayV0d: if ($C8kl2 >= 0 && $C8kl2 <= 0) { goto SSOee; UvHPs: BizException::throwsIfResponseError($rhLXE); goto UW1kN; SSOee: $rhLXE = PayOrderUtil::autoPay($v9Xk2['biz'], $v9Xk2['bizId'], 0); goto UvHPs; UW1kN: $Ix_Nr = empty($rhLXE['data']['order']['redirect']) ? modstart_web_url('') : $rhLXE['data']['order']['redirect']; goto ekDHZ; ekDHZ: return Response::send(0, null, null, $Ix_Nr); goto T0MPQ; T0MPQ: } goto C1Hhk; C1Hhk: $u7EZL = Session::get('autoClickPayType', null); goto oAzed; llo9b: } public function watch() { goto OZAb5; vEf0L: switch ($v9Xk2['status']) { case PayOrderStatus::NEW_ORDER: case PayOrderStatus::CREATED: return Response::generate(0, null, array('status' => 'new')); case PayOrderStatus::PAYED: return Response::generate(0, null, array('status' => 'payed')); case PayOrderStatus::CLOSED: return Response::generate(0, null, array('status' => 'expired')); default: return Response::generate(-1, 'order status error'); } goto Iuit7; fdCOi: $v9Xk2 = $TaEmZ['order']; goto vEf0L; OZAb5: $TaEmZ = Response::tryGetData($this->api->info()); goto fdCOi; Iuit7: } public function quick($rhvmB) { goto shyPG; kbiI3: try { goto qA_J_; hGkI5: BizException::throwsIf('订单不存在', $BelaH['code'] != $tmz5M); goto cboTc; rNP5A: BizException::throwsIfEmpty('订单不存在', $BelaH); goto hGkI5; P33Nr: ModelUtil::transactionCommit(); goto koV5O; qA_J_: $BelaH = ModelUtil::getWithLock('pay_order_quick', $gZ39D); goto rNP5A; cboTc: if ($BelaH['status'] == PayOrderQuickStatus::NEW_ORDER) { goto qOLcF; b3c1T: $g16tm = PayCenterBiz::get($BelaH['biz']); goto Ljv1Z; trFLN: BizException::throwsIfResponseError($rhLXE); goto o3VZ7; o3VZ7: $eQyQ4 = app(PayCenterPerform::class); goto tMA5M; W2k18: $v9Xk2 = PayOrderUtil::getOrder($krGfo['data']['orderSecretId']); goto wbygx; qOLcF: ModelUtil::decodeRecordJson($BelaH, array('param', 'session')); goto b3c1T; gKC1V: BizException::throwsIfResponseError($krGfo); goto W2k18; t8IsK: BizException::throwsIfEmpty('支付业务创建订单失败', $rhLXE); goto trFLN; mPEgI: $rhLXE = $g16tm->createOrderForQuick($BelaH); goto t8IsK; Ljv1Z: BizException::throwsIfEmpty('支付业务不存在', $g16tm); goto mPEgI; e_Wbd: ModelUtil::update('pay_order_quick', $BelaH['id'], array('status' => PayOrderQuickStatus::CREATED, 'orderId' => $v9Xk2['id'])); goto e08yA; FDEWM: $krGfo = $eQyQ4->performSubmitOrder($g16tm->name(), $rhLXE['data']['bizId'], $rhLXE['data']['feeTotal'], $rhLXE['data']['body'], array('ShowSuccessPage' => true)); goto gKC1V; e08yA: $MbUgJ = $krGfo['data']['payUrl']; goto Rm6u_; tMA5M: if (isset($rhLXE['data']['redirect'])) { InputPackage::mergeToInput('redirect', $rhLXE['data']['redirect']); } goto FDEWM; wbygx: BizException::throwsIfEmpty('订单不存在', $v9Xk2); goto e_Wbd; Rm6u_: } else { goto YnqUT; g0lub: $kep9x = PayOrderUtil::getOrderSecretId($v9Xk2['id']); goto d8IMs; YnqUT: $v9Xk2 = PayOrderUtil::get($BelaH['orderId']); goto xEh3Z; d8IMs: $MbUgJ = modstart_web_url('pay', array('order' => $kep9x)); goto Vw2k8; xEh3Z: BizException::throwsIfEmpty('订单不存在', $v9Xk2); goto g0lub; Vw2k8: } goto P33Nr; koV5O: } catch (BizException $qoTNG) { ModelUtil::transactionRollback(); return Response::sendError($qoTNG->getMessage()); } goto AbzEP; lv5m4: BizException::throwsIfEmpty('参数sn错误', $tmz5M); goto Yw_Wq; CGzeO: BizException::throwsIfEmpty('参数sn错误', $gZ39D); goto lv5m4; AbzEP: return $this->view('pay.quick', array('payUrl' => $MbUgJ, 'order' => $v9Xk2)); goto kVxRO; p3o_6: list($gZ39D, $tmz5M) = explode('_', $rhvmB); goto CGzeO; Yw_Wq: ModelUtil::transactionBegin(); goto kbiI3; shyPG: BizException::throwsIfEmpty('参数sn错误', $rhvmB); goto p3o_6; kVxRO: } public function success() { return $this->view('pay.success', array()); } }