<?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($shbIl, $iXUoW, $VUK_X, $r2pbP = array()) { goto OTUVH; rirHd: $r2pbP['order'] = array('id', 'desc'); goto AX4_D; AX4_D: return ModelUtil::paginate('member_money_log', $iXUoW, $VUK_X, $r2pbP); goto sZsJV; OTUVH: $r2pbP['where']['memberUserId'] = $shbIl; goto rirHd; sZsJV: } public static function getTotal($shbIl) { goto bMtHS; KVr6G: if (empty($QjHVP)) { return '0.00'; } goto MlCK1; MlCK1: return $QjHVP['total']; goto FAvtT; bMtHS: $QjHVP = ModelUtil::get('member_money', array('memberUserId' => $shbIl)); goto KVr6G; FAvtT: } public static function change($shbIl, $itE5Q, $VPhy3) { goto C0uOk; QD8w3: if (empty($QjHVP)) { $QjHVP = ModelUtil::insert('member_money', array('memberUserId' => $shbIl, 'total' => 0)); } goto JiMqA; URwhl: ModelUtil::update('member_money', array('id' => $QjHVP['id']), array('total' => $QjHVP['total'] + $itE5Q)); goto jA0tS; JiMqA: if ($itE5Q < 0 && $QjHVP['total'] + $itE5Q < 0) { BizException::throws('Member.MoneyChangeUtil -> total change to empty'); } goto w8oku; w8oku: ModelUtil::insert('member_money_log', array('memberUserId' => $shbIl, 'change' => $itE5Q, 'remark' => $VPhy3)); goto URwhl; TlgnP: $QjHVP = ModelUtil::getWithLock('member_money', array('memberUserId' => $shbIl)); goto QD8w3; C0uOk: if (!$itE5Q) { BizException::throws('Member.MoneyChangeUtil -> change empty'); } goto TlgnP; jA0tS: } public static function cash($shbIl, $k92oI, $VsvAp, $HWA34, $sL4jz, $dzPVS, $VPhy3 = '余额提现') { self::change($shbIl, -$k92oI, '余额提现'); ModelUtil::insert('member_money_cash', array('memberUserId' => $shbIl, 'status' => MemberMoneyCashStatus::VERIFYING, 'money' => $k92oI, 'moneyAfterTax' => $VsvAp, 'type' => $HWA34, 'realname' => $sL4jz, 'account' => $dzPVS, 'remark' => $VPhy3)); } public static function paginateCash($shbIl, $iXUoW, $VUK_X, $r2pbP = array()) { $r2pbP['where']['memberUserId'] = $shbIl; return ModelUtil::paginate('member_money_cash', $iXUoW, $VUK_X, $r2pbP); } public static function createCharge($shbIl, $nfjFE) { return ModelUtil::insert('member_money_charge', array('sn' => IdUtil::generateSN(), 'status' => MemberMoneyChargeStatus::CREATED, 'memberUserId' => $shbIl, 'fee' => $nfjFE)); } public static function processCharge($tNb60) { goto TCc1_; W1wMu: ModelUtil::update('member_money_charge', array('id' => $tNb60), array('status' => MemberMoneyChargeStatus::SUCCESS)); goto eNVz9; ndw4Q: if (empty($CbpNY)) { throw new \Exception('member_money_charge empty -> ' . $tNb60); } goto i1ifY; TCc1_: $CbpNY = ModelUtil::getWithLock('member_money_charge', array('id' => $tNb60)); goto ndw4Q; i1ifY: if ($CbpNY['status'] != MemberMoneyChargeStatus::CREATED) { throw new \Exception('member_money_charge status error -> ' . $tNb60); } goto BG9K4; BG9K4: self::change($CbpNY['memberUserId'], $CbpNY['fee'], '充值'); goto W1wMu; eNVz9: } }