<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Util; use ModStart\Core\Dao\ModelUtil; class MemberCreditUtil { public static function paginateLog($KJqKC, $JcqUq, $WrYIu, $iNhXN = array()) { goto OQXUQ; OQXUQ: $iNhXN['where']['memberUserId'] = $KJqKC; goto J_07l; wBUfg: return ModelUtil::paginate('member_credit_log', $JcqUq, $WrYIu, $iNhXN); goto kHOcA; J_07l: $iNhXN['order'] = array('id', 'desc'); goto wBUfg; kHOcA: } public static function getTotal($KJqKC) { goto ni18N; rCLsN: if (empty($Kwhgm)) { return 0; } goto YHkmw; ni18N: $Kwhgm = ModelUtil::get('member_credit', array('memberUserId' => $KJqKC)); goto rCLsN; YHkmw: return $Kwhgm['total']; goto SQEe_; SQEe_: } public static function change($KJqKC, $Eesbt, $gvic0) { goto ZDZ3A; ZDZ3A: if (!$Eesbt) { throw new \Exception('MemberCreditUtil -> change empty'); } goto NGwty; IbTB2: ModelUtil::insert('member_credit_log', array('memberUserId' => $KJqKC, 'change' => $Eesbt, 'remark' => $gvic0)); goto gTZh5; gS2Q3: if ($Eesbt < 0 && $Kwhgm['total'] + $Eesbt < 0) { throw new \Exception('MemberCreditUtil -> total change to empty'); } goto IbTB2; NGwty: $Kwhgm = ModelUtil::getWithLock('member_credit', array('memberUserId' => $KJqKC)); goto Dlbpt; gTZh5: $Kwhgm = ModelUtil::update('member_credit', array('id' => $Kwhgm['id']), array('total' => $Kwhgm['total'] + $Eesbt)); goto kIh3d; Dlbpt: if (empty($Kwhgm)) { $Kwhgm = ModelUtil::insert('member_credit', array('memberUserId' => $KJqKC, 'total' => 0)); } goto gS2Q3; kIh3d: if ($Kwhgm['total'] < 0) { throw new \Exception('MemberCreditUtil -> total empty'); } goto PMRt_; PMRt_: } }