Commit 0f892b2f by 泽锋 李

新增调拨费同步任务

parent 5c65111a
...@@ -201,5 +201,38 @@ namespace AutoTurnOver.DB ...@@ -201,5 +201,38 @@ namespace AutoTurnOver.DB
throw new Exception(" lms 接口异常: " + ex.StackTrace); throw new Exception(" lms 接口异常: " + ex.StackTrace);
} }
} }
/// <summary>
/// 获取调拨单真实费用
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static List<api_transfer_cost_real_dto.data_dto.items_dto> GetTransferCost(api_transfer_cost_real_input_dto data)
{
try
{
//查询采购建议明细
string url = ConfigHelper.GetValue("transfer_cost_real");
string resultStr = HttpHelper.Request(url, RequestType.POST, data.ToJson(), "application/json", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<api_transfer_cost_real_dto>();
if (result == null)
{
throw new Exception("未获取响应数据");
}
else
{
if (!result.isSuccess)
{
throw new Exception(result.message);
}
return result.data.items;
}
}
catch (Exception ex)
{
throw new Exception("调拨费用同步接口 异常: " + ex.Message);
throw new Exception("调拨费用同步接口 接口异常: " + ex.StackTrace);
}
}
} }
} }
...@@ -42,7 +42,7 @@ namespace AutoTurnOver.DB ...@@ -42,7 +42,7 @@ namespace AutoTurnOver.DB
parameters.Add("etime", etime.Value.ToString("yyyy-MM-dd 23:59:59")); parameters.Add("etime", etime.Value.ToString("yyyy-MM-dd 23:59:59"));
} }
sql += $" order by id desc limit {(page - 1) * rows},{rows} "; sql += $" order by id desc limit {(page - 1) * rows},{rows} ";
var order_list = conn.Query<dc_base_oms_sku>(sql, parameters,commandTimeout:0).AsList(); var order_list = conn.Query<dc_base_oms_sku>(sql, parameters, commandTimeout: 0).AsList();
if (order_list == null || order_list.Count <= 0) if (order_list == null || order_list.Count <= 0)
{ {
break; break;
...@@ -61,18 +61,18 @@ namespace AutoTurnOver.DB ...@@ -61,18 +61,18 @@ namespace AutoTurnOver.DB
var is_delete = ( var is_delete = (
(!bailun_interception_status.Any(v => v.Equals(order_item.bailun_interception_status, StringComparison.OrdinalIgnoreCase))) // 拦截单 (!bailun_interception_status.Any(v => v.Equals(order_item.bailun_interception_status, StringComparison.OrdinalIgnoreCase))) // 拦截单
|| ||
order_item.has_innersale==1 // 内购单 order_item.has_innersale == 1 // 内购单
|| ||
"Canceled".Equals(order_item.bailun_order_status, StringComparison.OrdinalIgnoreCase) // 取消单 "Canceled".Equals(order_item.bailun_order_status, StringComparison.OrdinalIgnoreCase) // 取消单
|| ||
((!"FBA".Equals(order_item.platform_type, StringComparison.OrdinalIgnoreCase)) && "CantHandle".Equals(order_item.bailun_order_status, StringComparison.OrdinalIgnoreCase)) // 非fba 的订单状态为取消 ((!"FBA".Equals(order_item.platform_type, StringComparison.OrdinalIgnoreCase)) && "CantHandle".Equals(order_item.bailun_order_status, StringComparison.OrdinalIgnoreCase)) // 非fba 的订单状态为取消
|| ||
order_item.has_scalp ==1 // 刷单 order_item.has_scalp == 1 // 刷单
|| ||
order_item.has_delete==1 order_item.has_delete == 1
|| ||
order_item.company_id!=1 order_item.company_id != 1
) ?1:0; ) ? 1 : 0;
#region 销售释放成本 #region 销售释放成本
...@@ -1066,7 +1066,7 @@ and t1.bj_date>=@btime and t1.bj_date<=@etime "; ...@@ -1066,7 +1066,7 @@ and t1.bj_date>=@btime and t1.bj_date<=@etime ";
occur_time = order_item.bj_date ?? new DateTime(1991, 1, 1), occur_time = order_item.bj_date ?? new DateTime(1991, 1, 1),
warehouse_code = "", warehouse_code = "",
pay_type = (int)dc_report_cash_flow_log_pay_type_enum.实时, pay_type = (int)dc_report_cash_flow_log_pay_type_enum.实时,
item_no = "Ebay-"+order_item.id.ToString() item_no = "Ebay-" + order_item.id.ToString()
}; };
item.pay_time = order_item.bj_date ?? new DateTime(1991, 1, 1); item.pay_time = order_item.bj_date ?? new DateTime(1991, 1, 1);
...@@ -1261,10 +1261,10 @@ where t1.report_date>=@btime and t1.report_date<=@etime "; ...@@ -1261,10 +1261,10 @@ where t1.report_date>=@btime and t1.report_date<=@etime ";
web_site = "", web_site = "",
remarks = "", remarks = "",
val = 0 - Math.Abs(order_item.cost * order_item.exchange_rate), val = 0 - Math.Abs(order_item.cost * order_item.exchange_rate),
occur_time = order_item.report_date , occur_time = order_item.report_date,
warehouse_code = "", warehouse_code = "",
pay_type = (int)dc_report_cash_flow_log_pay_type_enum.实时, pay_type = (int)dc_report_cash_flow_log_pay_type_enum.实时,
item_no = "amazon-"+order_item.id.ToString() item_no = "amazon-" + order_item.id.ToString()
}; };
item.pay_time = order_item.report_date; item.pay_time = order_item.report_date;
...@@ -1322,17 +1322,17 @@ where t1.report_date>=@btime and t1.report_date<=@etime "; ...@@ -1322,17 +1322,17 @@ where t1.report_date>=@btime and t1.report_date<=@etime ";
&& (s.platform_type == "" || s.platform_type.Equals(platform_type)) && (s.platform_type == "" || s.platform_type.Equals(platform_type))
&& (s.web_stite == "" || s.web_stite.Equals(web_stite)) && (s.web_stite == "" || s.web_stite.Equals(web_stite))
).OrderByDescending(s => s.web_stite).ToList(); ).OrderByDescending(s => s.web_stite).ToList();
if (item_configs == null || item_configs.Count<=0) if (item_configs == null || item_configs.Count <= 0)
{ {
return occur_time; return occur_time;
} }
else else
{ {
dc_report_cash_flow_config item_config = item_configs[0]; dc_report_cash_flow_config item_config = item_configs[0];
if (item_configs.Where(v=>v.settlement_type== (int)dc_report_cash_flow_settlement_type_enum.月度固定).Count()>1) if (item_configs.Where(v => v.settlement_type == (int)dc_report_cash_flow_settlement_type_enum.月度固定).Count() > 1)
{ {
// 取发生时间后,最早的一个付款日期 // 取发生时间后,最早的一个付款日期
item_config = item_configs.Where(s => s.settlement_type > occur_time.Day).OrderBy(s=>s.settlement_type).FirstOrDefault(); item_config = item_configs.Where(s => s.settlement_type > occur_time.Day).OrderBy(s => s.settlement_type).FirstOrDefault();
if (item_config == null) if (item_config == null)
{ {
// 如果没取到,则有可能是最后一天了,要下个月付款了,。则取最早的一天 // 如果没取到,则有可能是最后一天了,要下个月付款了,。则取最早的一天
...@@ -1347,12 +1347,12 @@ where t1.report_date>=@btime and t1.report_date<=@etime "; ...@@ -1347,12 +1347,12 @@ where t1.report_date>=@btime and t1.report_date<=@etime ";
{ {
item_config = temp_item_configs[1]; item_config = temp_item_configs[1];
} }
else if(temp_item_configs.Count==1) else if (temp_item_configs.Count == 1)
{ {
// 只有一条,取下期 // 只有一条,取下期
item_config = item_configs.OrderBy(s => s.settlement_type).FirstOrDefault(); item_config = item_configs.OrderBy(s => s.settlement_type).FirstOrDefault();
} }
else if (temp_item_configs.Count ==0) else if (temp_item_configs.Count == 0)
{ {
// 一条都没有,取整个月第二期 // 一条都没有,取整个月第二期
item_config = item_configs.OrderBy(s => s.settlement_type).ToList()[1]; item_config = item_configs.OrderBy(s => s.settlement_type).ToList()[1];
...@@ -1525,7 +1525,7 @@ GROUP BY platform_type,website"; ...@@ -1525,7 +1525,7 @@ GROUP BY platform_type,website";
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 3 }, date_type_str = "退款", remarks = "crm 抓取的退款数据,未区分仓库", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 3 }, date_type_str = "退款", remarks = "crm 抓取的退款数据,未区分仓库", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 15 }, date_type_str = "广告费", remarks = "未区分 sku , 仓库", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 15 }, date_type_str = "广告费", remarks = "未区分 sku , 仓库", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 16 }, date_type_str = "上架费", remarks = "未区分 sku , 仓库", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 16 }, date_type_str = "上架费", remarks = "未区分 sku , 仓库", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 4,3,15,16 }, date_type_str = "利润", remarks = "oms 中的订单,分摊到sku的利润", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 4, 3, 15, 16 }, date_type_str = "利润", remarks = "oms 中的订单,分摊到sku的利润", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 5 }, date_type_str = "平台费用", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 5 }, date_type_str = "平台费用", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 6 }, date_type_str = "释放销售成本", remarks = "采购成本,利润中已经计算了", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 6 }, date_type_str = "释放销售成本", remarks = "采购成本,利润中已经计算了", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 7 }, date_type_str = "释放头程费用", remarks = "", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 7 }, date_type_str = "释放头程费用", remarks = "", dates = new List<report_cash_flow_view_dto.date_dto>() });
...@@ -1537,7 +1537,7 @@ GROUP BY platform_type,website"; ...@@ -1537,7 +1537,7 @@ GROUP BY platform_type,website";
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 11 }, date_type_str = "fba费", remarks = " ", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 11 }, date_type_str = "fba费", remarks = " ", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 12 }, date_type_str = "paypal费", remarks = " ", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 12 }, date_type_str = "paypal费", remarks = " ", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 4, 3, 15, 16 }, date_type_str = "汇总利润", remarks = " oms 中的订单,销售额 - 销售成本 - 尾程费 - 头程费 - 退款 - 平台费 - fba费 -paypal 费 ", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 4, 3, 15, 16 }, date_type_str = "汇总利润", remarks = " oms 中的订单,销售额 - 销售成本 - 尾程费 - 头程费 - 退款 - 平台费 - fba费 -paypal 费 ", dates = new List<report_cash_flow_view_dto.date_dto>() });
datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 2,3,15,16,5,8,9,13,10,14,11,12 }, date_type_str = "现金流结余", remarks = " 销售金额 - 新增采购费用 - 新增头程费用 - 平台费用 - 尾程费用 ", dates = new List<report_cash_flow_view_dto.date_dto>() }); datas.Add(new report_cash_flow_view_dto { date_type = new List<int> { 2, 3, 15, 16, 5, 8, 9, 13, 10, 14, 11, 12 }, date_type_str = "现金流结余", remarks = " 销售金额 - 新增采购费用 - 新增头程费用 - 平台费用 - 尾程费用 ", dates = new List<report_cash_flow_view_dto.date_dto>() });
var btime = DateTime.Now.AddDays(-8).ToDayHome(); var btime = DateTime.Now.AddDays(-8).ToDayHome();
var etime = DateTime.Now.AddDays(-1).ToDayEnd(); var etime = DateTime.Now.AddDays(-1).ToDayEnd();
if (search.btime != null) if (search.btime != null)
...@@ -1840,5 +1840,50 @@ where t1.type=@type "; ...@@ -1840,5 +1840,50 @@ where t1.type=@type ";
return _connection.Page<dc_report_cash_flow_sku_group_dto>(sql, search, parameters); return _connection.Page<dc_report_cash_flow_sku_group_dto>(sql, search, parameters);
} }
/// <summary>
/// 同步调拨系统的真实费用
/// </summary>
public static void SynchroTransferCost()
{
var conn = _connection;
var page = 1;
var rows = 20;
while (true)
{
var items = ApiUtility.GetTransferCost(new api_transfer_cost_real_input_dto { data = new api_transfer_cost_real_input_dto.data_dto { page = new api_transfer_cost_real_input_dto.data_dto.page_dto { page = page,rows = rows},} });
if(items==null || items.Count <= 0)
{
break;
}
page++;
foreach (var item in items)
{
foreach (var skuItem in item.skus)
{
dc_base_transfer_cost_real db_data = new dc_base_transfer_cost_real()
{
bailun_sku = skuItem.sku,
sku_avg_cost = skuItem.skuAvgCost,
transfer_order_id = item.orderCode
};
db_data.id = conn.QuerySingleOrDefault<int?>(" select id from dc_base_transfer_cost_real where bailun_sku=@bailun_sku and transfer_order_id=@transfer_order_id limit 1 ", new {
bailun_sku = db_data.bailun_sku,
transfer_order_id = db_data.transfer_order_id
})??0;
if (db_data.id > 0)
{
conn.Update(db_data);
}
else
{
conn.Insert(db_data);
}
}
}
}
}
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
/// <summary>
/// 调拨系统获取真实费用
/// </summary>
public class api_transfer_cost_real_dto
{
public bool isSuccess { get; set; }
public string message { get; set; }
public data_dto data { get; set; }
public class data_dto
{
public List<items_dto> items { get; set; }
public class items_dto
{
public int id { get; set; }
public string boxCode { get; set; }
public string orderCode { get; set; }
public decimal blCost { get; set; }
public decimal blWeight { get; set; }
public decimal logisticCost { get; set; }
public decimal logisticWeight { get; set; }
public List<skus_dto> skus { get; set; }
public class skus_dto
{
public string sku { get; set; }
public string skuTitle { get; set; }
public int deliveryCount { get; set; }
public int storageCount { get; set; }
public decimal weight { get; set; }
public decimal skuAvgCost { get; set; }
}
}
}
}
public class api_transfer_cost_real_input_dto
{
public data_dto data { get; set; }
public class data_dto
{
public page_dto page { get; set; }
public class page_dto
{
public int page { get; set; }
public int rows { get; set; }
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// 财务结算后的真实运费
/// </summary>
public class dc_base_transfer_cost_real
{
public int id { get; set; }
public string transfer_order_id { get; set; }
public string bailun_sku { get; set; }
public decimal sku_avg_cost { get; set; }
}
}
...@@ -16,6 +16,8 @@ namespace ResetOutofstock ...@@ -16,6 +16,8 @@ namespace ResetOutofstock
var now = DateTime.Now; var now = DateTime.Now;
//report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"))); //report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{ {
services.AddHostedService<ResetOutofstockBackgrounService>(); services.AddHostedService<ResetOutofstockBackgrounService>();
......
...@@ -131,6 +131,25 @@ namespace ResetOutofstock ...@@ -131,6 +131,25 @@ namespace ResetOutofstock
} }
}); });
Task.Factory.StartNew(() =>
{
while (true)
{
try
{
Console.WriteLine($"开始同步真实调拨费,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report_cash_flow_dao.SynchroTransferCost();
Console.WriteLine($"结束同步真实调拨费,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Thread.Sleep(60 * 60 * 1000);
}
});
return Task.CompletedTask; return Task.CompletedTask;
} }
......
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
}, },
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList", "WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics", "Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus" "PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus",
"transfer_cost_real": "http://api.wms.bailuntec.com/api/services/app/OrderLogisticCostService/GetOrderLogisticCostPageList"
} }
...@@ -12,5 +12,6 @@ ...@@ -12,5 +12,6 @@
"PPS_ShortagePush": "http://bltpro.bailuntec.com/api/EbayTask/PushSkuEditQtyTask", "PPS_ShortagePush": "http://bltpro.bailuntec.com/api/EbayTask/PushSkuEditQtyTask",
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList", "WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics", "Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus" "PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus",
"transfer_cost_real": "http://api.wms.bailuntec.com/api/services/app/OrderLogisticCostService/GetOrderLogisticCostPageList"
} }
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
}, },
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList", "WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics", "Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus" "PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus",
"transfer_cost_real": "http://api.wms.bailuntec.com/api/services/app/OrderLogisticCostService/GetOrderLogisticCostPageList"
} }
\ No newline at end of file
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