You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
7.8 KiB
C#
196 lines
7.8 KiB
C#
using DS.Module.Core.Enums;
|
|
using DS.Module.Core;
|
|
using DS.WMS.Core.Fee.Entity;
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
using DS.WMS.Core.Flow.Entity;
|
|
using DS.WMS.Core.Flow.Interface;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using DS.WMS.Core.Fee.Interface;
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
namespace DS.WMS.Core.Fee.Method
|
|
{
|
|
/// <summary>
|
|
/// 费用申请单审核服务
|
|
/// </summary>
|
|
public class FeeApplicationAuditService : FeeServiceBase, IFeeApplicationAuditService
|
|
{
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <param name="serviceProvider"></param>
|
|
public FeeApplicationAuditService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
{
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取申请单明细
|
|
/// </summary>
|
|
/// <param name="id">申请单ID</param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult<List<FeeApplicationDetailDto>>> GetDetailsAsync(long id)
|
|
{
|
|
var details = await TenantDb.Queryable<FeeApplicationDetail>()
|
|
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
|
|
.LeftJoin<BusinessFeeStatus>((d, f, b) => f.BusinessId == b.BusinessId && f.BusinessType == b.BusinessType)
|
|
.Where(d => d.ApplicationId == id)
|
|
.Select((d, f, b) => new FeeApplicationDetailDto
|
|
{
|
|
AccTaxRate = f.AccTaxRate,
|
|
Amount = d.Amount,
|
|
FeeName = d.FeeName,
|
|
FeeType = f.FeeType,
|
|
FeeObject = f.CustomerName,
|
|
OriginalCurrency = d.OriginalCurrency,
|
|
OriginalRate = f.ExchangeRate,
|
|
ExchangeRate = d.ExchangeRate,
|
|
OriginalAmount = d.OriginalAmount,
|
|
BusinessId = b.BusinessId,
|
|
BusinessType = b.BusinessType,
|
|
IsBusinessLocking = b.IsBusinessLocking,
|
|
IsFeeLocking = b.IsFeeLocking
|
|
}).ToListAsync();
|
|
|
|
if (details.Count > 0)
|
|
{
|
|
var gList = details.GroupBy(x => x.BusinessType).ToList();
|
|
foreach (var g in gList)
|
|
{
|
|
var ids = g.Select(x => x.BusinessId).ToList();
|
|
switch (g.Key)
|
|
{
|
|
case BusinessType.OceanShippingExport:
|
|
var list1 = await TenantDb.Queryable<SeaExport>().Where(x => ids.Contains(x.Id)).Select(x => new
|
|
{
|
|
x.Id,
|
|
x.MBLNO,
|
|
x.CustomerNo,
|
|
x.CustomerName,
|
|
x.ETD,
|
|
x.CntrTotal,
|
|
x.AccountDate,
|
|
x.OperatorCode,
|
|
x.Vessel,
|
|
x.Voyno,
|
|
x.Carrier,
|
|
x.Forwarder,
|
|
x.BookingNo
|
|
}).ToListAsync();
|
|
foreach (var item in g)
|
|
{
|
|
var biz = list1.Find(x => x.Id == item.BusinessId);
|
|
if (biz != null)
|
|
{
|
|
item.MBLNO = biz.MBLNO;
|
|
item.CustomerName = biz.CustomerName;
|
|
item.CustomerNo = biz.CustomerNo;
|
|
item.ETD = biz.ETD;
|
|
item.CntrTotal = biz.CntrTotal;
|
|
item.AccountDate = biz.AccountDate;
|
|
item.Operator = biz.OperatorCode;
|
|
item.Vessel = biz.Vessel;
|
|
item.Voyage = biz.Voyno;
|
|
item.Carrier = biz.Carrier;
|
|
item.Forwarder = biz.Forwarder;
|
|
item.BookingNo = biz.BookingNo;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case BusinessType.OceanShippingImport:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return DataResult<List<FeeApplicationDetailDto>>.Success(details);
|
|
}
|
|
|
|
//public async Task<DataResult> AuditAsync()
|
|
//{
|
|
|
|
//}
|
|
|
|
/// <summary>
|
|
/// 根据审批结果更新申请单状态
|
|
/// </summary>
|
|
/// <param name="callback">回调信息</param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult> UpdateStatusAsync(FlowCallback callback)
|
|
{
|
|
var app = await TenantDb.Queryable<FeeApplication>().Where(x => x.Id == callback.BusinessId)
|
|
.Select(x => new FeeApplication
|
|
{
|
|
Id = x.Id,
|
|
Status = x.Status
|
|
}).FirstAsync();
|
|
|
|
var auditType = callback.AuditType.ToEnum<AuditType>();
|
|
long UserId = long.Parse(User.UserId);
|
|
DateTime dtNow = DateTime.Now;
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
try
|
|
{
|
|
switch (auditType)
|
|
{
|
|
case AuditType.PaidApplication:
|
|
app.AuditerId = UserId;
|
|
app.AuditerName = User.UserName;
|
|
app.AuditTime = dtNow;
|
|
app.Reason = callback.RejectReason;
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
{
|
|
app.Status = ApplicationStatus.AuditPassed;
|
|
app.Reason = string.Empty;
|
|
}
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
app.Status = ApplicationStatus.AuditRejected;
|
|
|
|
await TenantDb.Updateable(app).UpdateColumns(x => new
|
|
{
|
|
x.Status,
|
|
x.AuditerId,
|
|
x.AuditerName,
|
|
x.AuditTime,
|
|
x.Reason,
|
|
x.FlowId
|
|
}).ExecuteCommandAsync();
|
|
break;
|
|
|
|
case AuditType.ChargeApplication:
|
|
break;
|
|
|
|
default:
|
|
return DataResult.Failed("不支持的审批类型", MultiLanguageConst.Operation_Failed);
|
|
}
|
|
|
|
//驳回申请则逻辑删除关联工作流
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
{
|
|
await Db.Updateable(new FlowInstance
|
|
{
|
|
Id = callback.InstanceId,
|
|
Deleted = true,
|
|
DeleteBy = 0,
|
|
DeleteTime = DateTime.Now
|
|
}).UpdateColumns(x => new { x.Deleted, x.DeleteBy, x.DeleteTime }).ExecuteCommandAsync();
|
|
}
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
await ex.LogAsync(Db);
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
}
|
|
}
|
|
}
|
|
}
|