log service

This commit is contained in:
hujiabin 2022-09-26 21:08:55 +08:00
parent 5021a44067
commit f51f9ae9e6
10 changed files with 464 additions and 39 deletions

View File

@ -145,7 +145,6 @@ class ChipController extends BaseAuthedController
if (!$this->_doDemount($unique_id,$token_id)){ if (!$this->_doDemount($unique_id,$token_id)){
return; return;
} }
$this->_writeLog($token_id); //埋点
$hero = Hero::toDto(Hero::find($unique_id)); $hero = Hero::toDto(Hero::find($unique_id));
$propertyChgService->addHeroChg(); $propertyChgService->addHeroChg();
$this->_rspData([ $this->_rspData([
@ -156,7 +155,6 @@ class ChipController extends BaseAuthedController
if (! $this->_doDemountGun($unique_id,$token_id)){ if (! $this->_doDemountGun($unique_id,$token_id)){
return; return;
} }
$this->_writeLog($token_id); //埋点
$gun = Gun::toDto(Gun::find($unique_id)); $gun = Gun::toDto(Gun::find($unique_id));
$propertyChgService->addGunChg(); $propertyChgService->addGunChg();
$this->_rspData([ $this->_rspData([
@ -182,7 +180,6 @@ class ChipController extends BaseAuthedController
if (! $this->_doDemount($unique_id,$token_id_old)){ if (! $this->_doDemount($unique_id,$token_id_old)){
return; return;
} }
$this->_writeLog($token_id_old); //埋点
if (! $this->_doInlayHero($unique_id,$token_id_new)){ if (! $this->_doInlayHero($unique_id,$token_id_new)){
return; return;
} }
@ -196,7 +193,6 @@ class ChipController extends BaseAuthedController
if (! $this->_doDemountGun($unique_id,$token_id_old)){ if (! $this->_doDemountGun($unique_id,$token_id_old)){
return; return;
} }
$this->_writeLog($token_id_old); //埋点
if (! $this->_doInlayGun($unique_id,$token_id_new)){ if (! $this->_doInlayGun($unique_id,$token_id_new)){
return; return;
} }
@ -345,11 +341,23 @@ class ChipController extends BaseAuthedController
return; return;
} }
$cumulative_cost = 0; $cumulative_cost = 0;
$params = array();
foreach ($token_id_param as $val){ foreach ($token_id_param as $val){
$chip_param = Chip::getChipByTokenId($val); $chip_param = Chip::getChipByTokenId($val);
array_push($params,array(
'unique_id'=>$chip_param['idx'],
'token_id'=>$chip_param['token_id'],
));
$cumulative_cost += \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']); $cumulative_cost += \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']);
Chip::deleteChip(['token_id'=>$val]); Chip::deleteChip(['token_id'=>$val]);
} }
{
//埋点
$event = [
'name' => LogService::CHIP_SYNTH_MATERIAL,
];
LogService::ConsumableMaterial($event,$params);
}
$num = round(round(($cumulative_cost/$upgrade_cost),5)*10000); $num = round(round(($cumulative_cost/$upgrade_cost),5)*10000);
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addChip(); $propertyChgService->addChip();
@ -397,6 +405,18 @@ class ChipController extends BaseAuthedController
} }
User::update(['gold'=>$user['gold']-$mint_cost]); User::update(['gold'=>$user['gold']-$mint_cost]);
Chip::update($chip['token_id'],$fieldsKv); Chip::update($chip['token_id'],$fieldsKv);
$old_chip = Chip::toDto($chip);
$new_chip = Chip::toDto(Chip::getChipByTokenId($token_id));
{
//埋点
$event = [
'name' => LogService::CHIP_LUCKY,
'val' => $mint_cost
];
$old_chip['level'] = $old_chip['chip_grade'];
$new_chip['level'] = $new_chip['chip_grade'];
LogService::consumeCEG($event,$old_chip,$new_chip);
}
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$propertyChgService->addChip(); $propertyChgService->addChip();
@ -530,6 +550,7 @@ class ChipController extends BaseAuthedController
} }
public function test(){ public function test(){
// $nft_active = SqlHelper::ormSelect( // $nft_active = SqlHelper::ormSelect(
// myself()->_getSelfMysql(), // myself()->_getSelfMysql(),
// 't_nft_active', // 't_nft_active',
@ -550,9 +571,7 @@ class ChipController extends BaseAuthedController
// Chip::update($chip['token_id'],['strength'=>$tili]); // Chip::update($chip['token_id'],['strength'=>$tili]);
// } // }
// $this->_rspOk(); // $this->_rspOk();
// $a = mt\Parameter::getByName('CEG_Parameter');
$a =FormulaService::Hero_Parts_Synthetic_Cost();
print_r($_SERVER);
} }
@ -627,6 +646,16 @@ class ChipController extends BaseAuthedController
return false; return false;
} }
User::update(['gold'=>$user['gold']-$mint]); User::update(['gold'=>$user['gold']-$mint]);
$chipDto = Chip::toDto($chip);
{
//埋点
$event = [
'name' => LogService::CHIP_DEMOUNT,
'val' => $mint
];
$chipDto['level'] = $chipDto['chip_grade'];
LogService::consumeCEG($event,$chipDto,$chipDto);
}
} }
$where = ['inlay_state'=>0,'strength'=>$chip['strength_max']]; $where = ['inlay_state'=>0,'strength'=>$chip['strength_max']];
Hero::update($unique_id,$fieldsKv); Hero::update($unique_id,$fieldsKv);
@ -656,6 +685,16 @@ class ChipController extends BaseAuthedController
return false; return false;
} }
User::update(['gold'=>$user['gold']-$mint]); User::update(['gold'=>$user['gold']-$mint]);
$chipDto = Chip::toDto($chip);
{
//埋点
$event = [
'name' => LogService::CHIP_DEMOUNT,
'val' => $mint
];
$chipDto['level'] = $chipDto['chip_grade'];
LogService::consumeCEG($event,$chipDto,$chipDto);
}
} }
$where = ['inlay_state'=>0,'strength'=>$chip['strength_max']]; $where = ['inlay_state'=>0,'strength'=>$chip['strength_max']];
Gun::update($unique_id,$fieldsKv); Gun::update($unique_id,$fieldsKv);
@ -839,25 +878,4 @@ class ChipController extends BaseAuthedController
} }
} }
private function _writeLog($token_id){
$userDb = User::find($this->_getAccountId());
$chipDb = Chip::getChipByTokenId($token_id);
$nftDb = Nft::getNft($token_id);
{
$itemMeta = \mt\Item::get($nftDb['item_id']);
$nft = array(
'id' => $itemMeta['id'],
'name' => $itemMeta['name'],
'type' => '芯片NFT',
'level' => $chipDb['chip_grade'],
'createtime' => $nftDb['createtime'],
'is_ceg' => 1,
);
$event = array(
'name' => LogService::CHIP_DEMOUNT,
);
// LogService::jsonContentToLog($userDb,$nft,$event);
}
}
} }

View File

@ -4,10 +4,12 @@ require_once('models/Fragment.php');
require_once('models/Nft.php'); require_once('models/Nft.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
require_once('services/LogService.php');
use models\Fragment; use models\Fragment;
use models\Nft; use models\Nft;
use services\FormulaService; use services\FormulaService;
use services\LogService;
class FragmentController extends BaseAuthedController class FragmentController extends BaseAuthedController
{ {
@ -143,12 +145,34 @@ class FragmentController extends BaseAuthedController
// return; // return;
// } // }
//销毁碎片 //销毁碎片
$params =array();
foreach ($token_id_arr as $val){ foreach ($token_id_arr as $val){
array_push($params,array(
'unique_id'=>null,
'token_id'=>$val,
));
Fragment::deleteFragment(['token_id'=>$val]); Fragment::deleteFragment(['token_id'=>$val]);
} }
{
//埋点
$event = [
'name' => LogService::FRAGMENT_SYNTH_MATERIAL,
];
LogService::ConsumableMaterial($event,$params);
}
// $this->_decItems($costItems); // $this->_decItems($costItems);
//生成NFT英雄 //生成NFT英雄
Nft::addNft($itemMeta); $tokenid = Nft::addNft($itemMeta);
{
//埋点
$nftDb = Nft::getNft($tokenid);
$event = array(
'name' => LogService::HERO_FRAGMENT,
'val' => mt\Parameter::getByName('jigsaw_merge_h_price')['param_value']
);
LogService::fragmentSynth($event,$nftDb);
}
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$propertyChgService->addFragment(); $propertyChgService->addFragment();
@ -184,15 +208,37 @@ class FragmentController extends BaseAuthedController
// return; // return;
// } // }
//销毁碎片 //销毁碎片
$params =array();
foreach ($token_id_arr as $val){ foreach ($token_id_arr as $val){
array_push($params,array(
'unique_id'=>null,
'token_id'=>$val,
));
Fragment::deleteFragment(['token_id'=>$val]); Fragment::deleteFragment(['token_id'=>$val]);
} }
{
//埋点
$event = [
'name' => LogService::FRAGMENT_SYNTH_MATERIAL,
];
LogService::ConsumableMaterial($event,$params);
}
// $this->_decItems($costItems); // $this->_decItems($costItems);
$itemMetaList = mt\Item::getMetaListByType(mt\Item::HERO_TYPE); $itemMetaList = mt\Item::getMetaListByType(mt\Item::HERO_TYPE);
$key = rand(0,count($itemMetaList)-1); $key = rand(0,count($itemMetaList)-1);
$itemMeta = $itemMetaList[$key]; $itemMeta = $itemMetaList[$key];
//生成NFT英雄 //生成NFT英雄
Nft::addNft($itemMeta); $tokenid = Nft::addNft($itemMeta);
{
//埋点
$nftDb = Nft::getNft($tokenid);
$event = array(
'name' => LogService::HERO_FRAGMENT,
'val' => mt\Parameter::getByName('jigsaw_merge_h_price')['param_value']
);
LogService::fragmentSynth($event,$nftDb);
}
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$propertyChgService->addFragment(); $propertyChgService->addFragment();
@ -248,12 +294,34 @@ class FragmentController extends BaseAuthedController
// return; // return;
// } // }
//销毁碎片 //销毁碎片
$params = array();
foreach ($token_id_arr as $val){ foreach ($token_id_arr as $val){
array_push($params,array(
'unique_id'=>null,
'token_id'=>$val,
));
Fragment::deleteFragment(['token_id'=>$val]); Fragment::deleteFragment(['token_id'=>$val]);
} }
{
//埋点
$event = [
'name' => LogService::FRAGMENT_SYNTH_MATERIAL,
];
LogService::ConsumableMaterial($event,$params);
}
// $this->_decItems($costItems); // $this->_decItems($costItems);
//生成NFT英雄 //生成NFT英雄
Nft::addNft($itemMeta); $tokenid = Nft::addNft($itemMeta);
{
//埋点
$nftDb = Nft::getNft($tokenid);
$event = array(
'name' => LogService::GUN_FRAGMENT,
'val' => mt\Parameter::getByName('jigsaw_merge_w_price')['param_value']
);
LogService::fragmentSynth($event,$nftDb);
}
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$propertyChgService->addFragment(); $propertyChgService->addFragment();
@ -290,15 +358,37 @@ class FragmentController extends BaseAuthedController
// return; // return;
// } // }
//销毁碎片 //销毁碎片
$params = array();
foreach ($token_id_arr as $val){ foreach ($token_id_arr as $val){
array_push($params,array(
'unique_id'=>null,
'token_id'=>$val,
));
Fragment::deleteFragment(['token_id'=>$val]); Fragment::deleteFragment(['token_id'=>$val]);
} }
{
//埋点
$event = [
'name' => LogService::FRAGMENT_SYNTH_MATERIAL,
];
LogService::ConsumableMaterial($event,$params);
}
// $this->_decItems($costItems); // $this->_decItems($costItems);
$itemMetaList = mt\Item::getMetaListByType(mt\Item::GUN_TYPE); $itemMetaList = mt\Item::getMetaListByType(mt\Item::GUN_TYPE);
$key = rand(0,count($itemMetaList)-1); $key = rand(0,count($itemMetaList)-1);
$itemMeta = $itemMetaList[$key]; $itemMeta = $itemMetaList[$key];
//生成NFT英雄 //生成NFT英雄
Nft::addNft($itemMeta); $tokenid = Nft::addNft($itemMeta);
{
//埋点
$nftDb = Nft::getNft($tokenid);
$event = array(
'name' => LogService::GUN_FRAGMENT,
'val' => mt\Parameter::getByName('jigsaw_merge_w_price')['param_value']
);
LogService::fragmentSynth($event,$nftDb);
}
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$propertyChgService->addFragment(); $propertyChgService->addFragment();

View File

@ -15,6 +15,7 @@ require_once('models/Chip.php');
require_once('services/AwardService.php'); require_once('services/AwardService.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
require_once('services/RankActivityService.php'); require_once('services/RankActivityService.php');
require_once('services/LogService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\GunSkin; use models\GunSkin;
@ -23,6 +24,7 @@ use models\User;
use models\Gun; use models\Gun;
use models\Bag; use models\Bag;
use models\Chip; use models\Chip;
use services\LogService;
class GunController extends BaseAuthedController { class GunController extends BaseAuthedController {
@ -159,6 +161,7 @@ class GunController extends BaseAuthedController {
$this->_rspErr(5, "It's already the highest level"); $this->_rspErr(5, "It's already the highest level");
return; return;
} }
$is_cec = false;
if ($gunDb['gun_lv']+1 <15){ if ($gunDb['gun_lv']+1 <15){
$costItems = array( $costItems = array(
array( array(
@ -177,6 +180,7 @@ class GunController extends BaseAuthedController {
'item_num' => \services\FormulaService::Weapon_Upgrade_CEC_Expend($gunDb['gun_lv']+1) 'item_num' => \services\FormulaService::Weapon_Upgrade_CEC_Expend($gunDb['gun_lv']+1)
) )
); );
$is_cec = true;
} }
$lackItem = null; $lackItem = null;
@ -185,6 +189,30 @@ class GunController extends BaseAuthedController {
return; return;
} }
$gunDto = Gun::toDto($gunDb);
{
//埋点
$eventCEG = [
'name' => LogService::GUN_LEVEL_UP_CONSUME,
'val' => \services\FormulaService::Weapon_Upgrade_CEG_Expend($gunDb['gun_lv']+1)
];
$gunDto['level'] = $gunDto['gun_lv'];
$gunDto['item_id'] = $gunDto['gun_id'];
LogService::consumeCEG($eventCEG,$gunDto,$gunDto);
}
if ($is_cec){
{
//埋点
$eventCEC = [
'name' => LogService::GUN_LEVEL_UP_CONSUME,
'val' => \services\FormulaService::Weapon_Upgrade_CEC_Expend($gunDb['gun_lv']+1)
];
$gunDto['level'] = $gunDto['gun_lv'];
$gunDto['item_id'] = $gunDto['gun_id'];
LogService::consumeCEC($eventCEC,$gunDto,$gunDto);
}
}
$this->_decItems($costItems); $this->_decItems($costItems);
Gun::update($gunUniId, Gun::update($gunUniId,
array( array(
@ -357,6 +385,28 @@ class GunController extends BaseAuthedController {
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();
$propertyChgService->addGunChg(); $propertyChgService->addGunChg();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$gunDto = Gun::toDto($gunDb);
{
//埋点
$eventCEG = [
'name' => LogService::GUN_QUALITY_UP_CONSUME,
'val' => \services\FormulaService::Weapon_Advanced_CEG_Expend($gunDb['quality']+1)
];
$gunDto['level'] = $gunDto['gun_lv'];
$gunDto['item_id'] = $gunDto['gun_id'];
LogService::consumeCEG($eventCEG,$gunDto,$gunDto);
}
{
//埋点
$eventCEC = [
'name' => LogService::GUN_QUALITY_UP_CONSUME,
'val' => \services\FormulaService::Weapon_Advanced_CEC_Expend($gunDb['quality']+1)
];
$gunDto['level'] = $gunDto['gun_lv'];
$gunDto['item_id'] = $gunDto['gun_id'];
LogService::consumeCEC($eventCEC,$gunDto,$gunDto);
}
$this->_rspData(array( $this->_rspData(array(
'property_chg' => $propertyChgService->toDto(), 'property_chg' => $propertyChgService->toDto(),
)); ));
@ -464,6 +514,18 @@ class GunController extends BaseAuthedController {
$rankActivityService = new services\RankActivityService(); $rankActivityService = new services\RankActivityService();
$rankActivityService->heroUpgradeLevel($gunDb['gun_lv'] + 1); $rankActivityService->heroUpgradeLevel($gunDb['gun_lv'] + 1);
} }
{
//埋点
$event = [
'name' => LogService::GUN_LEVEL_UP,
];
$oldGun['level'] = $oldGun['gun_lv'];
$oldGun['item_id'] = $oldGun['gun_id'];
$newGun['level'] = $newGun['gun_lv'];
$newGun['item_id'] = $newGun['gun_id'];
LogService::LevelUpOrQualityUp($event,$oldGun,$newGun);
}
$this->_rspData(array( $this->_rspData(array(
'property_chg' => $propertyChgService->toDto(), 'property_chg' => $propertyChgService->toDto(),
'old_gun' => $oldGun, 'old_gun' => $oldGun,
@ -519,6 +581,19 @@ class GunController extends BaseAuthedController {
'unlock_time' => 0, 'unlock_time' => 0,
) )
); );
{
//埋点
$event = [
'name' => LogService::GUN_QUALITY_UP_MATERIAL,
];
$params = array(
array(
'unique_id'=>$costGunDb['idx'],
'token_id'=>$costGunDb['token_id'],
)
);
LogService::ConsumableMaterial($event,$params);
}
$rnd = rand(1, 100); $rnd = rand(1, 100);
$probability = \services\FormulaService::Weapon_Advanced_Probability($gunDb['quality'] + 1)*100; $probability = \services\FormulaService::Weapon_Advanced_Probability($gunDb['quality'] + 1)*100;
if ($rnd > $probability) { if ($rnd > $probability) {
@ -569,6 +644,18 @@ class GunController extends BaseAuthedController {
$this->_rspErr(1, 'quality is full'); $this->_rspErr(1, 'quality is full');
return; return;
} }
{
//埋点
$event = [
'name' => LogService::GUN_QUALITY_UP,
];
$oldGun['level'] = $oldGun['gun_lv'];
$oldGun['item_id'] = $oldGun['gun_id'];
$newGun['level'] = $newGun['gun_lv'];
$newGun['item_id'] = $newGun['gun_id'];
LogService::LevelUpOrQualityUp($event,$oldGun,$newGun);
}
$this->_rspData(array( $this->_rspData(array(
'state' => 1, 'state' => 1,
'property_chg' => $propertyChgService->toDto(), 'property_chg' => $propertyChgService->toDto(),

View File

@ -19,6 +19,7 @@ require_once('models/Chip.php');
require_once('services/AwardService.php'); require_once('services/AwardService.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
require_once('services/RankActivityService.php'); require_once('services/RankActivityService.php');
require_once('services/LogService.php');
@ -27,6 +28,7 @@ use models\Hero;
use models\Bag; use models\Bag;
use models\HeroSkin; use models\HeroSkin;
use models\Chip; use models\Chip;
use services\LogService;
class HeroController extends BaseAuthedController { class HeroController extends BaseAuthedController {
@ -299,6 +301,17 @@ class HeroController extends BaseAuthedController {
$rankActivityService = new services\RankActivityService(); $rankActivityService = new services\RankActivityService();
$rankActivityService->heroUpgradeLevel($heroDb['hero_lv'] + 1); $rankActivityService->heroUpgradeLevel($heroDb['hero_lv'] + 1);
} }
{
//埋点
$event = [
'name' => LogService::HERO_LEVEL_UP,
];
$oldHero['level'] = $oldHero['hero_lv'];
$oldHero['item_id'] = $oldHero['hero_id'];
$newHero['level'] = $newHero['hero_lv'];
$newHero['item_id'] = $newHero['hero_id'];
LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
}
$this->_rspData(array( $this->_rspData(array(
'property_chg' => $propertyChgService->toDto(), 'property_chg' => $propertyChgService->toDto(),
'old_hero' => $oldHero, 'old_hero' => $oldHero,
@ -352,6 +365,19 @@ class HeroController extends BaseAuthedController {
'unlock_time' => 0, 'unlock_time' => 0,
) )
); );
{
//埋点
$event = [
'name' => LogService::HERO_QUALITY_UP_MATERIAL,
];
$params = array(
array(
'unique_id'=>$costHeroDb['idx'],
'token_id'=>$costHeroDb['token_id'],
)
);
LogService::ConsumableMaterial($event,$params);
}
$rnd = rand(1, 100); $rnd = rand(1, 100);
$probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100; $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100;
if ($rnd > $probability) { if ($rnd > $probability) {
@ -364,6 +390,17 @@ class HeroController extends BaseAuthedController {
); );
$oldHero['advanced_count'] += 1; $oldHero['advanced_count'] += 1;
$newHero['advanced_count'] += 1; $newHero['advanced_count'] += 1;
{
//埋点
$event = [
'name' => LogService::HERO_QUALITY_UP,
];
$oldHero['level'] = $oldHero['hero_lv'];
$oldHero['item_id'] = $oldHero['hero_id'];
$newHero['level'] = $newHero['hero_lv'];
$newHero['item_id'] = $newHero['hero_id'];
LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
}
$this->_rspRawData(array( $this->_rspRawData(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
@ -405,6 +442,17 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(1, 'quality is full'); $this->_rspErr(1, 'quality is full');
return; return;
} }
{
//埋点
$event = [
'name' => LogService::HERO_QUALITY_UP,
];
$oldHero['level'] = $oldHero['hero_lv'];
$oldHero['item_id'] = $oldHero['hero_id'];
$newHero['level'] = $newHero['hero_lv'];
$newHero['item_id'] = $newHero['hero_id'];
LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
}
$this->_rspData(array( $this->_rspData(array(
'state' => 1, 'state' => 1,
'property_chg' => $propertyChgService->toDto(), 'property_chg' => $propertyChgService->toDto(),
@ -457,6 +505,7 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(5, "It's already the highest level"); $this->_rspErr(5, "It's already the highest level");
return; return;
} }
$is_cec = false;
if ($heroDb['hero_lv']+1 <15){ if ($heroDb['hero_lv']+1 <15){
$costItems = array( $costItems = array(
array( array(
@ -475,6 +524,7 @@ class HeroController extends BaseAuthedController {
'item_num' => \services\FormulaService::Hero_Upgrade_CEC_Expend($heroDb['hero_lv']+1) 'item_num' => \services\FormulaService::Hero_Upgrade_CEC_Expend($heroDb['hero_lv']+1)
) )
); );
$is_cec = true;
} }
$lackItem = null; $lackItem = null;
@ -482,6 +532,29 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return; return;
} }
$heroDto = Hero::toDto($heroDb);
{
//埋点
$eventCEG = [
'name' => LogService::HERO_LEVEL_UP_CONSUME,
'val' => \services\FormulaService::Hero_Upgrade_CEG_Expend($heroDb['hero_lv']+1)
];
$heroDto['level'] = $heroDto['hero_lv'];
$heroDto['item_id'] = $heroDto['hero_id'];
LogService::consumeCEG($eventCEG,$heroDto,$heroDto);
}
if ($is_cec){
{
//埋点
$eventCEC = [
'name' => LogService::HERO_LEVEL_UP_CONSUME,
'val' => \services\FormulaService::Hero_Upgrade_CEC_Expend($heroDb['hero_lv']+1)
];
$heroDto['level'] = $heroDto['hero_lv'];
$heroDto['item_id'] = $heroDto['hero_id'];
LogService::consumeCEC($eventCEC,$heroDto,$heroDto);
}
}
$this->_decItems($costItems); $this->_decItems($costItems);
{ {
@ -641,6 +714,7 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return; return;
} }
$this->_decItems($costItems); $this->_decItems($costItems);
Hero::update($heroUniId, Hero::update($heroUniId,
array( array(
@ -660,6 +734,29 @@ class HeroController extends BaseAuthedController {
$propertyChgService->addHeroChg(); $propertyChgService->addHeroChg();
$propertyChgService->addBagChg(); $propertyChgService->addBagChg();
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
$heroDto = Hero::toDto($heroDb);
{
//埋点
$eventCEG = [
'name' => LogService::HERO_QUALITY_UP_CONSUME,
'val' => \services\FormulaService::Hero_Advanced_CEG_Expend($heroDb['quality']+1)
];
$heroDto['level'] = $heroDto['hero_lv'];
$heroDto['item_id'] = $heroDto['hero_id'];
LogService::consumeCEG($eventCEG,$heroDto,$heroDto);
}
{
//埋点
$eventCEC = [
'name' => LogService::HERO_QUALITY_UP_CONSUME,
'val' => \services\FormulaService::Hero_Advanced_CEC_Expend($heroDb['quality']+1)
];
$heroDto['level'] = $heroDto['hero_lv'];
$heroDto['item_id'] = $heroDto['hero_id'];
LogService::consumeCEC($eventCEC,$heroDto,$heroDto);
}
$this->_rspData(array( $this->_rspData(array(
'property_chg' => $propertyChgService->toDto(), 'property_chg' => $propertyChgService->toDto(),
)); ));

View File

@ -35,7 +35,7 @@ class Fragment extends BaseModel
if (!$row) { if (!$row) {
$itemMeta = mt\Item::get($nftDb['item_id']); $itemMeta = mt\Item::get($nftDb['item_id']);
if ($itemMeta) { if ($itemMeta) {
self::addNftHero($itemMeta, $nftDb['token_id']); self::addFragment($itemMeta, $nftDb['token_id']);
$row = SqlHelper::ormSelectOne( $row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(), myself()->_getSelfMysql(),
't_fragment', 't_fragment',
@ -52,7 +52,7 @@ class Fragment extends BaseModel
} }
public static function addNftHero($fragmentMeta, $tokenId) public static function addFragment($fragmentMeta, $tokenId)
{ {
return self::internalAddHero( return self::internalAddHero(
myself()->_getMysql($tokenId), myself()->_getMysql($tokenId),

View File

@ -173,6 +173,7 @@ class Gun extends BaseModel {
} }
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']); $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']);
$dto = array( $dto = array(
'idx' => $row['idx'],
'gun_uniid' => $row['idx'], 'gun_uniid' => $row['idx'],
'gun_id' => $row['gun_id'], 'gun_id' => $row['gun_id'],
'gun_lv' => $row['gun_lv'], 'gun_lv' => $row['gun_lv'],

View File

@ -179,6 +179,7 @@ class Hero extends BaseModel {
} }
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']); $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
$dto = array( $dto = array(
'idx' => $row['idx'],
'token_id' => $row['token_id'], 'token_id' => $row['token_id'],
'hero_uniid' => $row['idx'], 'hero_uniid' => $row['idx'],
'hero_id' => $row['hero_id'], 'hero_id' => $row['hero_id'],

View File

@ -270,7 +270,9 @@ class Nft extends BaseModel {
public static function addNft($itemMeta){ public static function addNft($itemMeta){
if ($itemMeta) { if ($itemMeta) {
$tokenID = myself()->_getNowTime();
$tokenType = Nft::getTokenType($itemMeta); $tokenType = Nft::getTokenType($itemMeta);
if ($tokenType == Nft::NONE_TYPE) { if ($tokenType == Nft::NONE_TYPE) {
return false; return false;
} else { } else {
@ -278,7 +280,7 @@ class Nft extends BaseModel {
myself()->_getMarketMysql(), myself()->_getMarketMysql(),
't_nft', 't_nft',
array( array(
'token_id' => myself()->_getNowTime(), 'token_id' => $tokenID,
'token_type' => $tokenType, 'token_type' => $tokenType,
'game_id' => 2006, 'game_id' => 2006,
'item_id' => $itemMeta['id'], 'item_id' => $itemMeta['id'],
@ -287,7 +289,7 @@ class Nft extends BaseModel {
'modifytime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(),
) )
); );
return true; return $tokenID;
} }
} else { } else {
return false; return false;

View File

@ -447,8 +447,8 @@ class FormulaService extends BaseService {
//芯片升星累计成本 //芯片升星累计成本
public static function getChipCumulativeCost($grade){ public static function getChipCumulativeCost($grade){
//( SIGN(芯片星级<6)*(15*芯片星级*(芯片星级-1)+10)+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(80*(芯片星级-4)*( 芯片星级-3)+50) +SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)*( 芯片星级-7)*(2*芯片星级-15)/6+80*(芯片星级-8)+2100) +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)*(芯片星级-7)*(2*芯片星级-15)/6-14000)) *CEG_Discount_Rate //( SIGN(0<芯片星级<6)*(15*芯片星级*(芯片星级-1)+10)+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(80*(芯片星级-4)*( 芯片星级-3)+50) +SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)*( 芯片星级-7)*(2*芯片星级-15)/6+80*(芯片星级-8)+2100) +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)*(芯片星级-7)*(2*芯片星级-15)/6-14000)) *CEG_Discount_Rate
return (($grade<6?1:0)*(15*$grade*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*( $grade-3)+50) +($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*( $grade-7)*(2*$grade-15)/6+80*($grade-8)+2100) +($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-14000)) *self::CEG_Discount_Rate(); return (($grade>0?1:0)*($grade<6?1:0)*(15*$grade*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*( $grade-3)+50) +($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*( $grade-7)*(2*$grade-15)/6+80*($grade-8)+2100) +($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-14000)) *self::CEG_Discount_Rate();
//( SIGN(芯片星级<6)*((15*芯片星级+10)*(芯片星级-1)+10)+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(80*(芯片星级-4)*( 芯片星级-3)+90) +SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)*( 芯片星级-7)*(2*芯片星级-15)/6+80*(芯片星级-8)+2140) +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)*(芯片星级-7)*(2*芯片星级-15)/6-13960)) *CEG_Discount_Rate //( SIGN(芯片星级<6)*((15*芯片星级+10)*(芯片星级-1)+10)+SIGN(芯片星级>5)*SIGN(芯片星级<10)*(80*(芯片星级-4)*( 芯片星级-3)+90) +SIGN(芯片星级>9)*SIGN(芯片星级<14)*(370*(芯片星级-8)*( 芯片星级-7)*(2*芯片星级-15)/6+80*(芯片星级-8)+2140) +SIGN(芯片星级>13)*SIGN(芯片星级<16)*(600*(芯片星级-8)*(芯片星级-7)*(2*芯片星级-15)/6-13960)) *CEG_Discount_Rate
// return (($grade<6?1:0)*((15*$grade+10)*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*($grade-3)+90)+($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*($grade-7)*(2*$grade-15)/6+80*($grade-8)+2140)+($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-13960))*self::CEG_Discount_Rate(); // return (($grade<6?1:0)*((15*$grade+10)*($grade-1)+10)+($grade>5?1:0)*($grade<10?1:0)*(80*($grade-4)*($grade-3)+90)+($grade>9?1:0)*($grade<14?1:0)*(370*($grade-8)*($grade-7)*(2*$grade-15)/6+80*($grade-8)+2140)+($grade>13?1:0)*($grade<16?1:0)*(600*($grade-8)*($grade-7)*(2*$grade-15)/6-13960))*self::CEG_Discount_Rate();

View File

@ -3,8 +3,137 @@
namespace services; namespace services;
require_once('phpcommon/tglog.php');
class LogService require_once('models/User.php');
use mt;
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 CONSUME = 0; //消耗
const PRODUCT = 1; //产出
const PRONAME = 'game_20006_api';
const GAMEID = 2006;
public static function consumeCEG($event,$old_nft,$new_nft)
{
$data = self::userInfo();
$data['type'] = self::CONSUME;
$data['event_name'] = $event['name'];
$data['event_demand'] = 'CEG';
$data['event_demand_val'] = $event['val'];
$data['ceg_discount_rate'] = FormulaService::CEG_Discount_Rate(); //CEG折扣比率
$nft = self::nftInfo($old_nft,$new_nft);
$logInfo = array_merge($data,$nft);
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function consumeCEC($event, $old_nft,$new_nft)
{
$data = self::userInfo();
$data['type'] = self::CONSUME;
$data['event_name'] = $event['name'];
$data['event_demand'] = 'CEC';
$data['event_demand_val'] = $event['val'];
$data['cec_discount_rate'] = FormulaService::CEC_Discount_Rate(); //CEC折扣比率
$nft = self::nftInfo($old_nft,$new_nft);
$logInfo = array_merge($data,$nft);
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function product($event)
{
}
public static function LevelUpOrQualityUp( $event, $old_nft,$new_nft)
{
$data = self::userInfo();
$data['event_name'] = $event['name'];
$nft = self::nftInfo($old_nft,$new_nft);
$logInfo = array_merge($data,$nft);
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function fragmentSynth($event,$nft)
{
$data = self::userInfo();
$data['event_name'] = $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);
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($data));
}
public static function ConsumableMaterial($event,$params)
{
$data = self::userInfo();
$data['event_name'] = $event['name'];
foreach ($params as $k=>$v){
$data['param'.($k+1)] = $v;
}
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($data));
}
private static function userInfo(){
$user = User::find(myself()->_getAccountId());
$info = array(
'account_id' => myself()->_getAccountId(), //账号id
'channel' => myself()->_getChannel(), //账号channel
'openid' => myself()->_getOpenId(), //账号openid
'name' => $user['name'], //用户名字
'rank' => $user['rank'], //段位
'gold' => $user['gold'], //CEG金币
'diamond' => $user['diamond'], //CEC钻石
'account_register_time' => myself()->_getRegisterTime(), //账号注册时间
'ip' => $_SERVER['REMOTE_ADDR'], //用户ip
'_os' => getReqVal('_os', ''),
'_net' => getReqVal('_net', ''),
);
return $info;
}
private static function nftInfo($old_nft,$new_nft){
$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'], //NFT item ID
'nft_ quality' => $old_nft['quality'] ? $old_nft['quality'] : null, //NFT品阶
'nft_level' => $old_nft['level'] ? $old_nft['level'] : null, //NFT等级
'nft_ quality2' => $new_nft['quality'] ? $new_nft['quality'] : null, //NFT品阶2
'nft_level2' => $new_nft['level'] ? $new_nft['level'] : null, //NFT等级2
'old_nft' => json_encode($old_nft),
'new_nft' => json_encode($new_nft)
);
return $info;
}
} }