<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Api\Controller; use Illuminate\Routing\Controller; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Response; use ModStart\Core\Type\TypeUtil; use Module\Member\Auth\MemberUser; use Module\Member\Support\MemberLoginCheck; use Module\Member\Type\MemberMoneyCashType; use Module\Member\Util\MemberMoneyUtil; class MemberMoneyCashController extends Controller implements MemberLoginCheck { public function get() { goto Zqi4p; J_V4e: $I3eLy = modstart_config('Member_MoneyCashMin', 100); goto z_PRC; z_PRC: return Response::generateSuccessData(array('total' => $EWgvi, 'desc' => modstart_config('Member_MoneyCashDescription'), 'min' => sprintf('%0.2f', $I3eLy), 'rate' => modstart_config('Member_MoneyCashTaxRate', 0), 'types' => TypeUtil::dump(MemberMoneyCashType::class), 'canCash' => $EWgvi >= $I3eLy, 'defaultType' => MemberMoneyCashType::ALIPAY)); goto ye8ya; Zqi4p: $EWgvi = MemberMoneyUtil::getTotal(MemberUser::id()); goto J_V4e; ye8ya: } public function calc() { goto k3COw; k3COw: $Nw6ws = InputPackage::buildFromInput(); goto PwgMv; n0eRY: $EWgvi = MemberMoneyUtil::getTotal(MemberUser::id()); goto C2J8j; PwgMv: $oLfec = $Nw6ws->getDecimal('money'); goto vsZHP; wKDZo: return Response::generateSuccessData(array('value' => $hsART)); goto K23N6; oHg5S: $HZQez = modstart_config('Member_MoneyCashTaxRate', 0); goto PIiWi; vsZHP: if ($oLfec < modstart_config('Member_MoneyCashMin', 100)) { return Response::generateError('最小提现金额为' . modstart_config('Member_MoneyCashMin', 100)); } goto n0eRY; PIiWi: $HZQez = 100 - min(max($HZQez, 0), 99); goto zs7t5; zs7t5: $hsART = bcdiv(bcmul($oLfec, $HZQez, 2), 100, 2); goto wKDZo; C2J8j: if ($oLfec > $EWgvi) { return Response::generateError('余额不足'); } goto oHg5S; K23N6: } public function submit() { goto luUup; T9PLL: $Nw6ws = InputPackage::buildFromInput(); goto G1hFI; d20aJ: try { goto fYfhK; bEV6V: ModelUtil::transactionCommit(); goto EWP4p; fYfhK: ModelUtil::transactionBegin(); goto Rjh4X; Rjh4X: MemberMoneyUtil::cash(MemberUser::id(), $oLfec, $TXczQ, MemberMoneyCashType::ALIPAY, $SPspk, $iDoj1); goto bEV6V; EWP4p: } catch (\Exception $fWY9h) { ModelUtil::transactionRollback(); throw $fWY9h; } goto E8Q1x; E8Q1x: return Response::generate(0, '提交成功', null, modstart_web_url('member_money/cash/log')); goto SsBk_; GtO5l: if ($EWgvi < modstart_config('Member_MoneyCashMin', 100)) { return Response::generate(-1, '当前账户余额不满' . modstart_config('Member_MoneyCashMin', 100) . ',不能提现'); } goto BjllR; wiOuh: if ($oLfec < 0.01) { return Response::generate(-1, '提现金额不能为空'); } goto nWfQF; dn0Jf: $g_4iP = $Nw6ws->getType('type', MemberMoneyCashType::class); goto fpRYv; ZWf0b: $TXczQ = bcdiv(bcmul($oLfec, $HZQez, 2), 100, 2); goto d20aJ; fpRYv: switch ($g_4iP) { case MemberMoneyCashType::ALIPAY: goto nIl0T; to1hr: if (empty($iDoj1)) { return Response::generate(-1, '支付宝账号不能为空'); } goto ACWbR; H85m2: if (empty($SPspk)) { return Response::generate(-1, '支付宝姓名不能为空'); } goto to1hr; nIl0T: $SPspk = $Nw6ws->getTrimString('alipayRealname'); goto zxXLd; zxXLd: $iDoj1 = $Nw6ws->getTrimString('alipayAccount'); goto H85m2; ACWbR: break; goto uTJ4p; uTJ4p: default: return Response::generateError('支付类型错误'); } goto K2u4J; O8BeO: $HZQez = 100 - min(max($HZQez, 0), 99); goto ZWf0b; K2u4J: $EWgvi = MemberMoneyUtil::getTotal(MemberUser::id()); goto GtO5l; BjllR: $HZQez = modstart_config('Member_MoneyCashTaxRate', 0); goto O8BeO; luUup: if (!modstart_config('Member_MoneyCashEnable', false)) { return Response::generateError('功能未开启'); } goto T9PLL; nWfQF: if ($oLfec < modstart_config('Member_MoneyCashMin', 100)) { return Response::generate(-1, '提现金额至少为' . modstart_config('Member_MoneyCashMin', 100)); } goto dn0Jf; G1hFI: $oLfec = $Nw6ws->getDecimal('money'); goto wiOuh; SsBk_: } public function log() { goto m1GGm; UIplo: $fFBu8 = MemberMoneyUtil::paginateCash(MemberUser::id(), $Nw6ws->getPage(), $Nw6ws->getPageSize(), $AQ4wg); goto z8Oe2; m1GGm: $Nw6ws = InputPackage::buildFromInput(); goto mgJ7K; z8Oe2: return Response::generateSuccessPaginate($Nw6ws->getPage(), $Nw6ws->getPageSize(), $fFBu8); goto QaXqd; mgJ7K: $AQ4wg = array(); goto UIplo; QaXqd: } }