|
|
|
@ -1,8 +1,4 @@
|
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
|
using AngleSharp.Svg.Dom;
|
|
|
|
|
using Autofac.Core;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Enums;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
@ -11,12 +7,11 @@ using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Method;
|
|
|
|
|
using LanguageExt.Common;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
@ -33,7 +28,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
private readonly IUser user;
|
|
|
|
|
|
|
|
|
|
readonly ITaskService taskService;
|
|
|
|
|
Lazy<ITaskService> taskService2;
|
|
|
|
|
Lazy<IClientFlowInstanceService> flowService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
@ -45,6 +42,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
taskService = serviceProvider.GetRequiredService<ITaskService>();
|
|
|
|
|
taskService2 = new Lazy<ITaskService>(serviceProvider.GetRequiredService<ITaskService>());
|
|
|
|
|
flowService = new Lazy<IClientFlowInstanceService>(serviceProvider.GetRequiredService<IClientFlowInstanceService>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -58,7 +58,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var data = tenantDb.Queryable<Reimbursement>()
|
|
|
|
|
var data = tenantDb.Queryable<FeeReimbursement>()
|
|
|
|
|
.Where(whereList)
|
|
|
|
|
.Select<ReimbursementRes>().ToQueryPage(request.PageCondition);
|
|
|
|
|
return data;
|
|
|
|
@ -68,7 +68,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult AddReimbursement(ReimbursementReq req)
|
|
|
|
|
public async Task<DataResult> AddReimbursement(ReimbursementReq req)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
@ -83,38 +83,59 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//发票报销状态 校验 待完善
|
|
|
|
|
//if (inviceinfo.ReimbursementType == (int)ReimbursementTypeEnums.UnderReview) //报销中
|
|
|
|
|
//{
|
|
|
|
|
// return DataResult.Failed($"提交失败,发票号{item.InvoiceNumber}正在报销,请检查");
|
|
|
|
|
//}
|
|
|
|
|
//if (inviceinfo.ReimbursementType == (int)ReimbursementTypeEnums.Approved) //已报销
|
|
|
|
|
//{
|
|
|
|
|
// return DataResult.Failed($"提交失败,发票号{item.InvoiceNumber}已报销,请检查");
|
|
|
|
|
//}
|
|
|
|
|
if (inviceinfo.ReimbursementType == ReimbursementTypeEnums.UnderReview) //报销中
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed($"提交失败,发票号{item.InvoiceNumber}正在报销,请检查");
|
|
|
|
|
}
|
|
|
|
|
if (inviceinfo.ReimbursementType == ReimbursementTypeEnums.Approved) //已报销
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed($"提交失败,发票号{item.InvoiceNumber}已报销,请检查");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//添加主表信息
|
|
|
|
|
|
|
|
|
|
var data = req.Adapt<Reimbursement>();
|
|
|
|
|
var data = req.Adapt<FeeReimbursement>();
|
|
|
|
|
data.UserId = user.UserId;
|
|
|
|
|
data.ReimbursementId = "23"; //报销单编号.
|
|
|
|
|
var info = tenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
//添加子表信息
|
|
|
|
|
|
|
|
|
|
foreach (var item in req.Data)
|
|
|
|
|
{
|
|
|
|
|
var dataDetail = req.Adapt<FeeReimbursementDetail>();
|
|
|
|
|
var dataDetail = item.Adapt<FeeReimbursementDetail>();
|
|
|
|
|
dataDetail.Status = ReimbursementTypeEnums.NotSubmitted;
|
|
|
|
|
dataDetail.PId = info.Id;
|
|
|
|
|
|
|
|
|
|
tenantDb.Insertable(dataDetail).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
|
|
#region 增加审批任务
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = info.Id,
|
|
|
|
|
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.ReimbursementApproval.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.ReimbursementApproval.GetDescription()}】{user.UserName}提交的报销单审核",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.ReimbursementApproval.GetDescription()}】共包含发票{req.Data.Count()}张,报销金额{req.Data.Sum(t=>t.Amount)}元",
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return DataResult.Successed("添加成功!");
|
|
|
|
|
return await Task.FromResult(DataResult.Successed(result.Message));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
@ -125,7 +146,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
public DataResult<ReimbursementRes> GetReimbursementInfo(string id)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var data = tenantDb.Queryable<Reimbursement>()
|
|
|
|
|
var data = tenantDb.Queryable<FeeReimbursement>()
|
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
|
.Select<ReimbursementRes>()
|
|
|
|
|
.First();
|
|
|
|
@ -140,13 +161,13 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult ReimbursementRevoked(string id)
|
|
|
|
|
public async Task<DataResult> ReimbursementRevoked(string id)
|
|
|
|
|
{
|
|
|
|
|
//查询当前报销单
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var data = tenantDb.Queryable<Reimbursement>()
|
|
|
|
|
var data = tenantDb.Queryable<FeeReimbursement>()
|
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
|
.Select<Reimbursement>()
|
|
|
|
|
.Select<FeeReimbursement>()
|
|
|
|
|
.First();
|
|
|
|
|
|
|
|
|
|
if (data.Status != ReimbursementTypeEnums.NotSubmitted)
|
|
|
|
@ -159,79 +180,140 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
var dataDetail = tenantDb.Queryable<FeeReimbursementDetail>()
|
|
|
|
|
.Where(a => a.PId == long.Parse(id))
|
|
|
|
|
.Select<Reimbursement>()
|
|
|
|
|
.Select<FeeReimbursement>()
|
|
|
|
|
.ToList();
|
|
|
|
|
foreach (var item in dataDetail)
|
|
|
|
|
{
|
|
|
|
|
item.Status= ReimbursementTypeEnums.Revoked;
|
|
|
|
|
item.Status = ReimbursementTypeEnums.Revoked;
|
|
|
|
|
db.Updateable(item).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
//撤销审批任务
|
|
|
|
|
var tsreq = new TaskRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = data.Id,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.ReimbursementApproval.ToString(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var result = await taskService.WithdrawAsync(tsreq);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult.Successed(result.Message));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 审批通过
|
|
|
|
|
/// 根据审批结果更新申请单状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="callback">回调信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult ReimbursementApproved(string id)
|
|
|
|
|
public async Task<DataResult> UpdateStatusAsync(FlowCallback callback)
|
|
|
|
|
{
|
|
|
|
|
//查询当前报销单
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var data = tenantDb.Queryable<Reimbursement>()
|
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
|
.Select<Reimbursement>()
|
|
|
|
|
.First();
|
|
|
|
|
|
|
|
|
|
if (callback.AuditType != TaskBaseTypeEnum.ReimbursementApproval)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NoAuditItems));
|
|
|
|
|
var info = await tenantDb.Queryable<FeeReimbursement>().Where(x => x.Id == callback.BusinessId).FirstAsync();
|
|
|
|
|
if (info.IsNull())
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("不存在的报销单信息!"));
|
|
|
|
|
//审核通过
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
data.Status = ReimbursementTypeEnums.Approved;
|
|
|
|
|
db.Updateable(data).ExecuteCommand();
|
|
|
|
|
info.Status = ReimbursementTypeEnums.Approved;
|
|
|
|
|
tenantDb.Updateable(info).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
var dataDetail = tenantDb.Queryable<FeeReimbursementDetail>()
|
|
|
|
|
.Where(a => a.PId == long.Parse(id))
|
|
|
|
|
.Select<Reimbursement>()
|
|
|
|
|
.ToList();
|
|
|
|
|
foreach (var item in dataDetail)
|
|
|
|
|
var dtllist = tenantDb.Queryable<FeeReimbursementDetail>().Where(t => t.PId == info.Id).ToList();
|
|
|
|
|
foreach (var item in dtllist)
|
|
|
|
|
{
|
|
|
|
|
item.Status = ReimbursementTypeEnums.Approved;
|
|
|
|
|
tenantDb.Updateable(item).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
|
item.Status = ReimbursementTypeEnums.Approved;
|
|
|
|
|
db.Updateable(item).ExecuteCommand();
|
|
|
|
|
info.Status = ReimbursementTypeEnums.Rejected;
|
|
|
|
|
info.RejectReason = callback.RejectReason;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(info).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
var dtllist = tenantDb.Queryable<FeeReimbursementDetail>().Where(t => t.PId == info.Id).ToList();
|
|
|
|
|
foreach (var item in dtllist)
|
|
|
|
|
{
|
|
|
|
|
item.Status = ReimbursementTypeEnums.Approved;
|
|
|
|
|
item.RejectReason = callback.RejectReason;
|
|
|
|
|
tenantDb.Updateable(item).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
|
|
|
|
|
//return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 审批驳回
|
|
|
|
|
/// 通知审批执行人变更
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <param name="callback">回调信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult ReimbursementRejected(string id)
|
|
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="callback"/>为null时引发</exception>
|
|
|
|
|
public virtual async Task MarkerChangedAsync(MarkerChangedCallback callback)
|
|
|
|
|
{
|
|
|
|
|
//查询当前报销单
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var data = tenantDb.Queryable<Reimbursement>()
|
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
|
.Select<Reimbursement>()
|
|
|
|
|
.First();
|
|
|
|
|
//同步到钉钉
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报销单审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(AuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
if (await taskService2.Value.HasAuthorizedAsync())
|
|
|
|
|
{
|
|
|
|
|
return await taskService2.Value.AuditAsync(new TaskAuditRequest
|
|
|
|
|
{
|
|
|
|
|
Ids = request.Ids,
|
|
|
|
|
Remark = request.Remark,
|
|
|
|
|
Result = request.Result,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.ReimbursementApproval.ToString()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.Status = ReimbursementTypeEnums.Rejected;
|
|
|
|
|
db.Updateable(data).ExecuteCommand();
|
|
|
|
|
var list = await flowService.Value.GetInstanceByBSIdAsync(TaskBaseTypeEnum.ReimbursementApproval, ids: request.Ids);
|
|
|
|
|
if (list.Count != request.Ids.Length)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
|
|
|
|
|
|
|
|
|
|
var dataDetail = tenantDb.Queryable<FeeReimbursementDetail>()
|
|
|
|
|
.Where(a => a.PId == long.Parse(id))
|
|
|
|
|
.Select<Reimbursement>()
|
|
|
|
|
.ToList();
|
|
|
|
|
foreach (var item in dataDetail)
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
item.Status = ReimbursementTypeEnums.Rejected;
|
|
|
|
|
db.Updateable(item).ExecuteCommand();
|
|
|
|
|
var result = await flowService.Value.AuditAsync(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|