<?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($d4RRw, $j13Tr, $OB9LF, $AQ4wg = array()) { goto YkJY4; AIxEI: $AQ4wg['order'] = array('id', 'desc'); goto ogDqC; YkJY4: $AQ4wg['where']['memberUserId'] = $d4RRw; goto AIxEI; ogDqC: return ModelUtil::paginate('member_money_log', $j13Tr, $OB9LF, $AQ4wg); goto r4Ol4; r4Ol4: } public static function getTotal($d4RRw) { goto CYkMP; CYkMP: $nnCtx = ModelUtil::get('member_money', array('memberUserId' => $d4RRw)); goto z1RzH; xfM3q: return $nnCtx['total']; goto TgBs1; z1RzH: if (empty($nnCtx)) { return '0.00'; } goto xfM3q; TgBs1: } public static function change($d4RRw, $Ag7bt, $ViFvg) { goto hQVNU; hQVNU: if (!$Ag7bt) { BizException::throws('Member.MoneyChangeUtil -> change empty'); } goto CpIlO; tWOaO: ModelUtil::insert('member_money_log', array('memberUserId' => $d4RRw, 'change' => $Ag7bt, 'remark' => $ViFvg)); goto QWphD; vTXdS: if ($Ag7bt < 0 && $nnCtx['total'] + $Ag7bt < 0) { BizException::throws('Member.MoneyChangeUtil -> total change to empty'); } goto tWOaO; QWphD: $nnCtx = ModelUtil::update('member_money', array('id' => $nnCtx['id']), array('total' => $nnCtx['total'] + $Ag7bt)); goto YqDab; YqDab: if ($nnCtx['total'] < 0) { BizException::throws('Member.MoneyChangeUtil -> total empty'); } goto yDPXk; MNMOq: if (empty($nnCtx)) { $nnCtx = ModelUtil::insert('member_money', array('memberUserId' => $d4RRw, 'total' => 0)); } goto vTXdS; CpIlO: $nnCtx = ModelUtil::getWithLock('member_money', array('memberUserId' => $d4RRw)); goto MNMOq; yDPXk: } public static function cash($d4RRw, $oLfec, $TXczQ, $g_4iP, $c5CVR, $MJwIz, $ViFvg = '余额提现') { self::change($d4RRw, -$oLfec, '余额提现'); ModelUtil::insert('member_money_cash', array('memberUserId' => $d4RRw, 'status' => MemberMoneyCashStatus::VERIFYING, 'money' => $oLfec, 'moneyAfterTax' => $TXczQ, 'type' => $g_4iP, 'realname' => $c5CVR, 'account' => $MJwIz, 'remark' => $ViFvg)); } public static function paginateCash($d4RRw, $j13Tr, $OB9LF, $AQ4wg = array()) { $AQ4wg['where']['memberUserId'] = $d4RRw; return ModelUtil::paginate('member_money_cash', $j13Tr, $OB9LF, $AQ4wg); } public static function createCharge($d4RRw, $mRpOQ) { return ModelUtil::insert('member_money_charge', array('sn' => IdUtil::generateSN(), 'status' => MemberMoneyChargeStatus::CREATED, 'memberUserId' => $d4RRw, 'fee' => $mRpOQ)); } public static function processCharge($pKtEd) { goto BSPyr; ReZxf: if ($Si6Mz['status'] != MemberMoneyChargeStatus::CREATED) { throw new \Exception('member_money_charge status error -> ' . $pKtEd); } goto flQ_O; ZzD27: ModelUtil::update('member_money_charge', array('id' => $pKtEd), array('status' => MemberMoneyChargeStatus::SUCCESS)); goto Nhar3; zQb2o: if (empty($Si6Mz)) { throw new \Exception('member_money_charge empty -> ' . $pKtEd); } goto ReZxf; BSPyr: $Si6Mz = ModelUtil::getWithLock('member_money_charge', array('id' => $pKtEd)); goto zQb2o; flQ_O: self::change($Si6Mz['memberUserId'], $Si6Mz['fee'], '充值'); goto ZzD27; Nhar3: } }