update LogService

This commit is contained in:
hujiabin 2022-10-17 11:39:22 +08:00
parent 7c68b4a6bc
commit 6267008225

View File

@ -41,91 +41,101 @@ class LogService extends BaseService
public static function consumeCEG($event,$old_nft,$new_nft,$param = [])
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['type'] = self::CONSUME;
$data['event_name'] = $event['name'];
$data['log_class'] = $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,$param);
$logInfo['properties'] = array_merge($data,$nft,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($logInfo));
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function consumeCEC($event, $old_nft,$new_nft,$param = [])
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['type'] = self::CONSUME;
$data['event_name'] = $event['name'];
$data['log_class'] = $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,$param);
$logInfo['properties'] = array_merge($data,$nft,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($logInfo));
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function productCEG($event,$nft,$param = [])
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['type'] = self::PRODUCT;
$data['event_name'] = $event['name'];
$data['log_class'] = $event['name'];
$data['event_product'] = 'CEG';
$data['event_product_val'] = $event['val'];
$data['ceg_discount_rate'] = FormulaService::CEG_Discount_Rate(); //CEG折扣比率
$nftInfo = self::nftProductInfo($nft);
$logInfo = array_merge($data,$nftInfo,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($logInfo));
$logInfo['properties'] = array_merge($data,$nftInfo,$param);
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function productFragment($event,$param = [])
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['type'] = self::PRODUCT;
$data['event_name'] = $event['name'];
$data['log_class'] = $event['name'];
$data['event_product'] = 'Fragment';
$data['event_product_item_id'] = $event['item_id'];
$data['event_product_val'] = $event['number'];
$logInfo = array_merge($data,$param);
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($logInfo));
$logInfo['properties'] = array_merge($data,$param);
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function LevelUpOrQualityUp( $event, $old_nft,$new_nft)
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['event_name'] = $event['name'];
$data['log_class'] = $event['name'];
$nft = self::nftInfo($old_nft,$new_nft);
$logInfo = array_merge($data,$nft);
$logInfo['properties'] = array_merge($data,$nft);
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($logInfo));
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function fragmentSynth($event,$nft)
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['event_name'] = $event['name'];
$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);
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($data));
$logInfo['properties'] = $data;
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
public static function ConsumableMaterial($event,$params)
{
$logInfo = self::tokenRecord();
$data = self::userInfo();
$data['event_name'] = $event['name'];
$data['log_class'] = $event['name'];
foreach ($params as $k=>$v){
$data['param'.($k+1)] = $v;
}
TGLog::writeToLog(self::PRONAME,self::GAMEID,json_encode($data));
$logInfo['properties'] = $data;
TGLog::writeToLogWindows(self::PRONAME,self::GAMEID,json_encode($logInfo));
}
private static function userInfo()
@ -175,4 +185,19 @@ class LogService extends BaseService
}
private static function tokenRecord()
{
// $logInfo['log_class'] = $logInfo['log_class'];
// unset($logInfo['log_class']);
$data = array(
"#account_id" => myself()->_getAccountId(),
"#event_name"=> "token_record",
"#ip"=> $_SERVER['REMOTE_ADDR'],
"#time"=> myself()->_getNowTime(),
"#type"=> "track",
"properties"=>''
);
return $data;
}
}