mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
Feature repricing min max (#10)
amazon settlement import/export improvements
This commit is contained in:
@@ -36,33 +36,32 @@ namespace bnhtrade.Core.Logic.AmazonFBAInbound
|
||||
shipmentRequest.LastUpdatedAfter = dateTimeAfter.AddDays(-14);
|
||||
shipmentRequest.LastUpdatedBefore = dateTimeBefore;
|
||||
|
||||
List<Model.AmazonFBAInbound.ShipmentInfo> shipmentInfoList = shipmentRequest.GetShipmentInfo();
|
||||
List<Model.AmazonFba.ShipmentInfo> shipmentInfoList = shipmentRequest.GetShipmentInfo();
|
||||
|
||||
// build list of shipments returned from mws
|
||||
var dicShipExistsInDb = new Dictionary<string, bool>();
|
||||
foreach (var item in shipmentInfoList)
|
||||
{
|
||||
dicShipExistsInDb.Add(item.AmazonShipmentId, false);
|
||||
dicShipExistsInDb.Add(item.FbaShipmentId, false);
|
||||
}
|
||||
|
||||
// build list of shipmentId that do not exist in database
|
||||
int complete = 0;
|
||||
using (TransactionScope scope = new TransactionScope())
|
||||
{
|
||||
List<Model.AmazonFBAInbound.ShipmentInfo> newShipmentInfoList = null;
|
||||
List<Model.AmazonFba.ShipmentInfo> newShipmentInfoList = null;
|
||||
if (dicShipExistsInDb.Any())
|
||||
{
|
||||
var newShipmentId = new List<string>();
|
||||
|
||||
// query db for shipment header info
|
||||
var requestHeader = new Data.Database.FBAInbound.GetShipmentHeaderInfo(sqlConnectionString);
|
||||
requestHeader.ShipmentIdList = dicShipExistsInDb.Keys.ToList();
|
||||
var resultHeader = requestHeader.Execute();
|
||||
var resultHeader = new Data.Database.AmazonShipment.ReadShipmentInfo(sqlConnectionString)
|
||||
.HeaderByFbaShipmentId(dicShipExistsInDb.Keys.ToList());
|
||||
|
||||
// compare db and mws result
|
||||
foreach (var item in resultHeader)
|
||||
{
|
||||
dicShipExistsInDb[item.AmazonShipmentId] = true;
|
||||
dicShipExistsInDb[item.FbaShipmentId] = true;
|
||||
}
|
||||
foreach (var item in dicShipExistsInDb)
|
||||
{
|
||||
@@ -81,7 +80,7 @@ namespace bnhtrade.Core.Logic.AmazonFBAInbound
|
||||
foreach (var item in newShipmentInfoList)
|
||||
{
|
||||
var shipmentItemInfoRequest = new Data.AmazonMWS.FBAInbound.ListInboundShipmentItems();
|
||||
item.ShipmentItemInfoList = shipmentItemInfoRequest.GetByAmazonShipmentId(item.AmazonShipmentId);
|
||||
item.ShipmentItemInfoList = shipmentItemInfoRequest.GetByAmazonShipmentId(item.FbaShipmentId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,10 +90,10 @@ namespace bnhtrade.Core.Logic.AmazonFBAInbound
|
||||
foreach (var item in newShipmentInfoList)
|
||||
{
|
||||
// add the update date
|
||||
item.LastUpdatedUtc = dateTimeBefore;
|
||||
item.LastUpdated = dateTimeBefore;
|
||||
|
||||
// write to db
|
||||
var dbWrite = new Data.Database.FBAInbound.SetShipmentInfo(sqlConnectionString);
|
||||
var dbWrite = new Data.Database.AmazonShipment.SetShipmentInfo(sqlConnectionString);
|
||||
dbWrite.Excecute(item);
|
||||
complete = complete + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user