|
|
|
@ -205,7 +205,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task FetchExchangeRateAsync(IEnumerable<FeeRecord> items)
|
|
|
|
|
{
|
|
|
|
|
var exRecords = items.Where(x => x.ExchangeRate == null && x.Currency != x.LocalCurrency);
|
|
|
|
|
var exRecords = items.Where(x => x.Currency != x.LocalCurrency);
|
|
|
|
|
if (exRecords.Any())
|
|
|
|
|
{
|
|
|
|
|
var exchanges = exRecords.GroupBy(x => new
|
|
|
|
@ -233,27 +233,6 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
item.ExchangeRate = exchangeRates.Find(x => x.CurrencyFrom == item.Currency &&
|
|
|
|
|
x.CurrencyTo == item.LocalCurrency && x.FeeType == item.FeeType)?.Rate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
|
|
|
|
|
//var currencies = await TenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToListAsync();
|
|
|
|
|
//DateTime dtNow = DateTime.Now;
|
|
|
|
|
//foreach (var item in exRecords)
|
|
|
|
|
//{
|
|
|
|
|
// var currency = currencies.Find(x => x.CodeName == item.Currency);
|
|
|
|
|
// if (currency != null)
|
|
|
|
|
// {
|
|
|
|
|
// item.ExchangeRate = currency.DefaultRate;
|
|
|
|
|
// if (currency.Exchanges != null && currency.Exchanges.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// //取当前时间范围内的最新一条
|
|
|
|
|
// var exchange = currency.Exchanges.FindAll(x => x.Status == StatusEnum.Enable &&
|
|
|
|
|
// x.StartDate >= dtNow && x.EndDate <= dtNow).OrderByDescending(x => x.UpdateTime).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
// if (exchange != null)
|
|
|
|
|
// item.ExchangeRate = item.FeeType == FeeType.Receivable ? exchange.DRValue : exchange.CRValue;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|