|
|
@ -49,23 +49,23 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<List<FeeRecordRes>> GetListByPage(PageRequest request)
|
|
|
|
public async Task<DataResult<List<FeeRecordRes>>> GetListByPageAsync(PageRequest request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
long userId = long.Parse(user.UserId);
|
|
|
|
long userId = long.Parse(user.UserId);
|
|
|
|
//序列化查询条件
|
|
|
|
//序列化查询条件
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
var data = tenantDb.Queryable<FeeRecord>()
|
|
|
|
var data = await tenantDb.Queryable<FeeRecord>()
|
|
|
|
.Where(x => x.IsOpen || (!x.IsOpen && x.CreateBy == userId))
|
|
|
|
.Where(x => x.IsOpen || (!x.IsOpen && x.CreateBy == userId))
|
|
|
|
.Where(whereList)
|
|
|
|
.Where(whereList)
|
|
|
|
.Select<FeeRecordRes>()
|
|
|
|
.Select<FeeRecordRes>()
|
|
|
|
.ToQueryPage(request.PageCondition);
|
|
|
|
.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
|
|
//关联用户名称
|
|
|
|
//关联用户名称
|
|
|
|
var userIds = data.Data.Where(x => x.UpdateBy.HasValue).Select(x => x.UpdateBy.Value)
|
|
|
|
var userIds = data.Data.Where(x => x.UpdateBy.HasValue).Select(x => x.UpdateBy.Value)
|
|
|
|
//.Union(data.Data.Where(x => x.SubmitBy.HasValue).Select(x => x.SubmitBy.Value))
|
|
|
|
//.Union(data.Data.Where(x => x.SubmitBy.HasValue).Select(x => x.SubmitBy.Value))
|
|
|
|
.Union(data.Data.Select(x => x.CreateBy)).Distinct();
|
|
|
|
.Union(data.Data.Select(x => x.CreateBy)).Distinct();
|
|
|
|
var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
var users = await db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
foreach (var item in data.Data)
|
|
|
|
foreach (var item in data.Data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
@ -89,7 +89,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="query"></param>
|
|
|
|
/// <param name="query"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<List<FeeRecord>> GetList(string query)
|
|
|
|
public async Task<DataResult<List<FeeRecord>>> GetListAsync(string query)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
long userId = long.Parse(user.UserId);
|
|
|
|
long userId = long.Parse(user.UserId);
|
|
|
@ -101,7 +101,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
src = src.Where(whereList);
|
|
|
|
src = src.Where(whereList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var data = src.ToList();
|
|
|
|
var data = await src.ToListAsync();
|
|
|
|
return new DataResult<List<FeeRecord>>(ResultCode.Success) { Data = data };
|
|
|
|
return new DataResult<List<FeeRecord>>(ResultCode.Success) { Data = data };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="type">锁定范围</param>
|
|
|
|
/// <param name="type">锁定范围</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
bool IsFeeLocked(long bid, BusinessType businessType, FeeType type = FeeType.All)
|
|
|
|
internal async Task<bool> IsFeeLockedAsync(long bid, BusinessType businessType, FeeType type = FeeType.All)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
bool? isFeeLocking = null;
|
|
|
|
bool? isFeeLocking = null;
|
|
|
@ -123,8 +123,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
case FeeType.Payable:
|
|
|
|
case FeeType.Payable:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case FeeType.All:
|
|
|
|
case FeeType.All:
|
|
|
|
isFeeLocking = tenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
isFeeLocking = await tenantDb.Queryable<BusinessFeeStatus>().Where(
|
|
|
|
x => x.BusinessId == bid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).First();
|
|
|
|
x => x.BusinessId == bid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).FirstAsync();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isFeeLocking.GetValueOrDefault();
|
|
|
|
return isFeeLocking.GetValueOrDefault();
|
|
|
@ -135,29 +135,29 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="items">要提交的费用记录</param>
|
|
|
|
/// <param name="items">要提交的费用记录</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult InsertOrUpdate(IEnumerable<FeeRecord> items)
|
|
|
|
public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault();
|
|
|
|
var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault();
|
|
|
|
if (IsFeeLocked(first.BusinessId, first.BusinessType))
|
|
|
|
if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType))
|
|
|
|
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
var feeIds = items.Where(x => x.Id > 0).Select(x => x.Id).ToArray();
|
|
|
|
var feeIds = items.Where(x => x.Id > 0).Select(x => x.Id).ToArray();
|
|
|
|
//包含修改的项,需要检测费用状态再修改
|
|
|
|
//包含修改的项,需要检测费用状态再修改
|
|
|
|
if (feeIds.Length > 0)
|
|
|
|
if (feeIds.Length > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var fees = tenantDb.Queryable<FeeRecord>().Where(x => feeIds.Contains(x.Id)).Select(x => new FeeRecord
|
|
|
|
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => feeIds.Contains(x.Id)).Select(x => new FeeRecord
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
foreach (var fe in fees)
|
|
|
|
foreach (var fe in fees)
|
|
|
@ -173,7 +173,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
FetchExchangeRate(tenantDb, items);
|
|
|
|
await FetchExchangeRateAsync(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)
|
|
|
@ -184,41 +184,42 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.BusinessId = first.BusinessId;
|
|
|
|
item.BusinessId = first.BusinessId;
|
|
|
|
item.BusinessType = first.BusinessType;
|
|
|
|
item.BusinessType = first.BusinessType;
|
|
|
|
tenantDb.Insertable(item).ExecuteCommand();
|
|
|
|
await tenantDb.Insertable(item).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Updateable(item).IgnoreColumns(x => new
|
|
|
|
await tenantDb.Updateable(item).IgnoreColumns(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.FeeStatus,
|
|
|
|
x.FeeStatus,
|
|
|
|
x.CreateBy,
|
|
|
|
x.CreateBy,
|
|
|
|
x.CreateTime,
|
|
|
|
x.CreateTime,
|
|
|
|
x.BusinessId,
|
|
|
|
x.BusinessId,
|
|
|
|
|
|
|
|
x.BusinessType,
|
|
|
|
x.DeleteBy,
|
|
|
|
x.DeleteBy,
|
|
|
|
x.Deleted,
|
|
|
|
x.Deleted,
|
|
|
|
x.DeleteTime,
|
|
|
|
x.DeleteTime,
|
|
|
|
x.SubmitDate,
|
|
|
|
x.SubmitDate,
|
|
|
|
x.SubmitBy
|
|
|
|
x.SubmitBy
|
|
|
|
}).ExecuteCommand();
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(item);
|
|
|
|
list.Add(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
await tenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
|
|
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 (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
await tenantDb.Ado.RollbackTranAsync();
|
|
|
|
ex.Log(db);
|
|
|
|
await ex.LogAsync(db);
|
|
|
|
return DataResult.Failed("保存失败", MultiLanguageConst.DataUpdateFailed);
|
|
|
|
return DataResult.Failed("保存失败", MultiLanguageConst.DataUpdateFailed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WriteBackStatus(tenantDb, first.BusinessId, first.BusinessType);
|
|
|
|
await WriteBackStatusAsync(tenantDb, first.BusinessId, first.BusinessType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -229,17 +230,17 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="tidArray">模板ID</param>
|
|
|
|
/// <param name="tidArray">模板ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult CreateByTemplate(long bid, BusinessType businessType, params long[] tidArray)
|
|
|
|
public async Task<DataResult> CreateByTemplateAsync(long bid, BusinessType businessType, params long[] tidArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
bool hasExists = tenantDb.Queryable<FeeRecord>().LeftJoin<FeeTemplateDetail>((x, y) =>
|
|
|
|
bool hasExists = tenantDb.Queryable<FeeRecord>().LeftJoin<FeeTemplateDetail>((x, y) =>
|
|
|
|
x.FeeId == y.FeeId && x.FeeType == y.FeeType).Any((x, y) =>
|
|
|
|
x.FeeId == y.FeeId && x.FeeType == y.FeeType).Any(
|
|
|
|
x.BusinessId == bid && x.BusinessType == businessType && tidArray.Contains(y.TemplateId) && !y.Deleted);
|
|
|
|
(x, y) => x.BusinessId == bid && x.BusinessType == businessType && tidArray.Contains(y.TemplateId));
|
|
|
|
if (hasExists)
|
|
|
|
if (hasExists)
|
|
|
|
return DataResult.Failed("费用记录已存在", MultiLanguageConst.FeeRecordExist);
|
|
|
|
return DataResult.Failed("费用记录已存在", MultiLanguageConst.FeeRecordExist);
|
|
|
|
|
|
|
|
|
|
|
|
var details = tenantDb.Queryable<FeeTemplateDetail>().Where(x => tidArray.Contains(x.TemplateId) && !x.Deleted).Select(x => new
|
|
|
|
var details = await tenantDb.Queryable<FeeTemplateDetail>().Where(x => tidArray.Contains(x.TemplateId) && !x.Deleted).Select(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.FeeType,
|
|
|
|
x.FeeType,
|
|
|
|
x.FeeId,
|
|
|
|
x.FeeId,
|
|
|
@ -261,7 +262,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
x.IsInvoice,
|
|
|
|
x.IsInvoice,
|
|
|
|
x.SaleOrgId,
|
|
|
|
x.SaleOrgId,
|
|
|
|
x.Note
|
|
|
|
x.Note
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
List<FeeRecord> records = new List<FeeRecord>(details.Count);
|
|
|
|
List<FeeRecord> records = new List<FeeRecord>(details.Count);
|
|
|
|
foreach (var item in details)
|
|
|
|
foreach (var item in details)
|
|
|
@ -274,11 +275,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
FetchExchangeRate(tenantDb, records);
|
|
|
|
await FetchExchangeRateAsync(tenantDb, records);
|
|
|
|
|
|
|
|
int result = await tenantDb.Insertable(records).ExecuteCommandAsync();
|
|
|
|
int result = tenantDb.Insertable(records).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteBackStatus(tenantDb, bid, businessType);
|
|
|
|
await WriteBackStatusAsync(tenantDb, bid, businessType);
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -288,20 +288,20 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ids">费用记录ID</param>
|
|
|
|
/// <param name="ids">费用记录ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult Delete(params long[] ids)
|
|
|
|
public async Task<DataResult> DeleteAsync(params long[] ids)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
|
|
var model = tenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new { x.BusinessId, x.BusinessType }).First();
|
|
|
|
var model = await tenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new { x.BusinessId, x.BusinessType }).FirstAsync();
|
|
|
|
if (IsFeeLocked(model.BusinessId, model.BusinessType))
|
|
|
|
if (await IsFeeLockedAsync(model.BusinessId, model.BusinessType))
|
|
|
|
return DataResult.Failed("当前业务已费用锁定,禁止修改", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("当前业务已费用锁定,禁止修改", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
|
if (tenantDb.Queryable<FeeRecord>().Any(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission)))
|
|
|
|
if (await tenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission)))
|
|
|
|
return DataResult.Failed("只能删除状态为‘录入’或‘驳回提交’的费用", MultiLanguageConst.FeeRecordDelete);
|
|
|
|
return DataResult.Failed("只能删除状态为‘录入’或‘驳回提交’的费用", MultiLanguageConst.FeeRecordDelete);
|
|
|
|
|
|
|
|
|
|
|
|
int result = tenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommand();
|
|
|
|
int result = await tenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
WriteBackStatus(tenantDb, model.BusinessId, model.BusinessType);
|
|
|
|
await WriteBackStatusAsync(tenantDb, model.BusinessId, model.BusinessType);
|
|
|
|
|
|
|
|
|
|
|
|
return result > 0 ? DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess) : DataResult.Failed("删除失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return result > 0 ? DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess) : DataResult.Failed("删除失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -313,10 +313,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="remark">备注</param>
|
|
|
|
/// <param name="remark">备注</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult SubmitForApproval(FeeAuditType auditType, string remark, params long[] idArray)
|
|
|
|
public async Task<DataResult> SubmitForApprovalAsync(FeeAuditType auditType, string remark, params long[] idArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
|
|
|
|
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
|
|
|
|
x => new FeeRecord
|
|
|
|
x => new FeeRecord
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
@ -324,14 +324,14 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
FeeStatus = x.FeeStatus,
|
|
|
|
FeeStatus = x.FeeStatus,
|
|
|
|
FlowId = x.FlowId,
|
|
|
|
FlowId = x.FlowId,
|
|
|
|
BusinessId = x.BusinessId
|
|
|
|
BusinessId = x.BusinessId
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
if (fees.IsNullOrEmpty())
|
|
|
|
if (fees.IsNullOrEmpty())
|
|
|
|
return DataResult.Failed($"未能获取费用信息,提交失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed($"未能获取费用信息,提交失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
|
var bid = fees[0].BusinessId;
|
|
|
|
var bid = fees[0].BusinessId;
|
|
|
|
var bType = fees[0].BusinessType;
|
|
|
|
var bType = fees[0].BusinessType;
|
|
|
|
//业务状态检测
|
|
|
|
//业务状态检测
|
|
|
|
if (IsFeeLocked(bid, bType))
|
|
|
|
if (await IsFeeLockedAsync(bid, bType))
|
|
|
|
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
|
if (fees.Any(x => x.FlowId.HasValue))
|
|
|
|
if (fees.Any(x => x.FlowId.HasValue))
|
|
|
@ -341,7 +341,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return DataResult.Failed($"当前审批费用包含已结算/部分结算的费用,无法提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed($"当前审批费用包含已结算/部分结算的费用,无法提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
|
DataResult result = DataResult.Failed(string.Empty, MultiLanguageConst.Operation_Failed);
|
|
|
|
DataResult result = DataResult.Failed(string.Empty, MultiLanguageConst.Operation_Failed);
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (auditType == FeeAuditType.ApplyAudit)
|
|
|
|
if (auditType == FeeAuditType.ApplyAudit)
|
|
|
@ -355,25 +355,25 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
if (!result.Succeeded)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
await tenantDb.Ado.RollbackTranAsync();
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(fees).UpdateColumns(x => new
|
|
|
|
await tenantDb.Updateable(fees).UpdateColumns(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.Id,
|
|
|
|
x.Id,
|
|
|
|
x.FeeStatus,
|
|
|
|
x.FeeStatus,
|
|
|
|
x.SubmitBy,
|
|
|
|
x.SubmitBy,
|
|
|
|
x.SubmitDate,
|
|
|
|
x.SubmitDate,
|
|
|
|
x.FlowId
|
|
|
|
x.FlowId
|
|
|
|
}).ExecuteCommand();
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
await tenantDb.Ado.CommitTranAsync();
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
await tenantDb.Ado.RollbackTranAsync();
|
|
|
|
ex.Log(db);
|
|
|
|
await ex.LogAsync(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -472,16 +472,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="items">费用修改信息</param>
|
|
|
|
/// <param name="items">费用修改信息</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult SubmitForModification(IEnumerable<FeeModification> items)
|
|
|
|
public async Task<DataResult> SubmitForModificationAsync(IEnumerable<FeeModification> items)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var idList = items.Select(x => x.FeeRecordId).Distinct().ToList();
|
|
|
|
var idList = items.Select(x => x.FeeRecordId).Distinct().ToList();
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idList.Contains(x.Id)).Select(x => new FeeRecord
|
|
|
|
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idList.Contains(x.Id)).Select(x => new FeeRecord
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
if (fees.Count == 0)
|
|
|
|
if (fees.Count == 0)
|
|
|
|
return DataResult.Failed("未能获取费用信息", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("未能获取费用信息", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
@ -502,7 +502,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var fee in fees)
|
|
|
|
foreach (var fee in fees)
|
|
|
@ -528,16 +528,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var list = items.ToList();
|
|
|
|
var list = items.ToList();
|
|
|
|
tenantDb.Insertable(list).ExecuteCommand();
|
|
|
|
await tenantDb.Insertable(list).ExecuteCommandAsync();
|
|
|
|
tenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommand();
|
|
|
|
await tenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
await tenantDb.Ado.CommitTranAsync();
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
await tenantDb.Ado.RollbackTranAsync();
|
|
|
|
ex.Log(db);
|
|
|
|
await ex.LogAsync(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -547,17 +547,17 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult Withdraw(params long[] idArray)
|
|
|
|
public async Task<DataResult> WithdrawAsync(params long[] idArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
|
|
|
|
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
|
|
|
|
x => new FeeRecord
|
|
|
|
x => new FeeRecord
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
FeeStatus = x.FeeStatus,
|
|
|
|
FeeStatus = x.FeeStatus,
|
|
|
|
FlowId = x.FlowId
|
|
|
|
FlowId = x.FlowId
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (fees.IsNullOrEmpty())
|
|
|
|
if (fees.IsNullOrEmpty())
|
|
|
|
return DataResult.Failed("未能找到费用记录", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("未能找到费用记录", MultiLanguageConst.Operation_Failed);
|
|
|
@ -574,8 +574,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
await tenantDb.Ado.BeginTranAsync();
|
|
|
|
db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommand();
|
|
|
|
await db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in fees)
|
|
|
|
foreach (var item in fees)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -588,11 +588,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
item.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
item.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
|
|
|
|
|
|
|
//删除暂存数据
|
|
|
|
//删除暂存数据
|
|
|
|
var entity = tenantDb.Queryable<FeeModification>().OrderByDescending(
|
|
|
|
var entity = await tenantDb.Queryable<FeeModification>().OrderByDescending(
|
|
|
|
x => x.CreateTime).Select(x => new { x.Id, x.FeeRecordId }).First(x => x.FeeRecordId == item.Id);
|
|
|
|
x => x.CreateTime).Select(x => new { x.Id, x.FeeRecordId }).FirstAsync(x => x.FeeRecordId == item.Id);
|
|
|
|
if (entity != null)
|
|
|
|
if (entity != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Deleteable<FeeModification>().Where(x => x.Id == entity.Id).ExecuteCommand();
|
|
|
|
await tenantDb.Deleteable<FeeModification>().Where(x => x.Id == entity.Id).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case FeeStatus.ApplyDeletion:
|
|
|
|
case FeeStatus.ApplyDeletion:
|
|
|
@ -605,15 +605,15 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
item.FlowId = null;
|
|
|
|
item.FlowId = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(fees).UpdateColumns(x => new { x.Id, x.FeeStatus, x.SubmitBy, x.SubmitDate, x.FlowId }).ExecuteCommand();
|
|
|
|
await tenantDb.Updateable(fees).UpdateColumns(x => new { x.Id, x.FeeStatus, x.SubmitBy, x.SubmitDate, x.FlowId }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
await tenantDb.Ado.CommitTranAsync();
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
await tenantDb.Ado.RollbackTranAsync();
|
|
|
|
ex.Log(db);
|
|
|
|
await ex.LogAsync(db);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -625,17 +625,17 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="bid">业务ID</param>
|
|
|
|
/// <param name="bid">业务ID</param>
|
|
|
|
/// <param name="type">业务类型</param>
|
|
|
|
/// <param name="type">业务类型</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult SubmitBusinessAudit(long bid, BusinessType type)
|
|
|
|
public async Task<DataResult> SubmitBusinessAuditAsync(long bid, BusinessType type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var entity = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == bid &&
|
|
|
|
var entity = await tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == bid &&
|
|
|
|
x.BusinessType == BusinessType.OceanShippingExport).Select(x => new BusinessFeeStatus
|
|
|
|
x.BusinessType == BusinessType.OceanShippingExport).Select(x => new BusinessFeeStatus
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
IsFeeLocking = x.IsFeeLocking,
|
|
|
|
IsFeeLocking = x.IsFeeLocking,
|
|
|
|
BillAuditStatus = x.BillAuditStatus,
|
|
|
|
BillAuditStatus = x.BillAuditStatus,
|
|
|
|
FlowId = x.FlowId
|
|
|
|
FlowId = x.FlowId
|
|
|
|
}).First();
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (entity == null)
|
|
|
|
if (entity == null)
|
|
|
|
return DataResult.Failed("未能找到业务信息", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("未能找到业务信息", MultiLanguageConst.Operation_Failed);
|
|
|
@ -666,14 +666,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
entity.BillFeeStatusTime = DateTime.Now;
|
|
|
|
entity.BillFeeStatusTime = DateTime.Now;
|
|
|
|
entity.FlowId = instance.Id;
|
|
|
|
entity.FlowId = instance.Id;
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
await tenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.BillAuditStatus,
|
|
|
|
x.BillAuditStatus,
|
|
|
|
x.BillFeeStatusTime,
|
|
|
|
x.BillFeeStatusTime,
|
|
|
|
x.FlowId
|
|
|
|
x.FlowId
|
|
|
|
}).ExecuteCommand();
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改关联费用状态为提交审核
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -686,11 +688,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="enabled">是否启用</param>
|
|
|
|
/// <param name="enabled">是否启用</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult SetInvoiceEnabled(bool enabled, params long[] idArray)
|
|
|
|
public async Task<DataResult> SetInvoiceEnabledAsync(bool enabled, params long[] idArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var list = idArray.Select(x => new FeeRecord { Id = x, IsInvoice = enabled }).ToList();
|
|
|
|
var list = idArray.Select(x => new FeeRecord { Id = x, IsInvoice = enabled }).ToList();
|
|
|
|
int rows = tenantDb.Updateable(list).UpdateColumns(x => new { x.IsInvoice }).ExecuteCommand();
|
|
|
|
int rows = await tenantDb.Updateable(list).UpdateColumns(x => new { x.IsInvoice }).ExecuteCommandAsync();
|
|
|
|
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -701,15 +703,15 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="customerType">客户类别</param>
|
|
|
|
/// <param name="customerType">客户类别</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult SetCustomer(long customerId, string customerType, params long[] idArray)
|
|
|
|
public async Task<DataResult> SetCustomerAsync(long customerId, string customerType, params long[] idArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var model = tenantDb.Queryable<InfoClient>().Where(x => x.Id == customerId).Select(x => new
|
|
|
|
var model = await tenantDb.Queryable<InfoClient>().Where(x => x.Id == customerId).Select(x => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = customerId,
|
|
|
|
Id = customerId,
|
|
|
|
x.CodeName,
|
|
|
|
x.CodeName,
|
|
|
|
x.Name
|
|
|
|
x.Name
|
|
|
|
}).First();
|
|
|
|
}).FirstAsync();
|
|
|
|
if (model == null)
|
|
|
|
if (model == null)
|
|
|
|
return DataResult.Failed("未能找到费用对象信息,设置失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return DataResult.Failed("未能找到费用对象信息,设置失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
|
@ -721,7 +723,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
CustomerName = model.Name,
|
|
|
|
CustomerName = model.Name,
|
|
|
|
CustomerType = customerType
|
|
|
|
CustomerType = customerType
|
|
|
|
}).ToList();
|
|
|
|
}).ToList();
|
|
|
|
int rows = tenantDb.Updateable(list).UpdateColumns(x => new { x.CustomerId, x.CustomerCode, x.CustomerName, x.CustomerType }).ExecuteCommand();
|
|
|
|
int rows = await tenantDb.Updateable(list).UpdateColumns(x => new { x.CustomerId, x.CustomerCode, x.CustomerName, x.CustomerType }).ExecuteCommandAsync();
|
|
|
|
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -731,16 +733,14 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<CostAccountingForm> GetPrintInfo(BusinessType businessType, params long[] idArray)
|
|
|
|
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(BusinessType businessType, params long[] idArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CostAccountingForm form = null;
|
|
|
|
CostAccountingForm form = null;
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
switch (businessType)
|
|
|
|
switch (businessType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//case BusinessType.ChangeOrder:
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
case BusinessType.OceanShippingExport:
|
|
|
|
case BusinessType.OceanShippingExport:
|
|
|
|
form = GetOceanShippingExportForm(tenantDb, idArray);
|
|
|
|
form = await GetOceanShippingExportAsync(tenantDb, idArray);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case BusinessType.OceanShippingImport:
|
|
|
|
case BusinessType.OceanShippingImport:
|
|
|
|
|
|
|
|
|
|
|
@ -767,7 +767,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
new FeeRecord { Currency = "USD", FeeType = FeeType.Receivable },
|
|
|
|
new FeeRecord { Currency = "USD", FeeType = FeeType.Receivable },
|
|
|
|
new FeeRecord { Currency = "USD", FeeType = FeeType.Payable }
|
|
|
|
new FeeRecord { Currency = "USD", FeeType = FeeType.Payable }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
FetchExchangeRate(tenantDb, fees);
|
|
|
|
await FetchExchangeRateAsync(tenantDb, fees);
|
|
|
|
form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;
|
|
|
|
form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;
|
|
|
|
form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
|
|
|
|
form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
|
|
|
|
form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
|
|
|
|
form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
|
|
|
@ -776,11 +776,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return DataResult<CostAccountingForm>.Success(form);
|
|
|
|
return DataResult<CostAccountingForm>.Success(form);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取海运出口打印数据
|
|
|
|
CostAccountingForm GetOceanShippingExportForm(SqlSugarScopeProvider tenantDb, params long[] idArray)
|
|
|
|
async Task<CostAccountingForm> GetOceanShippingExportAsync(SqlSugarScopeProvider tenantDb, params long[] idArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CostAccountingForm form = null;
|
|
|
|
CostAccountingForm form = null;
|
|
|
|
var list = tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
|
|
|
|
var list = await tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
|
|
|
|
.Where((x, y) => idArray.Contains(x.Id)
|
|
|
|
.Where((x, y) => idArray.Contains(x.Id)
|
|
|
|
//&& x.FeeStatus == FeeStatus.SettlementCompleted
|
|
|
|
//&& x.FeeStatus == FeeStatus.SettlementCompleted
|
|
|
|
).Select((x, y) => new
|
|
|
|
).Select((x, y) => new
|
|
|
@ -802,7 +802,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
y.DischargePort,
|
|
|
|
y.DischargePort,
|
|
|
|
y.CntrTotal, //Volume
|
|
|
|
y.CntrTotal, //Volume
|
|
|
|
y.IssueType //放单方式
|
|
|
|
y.IssueType //放单方式
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
if (list.Count == 0)
|
|
|
|
return form;
|
|
|
|
return form;
|
|
|
@ -835,21 +835,23 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return form;
|
|
|
|
return form;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//回写业务主表的费用状态
|
|
|
|
/// <summary>
|
|
|
|
internal static void WriteBackStatus(SqlSugarScopeProvider tenantDb, long businessId, BusinessType businessType)
|
|
|
|
/// 回写业务表费用状态
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="tenantDb"></param>
|
|
|
|
|
|
|
|
/// <param name="businessId">业务ID</param>
|
|
|
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task WriteBackStatusAsync(SqlSugarScopeProvider tenantDb, long businessId, BusinessType businessType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var fees = tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType)
|
|
|
|
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType)
|
|
|
|
.Select(x => new FeeRecord
|
|
|
|
.Select(x => new FeeRecord
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//BusinessId = businessId,
|
|
|
|
|
|
|
|
//BusinessType = businessType,
|
|
|
|
|
|
|
|
FeeType = x.FeeType,
|
|
|
|
FeeType = x.FeeType,
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
}).ToList();
|
|
|
|
}).ToListAsync();
|
|
|
|
if (fees.IsNullOrEmpty())
|
|
|
|
if (fees.IsNullOrEmpty())
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var arFeeStatus = DetermineStatus(fees.FindAll(x => x.FeeType == FeeType.Receivable));
|
|
|
|
var arFeeStatus = DetermineStatus(fees.FindAll(x => x.FeeType == FeeType.Receivable));
|
|
|
|
var apFeeStatus = DetermineStatus(fees.FindAll(x => x.FeeType == FeeType.Payable));
|
|
|
|
var apFeeStatus = DetermineStatus(fees.FindAll(x => x.FeeType == FeeType.Payable));
|
|
|
@ -866,8 +868,14 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
upt = upt.SetColumns(x => x.APFeeStatus == apFeeStatus);
|
|
|
|
upt = upt.SetColumns(x => x.APFeeStatus == apFeeStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
upt.Where(x => x.BusinessType == businessType && x.BusinessId == businessId)
|
|
|
|
try
|
|
|
|
.ExecuteCommand();
|
|
|
|
{
|
|
|
|
|
|
|
|
await upt.Where(x => x.BusinessType == businessType && x.BusinessId == businessId).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await ex.LogAsync(db);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -879,6 +887,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
billFeeStatus = BillFeeStatus.NotEntered;
|
|
|
|
billFeeStatus = BillFeeStatus.NotEntered;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//全状态
|
|
|
|
else if (fees.All(x => x.FeeStatus == FeeStatus.Entering))
|
|
|
|
else if (fees.All(x => x.FeeStatus == FeeStatus.Entering))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
billFeeStatus = BillFeeStatus.Entering;
|
|
|
|
billFeeStatus = BillFeeStatus.Entering;
|
|
|
@ -903,6 +912,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
billFeeStatus = BillFeeStatus.SettlementCompleted;
|
|
|
|
billFeeStatus = BillFeeStatus.SettlementCompleted;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//部分状态
|
|
|
|
else if (fees.Any(x => x.FeeStatus == FeeStatus.Entering))
|
|
|
|
else if (fees.Any(x => x.FeeStatus == FeeStatus.Entering))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
billFeeStatus = BillFeeStatus.PartialEntering;
|
|
|
|
billFeeStatus = BillFeeStatus.PartialEntering;
|
|
|
@ -933,13 +943,13 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取汇率
|
|
|
|
//获取汇率
|
|
|
|
void FetchExchangeRate(SqlSugarScopeProvider tenantDb, IEnumerable<FeeRecord> items)
|
|
|
|
async Task FetchExchangeRateAsync(SqlSugarScopeProvider tenantDb, IEnumerable<FeeRecord> items)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var exRecords = items.Where(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency).ToList();
|
|
|
|
var exRecords = items.Where(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency).ToList();
|
|
|
|
if (exRecords.Count > 0)
|
|
|
|
if (exRecords.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
|
|
|
|
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();
|
|
|
|
var currencies = await tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToListAsync();
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
foreach (var item in exRecords)
|
|
|
|
foreach (var item in exRecords)
|
|
|
|
{
|
|
|
|
{
|
|
|
|