<?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($KJqKC, $qhsmj, $g78zi, $KfcNX = null) { goto A_Um0; nDi0l: $U8wjN['quotaUsed'] = 0; goto y4_gE; mlGDS: $U8wjN['memberUserId'] = $KJqKC; goto ZT__T; cjdfA: $U8wjN = ModelUtil::insert('member_card', $U8wjN); goto Hs3Gi; Hs3Gi: return $U8wjN; goto FtZWG; y4_gE: $U8wjN['quotaTotal'] = $g78zi; goto cjdfA; A_Um0: $U8wjN = array(); goto mlGDS; ZT_i1: $U8wjN['expire'] = $KfcNX; goto nDi0l; ZT__T: $U8wjN['biz'] = $qhsmj; goto ZT_i1; FtZWG: } public static function consume($KJqKC, $qhsmj, $g78zi = 1) { goto yPCLb; uXjMl: $uCVqt->quotaUsed += $g78zi; goto PEJ2k; n4Nzp: ModelUtil::transactionCommit(); goto Q4znS; yPCLb: ModelUtil::transactionBegin(); goto UMf5l; UMf5l: $uCVqt = MemberCard::where(array('memberUserId' => $KJqKC, 'biz' => $qhsmj))->where('expire', '>', date('Y-m-d H:i:s'))->whereRaw('quotaUsed+' . intval($g78zi) . ' <= quotaTotal')->orderBy('expire', 'asc')->first(); goto y2Zyj; PEJ2k: $uCVqt->save(); goto n4Nzp; Q4znS: return Response::generateSuccess(); goto FvZka; y2Zyj: if (empty($uCVqt)) { ModelUtil::transactionCommit(); return Response::generateError('额度不足'); } goto uXjMl; FvZka: } }