报销单功能模块

dev
douhandong 1 month ago
parent 1752f89777
commit 364b394760

@ -489,10 +489,16 @@ namespace DS.Module.Core
#region 报销审核
/// <summary>
/// 工作流报销审核
/// 报销审核
/// </summary>
[Description("工作流报销审核")]
ReimbursementApproval =1101
[Description("报销单审核")]
ReimbursementApproval =1101,
/// <summary>
/// 报销单审核
/// </summary>
[Description("报销单审核")]
Reimbursement_REJECTED = -1101
#endregion
}

@ -13,7 +13,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 报销单
/// </summary>
[SugarTable("fee_reimbursement", TableDescription = "报销单主表")]
public class Reimbursement : BaseModel<long>
public class FeeReimbursement : BaseModel<long>
{
/// <summary>
/// 报销用户Id
@ -40,6 +40,11 @@ namespace DS.WMS.Core.Fee.Entity
/// </summary>
public ReimbursementTypeEnums Status { get; set; }
/// <summary>
/// 驳回理由
/// </summary>
public string RejectReason { get; set; }
/// <summary>
/// 部门
/// </summary>

@ -13,7 +13,7 @@ namespace DS.WMS.Core.Fee.Entity
/// <summary>
/// 报销单详情
/// </summary>
[SugarTable("fee_reimbursementDetail", TableDescription = "报销单详情表")]
[SugarTable("fee_reimbursement_detail", TableDescription = "报销单详情表")]
public class FeeReimbursementDetail : BaseModel<long>
{
@ -39,8 +39,13 @@ namespace DS.WMS.Core.Fee.Entity
/// <summary>
/// 状态(未提交,审核中,审核通过,审核驳回,撤销) //与主表同步
/// 状态(未提交,审核中,审核通过,审核驳回,撤销) 与主表
/// </summary>
public ReimbursementTypeEnums Status { get; set; }
/// <summary>
/// 驳回理由 (与主表同步)
/// </summary>
public string RejectReason { get; set; }
}
}

@ -1,4 +1,5 @@
using DS.Module.Core.Data;
using DS.Module.Core.Enums;
using SqlSugar;
namespace DS.WMS.Core.Fee.Entity
@ -163,7 +164,7 @@ namespace DS.WMS.Core.Fee.Entity
/// <summary>
/// 报销状态 bxzt
/// </summary>
public string? ReimbursementStatus { get; set; }
public ReimbursementTypeEnums ReimbursementType { get; set; }
/// <summary>
/// 购方银行账号 gfyhzh

@ -1,8 +1,12 @@
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Flow.Dtos;
namespace DS.WMS.Core.Fee.Interface
{
/// <summary>
/// 报销模块
/// </summary>
public interface IReimbursementService
{
@ -19,7 +23,7 @@ namespace DS.WMS.Core.Fee.Interface
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult AddReimbursement(ReimbursementReq model);
Task< DataResult> AddReimbursement(ReimbursementReq model);
/// <summary>
/// 获取详情
@ -33,20 +37,29 @@ namespace DS.WMS.Core.Fee.Interface
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult ReimbursementRevoked(string id);
Task< DataResult> ReimbursementRevoked(string id);
/// <summary>
/// 报销单审批通过
/// 根据审批结果更新审批状态
/// </summary>
/// <param name="id"></param>
///<param name="callback">回调信息</param>
/// <returns></returns>
DataResult ReimbursementApproved(string id);
Task<DataResult> UpdateStatusAsync(FlowCallback callback);
/// <summary>
/// 报销单审批驳回
/// 通知审批执行人变更
/// </summary>
/// <param name="id"></param>
/// <param name="callback">回调信息</param>
/// <returns></returns>
DataResult ReimbursementRejected(string id);
Task MarkerChangedAsync(MarkerChangedCallback callback);
/// <summary>
/// 报销单审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult> AuditAsync(AuditRequest request);
}
}

@ -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;
}
}
}
}

@ -1,4 +1,5 @@
using DS.WMS.Core.Fee.Entity;
using DS.Module.Core.Enums;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.QuarztJobs.Dtos;
using DS.WMS.Core.QuarztJobs.Interface;
using DS.WMS.Core.QuarztJobs.Other;
@ -113,7 +114,7 @@ namespace DS.WMS.Core.QuarztJobs.Method
inInvoice.Amount = Iinfo.data.je;
inInvoice.SellerName = Iinfo.data.xfmc;
inInvoice.SpecialElements = Iinfo.data.tdys;
inInvoice.ReimbursementStatus = Iinfo.data.bxzt;
inInvoice.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
inInvoice.BuyerBankAccountNumber = Iinfo.data.gfyhzh;
inInvoice.SpecialElementTypeCode = Iinfo.data.tdyslxDm;
inInvoice.OperatorCode = Iinfo.data.czydm;

@ -1,7 +1,12 @@
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.TaskPlat.Dtos;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NLog;
using System.Net;
namespace DS.WMS.FeeApi.Controllers
{
@ -11,7 +16,7 @@ namespace DS.WMS.FeeApi.Controllers
public class ReimbursementController : ApiController
{
readonly IReimbursementService _service;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// 初始化
/// </summary>
@ -21,13 +26,31 @@ namespace DS.WMS.FeeApi.Controllers
_service = service;
}
//1获取当前登录人收款信息
// ClientBank/GetClientBankList
//2获取发票列表
// feeApi/InInvoicet/GetInInvoicet
/// <summary>
/// 获取报销单列表列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetReimbursementList")]
public DataResult<List<ReimbursementRes>> GetReimbursementList([FromBody] PageRequest request)
{
var res = _service.GetListByPage(request);
return res;
}
//3新增报销单,并同步到钉钉
/// <summary>
/// 获取报销单详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetReimbursementInfo")]
public DataResult<ReimbursementRes> GetReimbursementInfo([FromQuery] string id)
{
var res = _service.GetReimbursementInfo(id);
return res;
}
/// <summary>
/// 新增
@ -36,14 +59,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("AddReimbursement")]
public DataResult AddReimbursement([FromBody] ReimbursementReq req)
public async Task<DataResult> AddReimbursement([FromBody] ReimbursementReq req)
{
var res = _service.AddReimbursement(req);
var res =await _service.AddReimbursement(req);
return res;
}
//4未审批的报销单撤销
/// <summary>
/// 未审批的报销单撤销
/// </summary>
@ -51,48 +72,51 @@ namespace DS.WMS.FeeApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("ReimbursementRevoked")]
public DataResult ReimbursementRevoked([FromBody] string id)
public async Task<DataResult> ReimbursementRevoked([FromBody] string id)
{
var res = _service.ReimbursementRevoked(id);
var res = await _service.ReimbursementRevoked(id);
return res;
}
//5报销单审核通过
//6报销单审核驳回
//7获取报销单列表
/// <summary>
/// 列表
/// 按报销单审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetReimbursementList")]
public DataResult<List<ReimbursementRes>> GetReimbursementList([FromBody] PageRequest request)
[HttpPost, Route("Audit")]
public async Task<DataResult> AuditAsync([FromBody] AuditRequest request)
{
var res = _service.GetListByPage(request);
return res;
if (request.Ids.Length == 0 || (request.Result != 1 && request.Result != 2))
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _service.AuditAsync(request);
}
//8获取报销单详情
/// <summary>
/// 回调变更申请单审批状态(用于工作流框架的回调)
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpPost, Route("ChangeStatus")]
public async Task<IActionResult> ChangeStatusAsync([FromBody] FlowCallback callback)
{
var str = JsonConvert.SerializeObject(callback);
_logger.Info($"变更申请单审批状态回调,请求参数为:{str}");
await _service.UpdateStatusAsync(callback);
return StatusCode((int)HttpStatusCode.NoContent);
}
/// <summary>
/// 详情
/// 回调通知审批执行人变更(无需客户端手动调用)
/// </summary>
/// <param name="id"></param>
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpGet]
[Route("GetReimbursementInfo")]
public DataResult<ReimbursementRes> GetReimbursementInfo([FromQuery] string id)
[HttpPost, Route("MarkerChanged")]
public async Task<IActionResult> MarkerChangedAsync([FromBody] MarkerChangedCallback callback)
{
var res = _service.GetReimbursementInfo(id);
return res;
var str = JsonConvert.SerializeObject(callback);
_logger.Info($"通知审批执行人变更回调,请求参数为:{str}");
await _service.MarkerChangedAsync(callback);
return StatusCode((int)HttpStatusCode.NoContent);
}
//9财务银企直连付款接口
@ -103,8 +127,5 @@ namespace DS.WMS.FeeApi.Controllers
//11钉钉配置相关接口
}
}

Loading…
Cancel
Save