|
|
using DS.Module.Core;
|
|
|
using DS.Module.Core.Data;
|
|
|
using DS.Module.Core.Extensions;
|
|
|
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.Interface;
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
using Mapster;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
namespace DS.WMS.FeeApi.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 费用记录服务
|
|
|
/// </summary>
|
|
|
public class FeeRecordController : ApiController
|
|
|
{
|
|
|
readonly IFeeRecordService _feeService;
|
|
|
readonly IClientFlowInstanceService _flowService;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
|
/// <param name="feeService"></param>
|
|
|
/// <param name="flowService"></param>
|
|
|
public FeeRecordController(IFeeRecordService feeService, IClientFlowInstanceService flowService)
|
|
|
{
|
|
|
_feeService = feeService;
|
|
|
_flowService = flowService;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 列表
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("GetList")]
|
|
|
public DataResult<List<FeeRecordRes>> GetList([FromBody] PageRequest request)
|
|
|
{
|
|
|
var res = _feeService.GetListByPage(request);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据指定的查询条件获取统计信息
|
|
|
/// </summary>
|
|
|
/// <param name="request">查询条件</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("FeeStatistics")]
|
|
|
public DataResult<FeeStatistics> FeeStatistics([FromBody] FeeStatisticsRequest request)
|
|
|
{
|
|
|
if (request == null)
|
|
|
return DataResult<FeeStatistics>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var res = _feeService.GetList(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 DataResult Submit([FromBody] FeeRecordSubmit recordSubmit)
|
|
|
{
|
|
|
if (recordSubmit == null || recordSubmit.Items.IsNullOrEmpty())
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
if (recordSubmit.Items.Any(x => x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))
|
|
|
return DataResult.Failed("只能提交状态为‘录入’或‘驳回提交’的费用", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var list = recordSubmit.Items.Select(x => x.Adapt<FeeRecord>());
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
item.BusinessId = recordSubmit.BusinessId;
|
|
|
item.BusinessType = recordSubmit.BusinessType;
|
|
|
}
|
|
|
return _feeService.InsertOrUpdate(list);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据一组模板ID创建费用记录(引入模板)
|
|
|
/// </summary>
|
|
|
/// <param name="request">请求参数</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("CreateByTemplate")]
|
|
|
public DataResult CreateByTemplate([FromBody] FeeRecordByTemplate request)
|
|
|
{
|
|
|
if (request == null || request.TemplateIdList.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var res = _feeService.CreateByTemplate(request.BusinessId, request.BusinessType, request.TemplateIdList);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据费用记录ID删除
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Delete")]
|
|
|
public DataResult Delete([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var res = _feeService.Delete(model.Ids);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 提交审批
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyAudit")]
|
|
|
public DataResult ApplyAudit([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return _feeService.SubmitForApproval(FeeAuditType.ApplyAudit, model.Remark, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 申请删除
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyDeletion")]
|
|
|
public DataResult ApplyDeletion([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return _feeService.SubmitForApproval(FeeAuditType.ApplyDeletion, model.Remark, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 申请修改
|
|
|
/// </summary>
|
|
|
/// <param name="items">费用修改信息</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ApplyModification")]
|
|
|
public DataResult ApplyModification([FromBody] IEnumerable<FeeModification> items)
|
|
|
{
|
|
|
if (items.IsNullOrEmpty())
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return _feeService.SubmitForModification(items);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 撤销审批申请
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Withdraw")]
|
|
|
public DataResult Withdraw([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return _feeService.Withdraw(model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 变更费用审批状态
|
|
|
/// </summary>
|
|
|
/// <param name="callback">回调信息</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("ChangeStatus")]
|
|
|
public DataResult ChangeStatus([FromBody] FlowCallback callback)
|
|
|
{
|
|
|
if (callback == null)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return _feeService.UpdateAuditStatus(callback);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取费用核算单打印信息
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("GetPrintInfo")]
|
|
|
public DataResult<CostAccountingForm> GetPrintInfo(IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult<CostAccountingForm>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
return _feeService.GetPrintInfo((BusinessType)model.BusinessType, model.Ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置费用是否启用发票
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("SetInvoiceEnabled")]
|
|
|
public DataResult SetInvoiceEnabled(IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
bool enabled = Convert.ToBoolean(model.Value);
|
|
|
return _feeService.SetInvoiceEnabled(enabled, model.Ids);
|
|
|
}
|
|
|
}
|
|
|
}
|