139 lines
5.6 KiB
PHP
139 lines
5.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace services;
|
|
|
|
require_once('phpcommon/tglog.php');
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
} |