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.
158 lines
6.6 KiB
C#
158 lines
6.6 KiB
C#
using DS.Module.Core;
|
|
using DS.Module.Core.Enums;
|
|
using DS.Module.Core.Extensions;
|
|
using DS.Module.SqlSugar;
|
|
using DS.Module.UserModule;
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
using DS.WMS.Core.Fee.Entity;
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
using DS.WMS.Core.Info.Entity;
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
using DS.WMS.Core.Op.Dtos;
|
|
using DS.WMS.Core.Op.Dtos.TaskInteraction;
|
|
using DS.WMS.Core.Op.Entity;
|
|
using DS.WMS.Core.Op.Interface;
|
|
using DS.WMS.Core.Op.Interface.TaskInteraction;
|
|
using DS.WMS.Core.Op.Method.TaskInteraction;
|
|
using LanguageExt.Common;
|
|
using LanguageExt.Pipes;
|
|
using Mapster;
|
|
using Masuit.Tools.Systems;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using SqlSugar;
|
|
using System.Drawing;
|
|
using static AnyDiff.DifferenceLines;
|
|
|
|
namespace DS.WMS.Core.Op.Method
|
|
{
|
|
/// <summary>
|
|
/// 海运出口退舱接口
|
|
/// </summary>
|
|
public class SeaExportRefundService: ISeaExportRefundService
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly ISqlSugarClient db;
|
|
private readonly IUser user;
|
|
private readonly ISaasDbService saasService;
|
|
readonly ITaskService taskService;
|
|
private readonly ISeaExportCommonService seaComService;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="serviceProvider"></param>
|
|
public SeaExportRefundService(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
seaComService = _serviceProvider.GetRequiredService<ISeaExportCommonService>();
|
|
taskService = serviceProvider.GetRequiredService<ITaskService>();
|
|
}
|
|
|
|
#region 发起退舱
|
|
|
|
public async Task<DataResult> CreateRefundAuditTaskAsync(RefundTaskReq req)
|
|
{
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
var info = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).FirstAsync();
|
|
if (info.IsNull())
|
|
return await Task.FromResult(DataResult.Failed("不存在的海运出口信息!", MultiLanguageConst.SeaExportExist));
|
|
|
|
if (!req.IsReserveFee && tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == req.Id).Any())
|
|
{
|
|
return await Task.FromResult(DataResult.Failed("存在业务相关费用,是否保留费用?"));
|
|
}
|
|
if (req.IsReserveFee && tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == req.Id && x.FeeStatus == FeeStatus.Entering).Any())
|
|
{
|
|
return await Task.FromResult(DataResult.Failed("存在录入状态的费用!"));
|
|
}
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
{
|
|
BusinessId = req.Id,
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN_AUDIT.ToString(),
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN_AUDIT.GetDescription()}】{info?.CustomerNo}",
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN_AUDIT.GetDescription()}】{info?.CustomerNo}",
|
|
};
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
if (!result.Succeeded)
|
|
{
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
}
|
|
else {
|
|
var oldOrder = info.Adapt<SeaExport>();
|
|
info.RefundTag = RefundTagEnum.Normal;
|
|
info.RefundReason = req.RefundReason;
|
|
info.RefundRemark = req.RefundRemark;
|
|
int rows = await tenantDb.Updateable(info).UpdateColumns(x => new
|
|
{
|
|
x.RefundTag,x.RefundReason,x.RefundRemark
|
|
}).ExecuteCommandAsync();
|
|
|
|
await seaComService.SetGoodsStatus("YFTC", req.Id, tenantDb);
|
|
await seaComService.SaveSeaExportLogAsync(new SeaExportSaveLog()
|
|
{
|
|
OperateType = "Update",
|
|
OldOrder = oldOrder,
|
|
NewOrder = info,
|
|
SourceCode = "CreateRefundAuditTaskAsync",
|
|
SourceName = "发起退仓审核",
|
|
}, tenantDb);
|
|
return await Task.FromResult(DataResult.Successed(result.Message));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 退舱审核完成回调
|
|
/// </summary>
|
|
/// <param name="callback">回调信息</param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult> RefundAuditCallbackAsync(FlowCallback callback)
|
|
{
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
if (callback.AuditType != TaskBaseTypeEnum.RETURN_CABIN_AUDIT)
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NoAuditItems));
|
|
var info = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == callback.BusinessId).FirstAsync();
|
|
if (info.IsNull())
|
|
return await Task.FromResult(DataResult.Failed("不存在的海运出口信息!", MultiLanguageConst.SeaExportExist));
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
{
|
|
await seaComService.SetGoodsStatus("YSTC", callback.BusinessId, tenantDb);
|
|
//发起退舱确认任务
|
|
var taskReq = new TaskCreationRequest()
|
|
{
|
|
BusinessId = info.Id,
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN.ToString(),
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
};
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
if (!result.Succeeded)
|
|
{
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
await seaComService.SetGoodsStatus("TCBH", callback.BusinessId, tenantDb);
|
|
}
|
|
|
|
return DataResult.Success;
|
|
|
|
//return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
}
|
|
}
|
|
}
|