You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1051 lines
36 KiB
1051 lines
36 KiB
/*
|
|
按天排序的
|
|
*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
using System.Text;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
using Sog;
|
|
|
|
namespace bill_statistics
|
|
{
|
|
|
|
public class BillAlldays : Singleton<BillAlldays>
|
|
{
|
|
public Dictionary<DateTime, BillInfoEveryDay> m_billAllDays = new Dictionary<DateTime, BillInfoEveryDay>();
|
|
public Dictionary<int, rechargeInfo> m_firstRecharge = new Dictionary<int, rechargeInfo>();
|
|
|
|
public Dictionary<int, UserInfo> m_newUserWithDay = new Dictionary<int, UserInfo>();
|
|
public Dictionary<int, UserInfoLongKeep> m_newUserLongKeepWithDay = new Dictionary<int, UserInfoLongKeep>();
|
|
|
|
//广告id和上报信息的对应,比如渠道
|
|
public Dictionary<string, string> m_adjustCallback = new Dictionary<string, string>();
|
|
public Dictionary<string, int> m_adjustAllChannel = new Dictionary<string, int>();
|
|
|
|
|
|
public NumberFormatInfo nfi;
|
|
|
|
//自己的月玩牌局数
|
|
//public Dictionary<int, int> m_ourOwnGameCount = new Dictionary<int, int>();
|
|
|
|
public Dictionary<string, int> m_ownNameCount = new Dictionary<string, int>();
|
|
|
|
private DateTime m_readFileDayStartTime;
|
|
|
|
|
|
public BillAlldays()
|
|
{
|
|
|
|
|
|
var numFormat = CultureInfo.CurrentCulture.NumberFormat;
|
|
nfi = new NumberFormatInfo()
|
|
{
|
|
CurrencyDecimalDigits = numFormat.PercentDecimalDigits,
|
|
CurrencyDecimalSeparator = numFormat.PercentDecimalSeparator,
|
|
CurrencyGroupSeparator = numFormat.PercentGroupSeparator,
|
|
CurrencyGroupSizes = numFormat.PercentGroupSizes,
|
|
CurrencyNegativePattern = numFormat.PercentNegativePattern,
|
|
CurrencyPositivePattern = numFormat.PercentPositivePattern,
|
|
CurrencySymbol = numFormat.PercentSymbol
|
|
};
|
|
}
|
|
|
|
public void ReadDataFromFile(int onlyDayNumber)
|
|
{
|
|
LogFileListSvc.ReadDataFromFile();
|
|
if (onlyDayNumber > 0)
|
|
{
|
|
//只保留可以计算昨天到今天留存之类的数据
|
|
LogFileListSvc.DeleteNoUseFileByOnlyDayNumber(onlyDayNumber);
|
|
}
|
|
|
|
int readcountSeq = 0;
|
|
foreach (var filename in LogFileListSvc.AllFileName)
|
|
{
|
|
readcountSeq++;
|
|
|
|
string strFullPathName = LogFileListSvc.strDir + "/" + filename;
|
|
|
|
//入库模式需要预先判断是否已经入过了,重复入库会有问题
|
|
if (BillMode.Mode == BillModeType.EXPORT_HOUR_LOG || BillMode.Mode == BillModeType.EXPROT_ALL_HOUR)
|
|
{
|
|
//已经入过库了,忽略
|
|
if(ExportToMysql.Instance.CheckThisHourAlreadyInSql(strFullPathName))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
ReadOneFile(strFullPathName, readcountSeq);
|
|
}
|
|
BillStatistics.SaveDataToDB(Statistics_type.register, ExportToMysql.Instance.GetMySqlDB());
|
|
|
|
BillStatistics.SaveDataToDB(Statistics_type.recharge, ExportToMysql.Instance.GetMySqlDB());
|
|
|
|
}
|
|
|
|
private void ReadOneFile(string fileName, int readcountSeq)
|
|
{
|
|
Console.WriteLine("ReadOneFile {0}", fileName);
|
|
|
|
FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
|
StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8);
|
|
|
|
fileStream.Seek(0, SeekOrigin.Begin);
|
|
|
|
string content = streamReader.ReadLine();
|
|
|
|
//int line = 10;
|
|
while (content != null/* && line-- > 0*/) //注释掉的为不读数据,
|
|
{
|
|
ReadOneLineBillLog(content);
|
|
content = streamReader.ReadLine();
|
|
}
|
|
|
|
streamReader.Dispose();
|
|
fileStream.Dispose();
|
|
//最后一个文件读完了
|
|
if(readcountSeq == LogFileListSvc.AllFileName.Count)
|
|
{
|
|
BillInfoEveryDay lastDayInfo = GetBillInfoByDay(m_readFileDayStartTime, false);
|
|
if (lastDayInfo != null)
|
|
{
|
|
lastDayInfo.CalcAfterThisDayAllHourReadFinish();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ReadOneLineBillLog(string billlog)
|
|
{
|
|
//1055是客户端上报操作日志,没有计算意义,直接返回,提高效率
|
|
if (billlog.Contains("|iType=1055|"))
|
|
{
|
|
return;
|
|
}
|
|
|
|
string[] splitStr = billlog.Split('|');
|
|
if(splitStr.Length < 3)
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
int billType = BillTypeUtils.GetBillType(splitStr[1]);
|
|
|
|
DateTime curedateTime = BillTypeUtils.GetTime(splitStr[0]);
|
|
//获取这一天的标准时间
|
|
DateTime dayStartTime = curedateTime - curedateTime.TimeOfDay;
|
|
|
|
//新的一天了,说明老的一天的数据已经读完,调用一下计算接口,清理一些临时数据,节省内存
|
|
if(m_readFileDayStartTime != dayStartTime)
|
|
{
|
|
BillInfoEveryDay lastDayInfo = GetBillInfoByDay(m_readFileDayStartTime, false);
|
|
if(lastDayInfo != null)
|
|
{
|
|
lastDayInfo.CalcAfterThisDayAllHourReadFinish();
|
|
}
|
|
//设置成新的一天
|
|
m_readFileDayStartTime = dayStartTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int uid = 0;
|
|
string smallStrUid = splitStr[2].ToLower();
|
|
if (smallStrUid.Contains("uid"))
|
|
{
|
|
uid = BillTypeUtils.GetUid(smallStrUid);
|
|
}
|
|
|
|
//长时间的留存和付费,只计算少数逻辑
|
|
if (BillMode.Mode == BillModeType.LONG_KEEP)
|
|
{
|
|
//计算长留存和付费
|
|
switch (billType)
|
|
{
|
|
//login
|
|
case 1000:
|
|
ReadLoginBill(dayStartTime, splitStr);
|
|
break;
|
|
case 1005:
|
|
ReadPayGoogleSuccessRes(dayStartTime, splitStr);
|
|
break;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
switch (billType)
|
|
{
|
|
//login
|
|
case (int)BillLogType.Login:
|
|
ReadLoginBill(dayStartTime, splitStr);
|
|
break;
|
|
case (int)BillLogType.Logout:
|
|
ReadLogoutBill(dayStartTime, splitStr);
|
|
break;
|
|
case (int)BillLogType.PayGoogleSuccessRes:
|
|
ReadPayGoogleSuccessRes(dayStartTime, splitStr);
|
|
break;
|
|
case (int)BillLogType.DiamondChipExchange:
|
|
ReadDiamondChipExchange(dayStartTime, uid, splitStr);
|
|
break;
|
|
case (int)BillLogType.ChangeDiamond:
|
|
ReadChangeDiamond(dayStartTime, uid, splitStr);
|
|
break;
|
|
case (int)BillLogType.ChangeChip:
|
|
ReadChangeChip(dayStartTime, uid, splitStr);
|
|
break;
|
|
case (int)BillLogType.ChangeItem:
|
|
ReadChangeItem(dayStartTime, uid, splitStr);
|
|
break;
|
|
|
|
case 1030:
|
|
ReadMailStart(dayStartTime, uid, splitStr);
|
|
break;
|
|
case 1031:
|
|
ReadMailOpRet(dayStartTime, splitStr);
|
|
break;
|
|
case 1032:
|
|
ReadSendMailToPlayer(dayStartTime, uid, splitStr);
|
|
break;
|
|
/*case 1041:
|
|
ReadExchangeCouponDbRes(curedateTime,dayStartTime, splitStr);
|
|
break;*/
|
|
case 1051:
|
|
ReadFinishNewbitStep(dayStartTime, splitStr);
|
|
break;
|
|
case 1070:
|
|
ReadShareFacebook(dayStartTime, uid, splitStr);
|
|
break;
|
|
case 1071:
|
|
ReadGiveFriendChipDaily(dayStartTime, uid, splitStr);
|
|
break;
|
|
case 1072:
|
|
ReadInviteFacebook(dayStartTime, uid, splitStr);
|
|
break;
|
|
|
|
case 1090:
|
|
ReadFocusFacebook(dayStartTime, uid, splitStr);
|
|
break;
|
|
case 1091:
|
|
ReadFriendList(dayStartTime, uid, splitStr);
|
|
break;
|
|
case 3001:
|
|
ReadOnlineBill(dayStartTime, splitStr);
|
|
break;
|
|
|
|
case 4001:
|
|
ReadAdjustInstallReport(dayStartTime, splitStr);
|
|
break;
|
|
|
|
case 1142:
|
|
ReadDayRetentionOptimizetion(dayStartTime, uid, splitStr);
|
|
break;
|
|
case 1146:
|
|
ReadHorsePlay(dayStartTime, uid, splitStr);
|
|
break;
|
|
}
|
|
|
|
if (BillMode.Mode == BillModeType.EXPORT_HOUR_LOG || BillMode.Mode == BillModeType.EXPROT_ALL_HOUR)
|
|
{
|
|
if (BillTypeUtils.NeedExportToSqlByType(billType))
|
|
{
|
|
ExportToMysql.Instance.DoExportBillType(splitStr);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void ReadTreasureBuy(DateTime dateTime, int uid ,string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
int id = int.Parse(splitStr[3].Split('=')[1]);
|
|
long openTime = long.Parse(splitStr[4].Split('=')[1]);
|
|
int seq = int.Parse(splitStr[5].Split('=')[1]);
|
|
int totalCountPlayer = int.Parse(splitStr[7].Split('=')[1]);
|
|
|
|
|
|
info.AddTreasureBuy(uid, id, totalCountPlayer);
|
|
}
|
|
private void ReadTreasurePrize(DateTime dateTime, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
int id = int.Parse(splitStr[2].Split('=')[1]);
|
|
long openTime = long.Parse(splitStr[3].Split('=')[1]);
|
|
int seq = int.Parse(splitStr[4].Split('=')[1]);
|
|
long prizeUId = long.Parse(splitStr[7].Split('=')[1]);
|
|
int prizeIndex = int.Parse(splitStr[8].Split('=')[1]);
|
|
|
|
info.AddTreasure(id, prizeIndex,prizeUId);
|
|
}
|
|
|
|
|
|
private void ReadOnlineBill( DateTime dateTime, string[] splitStr )
|
|
{
|
|
int hour = int.Parse(splitStr[0].Split(' ')[1].Split(':')[0]);
|
|
int userNum = int.Parse(splitStr[2].Split('=')[1]);
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddOnlineUser(hour, userNum);
|
|
}
|
|
|
|
private void ReadLoginBill(DateTime dateTime, string[] splitStr)
|
|
{
|
|
DateTime curedateTime = BillTypeUtils.GetTime(splitStr[0]);
|
|
|
|
int accType = int.Parse(splitStr[2].Split('=')[1]);
|
|
|
|
int uid = int.Parse(splitStr[4].Split('=')[1]);
|
|
int loginCount = int.Parse(splitStr[5].Split('=')[1]);
|
|
|
|
|
|
bool bIsNew = (loginCount == 1);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
if (BillMode.Mode == BillModeType.LONG_KEEP)
|
|
{
|
|
info.AddLoginInfoForLongKeep(curedateTime, uid, accType, bIsNew);
|
|
}
|
|
else
|
|
{
|
|
string strAccount = splitStr[3].Split('=')[1];
|
|
int onlineTime = int.Parse(splitStr[6].Split('=')[1]);
|
|
int level = int.Parse(splitStr[7].Split('=')[1]);
|
|
Int64 chip = Int64.Parse(splitStr[8].Split('=')[1]);
|
|
Int64 diamond = Int64.Parse(splitStr[9].Split('=')[1]);
|
|
|
|
string nick = "";
|
|
if (splitStr.Length > 12)
|
|
{
|
|
nick = splitStr[12].Split('=')[1];
|
|
}
|
|
int totalPayCount = 0;//
|
|
string adid = null;//广告id
|
|
if(splitStr.Length > 14)
|
|
{
|
|
totalPayCount = int.Parse(splitStr[14].Split('=')[1]);
|
|
}
|
|
if(splitStr.Length > 22)
|
|
{
|
|
adid = splitStr[22].Split('=')[1];
|
|
}
|
|
int platform = 0;
|
|
if (splitStr.Length > 23)
|
|
{
|
|
platform = int.Parse(splitStr[23].Split('=')[1]);
|
|
}
|
|
|
|
int winPercent = 0;
|
|
if(splitStr.Length > 26)
|
|
{
|
|
winPercent = int.Parse(splitStr[26].Split('=')[1]);
|
|
}
|
|
info.AddLoginInfo(curedateTime, uid, strAccount, accType, bIsNew, chip, diamond, onlineTime, nick, totalPayCount,adid,platform, winPercent);
|
|
}
|
|
}
|
|
|
|
private void ReadLogoutBill(DateTime dateTime, string[] splitStr)
|
|
{
|
|
DateTime curedateTime = BillTypeUtils.GetTime(splitStr[0]);
|
|
|
|
int accType = int.Parse(splitStr[2].Split('=')[1]);
|
|
string strAccount = splitStr[3].Split('=')[1];
|
|
int uid = int.Parse(splitStr[4].Split('=')[1]);
|
|
int loginCount = int.Parse(splitStr[5].Split('=')[1]);
|
|
int onlineTime = int.Parse(splitStr[6].Split('=')[1]);
|
|
int level = int.Parse(splitStr[7].Split('=')[1]);
|
|
Int64 chip = Int64.Parse(splitStr[8].Split('=')[1]);
|
|
Int64 diamond = Int64.Parse(splitStr[9].Split('=')[1]);
|
|
string adid = null;
|
|
if (splitStr.Length > 11)
|
|
{
|
|
adid = splitStr[11].Split('=')[1];
|
|
}
|
|
|
|
bool bIsNew = (loginCount == 1);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
|
|
info.AddLogoutInfo(dateTime, curedateTime, accType, strAccount, uid, loginCount, onlineTime, level, chip, diamond, bIsNew, adid);
|
|
|
|
}
|
|
//2021-07-05 04:28:47|iType=1005|Iuid=104716|sitemid=gp_novicePack1|idiamond=0|imoney=499|sorderid=104716-1625473704-699-116737-gp_novicePack1-0-0-pm_499|iret=0|sorderid3rd=HUA10186179029|idiamondGift=0|ifirstPayUser=1|snick=nea200pl|ipayType=3|IaddChip=0|ipayStatus=2|iamount=499|scurrency=USD
|
|
private void ReadPayGoogleSuccessRes(DateTime dateTime, string[] splitStr)
|
|
{
|
|
int uid = int.Parse(splitStr[2].Split('=')[1]);
|
|
string strItemId = splitStr[3].Split('=')[1];
|
|
Int64 diamond = Int64.Parse(splitStr[4].Split('=')[1]);
|
|
int money = int.Parse(splitStr[5].Split('=')[1]);
|
|
string orderid = splitStr[6].Split('=')[1];
|
|
int ret = int.Parse(splitStr[7].Split('=')[1]);
|
|
|
|
int firstPay = 0;
|
|
if (splitStr.Length > 10)
|
|
{
|
|
firstPay = int.Parse(splitStr[10].Split('=')[1]);
|
|
}
|
|
|
|
|
|
Int64 addDiamond = 0;
|
|
|
|
if (splitStr.Length > 9)
|
|
{
|
|
addDiamond = int.Parse(splitStr[9].Split('=')[1]);
|
|
}
|
|
if (splitStr.Length == 9)
|
|
{
|
|
addDiamond = diamond;
|
|
}
|
|
|
|
DateTime now = DateTime.Parse(splitStr[0]);
|
|
|
|
//if (addDiamond > 0)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddPayGoogleSuccessRes(dateTime, uid, strItemId, addDiamond, money, orderid, ret, now, firstPay);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BillInfoEveryDay GetBillInfoByDay(DateTime dateTime, bool addNewIfNotExist = true)
|
|
{
|
|
if (m_billAllDays.ContainsKey(dateTime))
|
|
{
|
|
return m_billAllDays[dateTime];
|
|
}
|
|
|
|
if (addNewIfNotExist)
|
|
{
|
|
BillInfoEveryDay info = new BillInfoEveryDay();
|
|
info.BillDate = dateTime;
|
|
m_billAllDays.Add(dateTime, info);
|
|
|
|
return info;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
public void CalcAll()
|
|
{
|
|
//先排序
|
|
m_billAllDays = m_billAllDays.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
|
|
|
|
if(BillMode.Mode == BillModeType.LONG_KEEP)
|
|
{
|
|
foreach (KeyValuePair<DateTime, BillInfoEveryDay> pair in m_billAllDays)
|
|
{
|
|
CalcOneDayLongKeep(pair.Key, pair.Value);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
foreach (KeyValuePair<DateTime, BillInfoEveryDay> pair in m_billAllDays)
|
|
{
|
|
pair.Value.CalcThis();
|
|
}
|
|
|
|
foreach (KeyValuePair<DateTime, BillInfoEveryDay> pair in m_billAllDays)
|
|
{
|
|
CalcOneDay(pair.Key, pair.Value);
|
|
}
|
|
|
|
//月数据
|
|
CalcAllDayMonth();
|
|
}
|
|
|
|
|
|
// 新用户付费
|
|
CalcNewUserRechargeInfo();
|
|
}
|
|
|
|
public void NewUserRechargeMethod(PayGoogleSuccessRes pay, DateTime dateTime)
|
|
{
|
|
DateTime firstLoginBillDate;
|
|
|
|
if (BillMode.Mode == BillModeType.LONG_KEEP)
|
|
{
|
|
UserInfoLongKeep userInfo;
|
|
if (!m_newUserLongKeepWithDay.TryGetValue(pay.uid, out userInfo))
|
|
{
|
|
return;
|
|
}
|
|
|
|
firstLoginBillDate = userInfo.firstLoginBillDate;
|
|
}
|
|
else
|
|
{
|
|
UserInfo userInfo;
|
|
if (!m_newUserWithDay.TryGetValue(pay.uid, out userInfo))
|
|
{
|
|
return;
|
|
}
|
|
firstLoginBillDate = userInfo.firstLoginBillDate;
|
|
}
|
|
|
|
|
|
var firstDayInfo = GetBillInfoByDay(firstLoginBillDate);
|
|
|
|
TimeSpan ts = dateTime - firstLoginBillDate;
|
|
int daysGap = (int)ts.TotalDays;
|
|
|
|
if (daysGap < 1)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney1 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount1++;
|
|
}
|
|
|
|
if (daysGap < 2)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney2 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount2++;
|
|
}
|
|
|
|
if (daysGap < 3)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney3 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount3++;
|
|
}
|
|
|
|
if (daysGap < 7)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney7 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount7++;
|
|
}
|
|
|
|
if (daysGap < 14)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney14 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount14++;
|
|
}
|
|
|
|
if (daysGap < 30)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney30 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount30++;
|
|
}
|
|
|
|
if (daysGap < 60)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney60 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount60++;
|
|
}
|
|
|
|
if (daysGap < 90)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney90 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount90++;
|
|
}
|
|
|
|
if (daysGap < 120)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney120 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount120++;
|
|
}
|
|
|
|
if (daysGap < 150)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney150 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount150++;
|
|
}
|
|
|
|
if (daysGap < 180)
|
|
{
|
|
firstDayInfo.m_newUserRechargeMoney180 += pay.money;
|
|
firstDayInfo.m_newUserRechargeCount180++;
|
|
}
|
|
|
|
}
|
|
|
|
public void CalcNewUserRechargeInfo()
|
|
{
|
|
foreach (KeyValuePair<DateTime, BillInfoEveryDay> pair in m_billAllDays)
|
|
{
|
|
DateTime dateTime = pair.Key;
|
|
BillInfoEveryDay info = pair.Value;
|
|
|
|
foreach (var pay in info.m_PayGoogleSuccessResUser.Values)
|
|
{
|
|
NewUserRechargeMethod(pay, dateTime);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void CalcOneDayKeepLostUser(int index, DateTime dateTime, BillInfoEveryDay billInfo)
|
|
{
|
|
DateTime dateTimeNew = dateTime.AddDays(index);
|
|
if (m_billAllDays.ContainsKey(dateTimeNew))
|
|
{
|
|
BillInfoEveryDay billInfoNew = m_billAllDays[dateTimeNew];
|
|
billInfo.CalcUserKeep(index, billInfoNew);
|
|
|
|
billInfo.CalcLostUserChip(index, billInfoNew);
|
|
|
|
billInfo.CalcLostNewUserChip(index, billInfoNew);
|
|
|
|
}
|
|
}
|
|
|
|
private void CalcOneDayKeepLostUserLongKeep(int index, DateTime dateTime, BillInfoEveryDay billInfo)
|
|
{
|
|
DateTime dateTimeNew = dateTime.AddDays(index);
|
|
if (m_billAllDays.ContainsKey(dateTimeNew))
|
|
{
|
|
BillInfoEveryDay billInfoNew = m_billAllDays[dateTimeNew];
|
|
billInfo.CalcUserKeepNewLongKeep(index, billInfoNew);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CalcOneDay(DateTime dateTime, BillInfoEveryDay billInfo)
|
|
{
|
|
//算7天留存
|
|
int i = 0;
|
|
for (; i < 7; i++)
|
|
{
|
|
CalcOneDayKeepLostUser(i + 1, dateTime, billInfo);
|
|
}
|
|
|
|
//15
|
|
//30
|
|
CalcOneDayKeepLostUser(15, dateTime, billInfo);
|
|
CalcOneDayKeepLostUser(30, dateTime, billInfo);
|
|
}
|
|
|
|
private void CalcOneDayLongKeep(DateTime dateTime, BillInfoEveryDay billInfo)
|
|
{
|
|
//算7天留存
|
|
int i = 0;
|
|
for (; i < 7; i++)
|
|
{
|
|
CalcOneDayKeepLostUserLongKeep(i + 1, dateTime, billInfo);
|
|
}
|
|
|
|
//15
|
|
//30
|
|
CalcOneDayKeepLostUserLongKeep(15, dateTime, billInfo);
|
|
CalcOneDayKeepLostUserLongKeep(30, dateTime, billInfo);
|
|
CalcOneDayKeepLostUserLongKeep(60, dateTime, billInfo);
|
|
CalcOneDayKeepLostUserLongKeep(90, dateTime, billInfo);
|
|
CalcOneDayKeepLostUserLongKeep(120, dateTime, billInfo);
|
|
CalcOneDayKeepLostUserLongKeep(150, dateTime, billInfo);
|
|
CalcOneDayKeepLostUserLongKeep(180, dateTime, billInfo);
|
|
|
|
}
|
|
|
|
//计算月数据
|
|
private void CalcAllDayMonth()
|
|
{
|
|
foreach(var onedayPair in m_billAllDays)
|
|
{
|
|
DateTime datTime = onedayPair.Key;
|
|
|
|
//先把自己的加上
|
|
onedayPair.Value.AddForMonth(onedayPair.Value);
|
|
|
|
for (int i = 1 ; i < datTime.Day; i++)
|
|
{
|
|
//取前一天
|
|
DateTime lastDay = datTime.AddDays(-i);
|
|
|
|
if(m_billAllDays.ContainsKey(lastDay))
|
|
{
|
|
BillInfoEveryDay lastDayInfo = m_billAllDays[lastDay];
|
|
|
|
onedayPair.Value.AddForMonth(lastDayInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ReadMailOpRet(DateTime dateTime, string[] splitStr)
|
|
{
|
|
int opUid = int.Parse(splitStr[2].Split('=')[1]);
|
|
int opType = int.Parse(splitStr[3].Split('=')[1]);
|
|
uint mailID = uint.Parse(splitStr[4].Split('=')[1]);
|
|
int mailType = int.Parse(splitStr[5].Split('=')[1]);
|
|
int ownerUid = int.Parse(splitStr[6].Split('=')[1]);
|
|
int senderUid = int.Parse(splitStr[7].Split('=')[1]);
|
|
long senderTime = int.Parse(splitStr[8].Split('=')[1]);
|
|
int ret = int.Parse(splitStr[9].Split('=')[1]);
|
|
long insertUniqueID = long.Parse(splitStr[10].Split('=')[1]);
|
|
long getItemTime = long.Parse(splitStr[11].Split('=')[1]);
|
|
long deleteTime = long.Parse(splitStr[12].Split('=')[1]);
|
|
string title = splitStr[13].Split('=')[1];
|
|
string content = splitStr[14].Split('=')[1];
|
|
|
|
Int64 chip = 0;
|
|
|
|
|
|
if (splitStr.Length > 15)
|
|
{
|
|
if (splitStr[15].Contains("="))
|
|
{
|
|
chip = Int64.Parse(splitStr[15].Split('=')[1]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Int64 diamond = 0;
|
|
if (splitStr.Length > 16)
|
|
{
|
|
if (splitStr[16].Contains("="))
|
|
{
|
|
diamond = Int64.Parse(splitStr[16].Split('=')[1]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Int64 chip = Int64.Parse(splitStr[15].Split('=')[1]);
|
|
//Int64 diamond = Int64.Parse(splitStr[16].Split('=')[1]);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
info.AddMailOpRet(opUid, opType, mailID, mailType, ownerUid, senderUid, senderTime, ret, insertUniqueID, getItemTime,
|
|
deleteTime, title, content, chip, diamond);
|
|
|
|
}
|
|
private void ReadSendMailToPlayer(DateTime dateTime, long uid, string[] splitStr)
|
|
{
|
|
long targetUid = long.Parse(splitStr[3].Split('=')[1]);
|
|
long chip = long.Parse(splitStr[5].Split('=')[1]);
|
|
long tax = long.Parse(splitStr[6].Split('=')[1]);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.ChipSendPlayerMail += chip;
|
|
info.ChipSendPlayerMailTax += tax;
|
|
info.ChipConsume += /*chip + */tax;
|
|
info.ChipTrans += chip;
|
|
}
|
|
|
|
|
|
private void ReadExchangeCouponDbRes(DateTime curedateTim, DateTime dateTime, string[] splitStr)
|
|
{
|
|
int uid = int.Parse(splitStr[2].Split('=')[1]);
|
|
string nick = splitStr[3].Split('=')[1];
|
|
int itemid = int.Parse(splitStr[4].Split('=')[1]);
|
|
long uniqueID = long.Parse(splitStr[5].Split('=')[1]);
|
|
int phoneCardMoney = int.Parse(splitStr[6].Split('=')[1]);
|
|
string transactionId = splitStr[7].Split('=')[1];
|
|
int status = int.Parse(splitStr[8].Split('=')[1]);
|
|
int ret = int.Parse(splitStr[9].Split('=')[1]);
|
|
string trueName = splitStr[10].Split('=')[1];
|
|
string phoneNum = splitStr[11].Split('=')[1];
|
|
string telcom = splitStr[12].Split('=')[1];
|
|
string email = splitStr[13].Split('=')[1];
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
if (ret == 0)
|
|
{
|
|
info.AddExchangeCouponDbRes(curedateTim, uid, nick, itemid, uniqueID, phoneCardMoney, transactionId, status, ret, trueName, phoneNum, telcom, email);
|
|
}
|
|
|
|
}
|
|
|
|
private void ReadFinishNewbitStep(DateTime dateTime, string[] splitStr)
|
|
{
|
|
int uid = int.Parse(splitStr[2].Split('=')[1]);
|
|
int step = int.Parse(splitStr[3].Split('=')[1]);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
info.AddFinishNewbitStep(uid, step);
|
|
}
|
|
|
|
|
|
|
|
private void ReadShareFacebook(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
int rewardId = 0;
|
|
|
|
// 兼容老的日志格式
|
|
if (splitStr.Count() > 3)
|
|
{
|
|
rewardId = int.Parse(splitStr[3].Split('=')[1]);
|
|
}
|
|
|
|
info.AddShareFacebook(uid, rewardId);
|
|
}
|
|
|
|
private void ReadGiveFriendChipDaily(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
int recvUid = int.Parse(splitStr[3].Split('=')[1]);
|
|
|
|
info.AddGiveFriendChipDaily(uid, recvUid);
|
|
}
|
|
|
|
private void ReadInviteFacebook(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
|
|
int iCount = int.Parse(splitStr[3].Split('=')[1]);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddInviteFacebook(uid, iCount);
|
|
}
|
|
|
|
|
|
private void ReadFocusFacebook(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
info.AddFocusFacebook(uid);
|
|
}
|
|
|
|
|
|
|
|
private void ReadDiamondChipExchange(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
int iDescID = int.Parse(splitStr[3].Split('=')[1]);
|
|
Int64 iDiamond = Int64.Parse(splitStr[4].Split('=')[1]);
|
|
Int64 iChip = Int64.Parse(splitStr[5].Split('=')[1]);
|
|
Int64 iAfterDiamond = Int64.Parse(splitStr[6].Split('=')[1]);
|
|
Int64 iAfterChip = Int64.Parse(splitStr[7].Split('=')[1]);
|
|
int iIsDiscount = int.Parse(splitStr[8].Split('=')[1]);
|
|
int iItemId = int.Parse(splitStr[9].Split('=')[1]);
|
|
int iItemCount = int.Parse(splitStr[10].Split('=')[1]);
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddDiamondChipExchange(uid, iDescID, iDiamond, iChip, iAfterDiamond, iAfterChip, iIsDiscount, iItemId, iItemCount);
|
|
}
|
|
|
|
private void ReadChangeDiamond(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
Int64 ioldDiamond = Int64.Parse(splitStr[3].Split('=')[1]);
|
|
Int64 inewDiamond = Int64.Parse(splitStr[4].Split('=')[1]);
|
|
Int64 ichange = Int64.Parse(splitStr[5].Split('=')[1]);
|
|
string reason = splitStr[6].Split('=')[1];
|
|
string param1 = null;
|
|
if (splitStr.Length > 7)
|
|
{
|
|
param1 = splitStr[7].Split('=')[1];
|
|
}
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddChangeDiamond(uid, ioldDiamond, inewDiamond, ichange, reason, param1);
|
|
}
|
|
|
|
private void ReadChangeChip(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
DateTime curedateTime = BillTypeUtils.GetTime(splitStr[0]);
|
|
|
|
Int64 ioldChip = Int64.Parse(splitStr[3].Split('=')[1]);
|
|
Int64 inewChip = Int64.Parse(splitStr[4].Split('=')[1]);
|
|
Int64 ichange = Int64.Parse(splitStr[5].Split('=')[1]);
|
|
string reason = splitStr[6].Split('=')[1];
|
|
string param1 = null;
|
|
if(splitStr.Length > 7)
|
|
{
|
|
param1 = splitStr[7].Split('=')[1];
|
|
}
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
BillInfoEveryDay lastDayInfo = GetBillInfoByDay(dateTime.AddDays(-1),false);
|
|
|
|
info.AddChangeChip(curedateTime, uid, ioldChip, inewChip, ichange, reason, lastDayInfo,param1);
|
|
}
|
|
|
|
private void ReadChangeItem(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
DateTime curedateTime = BillTypeUtils.GetTime(splitStr[0]);
|
|
|
|
int itemId = Int32.Parse(splitStr[3].Split('=')[1]);
|
|
Int64 ioldCount = Int64.Parse(splitStr[5].Split('=')[1]);
|
|
Int64 inewCount = Int64.Parse(splitStr[6].Split('=')[1]);
|
|
Int64 ichangeCount = Int64.Parse(splitStr[7].Split('=')[1]);
|
|
string reason = splitStr[8].Split('=')[1];
|
|
//string param1 = null;
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
|
|
info.AddChangeItem(curedateTime, uid, itemId, ioldCount, inewCount, ichangeCount, reason);
|
|
}
|
|
|
|
public int GetOffDay(DateTime dTime)
|
|
{
|
|
DateTime tmpTime = dTime;
|
|
foreach (KeyValuePair<DateTime, BillInfoEveryDay> pair in m_billAllDays)
|
|
{
|
|
if(pair.Key>tmpTime)
|
|
{
|
|
tmpTime = pair.Key;
|
|
}
|
|
}
|
|
TimeSpan x = tmpTime - dTime;
|
|
int iDays = 7;
|
|
if((int)x.TotalDays<7)
|
|
{
|
|
iDays = (int)x.TotalDays;
|
|
}
|
|
|
|
return iDays;
|
|
}
|
|
|
|
|
|
private void ReadAdjustInstallReport(DateTime dateTime, string[] splitStr)
|
|
{
|
|
string channel = null;
|
|
string subchannel = null;
|
|
string adid = null;
|
|
|
|
foreach(var param in splitStr)
|
|
{
|
|
string[] keyvalue = param.Split('=');
|
|
if(keyvalue.Length != 2)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//渠道
|
|
if(keyvalue[0] == "snetwork_name")
|
|
{
|
|
|
|
channel = keyvalue[1];
|
|
|
|
}//广告id
|
|
else if(keyvalue[0] == "sgps_adid")
|
|
{
|
|
adid = keyvalue[1];
|
|
}
|
|
else if(keyvalue[0] == "sadgroup_name")
|
|
{
|
|
//applift需要子渠道
|
|
/*
|
|
if (channel == "Applift")
|
|
{
|
|
subchannel = keyvalue[1];
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
|
|
//添加到广告id和渠道的对应表中
|
|
if(string.IsNullOrEmpty(channel) == false
|
|
&& string.IsNullOrEmpty(adid) == false)
|
|
{
|
|
string full_channel = channel;
|
|
|
|
if(string.IsNullOrEmpty(subchannel) == false)
|
|
{
|
|
full_channel = channel + "|" + subchannel;
|
|
}
|
|
if(m_adjustCallback.ContainsKey(adid) == false)
|
|
{
|
|
m_adjustCallback.Add(adid, full_channel);
|
|
}
|
|
|
|
//所有渠道
|
|
if(m_adjustAllChannel.ContainsKey(channel) == false)
|
|
{
|
|
m_adjustAllChannel.Add(channel, 1);
|
|
}
|
|
|
|
if(full_channel != channel)
|
|
{
|
|
if (m_adjustAllChannel.ContainsKey(full_channel) == false)
|
|
{
|
|
m_adjustAllChannel.Add(full_channel, 1);
|
|
}
|
|
}
|
|
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddAdjustInstallReport(channel, full_channel, adid);
|
|
}
|
|
|
|
}
|
|
|
|
public string GetAdjustFullChannelByAdid(string adid)
|
|
{
|
|
if(string.IsNullOrEmpty(adid))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if(m_adjustCallback.ContainsKey(adid))
|
|
{
|
|
return m_adjustCallback[adid];
|
|
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void ReadMailStart(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
long opuid = long.Parse(splitStr[2].Split('=')[1]);
|
|
int mailType = int.Parse(splitStr[5].Split('=')[1]);
|
|
info.ReadMailStart(uid, mailType);
|
|
}
|
|
|
|
|
|
private void ReadFriendList(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
int friendCount = int.Parse(splitStr[4].Split('=')[1]);
|
|
int snsFriendCount = 0;
|
|
if (splitStr.Count() >= 6)
|
|
{
|
|
snsFriendCount = int.Parse(splitStr[5].Split('=')[1]);
|
|
}
|
|
|
|
int day = -1;
|
|
if(splitStr.Count() >= 7)
|
|
{
|
|
day = int.Parse(splitStr[6].Split('=')[1]);
|
|
}
|
|
|
|
info.AddFriendInfo(uid, friendCount, snsFriendCount, day);
|
|
}
|
|
|
|
private void ReadDayRetentionOptimizetion(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
int push1 = int.Parse(splitStr[2].Split('=')[1]);
|
|
int succ1 = int.Parse(splitStr[3].Split('=')[1]);
|
|
int push2 = int.Parse(splitStr[4].Split('=')[1]);
|
|
int succ2 = int.Parse(splitStr[5].Split('=')[1]);
|
|
int twice = int.Parse(splitStr[6].Split('=')[1]);
|
|
int total = int.Parse(splitStr[7].Split('=')[1]);
|
|
int totalsucc = int.Parse(splitStr[8].Split('=')[1]);
|
|
int day = 1;
|
|
if (splitStr.Count() >= 10)
|
|
{
|
|
day = int.Parse(splitStr[9].Split('=')[1]);
|
|
}
|
|
|
|
info.AddRetentionOptimizetion(day, push1, succ1, push2, succ2, twice, total, totalsucc);
|
|
}
|
|
|
|
private void ReadHorsePlay(DateTime dateTime, int uid, string[] splitStr)
|
|
{
|
|
BillInfoEveryDay info = GetBillInfoByDay(dateTime);
|
|
info.AddHorsePlay(uid);
|
|
}
|
|
}
|
|
}
|
|
|