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.

191 lines
6.7 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Data;
3 months ago
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<string> 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);
3 months ago
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 model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
bool isLocked = Convert.ToBoolean(model.Value);
return await _service.SetLockAsync(isLocked, model.Ids);
}
/// <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="tenant">租户信息</param>
/// <returns></returns>
[HttpPost, Route("AddTenant")]
public async Task<string> AddTenantAsync([FromServices] IInvoiceIssuanceService issuanceService, Tenant tenant)
{
return await issuanceService.AddTenantAsync(tenant);
}
}
}