Commit f592bfd6 by lizefeng

fix

parent 7045f25e
......@@ -866,7 +866,7 @@ namespace AutoTurnOver.Services
}
storageFee._create_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 });
if (oldData != null)
{
......@@ -989,7 +989,7 @@ namespace AutoTurnOver.Services
}
storageFee._create_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 });
if (oldData != null)
{
......@@ -1055,9 +1055,25 @@ namespace AutoTurnOver.Services
try
{
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() { };
using (StreamReader sr = new StreamReader(filePath.ReportDocumentId))
using (StreamReader sr = new StreamReader(reportData.ReportDocumentId))
{
response_str.AppendLine(sr.ReadToEnd());
sr.Close();
......@@ -1066,7 +1082,7 @@ namespace AutoTurnOver.Services
string jsonText = response_str.ToString();
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)
{
try
......@@ -1074,15 +1090,15 @@ namespace AutoTurnOver.Services
dc_profit_business_amazon_storage_fee storageFee = new dc_profit_business_amazon_storage_fee
{
currency = row.DataRowToString("currency"),
fulfillment_center = row.DataRowToString("fulfillment_center"),
fee_type = "月度仓储费",
currency = row.DataRowToString("currency_code"),
fulfillment_center = row.DataRowToString("currency_code"),
fee_type = "超量仓储费",
account = pamsAccount.Account,
asin = row.DataRowToString("asin"),
report_end_date = filePath.DataEndTime ?? new DateTime(1991, 1, 1)
asin = "OverageStorageFee",
report_end_date = reportData.DataEndTime ?? new DateTime(1991, 1, 1)
};
storageFee.fee = row.DataRowToNumber("estimated_monthly_storage_fee") ?? 0;
storageFee._date = DateTime.Parse(row.DataRowToString("month_of_charge"));
storageFee.fee = row.DataRowToNumber("charged_fee_amount") ?? 0;
storageFee._date = DateTime.Parse(row.DataRowToString("charged_date"));
storageFee.site = row.DataRowToString("country_code");
if ("GB".Equals(storageFee.site, StringComparison.CurrentCultureIgnoreCase))
{
......@@ -1090,7 +1106,7 @@ namespace AutoTurnOver.Services
}
storageFee._create_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 });
if (oldData != null)
{
......
......@@ -67,7 +67,7 @@ namespace ResetOutofstock
//new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport(report_id: "937084019471");
while (true)
{
new AmazonDataSynchroService().AnaFbaLongTermStorageFeeReport();
new AmazonDataSynchroService().AnaFbaOverageStorageFeeReport();
}
//new AmazonDataSynchroService().AnaReport(data_id: "17339571721");
}
......
......@@ -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(() =>
{
......
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