Commit f592bfd6 by lizefeng

fix

parent 7045f25e
...@@ -866,7 +866,7 @@ namespace AutoTurnOver.Services ...@@ -866,7 +866,7 @@ namespace AutoTurnOver.Services
} }
storageFee._create_date = DateTime.Now; storageFee._create_date = DateTime.Now;
storageFee._update_date = DateTime.Now; storageFee._update_date = DateTime.Now;
storageFee._unique_id = $"{storageFee.asin}-{storageFee._date.ToString("yyyy-MM")}-{storageFee.site}-{storageFee.account}-{storageFee.fulfillment_center}"; storageFee._unique_id = $"{storageFee.asin}-{storageFee._date.ToString("yyyy-MM")}-{storageFee.site}-{storageFee.account}-{storageFee.fulfillment_center}-{storageFee.fee_type}";
var oldData = MyMySqlConnection._connection.QueryFirstOrDefault<dc_profit_business_amazon_storage_fee>(" select * from dc_profit_business_amazon_storage_fee where _unique_id=@unique_id ", new { unique_id = storageFee._unique_id }); var oldData = MyMySqlConnection._connection.QueryFirstOrDefault<dc_profit_business_amazon_storage_fee>(" select * from dc_profit_business_amazon_storage_fee where _unique_id=@unique_id ", new { unique_id = storageFee._unique_id });
if (oldData != null) if (oldData != null)
{ {
...@@ -989,7 +989,7 @@ namespace AutoTurnOver.Services ...@@ -989,7 +989,7 @@ namespace AutoTurnOver.Services
} }
storageFee._create_date = DateTime.Now; storageFee._create_date = DateTime.Now;
storageFee._update_date = DateTime.Now; storageFee._update_date = DateTime.Now;
storageFee._unique_id = $"{storageFee.asin}-{storageFee._date.ToString("yyyy-MM")}-{storageFee.site}-{storageFee.account}-{storageFee.fulfillment_center}"; storageFee._unique_id = $"{storageFee.asin}-{storageFee._date.ToString("yyyy-MM")}-{storageFee.site}-{storageFee.account}-{storageFee.fulfillment_center}-{storageFee.fee_type}";
var oldData = MyMySqlConnection._connection.QueryFirstOrDefault<dc_profit_business_amazon_storage_fee>(" select * from dc_profit_business_amazon_storage_fee where _unique_id=@unique_id ", new { unique_id = storageFee._unique_id }); var oldData = MyMySqlConnection._connection.QueryFirstOrDefault<dc_profit_business_amazon_storage_fee>(" select * from dc_profit_business_amazon_storage_fee where _unique_id=@unique_id ", new { unique_id = storageFee._unique_id });
if (oldData != null) if (oldData != null)
{ {
...@@ -1055,9 +1055,25 @@ namespace AutoTurnOver.Services ...@@ -1055,9 +1055,25 @@ namespace AutoTurnOver.Services
try try
{ {
var pamsAccount = ApiServices.GetAmazonAccountList().FirstOrDefault(s => s.Id == ana_task.pams_account_id); var pamsAccount = ApiServices.GetAmazonAccountList().FirstOrDefault(s => s.Id == ana_task.pams_account_id);
var filePath = DownloadReportData(pamsAccount, ana_task.report_id); var reportData = DownloadReportData(pamsAccount, ana_task.report_id);
if (string.IsNullOrWhiteSpace(reportData.ReportDocumentId))
{
if (reportData.ProcessingStatus == Report.ProcessingStatusEnum.FATAL || reportData.ProcessingStatus == Report.ProcessingStatusEnum.CANCELLED)
{
ana_task.ana_status = -2;
MyMySqlConnection._connection.Update(ana_task);
return;
}
else
{
ana_task.report_par_json = reportData.ToJson();
MyMySqlConnection._connection.Update(ana_task);
return;
}
}
StringBuilder response_str = new StringBuilder() { }; StringBuilder response_str = new StringBuilder() { };
using (StreamReader sr = new StreamReader(filePath.ReportDocumentId)) using (StreamReader sr = new StreamReader(reportData.ReportDocumentId))
{ {
response_str.AppendLine(sr.ReadToEnd()); response_str.AppendLine(sr.ReadToEnd());
sr.Close(); sr.Close();
...@@ -1066,7 +1082,7 @@ namespace AutoTurnOver.Services ...@@ -1066,7 +1082,7 @@ namespace AutoTurnOver.Services
string jsonText = response_str.ToString(); string jsonText = response_str.ToString();
ana_task.content = jsonText; ana_task.content = jsonText;
var table = CsvFileHelper.ReadFromCSV(filePath.ReportDocumentId, true, '\t'); var table = CsvFileHelper.ReadFromCSV(reportData.ReportDocumentId, true, '\t');
foreach (DataRow row in table.Rows) foreach (DataRow row in table.Rows)
{ {
try try
...@@ -1074,15 +1090,15 @@ namespace AutoTurnOver.Services ...@@ -1074,15 +1090,15 @@ namespace AutoTurnOver.Services
dc_profit_business_amazon_storage_fee storageFee = new dc_profit_business_amazon_storage_fee dc_profit_business_amazon_storage_fee storageFee = new dc_profit_business_amazon_storage_fee
{ {
currency = row.DataRowToString("currency"), currency = row.DataRowToString("currency_code"),
fulfillment_center = row.DataRowToString("fulfillment_center"), fulfillment_center = row.DataRowToString("currency_code"),
fee_type = "月度仓储费", fee_type = "超量仓储费",
account = pamsAccount.Account, account = pamsAccount.Account,
asin = row.DataRowToString("asin"), asin = "OverageStorageFee",
report_end_date = filePath.DataEndTime ?? new DateTime(1991, 1, 1) report_end_date = reportData.DataEndTime ?? new DateTime(1991, 1, 1)
}; };
storageFee.fee = row.DataRowToNumber("estimated_monthly_storage_fee") ?? 0; storageFee.fee = row.DataRowToNumber("charged_fee_amount") ?? 0;
storageFee._date = DateTime.Parse(row.DataRowToString("month_of_charge")); storageFee._date = DateTime.Parse(row.DataRowToString("charged_date"));
storageFee.site = row.DataRowToString("country_code"); storageFee.site = row.DataRowToString("country_code");
if ("GB".Equals(storageFee.site, StringComparison.CurrentCultureIgnoreCase)) if ("GB".Equals(storageFee.site, StringComparison.CurrentCultureIgnoreCase))
{ {
...@@ -1090,7 +1106,7 @@ namespace AutoTurnOver.Services ...@@ -1090,7 +1106,7 @@ namespace AutoTurnOver.Services
} }
storageFee._create_date = DateTime.Now; storageFee._create_date = DateTime.Now;
storageFee._update_date = DateTime.Now; storageFee._update_date = DateTime.Now;
storageFee._unique_id = $"{storageFee.asin}-{storageFee._date.ToString("yyyy-MM")}-{storageFee.site}-{storageFee.account}-{storageFee.fulfillment_center}"; storageFee._unique_id = $"{storageFee._date.ToString("yyyy-MM")}-{storageFee.site}-{storageFee.account}-{storageFee.fulfillment_center}-{storageFee.fee_type}";
var oldData = MyMySqlConnection._connection.QueryFirstOrDefault<dc_profit_business_amazon_storage_fee>(" select * from dc_profit_business_amazon_storage_fee where _unique_id=@unique_id ", new { unique_id = storageFee._unique_id }); var oldData = MyMySqlConnection._connection.QueryFirstOrDefault<dc_profit_business_amazon_storage_fee>(" select * from dc_profit_business_amazon_storage_fee where _unique_id=@unique_id ", new { unique_id = storageFee._unique_id });
if (oldData != null) if (oldData != null)
{ {
......
...@@ -67,7 +67,7 @@ namespace ResetOutofstock ...@@ -67,7 +67,7 @@ namespace ResetOutofstock
//new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport(report_id: "937084019471"); //new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport(report_id: "937084019471");
while (true) while (true)
{ {
new AmazonDataSynchroService().AnaFbaLongTermStorageFeeReport(); new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport();
} }
//new AmazonDataSynchroService().AnaReport(data_id: "17339571721"); //new AmazonDataSynchroService().AnaReport(data_id: "17339571721");
} }
......
...@@ -827,6 +827,29 @@ namespace ResetOutofstock ...@@ -827,6 +827,29 @@ namespace ResetOutofstock
} }
}); });
Task.Factory.StartNew(() =>
{
while (true)
{
try
{
Console.WriteLine($"开始 解析亚马逊超量仓储费,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport();
new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport(-1);
Console.WriteLine($"结束 解析亚马逊超量仓储费,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(1000 * 3);
}
catch (Exception ex)
{
Console.WriteLine(" 解析解析亚马逊长期仓储费:" + ex.Message);
Console.WriteLine(" 解析解析亚马逊长期仓储费 :" + ex.StackTrace);
}
}
});
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
......
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