增加 统计新接口
增加每日02时自动更新统计
This commit is contained in:
1 parent
3dac74c6c2
commit
22c7ecd4d8
24 files changed
+1895
-255
No files matched your search
+129
-28
@@ -1,8 +1,9 @@
|
||||
using Autofac;
|
||||
using Autofac;
|
||||
using Autofac.Integration.WebApi;
|
||||
using Autofac.Integration.WebApi;
|
||||
using KJD_Web;
|
||||
using KJD_Web;
|
||||
using KJD_Web.Requests.Shops;
|
||||
using KJD_Web.Services.Shops;
|
||||
using KJD_Web.Services.Users;
|
||||
using Newtonsoft.Json;
|
||||
@@ -14,6 +15,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
@@ -44,36 +46,135 @@ internal class ShopTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAm()
|
||||
//[TestCase(1960967267443631281)]
|
||||
//[TestCase(1960967267443631212)]
|
||||
//[TestCase(1960967267443631213)]
|
||||
//[TestCase(1960967267443631215)]
|
||||
//[TestCase(1960967267443631216)]
|
||||
//[TestCase(1960967267443631218)]
|
||||
//[TestCase(1960967267443631219)]
|
||||
//[TestCase(1960967267443631221)]
|
||||
//[TestCase(1960967267443631222)]
|
||||
//[TestCase(1960967267443631223)]
|
||||
//[TestCase(1960967267443631224)]
|
||||
//[TestCase(1960967267443631226)]
|
||||
//[TestCase(1960967267443631227)]
|
||||
//[TestCase(1960967267443631228)]
|
||||
//[TestCase(1960967267443630057)]
|
||||
//[TestCase(1960967267443629984)]
|
||||
//[TestCase(1960967267443629858)]
|
||||
[TestCase(1960967267443629855)]
|
||||
//[TestCase(1960967267443629809)]
|
||||
//[TestCase(1960967267443629737)]
|
||||
//[TestCase(1960967267443627649)]
|
||||
//[TestCase(1960967267443627648)]
|
||||
public void TestAm(long id)
|
||||
{
|
||||
List<long> ShopIds = new List<long>
|
||||
{
|
||||
1960967267443631281,
|
||||
1960967267443631212,
|
||||
1960967267443631213,
|
||||
1960967267443631215,
|
||||
1960967267443631216,
|
||||
1960967267443631218,
|
||||
1960967267443631219,
|
||||
1960967267443631221,
|
||||
1960967267443631222,
|
||||
1960967267443631223,
|
||||
1960967267443631224,
|
||||
1960967267443631226,
|
||||
1960967267443631227,
|
||||
1960967267443631228,
|
||||
1960967267443630057,
|
||||
1960967267443629984,
|
||||
1960967267443629858,
|
||||
1960967267443629855,
|
||||
1960967267443629809,
|
||||
1960967267443629737,
|
||||
1960967267443627649,
|
||||
1960967267443627648
|
||||
};
|
||||
// List<long> ShopIds = new List<long>
|
||||
// {
|
||||
//1960967267443631281,
|
||||
//1960967267443631212,
|
||||
//1960967267443631213,
|
||||
//1960967267443631215,
|
||||
//1960967267443631216,
|
||||
//1960967267443631218,
|
||||
//1960967267443631219,
|
||||
//1960967267443631221,
|
||||
//1960967267443631222,
|
||||
//1960967267443631223,
|
||||
//1960967267443631224,
|
||||
//1960967267443631226,
|
||||
//1960967267443631227,
|
||||
//1960967267443631228,
|
||||
//1960967267443630057,
|
||||
//1960967267443629984,
|
||||
//1960967267443629858,
|
||||
//1960967267443629855,
|
||||
//1960967267443629809,
|
||||
//1960967267443629737,
|
||||
//1960967267443627649,
|
||||
//1960967267443627648
|
||||
// };
|
||||
|
||||
|
||||
var shopService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||
shopService.GetShopOrderAmountRange(ShopIds, DateTime.Now.AddMonths(-1), DateTime.Now);
|
||||
//shopService.GetShopOrderAmountRange(id, DateTime.Now.AddDays(-10));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetShopSalesOrderTest()
|
||||
{
|
||||
var shopService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||
DateTime startDate = DateTime.Parse("2026/08/01");
|
||||
DateTime endDate = DateTime.Parse("2026/10/07");
|
||||
DateTime date = startDate;
|
||||
while (date <= endDate)
|
||||
{
|
||||
Console.WriteLine($"开始:{date.ToLongDateString()}");
|
||||
try
|
||||
{
|
||||
shopService.ShopDailyStats(date);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"错误:{date.ToLongDateString()}");
|
||||
}
|
||||
date = date.AddDays(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
[Test]
|
||||
public void GetBuyerDailyStatsTest()
|
||||
{
|
||||
var shopService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||
shopService.BuyerDailyStats(DateTime.Parse("2026/10/02"), [1960967267443620449]);
|
||||
}
|
||||
[Test]
|
||||
public void UpdateStatsTest()
|
||||
{
|
||||
var shopService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||
shopService.UpdateStats(DateTime.Now.AddDays(-1).Date);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetShopStatsTest()
|
||||
{
|
||||
var shopService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||
var data = shopService.GetShopStats(DateTime.Parse("2026/10/01"), DateTime.Parse("2026/10/07"), "18990991234", null, ShopStatsGroupType.Day);
|
||||
var sb = new System.Text.StringBuilder();
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
sb.AppendLine("没有统计数据");
|
||||
}
|
||||
else
|
||||
{
|
||||
Func<long, string> yuan = fen => (fen / 100m).ToString("N2");
|
||||
|
||||
foreach (var shopId in data.Keys)
|
||||
{
|
||||
sb.AppendLine("==================== 商铺 " + shopId + " ====================");
|
||||
foreach (var r in data[shopId])
|
||||
{
|
||||
sb.AppendLine("[日期] " + r.StatDate.ToString("yyyy-MM-dd"));
|
||||
sb.AppendLine("[销售] 订单数: " + r.OrderCount
|
||||
+ " | 销售额: " + yuan(r.SalesAmount)
|
||||
+ " | 利润: " + yuan(r.ProfitAmount)
|
||||
+ " | 佣金: " + yuan(r.PlatformFee));
|
||||
sb.AppendLine("[售后] 退款单: " + r.RefundOrderCount
|
||||
+ " | 已退款: " + yuan(r.RefundDone)
|
||||
+ " | 退款中: " + yuan(r.RefundPending));
|
||||
sb.AppendLine("[买手] 采购单: " + r.PurchaseCount
|
||||
+ " | 采购额: " + yuan(r.TotalPurchase)
|
||||
+ " | 已退: " + yuan(r.DoneRefund)
|
||||
+ " | 未退: " + yuan(r.PendingRefund)
|
||||
+ " | 拒绝: " + yuan(r.RejectedRefund)
|
||||
+ " | 买手退款合计: " + yuan(r.TotalRefund));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine(sb.ToString());
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ internal class UserTest
|
||||
public void GetUserAmountSummate()
|
||||
{
|
||||
var userService = _container.Resolve<UserService>();
|
||||
var data = userService.GetUserAmountSummary("15395107196");
|
||||
var data = userService.GetUserAmountSummary("17734871710");
|
||||
Console.WriteLine(JsonConvert.SerializeObject(data));
|
||||
}
|
||||
//[Test]
|
||||
|
||||
Reference in new issue
Block a user