<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Util; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Exception\BizException; use ModStart\Core\Util\IdUtil; use Module\Member\Type\MemberMoneyCashStatus; use Module\Member\Type\MemberMoneyChargeStatus; class MemberMoneyUtil { public static function paginateLog($nlOSA, $WLCMC, $Aqj3Z, $f2U49 = array()) { goto Ob15h; nBGNS: $f2U49['order'] = array('id', 'desc'); goto nb08V; nb08V: return ModelUtil::paginate('member_money_log', $WLCMC, $Aqj3Z, $f2U49); goto nHCev; Ob15h: $f2U49['where']['memberUserId'] = $nlOSA; goto nBGNS; nHCev: } public static function getTotal($nlOSA) { goto kqel3; uzOks: return $a_yFh['total']; goto Sfwo5; oczn0: if (empty($a_yFh)) { return '0.00'; } goto uzOks; kqel3: $a_yFh = ModelUtil::get('member_money', array('memberUserId' => $nlOSA)); goto oczn0; Sfwo5: } public static function change($nlOSA, $Oa6V9, $gGBGD) { goto g9vda; W4vrJ: if ($Oa6V9 < 0 && $a_yFh['total'] + $Oa6V9 < 0) { BizException::throws('Member.MoneyChangeUtil -> total change to empty'); } goto ywStP; rNASl: $a_yFh = ModelUtil::getWithLock('member_money', array('memberUserId' => $nlOSA)); goto vUM0R; LH0K0: $a_yFh = ModelUtil::update('member_money', array('id' => $a_yFh['id']), array('total' => $a_yFh['total'] + $Oa6V9)); goto VvQwP; ywStP: ModelUtil::insert('member_money_log', array('memberUserId' => $nlOSA, 'change' => $Oa6V9, 'remark' => $gGBGD)); goto LH0K0; g9vda: if (!$Oa6V9) { BizException::throws('Member.MoneyChangeUtil -> change empty'); } goto rNASl; VvQwP: if ($a_yFh['total'] < 0) { BizException::throws('Member.MoneyChangeUtil -> total empty'); } goto LL8Kk; vUM0R: if (empty($a_yFh)) { $a_yFh = ModelUtil::insert('member_money', array('memberUserId' => $nlOSA, 'total' => 0)); } goto W4vrJ; LL8Kk: } public static function cash($nlOSA, $LKZdd, $eAxdj, $AIxhN, $ye8_7, $ww4e6, $gGBGD = '余额提现') { self::change($nlOSA, -$LKZdd, '余额提现'); ModelUtil::insert('member_money_cash', array('memberUserId' => $nlOSA, 'status' => MemberMoneyCashStatus::VERIFYING, 'money' => $LKZdd, 'moneyAfterTax' => $eAxdj, 'type' => $AIxhN, 'realname' => $ye8_7, 'account' => $ww4e6, 'remark' => $gGBGD)); } public static function paginateCash($nlOSA, $WLCMC, $Aqj3Z, $f2U49 = array()) { $f2U49['where']['memberUserId'] = $nlOSA; return ModelUtil::paginate('member_money_cash', $WLCMC, $Aqj3Z, $f2U49); } public static function createCharge($nlOSA, $S0Zs1) { return ModelUtil::insert('member_money_charge', array('sn' => IdUtil::generateSN(), 'status' => MemberMoneyChargeStatus::CREATED, 'memberUserId' => $nlOSA, 'fee' => $S0Zs1)); } public static function processCharge($ORfxY) { goto bkfGb; jq6Qm: ModelUtil::update('member_money_charge', array('id' => $ORfxY), array('status' => MemberMoneyChargeStatus::SUCCESS)); goto dLEdp; mpNsV: if (empty($aEbU7)) { throw new \Exception('member_money_charge empty -> ' . $ORfxY); } goto fOTik; fOTik: if ($aEbU7['status'] != MemberMoneyChargeStatus::CREATED) { throw new \Exception('member_money_charge status error -> ' . $ORfxY); } goto w6axs; bkfGb: $aEbU7 = ModelUtil::getWithLock('member_money_charge', array('id' => $ORfxY)); goto mpNsV; w6axs: self::change($aEbU7['memberUserId'], $aEbU7['fee'], '充值'); goto jq6Qm; dLEdp: } }