<?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 atbEz; FGt5S: if ($FF4cr >= 0 && $FF4cr <= 0) { goto CG0MG; yV6i0: return Response::send(0, null, null, $uBQi3); goto l2tO7; g1N3n: $uBQi3 = empty($Gs3Xd['data']['order']['redirect']) ? modstart_web_url('') : $Gs3Xd['data']['order']['redirect']; goto yV6i0; F9o9E: BizException::throwsIfResponseError($Gs3Xd); goto g1N3n; CG0MG: $Gs3Xd = PayOrderUtil::autoPay($MZHZc['biz'], $MZHZc['bizId'], 0); goto F9o9E; l2tO7: } goto xOoVa; npn0A: return $this->view('pay.index', array('order' => $MZHZc, 'autoClickPayType' => $ViF5p)); goto PNe32; xOoVa: $ViF5p = Session::get('autoClickPayType', null); goto HI62B; CoV1z: $FF4cr = floatval($EjVLg['order']['feeTotal']); goto FGt5S; HI62B: Session::forget('autoClickPayType'); goto npn0A; AblTH: $MZHZc = $EjVLg['order']; goto HriZh; HriZh: if (Request::isPost()) { return Response::jsonFromGenerate($this->api->submit($MZHZc, $EjVLg['orderSecretId'])); } goto CoV1z; atbEz: $EjVLg = Response::tryGetData($this->api->info()); goto AblTH; PNe32: } public function watch() { goto T9l0T; T9l0T: $EjVLg = Response::tryGetData($this->api->info()); goto pNK25; pNK25: $MZHZc = $EjVLg['order']; goto y1EMR; y1EMR: switch ($MZHZc['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 XlmwE; XlmwE: } public function quick($jxsQg) { goto A99aX; iNPlu: ModelUtil::transactionBegin(); goto FapHE; A99aX: BizException::throwsIfEmpty('参数sn错误', $jxsQg); goto ZgDDF; BPt7n: BizException::throwsIfEmpty('参数sn错误', $pNLgg); goto St9wb; ZgDDF: list($pNLgg, $lnnIZ) = explode('_', $jxsQg); goto BPt7n; St9wb: BizException::throwsIfEmpty('参数sn错误', $lnnIZ); goto iNPlu; zg6kH: return $this->view('pay.quick', array('payUrl' => $WHKmT, 'order' => $MZHZc)); goto mona6; FapHE: try { goto Vo7ow; k7pZe: BizException::throwsIfEmpty('订单不存在', $ngGXH); goto HF3e0; GUkAZ: if ($ngGXH['status'] == PayOrderQuickStatus::NEW_ORDER) { goto RAAmZ; RAAmZ: ModelUtil::decodeRecordJson($ngGXH, array('param', 'session')); goto r4GVU; b5wRR: $Gs3Xd = $Dnlri->createOrderForQuick($ngGXH); goto RHjxR; e6CYX: BizException::throwsIfEmpty('订单不存在', $MZHZc); goto gfQDx; gfQDx: ModelUtil::update('pay_order_quick', $ngGXH['id'], array('status' => PayOrderQuickStatus::CREATED, 'orderId' => $MZHZc['id'])); goto Vf8uu; xYQgU: BizException::throwsIfResponseError($tsF4E); goto OwqX1; B3mfw: $tsF4E = $g7VMp->performSubmitOrder($Dnlri->name(), $Gs3Xd['data']['bizId'], $Gs3Xd['data']['feeTotal'], $Gs3Xd['data']['body'], array('ShowSuccessPage' => true)); goto xYQgU; Ef40e: if (isset($Gs3Xd['data']['redirect'])) { InputPackage::mergeToInput('redirect', $Gs3Xd['data']['redirect']); } goto B3mfw; Vf8uu: $WHKmT = $tsF4E['data']['payUrl']; goto R7Ucq; OwqX1: $MZHZc = PayOrderUtil::getOrder($tsF4E['data']['orderSecretId']); goto e6CYX; r4GVU: $Dnlri = PayCenterBiz::get($ngGXH['biz']); goto Jpdn7; MTW87: BizException::throwsIfResponseError($Gs3Xd); goto FcOR9; RHjxR: BizException::throwsIfEmpty('支付业务创建订单失败', $Gs3Xd); goto MTW87; FcOR9: $g7VMp = app(PayCenterPerform::class); goto Ef40e; Jpdn7: BizException::throwsIfEmpty('支付业务不存在', $Dnlri); goto b5wRR; R7Ucq: } else { goto Tdocx; rUgyT: $WHKmT = modstart_web_url('pay', array('order' => $yIijQ)); goto uVKlH; Tdocx: $MZHZc = PayOrderUtil::get($ngGXH['orderId']); goto fL0Bv; fL0Bv: BizException::throwsIfEmpty('订单不存在', $MZHZc); goto r9m3u; r9m3u: $yIijQ = PayOrderUtil::getOrderSecretId($MZHZc['id']); goto rUgyT; uVKlH: } goto wcyik; Vo7ow: $ngGXH = ModelUtil::getWithLock('pay_order_quick', $pNLgg); goto k7pZe; HF3e0: BizException::throwsIf('订单不存在', $ngGXH['code'] != $lnnIZ); goto GUkAZ; wcyik: ModelUtil::transactionCommit(); goto LhyKL; LhyKL: } catch (BizException $hSVcc) { ModelUtil::transactionRollback(); return Response::sendError($hSVcc->getMessage()); } goto zg6kH; mona6: } public function success() { return $this->view('pay.success', array()); } }