cjy 1 month ago
commit 7897401cae

@ -1,4 +1,6 @@
using System;
using DS.Module.Core.Enums;
using DS.WMS.Core.Fee.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -14,12 +16,10 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public long Id { get; set; }
}
public class ReimbursementReq
{
/// <summary>
/// 报销用户Id
/// </summary>
public string UserId { get; set; }
/// <summary>
/// 报销单编号
@ -37,9 +37,14 @@ namespace DS.WMS.Core.Fee.Dtos
public string Reimburser { get; set; }
/// <summary>
/// 状态(待提交,已提交,审核中,审核通过,审核驳回,撤销)
/// 状态(未提交,审核中,审核通过,审核驳回,撤销)
/// </summary>
public ReimbursementTypeEnums Status { get; set; }
/// <summary>
/// 驳回理由
/// </summary>
public string Status { get; set; }
public string RejectReason { get; set; }
/// <summary>
/// 部门
@ -61,6 +66,36 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string BankName { get; set; }
/// <summary>
/// 收款人名称
/// </summary>
public string PayeeName { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; }
}
public class ReimbursementReq
{
public long Id { get; set; }
/// <summary>
/// 收款人账号
/// </summary>
public string PayeeAccountNumber { get; set; }
/// <summary>
/// 开户行
/// </summary>
public string BankName { get; set; }
/// <summary>
/// 收款人名称
/// </summary>
@ -87,5 +122,24 @@ namespace DS.WMS.Core.Fee.Dtos
public string InvoiceNumber { get; set; }
}
public class GetReimbursementRes: ReimbursementRes
{
public List<GetReimbursementResData> Data { get; set; }
}
public class GetReimbursementResData:InInvoice
{
public List<InInvoiceDetail> Data { get; set; }
}
public class SubmitReimbursementReq
{
/// <summary>
/// 报销单主键Id
/// </summary>
public long Id { get; set; }
}
}

@ -38,7 +38,7 @@ namespace DS.WMS.Core.Fee.Entity
/// <summary>
/// 状态(未提交,审核中,审核通过,审核驳回,撤销)
/// </summary>
public ReimbursementTypeEnums Status { get; set; }
public ReimbursementTypeEnums ReimbursementType { get; set; }
/// <summary>
/// 驳回理由
@ -46,9 +46,9 @@ namespace DS.WMS.Core.Fee.Entity
public string RejectReason { get; set; }
/// <summary>
/// 部门
/// 机构Id
/// </summary>
public string Department { get; set; }
public long OrgId { get; set; }
/// <summary>
/// 凭证号

@ -25,12 +25,20 @@ namespace DS.WMS.Core.Fee.Interface
/// <returns></returns>
Task< DataResult> AddReimbursement(ReimbursementReq model);
/// <summary>
/// 提交报销单进行审核
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Task<DataResult> SubmitReimbursement(SubmitReimbursementReq model);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<ReimbursementRes> GetReimbursementInfo(string id);
DataResult<GetReimbursementRes> GetReimbursementInfo(string id);
/// <summary>
/// 未审批的报销单撤销

@ -10,10 +10,13 @@ using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Interface;
using LanguageExt.Common;
using Mapster;
using Masuit.Tools.Database;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.Fee.Method
{
@ -72,6 +75,76 @@ namespace DS.WMS.Core.Fee.Method
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//修改
if (req.Id>0)
{
var FeeR = tenantDb.Queryable<FeeReimbursement>().Where(t => t.Id == req.Id).First();
if (FeeR == null)
{
return DataResult.Failed($"数据不存在,请检查");
}
if (FeeR.ReimbursementType!= ReimbursementTypeEnums.NotSubmitted)
{
return DataResult.Failed($"报销单状态不为未提交,不可修改");
}
var data = req.Adapt<FeeReimbursement>();
data.UserId = user.UserId;
data.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
data.Reimburser = user.UserName;
data.OrgId = user.OrgId;
var info = tenantDb.Updateable(data).ExecuteCommand();
//将子表数据删除,重新添加
var datadtl = tenantDb.Queryable<FeeReimbursementDetail>().Where(t => t.PId == req.Id).ToList();
foreach (var item in datadtl)
{
var ininfo = tenantDb.Queryable<InInvoice>().Where(t => t.InvoiceNumber == item.InvoiceNumber).First();
if (ininfo.ReimbursementType != ReimbursementTypeEnums.NotSubmitted)
{
return DataResult.Failed($"发票状态异常,不可修改");
}
}
tenantDb.Deleteable(datadtl).ExecuteCommand();
foreach (var item in req.Data)
{
//查询发票信息是否存在
var inviceinfo = tenantDb.Queryable<InInvoice>().Where(t => t.InvoiceNumber == item.InvoiceNumber).First();
if (inviceinfo == null)
{
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}已报销,请检查");
}
inviceinfo.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
tenantDb.Updateable(inviceinfo).ExecuteCommand();
var dataDetail = item.Adapt<FeeReimbursementDetail>();
dataDetail.Status = ReimbursementTypeEnums.NotSubmitted;
dataDetail.PId = req.Id;
tenantDb.Insertable(dataDetail).ExecuteCommand();
}
}
//新增
else
{
#region 提交报销数据校验
foreach (var item in req.Data)
{
@ -99,18 +172,89 @@ namespace DS.WMS.Core.Fee.Method
var data = req.Adapt<FeeReimbursement>();
data.UserId = user.UserId;
data.ReimbursementId = "23"; //报销单编号.
//data.ReimbursementId = "23"; //报销单编号.
//data.CreationTime = DateTime.Now;//制单时间
data.ReimbursementType = ReimbursementTypeEnums.NotSubmitted;
data.Reimburser = user.UserName;
data.OrgId = user.OrgId;
var info = tenantDb.Insertable(data).ExecuteReturnEntity();
//添加子表信息
foreach (var item in req.Data)
{
var inviceinfo = tenantDb.Queryable<InInvoice>().Where(t => t.InvoiceNumber == item.InvoiceNumber).First();
var dataDetail = item.Adapt<FeeReimbursementDetail>();
dataDetail.Status = ReimbursementTypeEnums.NotSubmitted;
dataDetail.PId = info.Id;
dataDetail.Amount = (decimal)inviceinfo.Amount;
tenantDb.Insertable(dataDetail).ExecuteReturnEntity();
}
}
return await Task.FromResult(DataResult.Successed("操作成功"));
}
/// <summary>
/// 提交报销单审核
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult> SubmitReimbursement(SubmitReimbursementReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var info= tenantDb.Queryable<FeeReimbursement>().Where(t => t.Id == req.Id).First();
if (info==null)
{
return DataResult.Failed($"报销单不存在,请检查");
}
if (info.ReimbursementType!=ReimbursementTypeEnums.NotSubmitted)
{
return DataResult.Failed($"报销单状态异常,请检查");
}
var Pinfo = tenantDb.Queryable<FeeReimbursementDetail>().Where(t => t.PId == req.Id).ToList();
#region 提交报销数据校验
foreach (var item in Pinfo)
{
//查询发票信息是否存在
var inviceinfo = tenantDb.Queryable<InInvoice>().Where(t => t.InvoiceNumber == item.InvoiceNumber).First();
if (inviceinfo == null)
{
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
//修改主表信息
info.ReimbursementId = "23"; //报销单编号.
info.CreationTime = DateTime.Now;//制单时间
info.ReimbursementType = ReimbursementTypeEnums.UnderReview;
info.Reimburser = user.UserName;
info.OrgId = user.OrgId;
var data = tenantDb.Updateable(info).ExecuteCommand();
//修改子表信息
foreach (var item in Pinfo)
{
item.Status = ReimbursementTypeEnums.UnderReview;
tenantDb.Updateable(item).ExecuteCommand();
}
@ -121,7 +265,7 @@ namespace DS.WMS.Core.Fee.Method
TaskTypeName = TaskBaseTypeEnum.ReimbursementApproval.ToString(),
TaskTitle = $"【{TaskBaseTypeEnum.ReimbursementApproval.GetDescription()}】{user.UserName}提交的报销单审核",
TaskDescription = $"【{TaskBaseTypeEnum.ReimbursementApproval.GetDescription()}】共包含发票{req.Data.Count()}张,报销金额{req.Data.Sum(t=>t.Amount)}元",
TaskDescription = $"【{TaskBaseTypeEnum.ReimbursementApproval.GetDescription()}】共包含发票{Pinfo.Count}张,报销金额{Pinfo.Sum(t => t.Amount)}元",
};
var result = await taskService.CreateTaskAsync(taskReq, false);
if (!result.Succeeded)
@ -130,29 +274,45 @@ namespace DS.WMS.Core.Fee.Method
}
else
{
return await Task.FromResult(DataResult.Successed(result.Message));
}
#endregion
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<ReimbursementRes> GetReimbursementInfo(string id)
public DataResult<GetReimbursementRes> GetReimbursementInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<FeeReimbursement>()
.Where(a => a.Id == long.Parse(id))
.Select<ReimbursementRes>()
.Select<GetReimbursementRes>()
.First();
var dtlist= tenantDb.Queryable<FeeReimbursementDetail>().Where(t => t.PId == data.Id).ToList();
foreach (var item in dtlist)
{
var dt= tenantDb.Queryable<InInvoice>().Where(t => t.InvoiceNumber == item.InvoiceNumber).Select<GetReimbursementResData>().First();
if (dt != null)
{
data.Data = new List<GetReimbursementResData>();
data.Data.Add(dt);
return DataResult<ReimbursementRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
foreach (var itemdata in data.Data)
{
itemdata.Data = new List<InInvoiceDetail>();
itemdata.Data = tenantDb.Queryable<InInvoiceDetail>().Where(t => t.InvoiceNumber == item.InvoiceNumber).ToList();
}
}
}
return DataResult<GetReimbursementRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
@ -170,12 +330,12 @@ namespace DS.WMS.Core.Fee.Method
.Select<FeeReimbursement>()
.First();
if (data.Status != ReimbursementTypeEnums.NotSubmitted)
if (data.ReimbursementType != ReimbursementTypeEnums.NotSubmitted)
{
return DataResult.Failed("报销单只有未审批可撤回!");
}
data.Status = ReimbursementTypeEnums.Revoked;
data.ReimbursementType = ReimbursementTypeEnums.Revoked;
db.Updateable(data).ExecuteCommand();
var dataDetail = tenantDb.Queryable<FeeReimbursementDetail>()
@ -184,7 +344,7 @@ namespace DS.WMS.Core.Fee.Method
.ToList();
foreach (var item in dataDetail)
{
item.Status = ReimbursementTypeEnums.Revoked;
item.ReimbursementType = ReimbursementTypeEnums.Revoked;
db.Updateable(item).ExecuteCommand();
}
@ -230,7 +390,7 @@ namespace DS.WMS.Core.Fee.Method
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
info.Status = ReimbursementTypeEnums.Approved;
info.ReimbursementType = ReimbursementTypeEnums.Approved;
tenantDb.Updateable(info).ExecuteCommand();
var dtllist = tenantDb.Queryable<FeeReimbursementDetail>().Where(t => t.PId == info.Id).ToList();
@ -244,7 +404,7 @@ namespace DS.WMS.Core.Fee.Method
}
if (callback.FlowStatus == FlowStatusEnum.Reject)
{
info.Status = ReimbursementTypeEnums.Rejected;
info.ReimbursementType = ReimbursementTypeEnums.Rejected;
info.RejectReason = callback.RejectReason;
tenantDb.Updateable(info).ExecuteCommand();

@ -228,6 +228,11 @@ public class UserReq
/// Desc:业务来源明细名称
/// </summary>
public string SourceDetailName { get; set; }
/// <summary>
/// 钉钉用户Id
/// </summary>
public string DingUserId { get; set; }
}
/// <summary>

@ -250,4 +250,12 @@ public class UserViewModel
/// </summary>
[Description("QQ")]
public string QQ { get; set; }
/// <summary>
/// 钉钉用户Id
/// </summary>
[Description("钉钉用户Id")]
public string DingUserId { get; set; }
}

@ -277,4 +277,10 @@ public class SysUser : UserTenantModel<long>
[SugarColumn(ColumnDescription = "业务来源明细名称", Length = 100, IsNullable = true)]
public string SourceDetailName { get; set; }
/// <summary>
/// 钉钉用户Id
/// </summary>
[Description("钉钉用户Id")]
public string DingUserId { get; set; }
}

@ -46,7 +46,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <returns></returns>
[HttpGet]
[Route("GetReimbursementInfo")]
public DataResult<ReimbursementRes> GetReimbursementInfo([FromQuery] string id)
public DataResult<GetReimbursementRes> GetReimbursementInfo([FromQuery] string id)
{
var res = _service.GetReimbursementInfo(id);
return res;
@ -65,6 +65,19 @@ namespace DS.WMS.FeeApi.Controllers
return res;
}
/// <summary>
/// 提交报销单审核
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("SubmitReimbursement")]
public async Task<DataResult> SubmitReimbursement([FromBody] SubmitReimbursementReq req)
{
var res = await _service.SubmitReimbursement(req);
return res;
}
/// <summary>
/// 未审批的报销单撤销
/// </summary>

Loading…
Cancel
Save