You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
8.3 KiB
C#

5 months ago
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.UserModule;
5 months ago
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Application.Interface;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Invoice.Entity;
5 months ago
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
{
/// <summary>
/// 发票申请API
5 months ago
/// </summary>
public class InvoiceApplicationController : ApiController
{
readonly IInvoiceApplicationService _service;
/// <summary>
/// 初始化
/// </summary>
/// <param name="service"></param>
public InvoiceApplicationController(IInvoiceApplicationService service)
{
_service = service;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetList")]
public async Task<DataResult<List<InvoiceApplicationDto>>> ListAsync([FromBody] PageRequest request)
{
return await _service.GetListAsync(request);
}
/// <summary>
/// 获取待开票的业务列表
5 months ago
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <remarks>注意!!【费用范围】一栏需通过 OtherQueryCondition 字段传入枚举值</remarks>
5 months ago
[HttpPost, Route("GetBizList")]
public async Task<DataResult<List<BizInvoiceApplication>>> BizListAsync([FromBody] PageRequest<FeeRange?> request)
5 months ago
{
return await _service.GetBizListAsync(request);
}
/// <summary>
/// 获取申请单详情
/// </summary>
/// <param name="id">申请单ID</param>
/// <returns></returns>
[HttpGet, Route("Get")]
public async Task<DataResult<InvoiceApplicationDto>> GetAsync([FromQuery] long id)
{
return await _service.GetAsync(id);
}
5 months ago
/// <summary>
/// 根据业务编号及类型获取关联费用记录
/// </summary>
/// <param name="items">业务ID和类型</param>
/// <returns></returns>
[HttpPost, Route("GetFees")]
public async Task<DataResult<InvoiceApplicaitonBiz>> GetFeesAsync([FromBody] params BizItem[] items)
{
if (items == null || items.Length == 0)
return DataResult<InvoiceApplicaitonBiz>.Failed("缺少请求参数");
5 months ago
return await _service.GetFeesAsync(items);
}
5 months ago
/// <summary>
/// 提交申请单
/// </summary>
/// <param name="application">申请单</param>
/// <returns></returns>
[HttpPost, Route("Save")]
public async Task<DataResult<InvoiceApplication>> SaveAsync([FromBody] InvoiceApplication application)
5 months ago
{
return await _service.SaveAsync(application);
}
/// <summary>
/// 按业务提交申请单
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("BizSave")]
public async Task<DataResult<InvoiceApplication>> SaveAsync([FromBody] ApplicationRequest<InvoiceApplication> request)
5 months ago
{
if (request.Items == null || request.Items.Count == 0)
return DataResult<InvoiceApplication>.Failed("缺少请求参数");
5 months ago
return await _service.SaveAsync(request);
}
/// <summary>
/// 删除发票明细
/// </summary>
/// <param name="model">发票明细ID</param>
/// <returns></returns>
[HttpPost, Route("DeleteInvoiceDetail")]
public async Task<DataResult> DeleteInvoiceDetailAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.DeleteInvoiceDetailAsync(model.Ids);
}
5 months ago
/// <summary>
/// 删除申请单明细
/// </summary>
/// <param name="model">申请单明细ID</param>
/// <returns></returns>
[HttpPost, Route("DeleteDetail")]
public async Task<DataResult> DeleteDetailAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
5 months ago
return await _service.DeleteDetailAsync(model.Ids);
}
/// <summary>
/// 删除申请单
/// </summary>
/// <param name="model">申请单ID</param>
/// <returns></returns>
[HttpPost, Route("Delete")]
public async Task<DataResult> DeleteAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
5 months ago
return await _service.DeleteAsync(model.Ids);
}
/// <summary>
/// 发起审批
/// </summary>
/// <param name="model">申请单ID</param>
/// <returns></returns>
[HttpPost, Route("ApplyAudit")]
public async Task<DataResult> ApplyAuditAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
5 months ago
return await _service.SubmitApprovalAsync(TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT, model.Remark, model.Ids);
5 months ago
}
/// <summary>
/// 撤销审批
/// </summary>
/// <param name="model">申请单ID</param>
/// <returns></returns>
[HttpPost, Route("Withdraw")]
public async Task<DataResult> WithdrawAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
5 months ago
return await _service.WithdrawAsync(model.Ids);
}
/// <summary>
/// 获取发票模板字段
5 months ago
/// </summary>
/// <param name="templateService"></param>
/// <param name="host"></param>
/// <returns></returns>
[HttpGet, Route("GetTemplateFields")]
public DataResult<List<TemplateField>> GetTemplateFields(
[FromServices] IInvoiceTemplateService templateService, [FromServices] IHostEnvironment host)
5 months ago
{
return templateService.GetFields(host);
}
/// <summary>
/// 获取发票模板列表
5 months ago
/// </summary>
/// <param name="templateService"></param>
/// <param name="createIfEmpty">如果为空,则创建默认模板</param>
/// <returns></returns>
[HttpGet, Route("GetTemplateList")]
public DataResult<List<InvoiceTemplate>> GetTemplateList(
[FromServices] IInvoiceTemplateService templateService, [FromQuery] bool createIfEmpty = true)
5 months ago
{
var user = HttpContext.RequestServices.GetRequiredService<IUser>();
long userId = long.Parse(user.UserId);
return templateService.GetList(userId, createIfEmpty);
5 months ago
}
/// <summary>
/// 保存发票模板
5 months ago
/// </summary>
/// <param name="templateService"></param>
/// <param name="templates">发票模板</param>
/// <returns></returns>
[HttpPost, Route("SaveTemplate")]
public DataResult<List<InvoiceTemplate>> SaveTemplate(
[FromServices] IInvoiceTemplateService templateService, [FromBody] params InvoiceTemplate[] templates)
5 months ago
{
return templateService.Save(templates);
}
/// <summary>
/// 以申请单的数据渲染发票模板
/// </summary>
/// <param name="id">发票申请ID</param>
/// <param name="template">模板文本</param>
/// <param name="templateService"></param>
/// <param name="host"></param>
/// <returns></returns>
[HttpGet, Route("RenderTemplate")]
public async Task<DataResult<string>> RenderTemplate([FromQuery] long id, [FromQuery] string template,
[FromServices] IInvoiceTemplateService templateService, [FromServices] IHostEnvironment host)
{
return await templateService.RenderTemplateAsync(id, template, host);
}
5 months ago
}
}