This commit is contained in:
hujiabin 2023-07-15 20:05:06 +08:00
parent 156d2f02e6
commit 67eb39c4e4

View File

@ -288,31 +288,8 @@ class PassController extends BaseAuthedController
public function buyLevel()
{
error_log("buyLevel : " . json_encode($_REQUEST));
// if (!$this->_isValidAddress()) {
// $this->_rspErr(1, 'address is empty');
// return;
// }
$level = getReqVal('level', '');
// $price = getReqVal('price', '');
$passMeta = \mt\BattlePass::find($level);
if (!$passMeta || $this->userInfo['level'] > $level ) {
$this->_rspErr(1, 'param level error or null');
return;
}
$celPrice = ($passMeta['total_exp'] - $this->userInfo['exp']) * \mt\Parameter::getVal('battlepass_buy_lv_price', '');
// if ($celPrice != $price) {
// $this->_rspErr(1, 'The price is wrong');
// return;
// }
// $response = services\BlockChainService::gameItemMallBuy(
// Transaction::BUY_EXP_ACTION_TYPE, services\BlockChainService::formatCurrency($price), V_ITEM_EXP, $passMeta['total_exp'] - $this->userInfo['exp']);
// $this->_setV(TN_DAILY_BUY_LEVEL_STATE, 0, 1);
// BcOrder::upsert($response['trans_id'], array(
// 'item_id' => V_ITEM_EXP,
// 'item_num' => $passMeta['total_exp'] - $this->userInfo['exp'],
// 'price' => $price,
// ));
$exp = getReqVal('exp', '');
$celPrice = $exp * \mt\Parameter::getVal('battlepass_buy_lv_price', '');
//校验用户钻石数量
$costItems = array(
array(
@ -327,14 +304,15 @@ class PassController extends BaseAuthedController
}
$this->_decItems($costItems);
//提升通行证等级
User::update(array(
'exp' => $passMeta['total_exp'],
'level' => $level,
));
$this->userInfo = $this->_safeGetOrmUserInfo();
//解锁至相应等级的奖励
$this->_updatePassData();
$items = array(
array(
'item_id' => V_ITEM_EXP,
'item_num' => $exp
)
);
$propertyChgService = new services\PropertyChgService();
$awardService = new services\AwardService();
$this->_addItems($items,$awardService,$propertyChgService);
$propertyChgService->addUserChg();
$this->_rspData(array(
'property_chg' => $propertyChgService->toDto(),