Commit 1f1167db by 泽锋 李

新增一个任务,计算最近7天的

parent 9c63db0b
......@@ -2405,6 +2405,49 @@ order by t1.gmt_modified asc
public DateTime? estimated_arrival_time { get; set; }
public DateTime create_time { get; set; }
}
/// <summary>
/// 刷新最近7天的订单总数
/// </summary>
public static void ResetOrders7()
{
// 清空数据先
_connection.Execute(" update dc_base_stock set orders_7=0 where orders_7>0 ", commandTimeout: 0);
var orderCounts = _connection.Query<reset_orders_7_dto>($@"select bailun_sku,warehouse_code,count(1) as 'orders_7' from dc_base_oms_sku_30 where
has_fba_s = 0
and has_delete = 0
and has_scalp = 0
and has_buyer_remark = 0
and has_platsku_remark = 0
and has_innersale = 0
and bailun_order_status !='Canceled'
and platform_order_type != '手工单'
and pay_time>=@btime and pay_time<=@etime and warehouse_code='GZBLWH' GROUP BY bailun_sku,warehouse_code",new {
btime = DateTime.Now.AddDays(-8).ToDayHome(),
etime = DateTime.Now.AddDays(-1).ToDayEnd(),
},commandTimeout:0);
// 写入
foreach (var item in orderCounts)
{
_connection.Execute(" update dc_base_stock set orders_7=@orders_7,orders_7_reset_date=now() where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ", new {
orders_7 = item.orders_7,
bailun_sku = item.bailun_sku,
warehouse_code = item.warehouse_code
}, commandTimeout: 0);
}
}
public class reset_orders_7_dto
{
public string bailun_sku { get; set; }
public string warehouse_code { get; set; }
public int orders_7 { get; set; }
}
}
......
......@@ -40,6 +40,7 @@ namespace ResetOutofstock
//base_sku_dao.SynchroSkuCharacter();
//report.ClearShopifyJitInventory();
//report.ShopifyJitInventory();
//daily.ResetOrders7();
}
catch (Exception ex)
......
......@@ -70,7 +70,7 @@ namespace ResetOutofstock
//dc_report_finance_dao.CalculationAccounts(DateTime.Now.AddDays(-90));
Console.WriteLine($"结束 财报应首付账款,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
......
......@@ -450,6 +450,29 @@ namespace ResetOutofstock
}
});
Task.Factory.StartNew(() =>
{
while (true)
{
try
{
Console.WriteLine($"开始 计算最近7天的订单数量,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
daily.ResetOrders7();
Console.WriteLine($"结束 计算最近7天的订单数量,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(4 * 60 * 60 * 1000);
}
catch (Exception ex)
{
Console.WriteLine("计算最近7天的订单数量:" + ex.Message);
Console.WriteLine("计算最近7天的订单数量:" + ex.StackTrace);
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment