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.

147 lines
5.0 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Invoice.Dto;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Invoice.Entity;
using DS.WMS.Core.Invoice.Interface;
using Microsoft.AspNetCore.Mvc;
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>
[HttpPost, Route("GetApplicationList")]
public async Task<DataResult<List<InvoiceApplicationDto>>> GetApplicationListAsync([FromBody]PageRequest request)
{
return await _service.GetApplicationListAsync(request);
}
/// <summary>
/// 获取发票申请明细
/// </summary>
/// <param name="id">申请单ID</param>
/// <returns></returns>
[HttpGet, Route("GetApplicationDetails")]
public async Task<DataResult<List<InvoiceApplicationDetailDto>>> GetApplicationDetailsAsync([FromQuery]long id)
{
return await _service.GetApplicationDetailsAsync(id);
}
/// <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);
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);
}
}
}