<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Util; use ModStart\Core\Dao\ModelUtil; class MemberCreditUtil { public static function paginateLog($d4RRw, $j13Tr, $OB9LF, $AQ4wg = array()) { goto UfsHU; B5Bgu: return ModelUtil::paginate('member_credit_log', $j13Tr, $OB9LF, $AQ4wg); goto dCCE1; EIw8T: $AQ4wg['order'] = array('id', 'desc'); goto B5Bgu; UfsHU: $AQ4wg['where']['memberUserId'] = $d4RRw; goto EIw8T; dCCE1: } public static function getTotal($d4RRw) { goto gTSce; FiSPr: return $nnCtx['total']; goto gHJ8t; gTSce: $nnCtx = ModelUtil::get('member_credit', array('memberUserId' => $d4RRw)); goto B1DUk; B1DUk: if (empty($nnCtx)) { return 0; } goto FiSPr; gHJ8t: } public static function change($d4RRw, $Ag7bt, $ViFvg) { goto wHza1; L8pbE: $nnCtx = ModelUtil::getWithLock('member_credit', array('memberUserId' => $d4RRw)); goto TpMg3; Z_lLo: ModelUtil::insert('member_credit_log', array('memberUserId' => $d4RRw, 'change' => $Ag7bt, 'remark' => $ViFvg)); goto UyPd_; TpMg3: if (empty($nnCtx)) { $nnCtx = ModelUtil::insert('member_credit', array('memberUserId' => $d4RRw, 'total' => 0)); } goto c6yX1; wHza1: if (!$Ag7bt) { throw new \Exception('MemberCreditUtil -> change empty'); } goto L8pbE; UyPd_: $nnCtx = ModelUtil::update('member_credit', array('id' => $nnCtx['id']), array('total' => $nnCtx['total'] + $Ag7bt)); goto Jz2mu; c6yX1: if ($Ag7bt < 0 && $nnCtx['total'] + $Ag7bt < 0) { throw new \Exception('MemberCreditUtil -> total change to empty'); } goto Z_lLo; Jz2mu: if ($nnCtx['total'] < 0) { throw new \Exception('MemberCreditUtil -> total empty'); } goto rgVWr; rgVWr: } }