<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Res\Util; use ModStart\Core\Dao\ModelUtil; use Module\Member\Util\MemberCreditUtil; use Module\Member\Util\MemberMoneyUtil; 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\Type\ResUserRewardVipType; class ResRewardUtil { public static function update($KDkZr, $WFQ0z, $zk4Tz) { goto cgZAA; Mt02i: ModelUtil::insert('res_asset_reward', array('sn' => $KDkZr, 'memberUserId' => $zk4Tz['memberUserId'], 'assetId' => $zk4Tz['id'], 'money' => $MgvDM, 'credit' => $BV9jA)); goto fGmpR; KDKzq: if ($zk4Tz['freeStatus'] == FreeStatus::FEE) { switch ($WFQ0z) { case AccessCreateFrom::CREATE_FROM_CREDIT: if ($zk4Tz['creditStatus'] == CreditStatus::ENABLE && $zk4Tz['creditCost'] > 0) { $B1gdm = self::rate('Res_UserRewardRateCredit'); if ($B1gdm > 0) { $BV9jA = intval($zk4Tz['creditCost'] * $B1gdm / 100); } } break; case AccessCreateFrom::CREATE_FROM_MONEY: if ($zk4Tz['moneyStatus'] == MoneyStatus::ENABLE && $zk4Tz['moneyCost'] > 0) { $B1gdm = self::rate('Res_UserRewardRateMoney'); if ($B1gdm > 0) { $MgvDM = bcmul($zk4Tz['moneyCost'], $B1gdm, 2); $MgvDM = bcdiv($MgvDM, 100, 2); } } break; case AccessCreateFrom::CREATE_FROM_VIP: goto GlxFJ; GlxFJ: $EpKdG = modstart_config('Res_UserRewardVipType', ResUserRewardVipType::CREDIT_MONEY); goto ou1me; cy3o9: break; goto vNx0b; ou1me: switch ($EpKdG) { case ResUserRewardVipType::CREDIT_MONEY: if ($zk4Tz['creditStatus'] == CreditStatus::ENABLE && $zk4Tz['creditCost'] > 0) { $B1gdm = self::rate('Res_UserRewardRateVipCredit'); if ($B1gdm > 0) { $BV9jA = intval($zk4Tz['creditCost'] * $B1gdm / 100); } } else { if ($zk4Tz['moneyStatus'] == MoneyStatus::ENABLE && $zk4Tz['moneyCost'] > 0) { $B1gdm = self::rate('Res_UserRewardRateVipMoney'); if ($B1gdm > 0) { $MgvDM = bcmul($zk4Tz['moneyCost'], $B1gdm, 2); $MgvDM = bcdiv($MgvDM, 100, 2); } } } break; case ResUserRewardVipType::MONEY_CREDIT: if ($zk4Tz['moneyStatus'] == MoneyStatus::ENABLE && $zk4Tz['moneyCost'] > 0) { $B1gdm = self::rate('Res_UserRewardRateVipMoney'); if ($B1gdm > 0) { $MgvDM = bcmul($zk4Tz['moneyCost'], $B1gdm, 2); $MgvDM = bcdiv($MgvDM, 100, 2); } } else { if ($zk4Tz['creditStatus'] == CreditStatus::ENABLE && $zk4Tz['creditCost'] > 0) { $B1gdm = self::rate('Res_UserRewardRateVipCredit'); if ($B1gdm > 0) { $BV9jA = intval($zk4Tz['creditCost'] * $B1gdm / 100); } } } break; } goto cy3o9; vNx0b: } } goto Mt02i; S2lIo: $BV9jA = 0; goto KDKzq; fGmpR: if ($BV9jA > 0) { goto eP0L6; NNUz6: MemberCreditUtil::change($zk4Tz['memberUserId'], $BV9jA, '资源下载佣金'); goto KLqm6; eP0L6: ModelUtil::transactionBegin(); goto NNUz6; KLqm6: ModelUtil::transactionCommit(); goto BVzXN; BVzXN: } else { if ($MgvDM > 0) { goto vi7bN; iE94c: ModelUtil::transactionCommit(); goto WPVBJ; h0uYJ: MemberMoneyUtil::change($zk4Tz['memberUserId'], $MgvDM, '资源下载佣金'); goto iE94c; vi7bN: ModelUtil::transactionBegin(); goto h0uYJ; WPVBJ: } } goto uIy5b; eGlIC: $MgvDM = 0; goto S2lIo; cgZAA: if (ModelUtil::exists('res_asset_reward', array('sn' => $KDkZr))) { return; } goto eGlIC; uIy5b: } public static function rate($UtKOH, $qumIj = 0, $FWlTx = 100) { $B1gdm = modstart_config($UtKOH, 60); return min(max($B1gdm, $qumIj), $FWlTx); } }