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.

214 lines
7.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Enums;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Invoice.Entity;
using DS.WMS.Core.Invoice.Interface;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace DS.WMS.FeeApi.Controllers
{
/// <summary>
/// 标准按申请开票API
/// </summary>
public class GeneralInvoiceController : ApiController
{
readonly IGeneralInvoiceService _service;
/// <summary>
/// 初始化
/// </summary>
/// <param name="service"></param>
public GeneralInvoiceController(IGeneralInvoiceService service)
{
_service = service;
}
/// <summary>
/// 获取开票分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <remarks>【编号检索】需通过 OtherQueryCondition 字段传入</remarks>
[HttpPost, Route("GetList")]
public async Task<DataResult<InvoiceList>> GetListAsync([FromBody] PageRequest<NumberQuery> request)
{
return await _service.GetListAsync(request);
}
/// <summary>
/// 获取发票申请分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetApplicationList")]
public async Task<DataResult<List<InvoiceApplicationDto>>> GetApplicationListAsync([FromBody] PageRequest request)
{
return await _service.GetApplicationListAsync(request);
}
/// <summary>
/// 获取发票申请明细
/// </summary>
/// <param name="model">一组申请单ID</param>
/// <returns></returns>
[HttpPost, Route("GetApplicationDetails")]
public async Task<DataResult<List<InvoiceApplicationDetailDto>>> GetApplicationDetailsAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult<List<InvoiceApplicationDetailDto>>.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.GetApplicationDetailsAsync(model.Ids);
}
/// <summary>
/// 获取发票详情
/// </summary>
/// <param name="id">发票ID</param>
/// <returns></returns>
[HttpGet, Route("Get")]
public async Task<DataResult<InvoiceDto>> GetAsync(long id)
{
return await _service.GetAsync(id);
}
/// <summary>
/// 提交发票开票
/// </summary>
/// <param name="request">请求参数</param>
/// <returns></returns>
[HttpPost, Route("Save")]
public async Task<DataResult<Invoice>> SaveAsync([FromBody] InvoiceRequest<Invoice> request)
{
if (!ModelState.IsValid)
return DataResult<Invoice>.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
request.Invoice.Mode = InvoiceMode.Applcation;
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);
}
/// <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);
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);
return await _service.DeleteAsync(model.Ids);
}
/// <summary>
/// 设置发票的锁定状态
/// </summary>
/// <param name="model">发票ID</param>
/// <returns></returns>
[HttpPost, Route("SetLock")]
public async Task<DataResult> SetLockAsync([FromBody] IdModel<bool> model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.SetLockAsync(model.Value, model.Ids);
}
/// <summary>
/// 请求开票API查询发票状态
/// </summary>
/// <param name="issuanceService"></param>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost, Route("ApiQuery")]
public async Task<DataResult> ApiQueryAsync([FromServices] IInvoiceIssuanceService issuanceService, long id)
{
return await issuanceService.UpdateInvoiceNumberAsync(id);
}
/// <summary>
/// 发起开票请求
/// </summary>
/// <param name="issuanceService"></param>
/// <param name="idModel">开票的发票ID</param>
/// <returns></returns>
[HttpPost, Route("Initiate")]
public async Task<DataResult> InitiateAsync([FromServices] IInvoiceIssuanceService issuanceService,
[FromBody] IdModel idModel)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await issuanceService.InitiateAsync(idModel.Ids);
}
/// <summary>
/// 发起冲红
/// </summary>
/// <param name="issuanceService"></param>
/// <param name="request">请求参数</param>
/// <returns></returns>
[HttpPost, Route("Reverse")]
public async Task<DataResult> ReverseAsync([FromServices] IInvoiceIssuanceService issuanceService,
[FromBody] InvoiceReversalRequest request)
{
return await issuanceService.ReverseAsync(request);
}
/// <summary>
/// 发送开票邮件
/// </summary>
/// <param name="issuanceService"></param>
/// <param name="id">发票ID</param>
/// <returns></returns>
[HttpPost, Route("SendMail")]
public async Task<DataResult> SendMailAsync([FromServices] IInvoiceIssuanceService issuanceService, long id)
{
return await issuanceService.SendMailAsync(id);
}
/// <summary>
/// 添加租户信息
/// </summary>
/// <param name="issuanceService"></param>
/// <param name="tenant">租户信息</param>
/// <returns></returns>
[HttpPost, Route("AddTenant")]
public async Task<string> AddTenantAsync([FromServices] IInvoiceIssuanceService issuanceService, Tenant tenant)
{
return await issuanceService.AddTenantAsync(tenant);
}
}
}