1
This commit is contained in:
parent
5e662854ee
commit
20aaec0787
@ -4,10 +4,11 @@ require_once('models/Chip.php');
|
|||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/Gun.php');
|
require_once('models/Gun.php');
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
|
require_once('models/Nft.php');
|
||||||
require_once('mt/ChipAttr.php');
|
require_once('mt/ChipAttr.php');
|
||||||
require_once('services/FormulaService.php');
|
require_once('services/FormulaService.php');
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
require_once('phpcommon/tglog.php');
|
require_once('services/LogService.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -15,10 +16,10 @@ use models\Chip;
|
|||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\Gun;
|
use models\Gun;
|
||||||
use models\User;
|
use models\User;
|
||||||
|
use models\Nft;
|
||||||
use services\FormulaService;
|
use services\FormulaService;
|
||||||
use services\NftService;
|
use services\LogService;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use phpcommon\TGLog;
|
|
||||||
|
|
||||||
class ChipController extends BaseAuthedController
|
class ChipController extends BaseAuthedController
|
||||||
{
|
{
|
||||||
@ -144,6 +145,7 @@ 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([
|
||||||
@ -154,6 +156,7 @@ 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([
|
||||||
@ -179,6 +182,7 @@ 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;
|
||||||
}
|
}
|
||||||
@ -192,6 +196,7 @@ 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;
|
||||||
}
|
}
|
||||||
@ -328,11 +333,11 @@ class ChipController extends BaseAuthedController
|
|||||||
|
|
||||||
public function syntheticChip(){
|
public function syntheticChip(){
|
||||||
$token_id_main = trim(getReqVal('token_id_main', 0));
|
$token_id_main = trim(getReqVal('token_id_main', 0));
|
||||||
$token_id_param = explode(' ',getReqVal('token_id_param', 0));
|
$token_id_param = array_filter(explode(' ',getReqVal('token_id_param', 0)));
|
||||||
if (! $token_id_main || count($token_id_param)<=0 ) {
|
// if (! $token_id_main || count($token_id_param)<=0 ) {
|
||||||
$this->_rspErr(1, 'Please enter instructions');
|
// $this->_rspErr(1, 'Please enter instructions token_id_param');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
$chip_main = Chip::getChipByTokenId($token_id_main);
|
$chip_main = Chip::getChipByTokenId($token_id_main);
|
||||||
$upgrade_cost = \services\FormulaService::getChipUpgradeCost($chip_main['chip_grade']+1);
|
$upgrade_cost = \services\FormulaService::getChipUpgradeCost($chip_main['chip_grade']+1);
|
||||||
if ($upgrade_cost==0){
|
if ($upgrade_cost==0){
|
||||||
@ -343,19 +348,28 @@ class ChipController extends BaseAuthedController
|
|||||||
foreach ($token_id_param as $val){
|
foreach ($token_id_param as $val){
|
||||||
$chip_param = Chip::getChipByTokenId($val);
|
$chip_param = Chip::getChipByTokenId($val);
|
||||||
$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]);
|
||||||
}
|
}
|
||||||
|
$this->_rspData([
|
||||||
|
'state' => 0,
|
||||||
|
'data' => [
|
||||||
|
'main'=>$token_id_main,
|
||||||
|
'param'=>$token_id_param,
|
||||||
|
'main_cost'=>$upgrade_cost,
|
||||||
|
'param_cost'=>$cumulative_cost,
|
||||||
|
],
|
||||||
|
]);return;
|
||||||
$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();
|
||||||
if ($num<rand(1,10000)){
|
if ($num<rand(1,10000)){ echo 'NO';die;
|
||||||
//合成失败
|
//合成失败
|
||||||
$this->_rspData([
|
$this->_rspData([
|
||||||
'state' => 0,
|
'state' => 0,
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{echo 'OK';die;
|
||||||
//合成成功
|
//合成成功
|
||||||
$this->_upgraded($chip_main);
|
$this->_upgraded($chip_main);
|
||||||
$chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main));
|
$chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main));
|
||||||
@ -548,7 +562,7 @@ class ChipController extends BaseAuthedController
|
|||||||
// $this->_rspOk();
|
// $this->_rspOk();
|
||||||
// $a = mt\Parameter::getByName('CEG_Parameter');
|
// $a = mt\Parameter::getByName('CEG_Parameter');
|
||||||
$a =FormulaService::Hero_Parts_Synthetic_Cost();
|
$a =FormulaService::Hero_Parts_Synthetic_Cost();
|
||||||
print_r($a);
|
print_r($_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -835,4 +849,25 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
10
webapp/services/LogService.php
Normal file
10
webapp/services/LogService.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
|
||||||
|
class LogService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user