|
|
@ -156,6 +156,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
|
|
|
|
FetchExchangeRate(tenantDb, items);
|
|
|
|
|
|
|
|
|
|
|
|
List<FeeRecord> list = new List<FeeRecord>(items.Count());
|
|
|
|
List<FeeRecord> list = new List<FeeRecord>(items.Count());
|
|
|
|
foreach (var item in items)
|
|
|
|
foreach (var item in items)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -190,15 +193,43 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
var list2 = list.Select(x => x.Adapt<FeeRecordRes>()).ToList();
|
|
|
|
var list2 = list.Select(x => x.Adapt<FeeRecordRes>()).ToList();
|
|
|
|
return DataResult.Successed("保存成功", list2, MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("保存成功", list2, MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
//throw;
|
|
|
|
ex.Log(db);
|
|
|
|
return DataResult.Failed("保存失败", MultiLanguageConst.DataUpdateFailed);
|
|
|
|
return DataResult.Failed("保存失败", MultiLanguageConst.DataUpdateFailed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FetchExchangeRate(SqlSugarScopeProvider tenantDb, IEnumerable<FeeRecord> records)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var exRecords = records.Where(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency).ToList();
|
|
|
|
|
|
|
|
if (exRecords.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
|
|
|
|
|
|
|
|
var currencies = tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToList();
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//取当前时间范围内的最新一条
|
|
|
|
|
|
|
|
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 == 1 ? exchange.DRValue : exchange.CRValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 根据模板ID创建
|
|
|
|
/// 根据模板ID创建
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -250,30 +281,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
var exRecords = records.FindAll(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency);
|
|
|
|
FetchExchangeRate(tenantDb, records);
|
|
|
|
if (exRecords.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
|
|
|
|
|
|
|
|
var currencies = tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToList();
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//取当前时间范围内的最新一条
|
|
|
|
|
|
|
|
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 == 1 ? exchange.DRValue : exchange.CRValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = tenantDb.Insertable(records).ExecuteCommand();
|
|
|
|
int result = tenantDb.Insertable(records).ExecuteCommand();
|
|
|
|
return result > 0 ? DataResult.Successed("保存成功", records, MultiLanguageConst.DataCreateSuccess) : DataResult.Successed("操作失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return result > 0 ? DataResult.Successed("保存成功", records, MultiLanguageConst.DataCreateSuccess) : DataResult.Successed("操作失败!", MultiLanguageConst.Operation_Failed);
|
|
|
@ -375,6 +383,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
|
|
|
|
ex.Log(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -509,8 +518,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Insertable<FeeModification>(items).ExecuteCommand();
|
|
|
|
var list = items.ToList();
|
|
|
|
tenantDb.Updateable<FeeRecord>(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommand();
|
|
|
|
tenantDb.Insertable(list).ExecuteCommand();
|
|
|
|
|
|
|
|
tenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
@ -518,7 +528,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
//todo:记录错误日志
|
|
|
|
ex.Log(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -641,10 +651,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
//todo:记录错误日志
|
|
|
|
ex.Log(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -676,12 +686,12 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return DataResult.Failed($"以下费用项:{msg} 未在审批状态中,无需撤销", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed($"以下费用项:{msg} 未在审批状态中,无需撤销", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty });
|
|
|
|
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty }).ToList();
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
tenantDb.Updateable<FlowInstance>(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommand();
|
|
|
|
db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in fees)
|
|
|
|
foreach (var item in fees)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -711,7 +721,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
//todo:记录错误日志
|
|
|
|
ex.Log(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -724,7 +734,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
//public DataResult AuditBusiness(int type, long bid)
|
|
|
|
//public DataResult AuditBusiness(int type, long bid)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|