<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Util; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use Module\Member\Model\MemberCard; class MemberCardUtil { public static function create($shbIl, $g16tm, $Oferv, $Jd4L6 = null) { goto P97XH; XPxq7: $avcnU['expire'] = $Jd4L6; goto Ja82Y; Ja82Y: $avcnU['quotaUsed'] = 0; goto PYD9L; P97XH: $avcnU = array(); goto FlPks; rO3LV: return $avcnU; goto o63Iz; FlPks: $avcnU['memberUserId'] = $shbIl; goto WTmwe; PYD9L: $avcnU['quotaTotal'] = $Oferv; goto WYzv4; WYzv4: $avcnU = ModelUtil::insert('member_card', $avcnU); goto rO3LV; WTmwe: $avcnU['biz'] = $g16tm; goto XPxq7; o63Iz: } public static function consume($shbIl, $g16tm, $Oferv = 1) { goto OIOgL; bquE8: ModelUtil::transactionCommit(); goto sgvMO; sgvMO: return Response::generateSuccess(); goto ty_w2; ytGmU: if (empty($Dw0Jm)) { ModelUtil::transactionCommit(); return Response::generateError('额度不足'); } goto Baau1; Baau1: $Dw0Jm->quotaUsed += $Oferv; goto rCbqv; OIOgL: ModelUtil::transactionBegin(); goto OBI0Z; rCbqv: $Dw0Jm->save(); goto bquE8; OBI0Z: $Dw0Jm = MemberCard::where(array('memberUserId' => $shbIl, 'biz' => $g16tm))->where('expire', '>', date('Y-m-d H:i:s'))->whereRaw('quotaUsed+' . intval($Oferv) . ' <= quotaTotal')->orderBy('expire', 'asc')->first(); goto ytGmU; ty_w2: } }