|
|
@@ -1,4 +1,5 @@
|
|
|
using dodohold.core;
|
|
|
+using Google.Protobuf.WellKnownTypes;
|
|
|
using System.Text.Json;
|
|
|
using TencentCloud.Cdn.V20180606.Models;
|
|
|
using TencentCloud.Tse.V20201207.Models;
|
|
|
@@ -251,7 +252,7 @@ namespace molilian.core
|
|
|
//tableName2
|
|
|
}
|
|
|
|
|
|
- public static DBContext.Table FillLinkTypeData(DBContext.Table update, int data_type, DateTime report_date)
|
|
|
+ public static DBContext.Table FillLinkTypeData(DBContext.Table update, int data_type, DateTime report_date, TkChannelEnum channel)
|
|
|
{
|
|
|
long req_other_aff_num = 0;//1
|
|
|
long req_goods_num = 0;//2
|
|
|
@@ -264,50 +265,55 @@ namespace molilian.core
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- string tableName = $"tk_parse_logs_{report_date:yyyyMMdd}";
|
|
|
-
|
|
|
- string exist_sql = @$"SELECT IF( EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_name = '{tableName}'), 1, 0) AS table_exists;";
|
|
|
-
|
|
|
- int exist_table = DBContext.ExecuteScalar<int>(exist_sql);
|
|
|
- if (exist_table == 1)
|
|
|
+ switch (channel)
|
|
|
{
|
|
|
- var linkTypeTotal = new DBContext.Table(tableName)
|
|
|
- .Fields("linkType, count(*) AS total")
|
|
|
- .GroupBy("linkType")
|
|
|
- .Select<dynamic>();
|
|
|
+ case TkChannelEnum.tb:
|
|
|
+ string tableName = $"tk_parse_logs_{report_date:yyyyMMdd}";
|
|
|
+ string exist_sql = @$"SELECT IF( EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_name = '{tableName}'), 1, 0) AS table_exists;";
|
|
|
|
|
|
- foreach (var t in linkTypeTotal)
|
|
|
- {
|
|
|
- int linkType = t.linkType;
|
|
|
- long total = t.total;
|
|
|
- switch (linkType)
|
|
|
+ int exist_table = DBContext.ExecuteScalar<int>(exist_sql);
|
|
|
+ if (exist_table == 1)
|
|
|
{
|
|
|
- case 1: req_other_aff_num = total; break;
|
|
|
- case 2: req_goods_num = total; break;
|
|
|
- case 3: req_live_num = total; break;
|
|
|
- case 4: req_video_num = total; break;
|
|
|
- case 5: req_shop_num = total; break;
|
|
|
- case 6: req_base_num = total; break;
|
|
|
- case 7: req_note_num = total; break;
|
|
|
+ var linkTypeTotal = new DBContext.Table(tableName)
|
|
|
+ .Fields("linkType, count(*) AS total")
|
|
|
+ .GroupBy("linkType")
|
|
|
+ .Select<dynamic>();
|
|
|
+
|
|
|
+ foreach (var t in linkTypeTotal)
|
|
|
+ {
|
|
|
+ int linkType = t.linkType;
|
|
|
+ long total = t.total;
|
|
|
+ switch (linkType)
|
|
|
+ {
|
|
|
+ case 1: req_other_aff_num = total; break;
|
|
|
+ case 2: req_goods_num = total; break;
|
|
|
+ case 3: req_live_num = total; break;
|
|
|
+ case 4: req_video_num = total; break;
|
|
|
+ case 5: req_shop_num = total; break;
|
|
|
+ case 6: req_base_num = total; break;
|
|
|
+ case 7: req_note_num = total; break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- string total_key = data_type switch
|
|
|
- {
|
|
|
- 1 => "parse_total",
|
|
|
- 2 or _ => "coupon_total",
|
|
|
- };
|
|
|
+ string total_key = data_type switch
|
|
|
+ {
|
|
|
+ 1 => "parse_total",
|
|
|
+ 2 or _ => "coupon_total",
|
|
|
+ };
|
|
|
|
|
|
- string[] deeplink_keys = ["home", "success", "fail"];
|
|
|
- string accountName = "all";
|
|
|
- foreach (var keyname in deeplink_keys)
|
|
|
- {
|
|
|
- string cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date:yyyyMMdd}";
|
|
|
- int value = TkLogCore.GetTotal(cacheKey);
|
|
|
- if (value == 0) continue;
|
|
|
- resp_deeplink_num += value;
|
|
|
+ string[] deeplink_keys = ["home", "success", "fail"];
|
|
|
+ string accountName = "all";
|
|
|
+ foreach (var keyname in deeplink_keys)
|
|
|
+ {
|
|
|
+ string cacheKey = $":{total_key}:dp_{keyname}:{accountName}:{report_date:yyyyMMdd}";
|
|
|
+ int value = TkLogCore.GetTotal(cacheKey);
|
|
|
+ if (value == 0) continue;
|
|
|
+ resp_deeplink_num += value;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
@@ -412,9 +418,9 @@ namespace molilian.core
|
|
|
.Add("pay_ord_amt", exist_report_dailys.cosPrice) //付款金额
|
|
|
.Add("pay_ord_num", exist_report_dailys.orderNum)
|
|
|
.Add("order_ord_num", 0)
|
|
|
- .Add("eff_ord_amt", exist_report_dailys.finishCosPrice) //有效订单金额 有效订单金额
|
|
|
- .Add("eff_ord_num", exist_report_dailys.finishOrderNum) //有效付款笔数
|
|
|
- .Add("eff_tk_disp_tfee", exist_report_dailys.finishCosFee); //有效付款预估收入 预估收入
|
|
|
+ .Add("eff_ord_amt", exist_report_dailys.cosPrice) //有效订单金额 有效订单金额
|
|
|
+ .Add("eff_ord_num", exist_report_dailys.orderNum) //有效付款笔数
|
|
|
+ .Add("eff_tk_disp_tfee", exist_report_dailys.cosFee); //有效付款预估收入 预估收入
|
|
|
}
|
|
|
|
|
|
var exist = new DBContext.Table(center_conn, "center_daily_logs")
|
|
|
@@ -435,16 +441,22 @@ namespace molilian.core
|
|
|
|
|
|
if (exist_report_dailys != null)
|
|
|
{
|
|
|
+ decimal feeAmount = Math.Round(0.01m * (decimal)exist_report_dailys.feeAmount, 2);
|
|
|
+ decimal orderAmount = Math.Round(0.01m * (decimal)exist_report_dailys.orderAmount, 2);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
update.Add("uclk_uv", 0)
|
|
|
.Add("pay_ord_uv", 0)//付款人数
|
|
|
.Add("uclk_pv", 0) //点击量 点击次数
|
|
|
- .Add("pay_tk_disp_tfee", exist_report_dailys.feeAmount)//预估收入 付款预估收入
|
|
|
- .Add("pay_ord_amt", exist_report_dailys.orderAmount) //付款金额
|
|
|
+ .Add("pay_tk_disp_tfee", feeAmount)//预估收入 付款预估收入
|
|
|
+ .Add("pay_ord_amt", orderAmount) //付款金额
|
|
|
.Add("pay_ord_num", exist_report_dailys.orderNum)
|
|
|
.Add("order_ord_num", 0)
|
|
|
- .Add("eff_ord_amt", exist_report_dailys.orderAmount) //有效订单金额 有效订单金额
|
|
|
+ .Add("eff_ord_amt", orderAmount) //有效订单金额 有效订单金额
|
|
|
.Add("eff_ord_num", exist_report_dailys.orderNum) //有效付款笔数
|
|
|
- .Add("eff_tk_disp_tfee", exist_report_dailys.feeAmount); //有效付款预估收入 预估收入
|
|
|
+ .Add("eff_tk_disp_tfee", feeAmount); //有效付款预估收入 预估收入
|
|
|
}
|
|
|
|
|
|
var exist = new DBContext.Table(center_conn, "center_daily_logs")
|
|
|
@@ -463,7 +475,7 @@ namespace molilian.core
|
|
|
if (data_type == 1)
|
|
|
{
|
|
|
//todo 只有转链需要处理,优惠券和京东(未上线)暂不处理
|
|
|
- update = FillLinkTypeData(update, data_type, log_date);
|
|
|
+ update = FillLinkTypeData(update, data_type, log_date, channel);
|
|
|
}
|
|
|
if (record == null)
|
|
|
{
|