<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Res\AssetAccess; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\Response; use Module\Member\Util\MemberCreditUtil; use Module\Member\Util\MemberVipUtil; use Module\Res\AssetAccess\Type\AccessCreateFrom; use Module\Res\AssetAccess\Type\CreditStatus; use Module\Res\AssetAccess\Type\FreeStatus; use Module\Res\AssetAccess\Type\MoneyStatus; use Module\Res\AssetAccess\Type\VipStatus; use Module\Res\Util\ResRewardUtil; class AssetAccess { public static function buy($DOZ5u, $Qnz4g, $zk4Tz, $KJqKC, $noJFF) { goto iXd6_; pnvfI: return Response::generateSuccess(); goto KI7tg; DoXPV: $QmtOD = ModelUtil::model($noJFF)->where(array('assetId' => $zk4Tz['id'], 'memberUserId' => $KJqKC))->whereRaw('(expire IS NULL OR expire > NOW())')->first(); goto CG5A3; NC11C: switch ($Qnz4g) { case AccessCreateFrom::CREATE_FROM_CREDIT: goto kf312; ZvhMX: ModelUtil::transactionCommit(); goto dgIqg; PlNzZ: $ahibX = MemberCreditUtil::getTotal($KJqKC); goto g4j30; YWj5_: MemberCreditUtil::change($KJqKC, -$zk4Tz['creditCost'], '购买《' . $DOZ5u . '》'); goto OgW_q; GV_SR: break; goto TtFw3; vgSwv: if (empty($zk4Tz['creditCost'])) { return Response::generateError('资产积分购买价格为空'); } goto PlNzZ; kf312: if (CreditStatus::ENABLE != $zk4Tz['creditStatus']) { return Response::generateError('资产不支持积分购买'); } goto vgSwv; g4j30: if ($ahibX < $zk4Tz['creditCost']) { return Response::generateError('积分不足'); } goto ypwwq; OgW_q: $QmtOD = ModelUtil::insert($noJFF, array('assetId' => $zk4Tz['id'], 'memberUserId' => $KJqKC, 'expire' => null, 'createFrom' => AccessCreateFrom::CREATE_FROM_CREDIT)); goto ZvhMX; dgIqg: ResRewardUtil::update('Credit:' . $QmtOD['id'], AccessCreateFrom::CREATE_FROM_CREDIT, $zk4Tz); goto GV_SR; ypwwq: ModelUtil::transactionBegin(); goto YWj5_; TtFw3: case AccessCreateFrom::CREATE_FROM_MONEY: ModelUtil::insert($noJFF, array('assetId' => $zk4Tz['id'], 'memberUserId' => $KJqKC, 'expire' => null, 'createFrom' => AccessCreateFrom::CREATE_FROM_MONEY)); break; } goto pnvfI; CG5A3: if (!empty($QmtOD)) { return Response::generateError('资产已购买'); } goto NC11C; RekBD: if (empty($KJqKC)) { return Response::generateError('用户未登录'); } goto DoXPV; iXd6_: if (empty($zk4Tz)) { return Response::generateError('资产不存在'); } goto RekBD; KI7tg: } public static function check($zk4Tz, $KJqKC, $Zcpe6, $noJFF, $BrM90 = false) { goto Rt0zV; qkixG: if ($nV1c1->check) { if (!empty($KJqKC)) { goto QmKKB; LN7_w: if (!empty($QmtOD)) { $nV1c1->data = $QmtOD->toArray(); } goto AjBxk; AjBxk: if ($BrM90 && empty($QmtOD) && $Zcpe6) { if (in_array($Zcpe6, $zk4Tz['vipIds'])) { $nV1c1->data = ModelUtil::insert($noJFF, array('assetId' => $zk4Tz['id'], 'memberUserId' => $KJqKC, 'expire' => null, 'createFrom' => AccessCreateFrom::CREATE_FROM_VIP)); ResRewardUtil::update('Vip:' . $nV1c1->data['id'], AccessCreateFrom::CREATE_FROM_VIP, $zk4Tz); } } goto e2vmA; QmKKB: $QmtOD = ModelUtil::model($noJFF)->where(array('assetId' => $zk4Tz['id'], 'memberUserId' => $KJqKC))->whereRaw('(expire IS NULL OR expire > NOW())')->first(); goto LN7_w; e2vmA: } } goto O123_; S0eQ8: if (!empty($zk4Tz)) { goto iASSD; GC6hN: $Y4CY2 = $zk4Tz['vipIds']; goto lVm0n; B9fqE: if ($zk4Tz['creditStatus'] == CreditStatus::ENABLE) { $nV1c1->creditSupport = true; } goto O9YSO; RRC1y: $zk4Tz['vipIds'] = $Y4CY2; goto B9fqE; lVm0n: if (is_string($Y4CY2)) { $Y4CY2 = @json_decode($Y4CY2, true); } goto yxmyR; yxmyR: if (empty($Y4CY2)) { $Y4CY2 = array(); } goto RRC1y; aYvqX: if ($zk4Tz['vipStatus'] == VipStatus::ENABLE) { $nV1c1->vipSupport = true; } goto GC6hN; iASSD: if (FreeStatus::FEE == $zk4Tz['freeStatus']) { $nV1c1->check = true; } goto aYvqX; O9YSO: if ($zk4Tz['moneyStatus'] == MoneyStatus::ENABLE) { $nV1c1->moneySupport = true; } goto Woquw; Woquw: } goto q5L4J; ydOYV: if ($nV1c1->creditSupport) { $nV1c1->creditCost = $zk4Tz['creditCost']; } goto LJFbM; q5L4J: if ($nV1c1->vipSupport) { goto ybfS1; ahMyR: $nV1c1->vipList = array(); goto Z61jI; Z61jI: foreach ($KF9Vc as $SeeMj) { if (!in_array($SeeMj['id'], $zk4Tz['vipIds'])) { continue; } $nV1c1->vipList[] = array('title' => $SeeMj['title']); } goto Ov_1O; ybfS1: $KF9Vc = MemberVipUtil::map(); goto ahMyR; Ov_1O: } goto ydOYV; LJFbM: if ($nV1c1->moneySupport) { $nV1c1->moneyCost = $zk4Tz['moneyCost']; } goto qkixG; Rt0zV: $nV1c1 = new AccessCheckResult(); goto S0eQ8; O123_: return $nV1c1; goto yI31M; yI31M: } }