|
|
using DS.Module.Core;
|
|
|
using DS.Module.Core.Data;
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
using DS.WMS.Core.Fee.Method.ReportProviders;
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
namespace DS.WMS.FeeApi.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 费用记录服务
|
|
|
/// </summary>
|
|
|
public class FeeRecordController : ApiController
|
|
|
{
|
|
|
readonly IFeeRecordService _feeService;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
|
/// <param name="feeService"></param>
|
|
|
public FeeRecordController(IFeeRecordService feeService)
|
|
|
{
|
|
|
_feeService = feeService;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 列表
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("GetList")]
|
|
|
public async Task<DataResult<List<FeeRecordRes>>> GetListAsync([FromBody] PageRequest request)
|
|
|
{
|
|
|
return await _feeService.GetListAsync(request);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据查询条件获取费用数据(仅用于获取数据,不作UI展示用)
|
|
|
/// </summary>
|
|
|
/// <param name="query">JSON格式的查询条件</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet, Route("GetQuery")]
|
|
|
public async Task<DataResult<List<FeeRecord>>> GetListAsync(string query)
|
|
|
{
|
|
|
return await _feeService.GetListAsync(query);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取费用申请修改的新值
|
|
|
/// </summary>
|
|
|
/// <param name="id">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet, Route("GetModifyValue")]
|
|
|
public async Task<DataResult<FeeModification>> GetModifyValue(long id)
|
|
|
{
|
|
|
return await _feeService.GetModifyValue(id);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据指定的查询条件获取统计信息
|
|
|
/// </summary>
|
|
|
/// <param name="request">查询条件</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("FeeStatistics")]
|
|
|
public async Task<DataResult<FeeStatistics>> StatisticsAsync([FromBody] FeeStatisticsRequest request)
|
|
|
{
|
|
|
if (request == null)
|
|
|
return DataResult<FeeStatistics>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var res = await _feeService.GetListAsync(request.QueryCondition);
|
|
|
if (!res.Succeeded)
|
|
|
return DataResult<FeeStatistics>.Error(res.Message);
|
|
|
|
|
|
var stat = new FeeStatistics(res.Data);
|
|
|
return DataResult<FeeStatistics>.Success(stat);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存费用
|
|
|
/// </summary>
|
|
|
/// <param name="recordSubmit"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Submit")]
|
|
|
public async Task<DataResult> SubmitAsync([FromBody] FeeRecordSubmit recordSubmit)
|
|
|
{
|
|
|
if (recordSubmit.Items == null)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
if (recordSubmit.Items.Any(x => x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))
|
|
|
return DataResult.Failed("只能提交状态为‘录入’或‘驳回提交’的费用", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
foreach (var item in recordSubmit.Items)
|
|
|
{
|
|
|
item.BusinessId = recordSubmit.BusinessId;
|
|
|
item.BusinessType = recordSubmit.BusinessType;
|
|
|
item.FeeStatus = FeeStatus.Entering;
|
|
|
}
|
|
|
return await _feeService.SaveAsync(recordSubmit.Items);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存费用并提交审核
|
|
|
/// </summary>
|
|
|
/// <param name="recordSubmit"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("SubmitWithAudit")]
|
|
|
public async Task<DataResult> SubmitWithAuditAsync([FromBody] FeeRecordSubmit recordSubmit)
|
|
|
{
|
|
|
if (recordSubmit.Items == null)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
if (recordSubmit.Items.Any(x => x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))
|
|
|
return DataResult.Failed("只能提交状态为‘录入’或‘驳回提交’的费用", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
foreach (var item in recordSubmit.Items)
|
|
|
{
|
|
|
item.BusinessId = recordSubmit.BusinessId;
|
|
|
item.BusinessType = recordSubmit.BusinessType;
|
|
|
item.FeeStatus = FeeStatus.Entering;
|
|
|
}
|
|
|
return await _feeService.SaveAndSubmitAsync(recordSubmit.Items);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据一组模板ID创建费用记录(引入模板)
|
|
|
/// </summary>
|
|
|
/// <param name="request">请求参数</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("CreateByTemplate")]
|
|
|
public async Task<DataResult> CreateByTemplateAsync([FromBody] FeeRecordByTemplate request)
|
|
|
{
|
|
|
if (request == null || request.TemplateIdList?.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.CreateByTemplateAsync(request.BusinessId, request.BusinessType, request.TemplateIdList);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据费用记录ID删除
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Delete")]
|
|
|
public async Task<DataResult> DeleteAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model.Ids == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.DeleteAsync(model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 提交审批
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyAudit")]
|
|
|
public async Task<DataResult> ApplyAuditAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model.Ids == null || model.Ids?.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.SubmitForApprovalAsync(TaskBaseTypeEnum.FEE_AUDIT, model.Remark, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 申请删除
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyDeletion")]
|
|
|
public async Task<DataResult> ApplyDeletionAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids?.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.SubmitForApprovalAsync(TaskBaseTypeEnum.FEE_DELETE_AUDIT, model.Remark, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 申请修改
|
|
|
/// </summary>
|
|
|
/// <param name="items">费用修改信息</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyModification")]
|
|
|
public async Task<DataResult> ApplyModificationAsync([FromBody] IEnumerable<FeeModification> items)
|
|
|
{
|
|
|
if (items == null || !items.Any())
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.SubmitForModificationAsync(items);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 撤销审批申请
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Withdraw")]
|
|
|
public async Task<DataResult> WithdrawAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids?.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.WithdrawAsync(model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 发起整票审核
|
|
|
/// </summary>
|
|
|
/// <param name="model">业务ID和类型</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyBusinessAudit")]
|
|
|
public async Task<DataResult> ApplyBusinessAuditAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (!long.TryParse(model.Id, out long bid) || model.BusinessType == null)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.SubmitBusinessAuditAsync(bid, (BusinessType)model.BusinessType.Value);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 撤销整票审核
|
|
|
/// </summary>
|
|
|
/// <param name="model">业务ID和类型</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("WithdrawBusiness")]
|
|
|
public async Task<DataResult> WithdrawBusinessAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (!long.TryParse(model.Id, out long bid) || model.BusinessType == null)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.SubmitBusinessAuditAsync(bid, (BusinessType)model.BusinessType.Value);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取费用打印数据
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("GetPrintInfo")]
|
|
|
public async Task<DataResult<dynamic>> GetPrintInfoAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids?.Length == 0)
|
|
|
return DataResult<dynamic>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
string? providerName = model.Value?.ToString();
|
|
|
if (string.IsNullOrEmpty(providerName))
|
|
|
providerName = typeof(CostAccountingReport).AssemblyQualifiedName;
|
|
|
|
|
|
return await _feeService.GetPrintInfoAsync(providerName, (BusinessType)model.BusinessType.Value, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置费用是否启用发票
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("SetInvoiceEnabled")]
|
|
|
public async Task<DataResult> SetInvoiceEnabledAsync([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids?.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
bool enabled = Convert.ToBoolean(model.Value);
|
|
|
return await _feeService.SetInvoiceEnabledAsync(enabled, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 刷新业务表费用状态
|
|
|
/// </summary>
|
|
|
/// <param name="bsId">业务ID</param>
|
|
|
/// <param name="bsType">业务类型</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("RefreshBusinessFeeStatus")]
|
|
|
public async Task<IActionResult> RefreshBusinessFeeStatusAsync(long bsId, BusinessType bsType)
|
|
|
{
|
|
|
await _feeService.WriteBackStatusAsync(bsId, bsType);
|
|
|
return Ok();
|
|
|
}
|
|
|
}
|
|
|
}
|