|
|
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.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.GetListByPageAsync(request);
|
|
|
}
|
|
|
|
|
|
/// <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 == null || 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>
|
|
|
/// 根据一组模板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(AuditType.FeeAudit, 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(AuditType.FeeDelete, 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(IdModel model)
|
|
|
{
|
|
|
if (model == null || !long.TryParse(model.Id, out long bid))
|
|
|
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<CostAccountingForm>> GetPrintInfoAsync(IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids?.Length == 0)
|
|
|
return DataResult<CostAccountingForm>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return await _feeService.GetPrintInfoAsync((BusinessType)model.BusinessType.Value, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置费用是否启用发票
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("SetInvoiceEnabled")]
|
|
|
public async Task<DataResult> SetInvoiceEnabledAsync(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);
|
|
|
}
|
|
|
}
|
|
|
}
|