Browse Source

1

AddValidOverTime
shanji 2 years ago
parent
commit
bb605777a6
  1. 6
      BBWY.Server.API/Controllers/TestController.cs
  2. 49
      BBWY.Server.Business/TestBusiness.cs

6
BBWY.Server.API/Controllers/TestController.cs

@ -36,5 +36,11 @@ namespace BBWY.Server.API.Controllers
{
testBusiness.DeleteJDTask();
}
[HttpPost]
public void RepairOrderProfit()
{
testBusiness.RepairOrderProfit();
}
}
}

49
BBWY.Server.Business/TestBusiness.cs

@ -272,6 +272,55 @@ namespace BBWY.Server.Business
}
}
public void RepairOrderProfit()
{
var startTime = DateTime.Parse("2023-10-16");
var orderList = fsql.Select<Order>().Where(o => o.FreightPrice > 0 &&
o.IsGift == false &&
o.OrderState != Enums.OrderState. &&
o.StorageType != null &&
o.StorageType != Enums.StorageType.SD &&
o.StartTime >= startTime)
.ToList();
var orderIdList = orderList.Select(o => o.Id).ToList();
var orderCostList = fsql.Select<OrderCost>(orderIdList).ToList();
List<IUpdate<OrderCost>> updateList = new List<IUpdate<OrderCost>>();
int index = 0;
foreach (var orderCost in orderCostList)
{
index++;
Console.WriteLine($"{DateTime.Now} OrderProgress {index}/{orderCostList.Count()}");
var order = orderList.FirstOrDefault(o => o.Id == orderCost.OrderId);
if (order == null)
continue;
orderCost.CalculationOrderProfitAndCost(order, null);
updateList.Add(fsql.Update<OrderCost>(orderCost.OrderId).Set(oc => oc.Profit, orderCost.Profit)
.Set(oc => oc.PlatformCommissionAmount, orderCost.PlatformCommissionAmount));
if (updateList.Count() > 10)
{
Console.WriteLine($"{DateTime.Now} 执行数据库更新");
fsql.Transaction(() =>
{
foreach (var update in updateList)
update.ExecuteAffrows();
});
updateList.Clear();
}
}
if (updateList.Count() > 0)
{
Console.WriteLine($"{DateTime.Now} 最后执行数据库更新");
fsql.Transaction(() =>
{
foreach (var update in updateList)
update.ExecuteAffrows();
});
updateList.Clear();
}
}
public void DeleteJDTask()
{
var appKey = "E1AA9247D5583A6D87449CE6AB290185";

Loading…
Cancel
Save