Commit 0328f60a by lizefeng

优化账单抓取

parent d60c2315
......@@ -22,6 +22,7 @@ namespace AutoTurnOver.Models
public string buyer_name { get; set; }
public string buyer_phone_number { get; set; }
public string sku { get; set; }
public string product_name { get; set; }
public decimal? quantity_shipped { get; set; }
public string currency { get; set; }
......
......@@ -150,6 +150,8 @@ namespace AutoTurnOver.Services.Dto
public DateTime? DepositDate { get; set; }
}
[JsonProperty("OtherTransaction")]
[JsonConverter(typeof(OtherTransactionDataConverter))]
public List<OtherTransactionDto> OtherTransaction { get; set; } = new List<OtherTransactionDto> { };
public class OtherTransactionDto
......@@ -209,13 +211,10 @@ namespace AutoTurnOver.Services.Dto
}
public PromotionDto Promotion { get; set; }
public class PromotionDto
{
public string MerchantPromotionID { get; set; }
public string Type { get; set; }
public Amount Amount { get; set; }
}
[JsonProperty("Promotion")]
[JsonConverter(typeof(PromotionDataConverter))]
public List<PromotionDto> Promotion { get; set; }
}
}
}
......@@ -260,13 +259,10 @@ namespace AutoTurnOver.Services.Dto
}
public PromotionDto PromotionAdjustment { get; set; }
public class PromotionDto
{
public string MerchantPromotionID { get; set; }
public string Type { get; set; }
public Amount Amount { get; set; }
}
[JsonProperty("PromotionAdjustment")]
[JsonConverter(typeof(PromotionDataConverter))]
public List<PromotionDto> PromotionAdjustment { get; set; }
}
}
}
......@@ -285,6 +281,12 @@ namespace AutoTurnOver.Services.Dto
}
}
}
public class PromotionDto
{
public string MerchantPromotionID { get; set; }
public string Type { get; set; }
public Amount Amount { get; set; }
}
public class FeeDto
{
public string Type { get; set; }
......@@ -330,6 +332,36 @@ namespace AutoTurnOver.Services.Dto
serializer.Serialize(writer, value);
}
}
class OtherTransactionDataConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(ApiAmazonSettlementDto.AmazonEnvelopeDto.MessageDto.SettlementReportDto.OtherTransactionDto));
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JToken token = JToken.Load(reader);
if (token.Type == JTokenType.Array)
{
return token.ToObject<List<ApiAmazonSettlementDto.AmazonEnvelopeDto.MessageDto.SettlementReportDto.OtherTransactionDto>>();
}
if (token.Type == JTokenType.Object)
{
return new List<ApiAmazonSettlementDto.AmazonEnvelopeDto.MessageDto.SettlementReportDto.OtherTransactionDto> { token.ToObject<ApiAmazonSettlementDto.AmazonEnvelopeDto.MessageDto.SettlementReportDto.OtherTransactionDto>() };
}
else
{
return new List<ApiAmazonSettlementDto.AmazonEnvelopeDto.MessageDto.SettlementReportDto.OtherTransactionDto> { };
}
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
serializer.Serialize(writer, value);
}
}
class RefundDataConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
......@@ -453,6 +485,38 @@ namespace AutoTurnOver.Services.Dto
}
}
class PromotionDataConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(ApiAmazonSettlementDto.AmazonEnvelopeDto.PromotionDto));
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JToken token = JToken.Load(reader);
if (token.Type == JTokenType.Array)
{
var test = token.ToString();
return token.ToObject<List<ApiAmazonSettlementDto.AmazonEnvelopeDto.PromotionDto>>();
}
if (token.Type == JTokenType.Object)
{
return new List<ApiAmazonSettlementDto.AmazonEnvelopeDto.PromotionDto> { token.ToObject<ApiAmazonSettlementDto.AmazonEnvelopeDto.PromotionDto> () };
}
else
{
return new List<ApiAmazonSettlementDto.AmazonEnvelopeDto.FeeDto> { };
}
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
serializer.Serialize(writer, value);
}
}
class AdjustedItemDataConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
......
......@@ -42,52 +42,39 @@ namespace AutoTurnOver.Utility
}
public static string DataRowToString(this DataRow row, string key)
public static string DataRowToString(this DataRow row,int index)
{
if (row[key] == null)
if (row[index] == null)
{
return null;
}
else
{
return row[key].ToString();
return row[index].ToString();
}
}
public static DateTime? DataRowToDateTime(this DataRow row, string key)
{
try
public static DateTime? DataRowToDateTime(this DataRow row,int index)
{
if (row[key] == null)
if (row[index] == null)
{
return null;
}
else
{
return DateTime.Parse( row[key].ToString());
return DateTime.Parse(row[index].ToString());
}
}
catch (Exception ex)
public static decimal? DataRowToNumber(this DataRow row,int index)
{
return null;
}
}
public static decimal? DataRowToNumber(this DataRow row, string key)
{
try
{
if (row[key] == null)
if (row[index] == null)
{
return null;
}
else
{
return decimal.Parse( row[key].ToString());
}
}
catch (Exception ex)
{
return null;
return decimal.Parse(row[index].ToString());
}
}
......
......@@ -54,10 +54,10 @@ namespace ResetOutofstock
//new AmazonDataSynchroService().SynchroFinancialEventGroups();
//new AmazonDataSynchroService().SynchroReportIds();
//new AmazonDataSynchroService().SynchroReportIds(FikaAmazonAPI.Utils.Constants.ReportTypes.GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL);
//new AmazonDataSynchroService().SynchroReportIds(FikaAmazonAPI.Utils.Constants.ReportTypes.GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL,10);
//while (true)
//{
// new AmazonDataSynchroService().AnaFbaShipmentReport();
// new AmazonDataSynchroService().AnaReport(-1);
//}
}
catch (Exception ex)
......
......@@ -623,7 +623,7 @@ namespace ResetOutofstock
try
{
Console.WriteLine($"开始 拉取亚马逊费用流水,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new AmazonDataSynchroService().SynchroReportIds(FikaAmazonAPI.Utils.Constants.ReportTypes.GET_V2_SETTLEMENT_REPORT_DATA_XML);
new AmazonDataSynchroService().SynchroReportIds(FikaAmazonAPI.Utils.Constants.ReportTypes.GET_V2_SETTLEMENT_REPORT_DATA_XML,9);
Console.WriteLine($"结束 拉取亚马逊费用流水,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(1000 * 60 * 3 );
}
......@@ -645,7 +645,7 @@ namespace ResetOutofstock
try
{
Console.WriteLine($"开始 拉取亚马逊 fba发货,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new AmazonDataSynchroService().SynchroReportIds(FikaAmazonAPI.Utils.Constants.ReportTypes.GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL);
new AmazonDataSynchroService().SynchroReportIds(FikaAmazonAPI.Utils.Constants.ReportTypes.GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL,9);
Console.WriteLine($"结束 拉取亚马逊 fba发货,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(1000 * 60 * 3 );
}
......
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