|
|
@@ -42,7 +42,7 @@ namespace molilian.api.Controllers
|
|
|
return new APIResult(new { data = new { success = false, msg = "更新失败,请检查输入的cookie" } });
|
|
|
}
|
|
|
|
|
|
- int result = 0;
|
|
|
+ int result;
|
|
|
switch (name)
|
|
|
{
|
|
|
case "enable_fake_click":
|
|
|
@@ -59,11 +59,8 @@ namespace molilian.api.Controllers
|
|
|
default:
|
|
|
return new APIResult(new { data = new { success = false, msg = "更新失败,未授权操作" } });
|
|
|
}
|
|
|
-
|
|
|
- TkPoolCore.Refresh();
|
|
|
-
|
|
|
bool success = result > 0;
|
|
|
-
|
|
|
+ if (success) await EndPointCore.NotifyReload(true);
|
|
|
return new APIResult(new
|
|
|
{
|
|
|
data = new { success, msg = success ? "更新成功" : "更新失败,请检查输入信息" },
|
|
|
@@ -188,7 +185,9 @@ namespace molilian.api.Controllers
|
|
|
var result = new DBContext.Table("v_tk_report_dailys")
|
|
|
.LeftJoin("daily_logs",
|
|
|
"B.log_date = A.report_date AND B.accountId=@dailys_accountId",
|
|
|
- "total_count, B.abandon_count, B.success_count, B.abandon_percentage, B.success_percentage")
|
|
|
+ "total_count, B.abandon_count, B.success_count, B.abandon_percentage, B.success_percentage," +
|
|
|
+ "B.parse_total_count, B.parse_abandon_count, B.parse_success_count, B.parse_abandon_percentage, B.parse_success_percentage," +
|
|
|
+ "B.coupon_total_count, B.coupon_abandon_count, B.coupon_success_count, B.coupon_abandon_percentage, B.coupon_success_percentage")
|
|
|
.Where(filter, new { dailys_accountId, dailys_accountName, stime, etime })
|
|
|
.Page(size, page)
|
|
|
.Order(orderBy)
|
|
|
@@ -198,27 +197,37 @@ namespace molilian.api.Controllers
|
|
|
foreach (var item in result.List)
|
|
|
{
|
|
|
if (item.total_count > 0) continue;
|
|
|
- item.total_count = RedisHelper.Get<int>($":total:all:{item.report_date:yyyyMMdd}");
|
|
|
+ item.total_count = TkLogCore.GetTotal($":total:all:{item.report_date:yyyyMMdd}");
|
|
|
if (item.total_count == 0) continue;
|
|
|
- item.success_count = RedisHelper.Get<int>($":total:all:success:{item.report_date:yyyyMMdd}");
|
|
|
- item.abandon_count = RedisHelper.Get<int>($":total:all:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
-
|
|
|
-
|
|
|
-#if DEBUG
|
|
|
- //if (item.report_date == DateTime.Now.Date)
|
|
|
- //{
|
|
|
- // RedisHelper.Set($":total:all:{item.report_date:yyyyMMdd}", item.total_count / 2);
|
|
|
- // RedisHelper.Set($":total:all:success:{item.report_date:yyyyMMdd}", item.total_count / 2);
|
|
|
- // RedisHelper.Set($":total:all:放弃转链:{item.report_date:yyyyMMdd}", item.abandon_count / 2);
|
|
|
- //}
|
|
|
-#endif
|
|
|
-
|
|
|
-
|
|
|
+ item.success_count = TkLogCore.GetTotal($":total:all:success:{item.report_date:yyyyMMdd}");
|
|
|
+ item.abandon_count = TkLogCore.GetTotal($":total:all:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
if (item.total_count > 0)
|
|
|
{
|
|
|
item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
|
|
|
item.abandon_percentage = $"{item.abandon_count / (double)item.total_count * 100:f2}%";
|
|
|
}
|
|
|
+
|
|
|
+ if (item.parse_total_count > 0) continue;
|
|
|
+ item.parse_total_count = TkLogCore.GetTotal($":parse_total:all:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.parse_total_count == 0) continue;
|
|
|
+ item.parse_success_count = TkLogCore.GetTotal($":parse_total:all:success:{item.report_date:yyyyMMdd}");
|
|
|
+ item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:all:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.parse_total_count > 0)
|
|
|
+ {
|
|
|
+ item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
|
|
|
+ item.parse_abandon_percentage = $"{item.parse_abandon_count / (double)item.parse_total_count * 100:f2}%";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.coupon_total_count > 0) continue;
|
|
|
+ item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:all:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.coupon_total_count == 0) continue;
|
|
|
+ item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:all:success:{item.report_date:yyyyMMdd}");
|
|
|
+ item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:all:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.coupon_total_count > 0)
|
|
|
+ {
|
|
|
+ item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
|
|
|
+ item.coupon_abandon_percentage = $"{item.coupon_abandon_count / (double)item.coupon_total_count * 100:f2}%";
|
|
|
+ }
|
|
|
}
|
|
|
return new APIResult(new { data = result });
|
|
|
}
|
|
|
@@ -267,7 +276,9 @@ namespace molilian.api.Controllers
|
|
|
var result = new DBContext.Table("tk_report")
|
|
|
.LeftJoin("daily_logs",
|
|
|
"B.log_date = A.report_date AND B.accountId=A.accountId",
|
|
|
- "total_count, B.abandon_count, B.success_count, B.abandon_percentage, B.success_percentage")
|
|
|
+ "total_count, B.abandon_count, B.success_count, B.abandon_percentage, B.success_percentage," +
|
|
|
+ "B.parse_total_count, B.parse_abandon_count, B.parse_success_count, B.parse_abandon_percentage, B.parse_success_percentage," +
|
|
|
+ "B.coupon_total_count, B.coupon_abandon_count, B.coupon_success_count, B.coupon_abandon_percentage, B.coupon_success_percentage")
|
|
|
.Where(filter, new { accountId, stime, etime })
|
|
|
.Page(size, page)
|
|
|
.Order(orderBy)
|
|
|
@@ -279,33 +290,56 @@ namespace molilian.api.Controllers
|
|
|
{
|
|
|
//var tk = TkPoolCore.GetOne(item.accountId);
|
|
|
//if (tk != null) item.accountName = tk.company;
|
|
|
-
|
|
|
- if (item.total_count > 0) continue;
|
|
|
-
|
|
|
string accountName = $"{TkChannelEnum.tb}_{item.accountId}";
|
|
|
|
|
|
- item.total_count = RedisHelper.Get<int>($":total:{accountName}:{item.report_date:yyyyMMdd}");
|
|
|
if (item.total_count == 0)
|
|
|
{
|
|
|
- //todo 过度用, 0613 跑两天就可以删掉
|
|
|
- accountName = item.accountName;
|
|
|
- item.total_count = RedisHelper.Get<int>($":total:{accountName}:{item.report_date:yyyyMMdd}");
|
|
|
+ item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.total_count == 0)
|
|
|
+ {
|
|
|
+ //todo 过度用, 0613 跑两天就可以删掉
|
|
|
+ accountName = item.accountName;
|
|
|
+ item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMdd}");
|
|
|
+ }
|
|
|
+ if (item.total_count == 0) continue;
|
|
|
+ item.success_count = TkLogCore.GetTotal($":total:{accountName}:success:{item.report_date:yyyyMMdd}");
|
|
|
+ item.abandon_count = TkLogCore.GetTotal($":total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
+
|
|
|
+ if (item.total_count > 0)
|
|
|
+ {
|
|
|
+ item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
|
|
|
+ item.abandon_percentage = $"{item.abandon_count / (double)item.total_count * 100:f2}%";
|
|
|
+ }
|
|
|
}
|
|
|
- if (item.total_count == 0) continue;
|
|
|
- item.success_count = RedisHelper.Get<int>($":total:{accountName}:success:{item.report_date:yyyyMMdd}");
|
|
|
- item.abandon_count = RedisHelper.Get<int>($":total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
|
|
|
- if (item.total_count > 0)
|
|
|
+ if (item.parse_total_count == 0)
|
|
|
{
|
|
|
- item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
|
|
|
- item.abandon_percentage = $"{item.abandon_count / (double)item.total_count * 100:f2}%";
|
|
|
+ item.parse_total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.parse_total_count == 0) continue;
|
|
|
+ item.parse_success_count = TkLogCore.GetTotal($":parse_total:{accountName}:success:{item.report_date:yyyyMMdd}");
|
|
|
+ item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
+
|
|
|
+ if (item.parse_total_count > 0)
|
|
|
+ {
|
|
|
+ item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
|
|
|
+ item.parse_abandon_percentage = $"{item.parse_abandon_count / (double)item.parse_total_count * 100:f2}%";
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- //public int api_req_num { get; set; } = 0;
|
|
|
- //public int abandon_num { get; set; } = 0;
|
|
|
- //public int success_num { get; set; } = 0;
|
|
|
+ if (item.coupon_total_count == 0)
|
|
|
+ {
|
|
|
+ item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:{accountName}:{item.report_date:yyyyMMdd}");
|
|
|
+ if (item.coupon_total_count == 0) continue;
|
|
|
+ item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:{accountName}:success:{item.report_date:yyyyMMdd}");
|
|
|
+ item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:{accountName}:放弃转链:{item.report_date:yyyyMMdd}");
|
|
|
+
|
|
|
+ if (item.coupon_total_count > 0)
|
|
|
+ {
|
|
|
+ item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
|
|
|
+ item.coupon_abandon_percentage = $"{item.coupon_abandon_count / (double)item.coupon_total_count * 100:f2}%";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return new APIResult(new { data = result });
|
|
|
}
|
|
|
|
|
|
@@ -360,24 +394,54 @@ namespace molilian.api.Controllers
|
|
|
|
|
|
foreach (var item in result.List)
|
|
|
{
|
|
|
- if (item.total_count > 0) continue;
|
|
|
-
|
|
|
string accountName = $"{TkChannelEnum.tb}_{item.accountId}";
|
|
|
- item.total_count = RedisHelper.Get<int>($":total:{accountName}:{item.report_date:yyyyMMddHH}");
|
|
|
if (item.total_count == 0)
|
|
|
{
|
|
|
- //todo 过度用, 0613 跑两天就可以删掉
|
|
|
- accountName = item.accountName;
|
|
|
- item.total_count = RedisHelper.Get<int>($":total:{accountName}:{item.report_date:yyyyMMddHH}");
|
|
|
+ item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMddHH}");
|
|
|
+ if (item.total_count == 0)
|
|
|
+ {
|
|
|
+ //todo 过度用, 0613 跑两天就可以删掉
|
|
|
+ accountName = item.accountName;
|
|
|
+ item.total_count = TkLogCore.GetTotal($":total:{accountName}:{item.report_date:yyyyMMddHH}");
|
|
|
+ }
|
|
|
+ if (item.total_count == 0) continue;
|
|
|
+ item.success_count = TkLogCore.GetTotal($":total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
|
|
|
+ item.abandon_count = TkLogCore.GetTotal($":total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
|
|
|
+
|
|
|
+ if (item.total_count > 0)
|
|
|
+ {
|
|
|
+ item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
|
|
|
+ item.abandon_percentage = $"{item.abandon_count / (double)item.total_count * 100:f2}%";
|
|
|
+ }
|
|
|
}
|
|
|
- if (item.total_count == 0) continue;
|
|
|
- item.success_count = RedisHelper.Get<int>($":total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
|
|
|
- item.abandon_count = RedisHelper.Get<int>($":total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
|
|
|
|
|
|
- if (item.total_count > 0)
|
|
|
+ if (item.parse_total_count == 0)
|
|
|
{
|
|
|
- item.success_percentage = $"{item.success_count / (double)item.total_count * 100:f2}%";
|
|
|
- item.abandon_percentage = $"{item.abandon_count / (double)item.total_count * 100:f2}%";
|
|
|
+ item.parse_total_count = TkLogCore.GetTotal($":parse_total:{accountName}:{item.report_date:yyyyMMddHH}");
|
|
|
+ if (item.parse_total_count == 0) continue;
|
|
|
+ item.parse_success_count = TkLogCore.GetTotal($":parse_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
|
|
|
+ item.parse_abandon_count = TkLogCore.GetTotal($":parse_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
|
|
|
+
|
|
|
+ if (item.parse_total_count > 0)
|
|
|
+ {
|
|
|
+ item.parse_success_percentage = $"{item.parse_success_count / (double)item.parse_total_count * 100:f2}%";
|
|
|
+ item.parse_abandon_percentage = $"{item.parse_abandon_count / (double)item.parse_total_count * 100:f2}%";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.coupon_total_count == 0)
|
|
|
+ {
|
|
|
+ item.coupon_total_count = TkLogCore.GetTotal($":coupon_total:{accountName}:{item.report_date:yyyyMMddHH}");
|
|
|
+
|
|
|
+ if (item.coupon_total_count == 0) continue;
|
|
|
+ item.coupon_success_count = TkLogCore.GetTotal($":coupon_total:{item.accountName}:success:{item.report_date:yyyyMMddHH}");
|
|
|
+ item.coupon_abandon_count = TkLogCore.GetTotal($":coupon_total:{item.accountName}:放弃转链:{item.report_date:yyyyMMddHH}");
|
|
|
+
|
|
|
+ if (item.coupon_total_count > 0)
|
|
|
+ {
|
|
|
+ item.coupon_success_percentage = $"{item.coupon_success_count / (double)item.coupon_total_count * 100:f2}%";
|
|
|
+ item.coupon_abandon_percentage = $"{item.coupon_abandon_count / (double)item.coupon_total_count * 100:f2}%";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return new APIResult(new { data = result });
|
|
|
@@ -393,6 +457,7 @@ namespace molilian.api.Controllers
|
|
|
var report_date = form.PathReadArray<string>("query_date[]");
|
|
|
var accountName = form.Read("accountName", string.Empty);
|
|
|
var isHourtrend = form.Read<bool>("isLeaf", false);
|
|
|
+ var total_key = form.Read("total_key", "total");
|
|
|
|
|
|
if (string.IsNullOrEmpty(accountName)) accountName = "all";
|
|
|
|
|
|
@@ -402,39 +467,33 @@ namespace molilian.api.Controllers
|
|
|
string _report_date = stime.ToString("yyyyMMdd");
|
|
|
if (isHourtrend) _report_date = stime.ToString("yyyyMMddHH");
|
|
|
|
|
|
- string cacheKey = $":total:{accountName}:{_report_date}";
|
|
|
- double total = RedisHelper.Get<int>(cacheKey);
|
|
|
+ string cacheKey = $":{total_key}:{accountName}:{_report_date}";
|
|
|
+ double total = TkLogCore.GetTotal(cacheKey);
|
|
|
if (total > 0)
|
|
|
{
|
|
|
- string[] keys = new string[] { "success" };
|
|
|
- cacheKey = $":total:{accountName}:message:{_report_date}";
|
|
|
- string[] message_keys = RedisHelper.SMembers(cacheKey);
|
|
|
+ string[] keys = ["success"];
|
|
|
+ cacheKey = $":{total_key}:{accountName}:message:{_report_date}";
|
|
|
+ string[] message_keys = TkLogCore.GetTotalKeys(cacheKey);
|
|
|
|
|
|
string[] combinedKeys = keys.Union(message_keys).ToArray();
|
|
|
|
|
|
foreach (var keyname in combinedKeys)
|
|
|
{
|
|
|
- cacheKey = $":total:{accountName}:{keyname}:{_report_date}";
|
|
|
- int value = RedisHelper.Get<int>(cacheKey);
|
|
|
+ cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
|
|
|
+ int value = TkLogCore.GetTotal(cacheKey);
|
|
|
if (value == 0) continue;
|
|
|
-#if DEBUG
|
|
|
- //RedisHelper.Set(cacheKey, value / 2);
|
|
|
-#endif
|
|
|
result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
|
|
|
}
|
|
|
result = result.OrderByDescending(item => item.value).ToList();
|
|
|
|
|
|
- cacheKey = $":total:{accountName}:reason:{_report_date}";
|
|
|
- string[] reason_keys = RedisHelper.SMembers(cacheKey);
|
|
|
+ cacheKey = $":{total_key}:{accountName}:reason:{_report_date}";
|
|
|
+ string[] reason_keys = TkLogCore.GetTotalKeys(cacheKey);
|
|
|
|
|
|
foreach (var keyname in reason_keys)
|
|
|
{
|
|
|
- cacheKey = $":total:{accountName}:{keyname}:{_report_date}";
|
|
|
- int value = RedisHelper.Get<int>(cacheKey);
|
|
|
+ cacheKey = $":{total_key}:{accountName}:{keyname}:{_report_date}";
|
|
|
+ int value = TkLogCore.GetTotal(cacheKey);
|
|
|
if (value == 0) continue;
|
|
|
-#if DEBUG
|
|
|
- //RedisHelper.Set(cacheKey, value / 2);
|
|
|
-#endif
|
|
|
reason_result.Add(new { name = keyname, value, increases = Math.Round(value / total * 100, 2) });
|
|
|
}
|
|
|
reason_result = reason_result.OrderByDescending(item => item.value).ToList();
|