1
This commit is contained in:
parent
c3ffbb68bd
commit
0bb3f2d9f9
@ -12,7 +12,7 @@ require_once('models/Nft.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
|
||||
require_once('services/LogService.php');
|
||||
require_once('services/NameService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
@ -20,6 +20,7 @@ use models\Bag;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Nft;
|
||||
use services\LogService;
|
||||
|
||||
class BagController extends BaseAuthedController {
|
||||
|
||||
@ -137,6 +138,14 @@ class BagController extends BaseAuthedController {
|
||||
'item_num' => mt\Parameter::getVal('rename_diamond_cost', 0)
|
||||
)
|
||||
));
|
||||
{
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::USER_RENAME,
|
||||
'val' => mt\Parameter::getVal('rename_diamond_cost', 0)
|
||||
];
|
||||
LogService::consumeDiamond($event);
|
||||
}
|
||||
$this->propertyChgService->addUserChg();
|
||||
} else {
|
||||
$this->_decItems(array(
|
||||
|
@ -206,6 +206,15 @@ class ChipController extends BaseAuthedController
|
||||
$this->_decItems($costItems);
|
||||
Bag::decItem(V_ITEM_CHIP_META,$stone);
|
||||
|
||||
{
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::CHIP_LEVEL_UP,
|
||||
'val' => $gold
|
||||
];
|
||||
LogService::consumeGold($event);
|
||||
}
|
||||
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addChip();
|
||||
$propertyChgService->addBagChg();
|
||||
|
@ -150,15 +150,15 @@ class HeroController extends BaseAuthedController {
|
||||
'item_num' => $nextLevelMeta['serum']
|
||||
)
|
||||
);
|
||||
$metaList = mt\Item::getMetaListByType(mt\Item::FRAGMENT_TYPE);
|
||||
foreach ($metaList as $meta){
|
||||
if ($meta['relationship'] == $heroDb['hero_id']) {
|
||||
array_push($costItems,array(
|
||||
'item_id' => $meta['id'],
|
||||
'item_num' => $nextLevelMeta['piece'],
|
||||
));
|
||||
}
|
||||
}
|
||||
// $metaList = mt\Item::getMetaListByType(mt\Item::FRAGMENT_TYPE);
|
||||
// foreach ($metaList as $meta){
|
||||
// if ($meta['relationship'] == $heroDb['hero_id']) {
|
||||
// array_push($costItems,array(
|
||||
// 'item_id' => $meta['id'],
|
||||
// 'item_num' => $nextLevelMeta['piece'],
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
$heroDto = Hero::toDto($heroDb);
|
||||
$newHeroDto = $heroDto;
|
||||
$newHeroDto['hero_lv'] += 1;
|
||||
@ -237,6 +237,14 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_decItems($costItems);
|
||||
Bag::decItem($piece_item_id,$nextLevelMeta['piece']);
|
||||
Bag::decItem(V_ITEM_HERO_META,$nextLevelMeta['serum']);
|
||||
{
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::HERO_LEVEL_UP,
|
||||
'val' => $nextLevelMeta['gold']
|
||||
];
|
||||
LogService::consumeGold($event);
|
||||
}
|
||||
|
||||
$attrs = Hero::LvUpAddAttr($heroDb);
|
||||
Hero::update($heroUniId, array(
|
||||
@ -260,6 +268,85 @@ class HeroController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
英雄升级
|
||||
*/
|
||||
public function upgradeLvNew()
|
||||
{
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
$oldHero = Hero::toDto($heroDb);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(100, 'param error or null');
|
||||
return;
|
||||
}
|
||||
|
||||
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
||||
if (!$heroMeta) {
|
||||
$this->_rspErr(100, 'server internal error');
|
||||
return;
|
||||
}
|
||||
$nextLevelMeta = mt\HeroLevel::getByLevel($heroDb['hero_lv'] + 1);
|
||||
if (!$nextLevelMeta) {
|
||||
$this->_rspErr(5, "It's already the highest level");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//校验英雄水晶数量
|
||||
$num = Bag::getItemCount(V_ITEM_HERO_META);
|
||||
if ($num < $nextLevelMeta['serum']){
|
||||
$this->_rspErr(3, "Lack of hero crystal");
|
||||
return;
|
||||
}
|
||||
|
||||
//校验用户gold数量
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $nextLevelMeta['gold']
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
Bag::decItem(V_ITEM_HERO_META,$nextLevelMeta['serum']);
|
||||
{
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::HERO_LEVEL_UP,
|
||||
'val' => $nextLevelMeta['gold']
|
||||
];
|
||||
LogService::consumeGold($event);
|
||||
}
|
||||
|
||||
$attrs = Hero::LvUpAddAttr($heroDb);
|
||||
Hero::update($heroUniId, array(
|
||||
'hero_lv' => $heroDb['hero_lv'] + 1,
|
||||
'rand_attr' => json_encode($attrs),
|
||||
'state' => Hero::GETED_STATE,
|
||||
));
|
||||
|
||||
if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) {
|
||||
myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1);
|
||||
}
|
||||
$newHero = Hero::toDto(Hero::find($heroUniId));
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addUserChg();
|
||||
$propertyChgService->addBagChg();
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'old_hero' => $oldHero,
|
||||
'new_hero' => $newHero,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
英雄预设
|
||||
*/
|
||||
|
@ -12,131 +12,66 @@ use models\User;
|
||||
use phpcommon\TGLog;
|
||||
class LogService extends BaseService
|
||||
{
|
||||
const HERO_LEVEL_UP = "hero_levelUp"; //英雄升级
|
||||
const HERO_LEVEL_UP_CONSUME = "hero_levelUp_consume"; //英雄升级mint
|
||||
const GUN_LEVEL_UP = "weapon_levelUp"; //枪械升级
|
||||
const GUN_LEVEL_UP_CONSUME = "weapon_levelUp_consume"; //枪械升级mint
|
||||
const HERO_QUALITY_UP = "hero_qualityUp"; //英雄升星
|
||||
const HERO_QUALITY_UP_CONSUME = "hero_qualityUp_consume"; //英雄升星mint
|
||||
const HERO_QUALITY_UP_MATERIAL = "hero_qualityUp_material"; //英雄升星消耗材料
|
||||
const GUN_QUALITY_UP = "weapon_qualityUp"; //枪械升星
|
||||
const GUN_QUALITY_UP_CONSUME = "weapon_qualityUp_consume"; //枪械升星mint
|
||||
const GUN_QUALITY_UP_MATERIAL = "weapon_qualityUp_material";//枪械升星消耗材料
|
||||
const CHIP_DEMOUNT = "chip_demount"; //芯片拆卸mint
|
||||
const CHIP_LUCKY = "chip_lucky"; //芯片幸运值mint
|
||||
const CHIP_SYNTH_MATERIAL = "chip_synth_material"; //芯片合成材料
|
||||
const HERO_FRAGMENT = "hero_fragment_synth"; //英雄碎片合成U
|
||||
const GUN_FRAGMENT = "weapon_fragment_synth"; //枪械碎片合成U
|
||||
const FRAGMENT_SYNTH_MATERIAL = "fragment_synth_material"; //芯片合成材料
|
||||
const USER_RENAME = "user_rename"; //用户改名
|
||||
const HERO_LEVEL_UP = "hero_level_Up"; //英雄升级
|
||||
const CHIP_LEVEL_UP = "chip_level_Up"; //芯片升级
|
||||
|
||||
const CONSUME = 0; //消耗 ↑
|
||||
const PRODUCT = 1; //产出 ↓
|
||||
const CONSUME_TYPE = 0; //消耗 ↑
|
||||
const PRODUCT_TYPE = 1; //产出 ↓
|
||||
|
||||
const BATTLE_AWARD_PVP = "battle_award_pvp"; //PVP战斗奖励
|
||||
const BATTLE_AWARD_PVE = "battle_award_pve"; //PVE战斗奖励
|
||||
const BATTLE_AWARD_MATCH = "battle_award_match"; //排位赛战斗奖励
|
||||
const BATTLE_AWARD_RANK = "battle_award_rank"; //排位赛战斗奖励
|
||||
|
||||
const PRONAME = 'game_2006_api';
|
||||
const GAMEID = 2006;
|
||||
|
||||
public static function consumeCEG($event,$old_nft,$new_nft,$param = [])
|
||||
const GOLD_TYPE = 0;
|
||||
const DIAMOND_TYPE = 1;
|
||||
|
||||
public static function consumeGold($event,$param = [])
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['type'] = self::CONSUME;
|
||||
$data['log_class'] = $event['name'];
|
||||
$data['event_demand'] = 'CEG';
|
||||
$data['type'] = self::CONSUME_TYPE;
|
||||
$data['event_name'] = $event['name'];
|
||||
$data['event_type'] = self::GOLD_TYPE;
|
||||
$data['event_demand'] = 'gold';
|
||||
$data['event_demand_val'] = $event['val'];
|
||||
$data['ceg_discount_rate'] = FormulaService::CEG_Discount_Rate(); //CEG折扣比率
|
||||
|
||||
$nft = self::nftInfo($old_nft,$new_nft);
|
||||
$logInfo['properties'] = array_merge($data,$nft,$param);
|
||||
|
||||
$logInfo['properties'] = array_merge($data,$param);
|
||||
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
public static function consumeCEC($event, $old_nft,$new_nft,$param = [])
|
||||
public static function consumeDiamond($event,$param = [])
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['type'] = self::CONSUME;
|
||||
$data['log_class'] = $event['name'];
|
||||
$data['event_demand'] = 'CEC';
|
||||
$data['type'] = self::CONSUME_TYPE;
|
||||
$data['event_name'] = $event['name'];
|
||||
$data['event_type'] = self::DIAMOND_TYPE;
|
||||
$data['event_demand'] = 'diamond';
|
||||
$data['event_demand_val'] = $event['val'];
|
||||
$data['cec_discount_rate'] = FormulaService::CEC_Discount_Rate(); //CEC折扣比率
|
||||
|
||||
$nft = self::nftInfo($old_nft,$new_nft);
|
||||
$logInfo['properties'] = array_merge($data,$nft,$param);
|
||||
$logInfo['properties'] = array_merge($data,$param);
|
||||
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
public static function productCEG($event,$nft,$param = [])
|
||||
public static function productGold($event,$param = [])
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['type'] = self::PRODUCT;
|
||||
$data['log_class'] = $event['name'];
|
||||
$data['event_product'] = 'CEG';
|
||||
$data['type'] = self::PRODUCT_TYPE;
|
||||
$data['event_name'] = $event['name'];
|
||||
$data['event_type'] = self::GOLD_TYPE;
|
||||
$data['event_product'] = 'gold';
|
||||
$data['event_product_val'] = $event['val'];
|
||||
$data['ceg_discount_rate'] = FormulaService::CEG_Discount_Rate(); //CEG折扣比率
|
||||
|
||||
$nftInfo = self::nftProductInfo($nft);
|
||||
$logInfo['properties'] = array_merge($data,$nftInfo,$param);
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
public static function productFragment($event,$param = [])
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['type'] = self::PRODUCT;
|
||||
$data['log_class'] = $event['name'];
|
||||
$data['event_product'] = 'Fragment';
|
||||
$data['event_product_item_id'] = $event['item_id'];
|
||||
$data['event_product_val'] = $event['number'];
|
||||
$logInfo['properties'] = array_merge($data,$param);
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
public static function LevelUpOrQualityUp( $event, $old_nft,$new_nft)
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['log_class'] = $event['name'];
|
||||
|
||||
$nft = self::nftInfo($old_nft,$new_nft);
|
||||
$logInfo['properties'] = array_merge($data,$nft);
|
||||
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
public static function fragmentSynth($event,$nft)
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['log_class'] = $event['name'];
|
||||
$data['event_demand'] = 'U';
|
||||
$data['event_demand_val'] = $event['val'];
|
||||
$data['nft_token_id'] = $nft['token_id'];
|
||||
$data['nft_item_id'] = $nft['item_id'];
|
||||
$data['nft_info'] = json_encode($nft);
|
||||
$logInfo['properties'] = $data;
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
public static function ConsumableMaterial($event,$params)
|
||||
{
|
||||
$logInfo = self::tokenRecord();
|
||||
$data = self::userInfo();
|
||||
$data['log_class'] = $event['name'];
|
||||
foreach ($params as $k=>$v){
|
||||
$data['param'.($k+1)] = $v;
|
||||
}
|
||||
$logInfo['properties'] = $data;
|
||||
TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo);
|
||||
}
|
||||
|
||||
private static function userInfo()
|
||||
{
|
||||
@ -145,10 +80,11 @@ class LogService extends BaseService
|
||||
'account_id' => myself()->_getAccountId(), //账号id
|
||||
'channel' => myself()->_getChannel(), //账号channel
|
||||
'openid' => myself()->_getOpenId(), //账号openid
|
||||
'adress' => myself()->_getAddress(), //账号openid
|
||||
'name' => $user['name'], //用户名字
|
||||
'rank' => $user['rank'], //段位
|
||||
'gold' => $user['gold'], //CEG金币
|
||||
'diamond' => $user['diamond'], //CEC钻石
|
||||
'gold' => $user['gold'], //金币
|
||||
'diamond' => $user['diamond'], //钻石
|
||||
'account_register_time' => myself()->_getRegisterTime(), //账号注册时间
|
||||
'ip' => $_SERVER['REMOTE_ADDR'], //用户ip
|
||||
'_os' => getReqVal('_os', ''),
|
||||
@ -157,61 +93,6 @@ class LogService extends BaseService
|
||||
return $info;
|
||||
}
|
||||
|
||||
private static function nftInfo($old_nft,$new_nft)
|
||||
{
|
||||
foreach ($old_nft as $k => $v){
|
||||
if ($k == 'hero_id'){
|
||||
$old_nft['item_id'] = $old_nft[$k];
|
||||
}else if ($k == 'gun_id'){
|
||||
$old_nft['item_id'] = $old_nft[$k];
|
||||
}else if($k == 'item_id'){
|
||||
$old_nft['item_id'] = $old_nft[$k];
|
||||
}
|
||||
}
|
||||
foreach ($new_nft as $k => $v){
|
||||
if ($k == 'hero_id'){
|
||||
$new_nft['item_id'] = $new_nft[$k];
|
||||
}else if ($k == 'gun_id'){
|
||||
$new_nft['item_id'] = $new_nft[$k];
|
||||
}else if($k == 'item_id'){
|
||||
$new_nft['item_id'] = $new_nft[$k];
|
||||
}
|
||||
}
|
||||
$info = array(
|
||||
'nft_unique_id' => $old_nft['idx'], //NFT idx
|
||||
'nft_token_id' => $old_nft['token_id']?$old_nft['token_id']:null, //NFT token ID
|
||||
'nft_item_id' => $old_nft['item_id']?$old_nft['item_id']:null, //NFT item ID
|
||||
'nft_quality' => isset($old_nft['quality']) ? $old_nft['quality'] : null, //NFT品阶
|
||||
'nft_level' => $old_nft['level'] ? $old_nft['level'] : null, //NFT等级
|
||||
'nft_quality2' => isset($new_nft['quality']) ? $new_nft['quality'] : null, //NFT品阶2
|
||||
'nft_level2' => $new_nft['level'] ? $new_nft['level'] : null, //NFT等级2
|
||||
'nft_info' => json_encode($old_nft),
|
||||
'new_nft' => json_encode($new_nft)
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
private static function nftProductInfo($nft)
|
||||
{
|
||||
foreach ($nft as $k => $v){
|
||||
if ($k == 'hero_id'){
|
||||
$nft['item_id'] = $nft[$k];
|
||||
}else if ($k == 'gun_id'){
|
||||
$nft['item_id'] = $nft[$k];
|
||||
}else if($k == 'item_id'){
|
||||
$nft['item_id'] = $nft[$k];
|
||||
}
|
||||
}
|
||||
$info = array(
|
||||
'nft_unique_id' => $nft['idx'], //NFT idx
|
||||
'nft_token_id' => $nft['token_id']?$nft['token_id']:null, //NFT token ID
|
||||
'nft_item_id' => $nft['item_id']?$nft['item_id']:null, //NFT item ID
|
||||
'nft_info' => json_encode($nft),
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
private static function tokenRecord()
|
||||
{
|
||||
// $logInfo['log_class'] = $logInfo['log_class'];
|
||||
|
@ -725,13 +725,25 @@ class TameBattleDataService extends BaseService {
|
||||
foreach ($data['members'] as $member){
|
||||
if ($member['account_id'] == myself()->_getAccountId()){
|
||||
if ($member['reward']['items']){
|
||||
$gold= 0;
|
||||
$items = array();
|
||||
foreach ($member['reward']['items'] as $value){
|
||||
if ($value['item_id'] == V_ITEM_GOLD){
|
||||
$gold = $value['item_num'];
|
||||
}
|
||||
if ($value['item_id'] != V_ITEM_STAR){
|
||||
array_push($items,$value);
|
||||
}
|
||||
}
|
||||
myself()->_addItems($items, $awardService,$propertyChgService);
|
||||
if ($gold > 0){
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::BATTLE_AWARD_PVP,
|
||||
'val' => $gold
|
||||
];
|
||||
LogService::productGold($event);
|
||||
}
|
||||
}
|
||||
if ($member['reward']['hero']['hero_uniid']){
|
||||
Hero::update($member['reward']['hero']['hero_uniid'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user