diff --git a/BBWY.Server.Business/Extensions/OrderCostExtension.cs b/BBWY.Server.Business/Extensions/OrderCostExtension.cs index 96ce4353..be64c941 100644 --- a/BBWY.Server.Business/Extensions/OrderCostExtension.cs +++ b/BBWY.Server.Business/Extensions/OrderCostExtension.cs @@ -107,4 +107,4 @@ namespace BBWY.Server.Business.Extensions ocd.TotalCost - ocd.DeliveryExpressFreight - koudian; } } -} +} \ No newline at end of file diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs index bd2edaa4..79677e74 100644 --- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs +++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs @@ -285,8 +285,9 @@ namespace BBWY.Server.Business var totalActualAmount = currentSkuOrderSkuList.Sum(osku => { - var pingtaibutie = (osku.PingTaiChengDanYouHuiQuan ?? 0M) + (osku.SuperRedEnvelope ?? 0M) + (osku.XianPinLeiDongQuan ?? 0M) + (osku.JingDou ?? 0M) + (osku.DongQuan ?? 0M); - return (((osku.ShouldPay ?? 0M) + (osku.Balance ?? 0M) - (osku.VenderFee ?? 0M) + pingtaibutie) * osku.ItemTotal) ?? 0M; + //var pingtaibutie = (osku.PingTaiChengDanYouHuiQuan ?? 0M) + (osku.SuperRedEnvelope ?? 0M) + (osku.XianPinLeiDongQuan ?? 0M) + (osku.JingDou ?? 0M) + (osku.DongQuan ?? 0M); + //return (((osku.ShouldPay ?? 0M) + (osku.Balance ?? 0M) - (osku.VenderFee ?? 0M) + pingtaibutie) * osku.ItemTotal) ?? 0M; + return (((osku.ActualAmount ?? 0M) - (osku.VenderFee ?? 0M)) * osku.ItemTotal) ?? 0M; }); var totalProfit = currentSpuCostDetailList.Sum(ocd => ocd.SkuGrossProfit); diff --git a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs index 27837954..b474d384 100644 --- a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs +++ b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs @@ -583,6 +583,14 @@ namespace BBWY.Server.Business XianPinLeiJingQuan = oskuCF?.XianPinLeiJingQuan ?? 0M, ZhiFuYingXiaoYouHui = oskuCF?.ZhiFuYingXiaoYouHui ?? 0M }; + + osku.ActualAmount = osku.ShouldPay + + osku.Balance + + osku.PingTaiChengDanYouHuiQuan + + osku.SuperRedEnvelope + + osku.XianPinLeiDongQuan + + osku.JingDou + + osku.DongQuan; insertOrderSkuList.Add(osku); //} //CumulativeSkuDailySalesDetail(skuDailySalesDetailDictionary, dbOrder.StartTime.Value, shopId, skuId, wareId, jdPrice, itemTotal); @@ -624,6 +632,14 @@ namespace BBWY.Server.Business var isDetailChanged = (dbOsku.ShouldPay == 0 || dbOsku.ShouldPay == null) && oskuCF != null && oskuCF.ShouldPay != 0; if (dbOsku.ProductId != wareId || isDetailChanged) { + var skuActualAmount = oskuCF.ShouldPay + + oskuCF.Balance + + oskuCF.PingTaiChengDanYouHuiQuan + + oskuCF.SuperRedEnvelope + + oskuCF.XianPinLeiDongQuan + + oskuCF.JingDou + + oskuCF.DongQuan; + var update = fsql.Update(dbOsku.Id) .SetIf(dbOsku.ProductId != wareId, osku => osku.ProductId, wareId) .SetIf(isDetailChanged, osku => osku.ShouldPay, oskuCF?.ShouldPay) @@ -652,7 +668,8 @@ namespace BBWY.Server.Business .SetIf(isDetailChanged, osku => osku.VenderFee, oskuCF?.VenderFee) .SetIf(isDetailChanged, osku => osku.XianPinLeiDongQuan, oskuCF?.XianPinLeiDongQuan) .SetIf(isDetailChanged, osku => osku.XianPinLeiJingQuan, oskuCF?.XianPinLeiJingQuan) - .SetIf(isDetailChanged, osku => osku.ZhiFuYingXiaoYouHui, oskuCF?.ZhiFuYingXiaoYouHui); + .SetIf(isDetailChanged, osku => osku.ZhiFuYingXiaoYouHui, oskuCF?.ZhiFuYingXiaoYouHui) + .SetIf(isDetailChanged, osku => osku.ActualAmount, skuActualAmount); ; updateOrderSkuDictionary.Add(skuUpdateKey, update); } diff --git a/BBWY.Server.Model/Db/Order/OrderSku.cs b/BBWY.Server.Model/Db/Order/OrderSku.cs index a93694c1..1a71d286 100644 --- a/BBWY.Server.Model/Db/Order/OrderSku.cs +++ b/BBWY.Server.Model/Db/Order/OrderSku.cs @@ -236,6 +236,12 @@ namespace BBWY.Server.Model.Db [Column(DbType = "decimal(18,2)")] public decimal? ZhiFuYingXiaoYouHui { get; set; } = 0.00M; + /// + /// 实收金额,计价单位:元 + /// + [Column(DbType = "decimal(18,2)")] + public decimal? ActualAmount { get; set; } = 0.00M; + } } diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index 624d20ea..af0464aa 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -1,6 +1,7 @@ using BBWY._1688SDK.entity.Order; using BBWY.Common.Models; using BBWY.Server.Business; +using BBWY.Server.Model.Db; using com.alibaba.openapi.client; using com.alibaba.openapi.client.policy; using Jd.Api; @@ -18,6 +19,7 @@ using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Security.Policy; using System.Text; +using System.Threading; namespace BBWY.Test { @@ -50,8 +52,8 @@ namespace BBWY.Test var appkey = "E1AA9247D5583A6D87449CE6AB290185"; var appSecret = "e479558ddd9e40f8929cfc00c6cbbc9c"; - // var appkey = "120EA9EC65AB017567D78CC1139EEEA5"; - // var appSecret = "8a42bc2301e8439b896e99f5475e0a9b"; + // var appkey = "120EA9EC65AB017567D78CC1139EEEA5"; + // var appSecret = "8a42bc2301e8439b896e99f5475e0a9b"; ////0e61c4a8ec3e4df4b5836e10884db9220yth 齐盛 var token = "8404898e42d04358879785f0e576019cwndg"; //爱维亲玩具专营店 @@ -64,15 +66,54 @@ namespace BBWY.Test //var token = "44c19a1c1fbd4641957e6e8985ed1358jmtl"; //森王玩具 //var token = "4a0ddc095e054c7aa90adcaccb14f83cwzgr"; //可比车品 //var token = "50a4c0f5c55848b5a8a715709e8d6fe0jntb"; //卿卿玩具专营店 + var fsql = new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy_test;charset=utf8;sslmode=none;").Build(); + var sercvice = new ServiceCollection(); + sercvice.AddHttpClient(); + var servicePriovder = sercvice.BuildServiceProvider(); + var restApiService = new Common.Http.RestApiService(servicePriovder.GetRequiredService()); - + var files = System.IO.Directory.GetFiles(@"C:\Users\pengcong001\Desktop\bbwylog"); + var startTime = DateTime.Parse("2023-10-16"); + var endTime = DateTime.Parse("2023-11-22"); + foreach (var file in files) + { + var fileName = file.Substring(file.LastIndexOf("\\") + 1); + Console.WriteLine(file); + + var lines = System.IO.File.ReadAllLines(file); + var priceModifyMsgList = lines.Where(l => !string.IsNullOrEmpty(l) && l.Contains("ORDER_BUYER_VIEW_ORDER_PRICE_MODIFY")).ToList(); + var orderIndex = 0; + foreach (var priceModifyMsg in priceModifyMsgList) + { + orderIndex++; + var poId = JObject.Parse(priceModifyMsg)["data"]["orderId"].ToString(); + var orderDropshipping = fsql.Select().Where(o => o.PurchaseOrderId == poId).ToOne(); + if (orderDropshipping == null) + continue; + var orderId = orderDropshipping.OrderId; + var shopId = orderDropshipping.ShopId; + + var result = restApiService.SendRequest("http://bbwytest.qiyue666.com/", "api/test/RepairSkuDetailAndSkuGriooProfit", new + { + StartTime = startTime, + EndTime = endTime, + ShopId = shopId, + OrderId = orderId, + OrderIdList = new List() + }, null, HttpMethod.Post); + Console.WriteLine($"{DateTime.Now} {fileName} {orderIndex}/{priceModifyMsgList.Count()} HttpResult{result.StatusCode}"); + Thread.Sleep(2000); + } + try + { + System.IO.File.Delete(file); + } + catch { } + } - var list1 = new List() { 10079228186359, 10082297500241, 10082297500240, 10080447316056, 10079220447523, 10079201912937, 10079200088836, 10079200088833, 10079200088835, 10079200088832, 10079200088837, 10079194625126, 10083879389389, 10079200088834, 10083879389388, 10079124348172, 10079124348173, 10079144365199, 10079144365198, 10079115478818, 10079115478817, 10079115478819, 10079139644032, 10079139644033, 10079080505031, 10079080505032, 10079075020922, 10079075020921, 10079179600978, 10079178664215, 10079140753258, 10079123319498, 10079123319497, 10079140753259, 10079139644034, 10079075020917, 10079075020916, 10079075020919, 10079075020915, 10079075020920, 10079068398356, 10079068398357, 10079068398359, 10079068398358, 10079068398355, 10079070766630, 10079070766628, 10079070766629, 10079070766627, 10079061727434, 10079061727435, 10079067078716, 10079067078715, 10079051550275, 10079065234196, 10078949765112, 10079051550272, 10079051550273, 10078995578574, 10081271571077, 10078995578584, 10081271571078, 10079005060684, 10079005060685, 10078954770972, 10078954770970, 10078954770973, 10078954770971, 10078954090365, 10078950737155, 10078950737156, 10078950737154, 10078995578575, 10078995578573, 10079051550274, 10078942630181, 10078942630178, 10078942630180, 10078942630179, 10078949642109, 10078949642110, 10078949765111, 10078932762284, 10078932762282, 10078932762283, 10078932762285, 10078932762281, 10078932762280, 10078929048530, 10078929048529, 10078936875484, 10078936875486, 10078936875483, 10078936875482, 10078936875485, 10078927516637, 10078927516638, 10078927516636, 10078929048528, 10078924483318, 10078923909230, 10078923909232, 10078923909231, 10078915305594, 10078915305595, 10078915305596, 10078914570530, 10078913764603, 10078913764604, 10078893084597, 10078893084596, 10078895132329, 10078895132330, 10078926484276, 10078889852852, 10078885484651, 10078886812153, 10078887252150, 10078887252149, 10078881382522, 10078888593569, 10078884983577, 10078888593568, 10078886812154, 10078886812152, 10078888998815, 10078882492446, 10078882492445, 10078882939250, 10078886812151, 10078882939249, 10078889511230, 10078886812150, 10078887717699, 10078887717700, 10078881382521, 10078881382520, 10078881382519, 10078881382518, 10078878463607, 10078878463601, 10078878463603, 10078878463600, 10078878463606, 10078878463604, 10078878463602, 10078880399096, 10078878463608, 10078880399097, 10078878463605, 10078880399094, 10078875403071, 10079281444782, 10078880399095, 10078875403072, 10078874775401, 10078872017883, 10079059750532, 10079059750533, 10079059750534, 10079059750529, 10079059750530, 10078872696834, 10078872311300, 10078873232966, 10078873585555, 10078872311299, 10078872311301, 10079277073137, 10079277073138, 10079277073139, 10079277073140, 10079277073141 }.Distinct().ToList(); - - Console.WriteLine(list1.Count()); Console.ReadKey(); } diff --git a/BBWY.Test/Properties/launchSettings.json b/BBWY.Test/Properties/launchSettings.json new file mode 100644 index 00000000..33504c94 --- /dev/null +++ b/BBWY.Test/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "WSL": { + "commandName": "WSL2", + "distributionName": "" + } + } +} \ No newline at end of file