| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
-
- using dodohold.core;
- using System.Text.Json;
- namespace molilian.core
- {
- public partial class ApiReportCore
- {
- public class RecordDTO
- {
- public int id { get; set; }
- public int data_type { get; set; }
- public DateTime report_date { get; set; }
- public int uclk_uv { get; set; }
- public int uclk_pv { get; set; }
- public int pay_ord_num { get; set; }
- public int order_ord_num { get; set; }
- public decimal pay_ord_amt { get; set; }
- public decimal pay_tk_disp_tfee { get; set; }
- public int pay_ord_uv { get; set; }
- public int eff_ord_num { get; set; }
- public decimal eff_ord_amt { get; set; }
- public decimal eff_tk_disp_tfee { get; set; }
- public int total_count { get; set; }
- public int abandon_count { get; set; }
- public int success_count { get; set; }
- }
- public static async Task<List<dynamic>> ReportDailysAsync(JsonElement form, string clientIp, bool debug = false)
- {
- List<dynamic> list = [];
- //那就是入参日期和type
- //我们给出指定日期的:点击 付款 有效付款 转链API调用
- //type可以不入参,留空就两个场景的数据都显示就行了
- //先只要成功的就行了,,到时候他们要明细再加就行了
- int data_type = form.Read("type", 0);
- var report_date = form.PathReadArray<string>("query_date[]");
- DateTime stime = DateTime.Now.AddDays(-1).Date, etime = stime;
- if (report_date.Count == 2)
- {
- if (DateTime.TryParse(report_date[0], out stime) && DateTime.TryParse(report_date[1], out etime))
- {
- stime = stime.Date;
- etime = etime.Date;
- }
- }
- switch (data_type)
- {
- case 1:
- case 2:
- {
- var data = await DataTypeReportDailysAsync(data_type, stime, etime, clientIp, debug);
- list.AddRange(data);
- }
- break;
- default:
- {
- int[] types = { 1, 2 };
- foreach (var type in types)
- {
- var data = await DataTypeReportDailysAsync(type, stime, etime, clientIp, debug);
- list.AddRange(data);
- }
- }
- break;
- }
- return list;
- }
- public static async Task<List<dynamic>> DataTypeReportDailysAsync(int data_type, DateTime stime, DateTime etime, string clientIp, bool debug = false)
- {
- string filter = "`is_show`=@is_show AND data_type=@data_type AND report_date>=@stime AND report_date<=@etime";
- string orderBy = "report_date DESC";
- var list = new DBContext.Table("api_call_report_dailys")
- .Where(filter, new { is_show = true, data_type, stime, etime })
- .Order(orderBy)
- .Select<RecordDTO>().ToList();
- if (!debug)
- {
- if (list.Count != 0)
- {
- var ids = list.Select(o => o.id).ToList();
- new DBContext.Table("api_call_report_dailys")
- .Add("read_num:", "read_num+1")
- .Where("id IN @ids", new { ids })
- .Update();
- }
- }
- List<dynamic> data = list.Select(e => new
- {
- report_date = e.report_date.ToString("yyyy-MM-dd"),
- type = e.data_type,
- e.uclk_uv,
- e.uclk_pv,
- e.pay_ord_num,
- e.order_ord_num,
- e.pay_ord_amt,
- e.pay_tk_disp_tfee,
- e.pay_ord_uv,
- e.eff_ord_num,
- e.eff_ord_amt,
- e.eff_tk_disp_tfee,
- e.total_count,
- //e.abandon_count,
- e.success_count
- }).ToList<dynamic>();
- return data;
- }
- }
- }
|