<?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($d4RRw, $i9_MK, $AdB9D, $Tsb75 = null) { goto IL0V_; UNaTu: return $Pg57y; goto XwZlX; sVBnk: $Pg57y['expire'] = $Tsb75; goto VcBPO; C0xc3: $Pg57y = ModelUtil::insert('member_card', $Pg57y); goto UNaTu; VcBPO: $Pg57y['quotaUsed'] = 0; goto t6G3N; IL0V_: $Pg57y = array(); goto XXpca; XXpca: $Pg57y['memberUserId'] = $d4RRw; goto qtamj; qtamj: $Pg57y['biz'] = $i9_MK; goto sVBnk; t6G3N: $Pg57y['quotaTotal'] = $AdB9D; goto C0xc3; XwZlX: } public static function consume($d4RRw, $i9_MK, $AdB9D = 1) { goto QgKaL; tlxYE: return Response::generateSuccess(); goto obYWc; f2Lc2: $ugK0h->save(); goto QISjZ; me0jD: $ugK0h = MemberCard::where(array('memberUserId' => $d4RRw, 'biz' => $i9_MK))->where('expire', '>', date('Y-m-d H:i:s'))->whereRaw('quotaUsed+' . intval($AdB9D) . ' <= quotaTotal')->orderBy('expire', 'asc')->first(); goto Wr5x_; QgKaL: ModelUtil::transactionBegin(); goto me0jD; QISjZ: ModelUtil::transactionCommit(); goto tlxYE; Wr5x_: if (empty($ugK0h)) { ModelUtil::transactionCommit(); return Response::generateError('额度不足'); } goto q5Yys; q5Yys: $ugK0h->quotaUsed += $AdB9D; goto f2Lc2; obYWc: } }