|
|
using DS.Module.Core;
|
|
|
using DS.Module.Core.Data;
|
|
|
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 InvoiceController : ApiController
|
|
|
{
|
|
|
readonly IInvoiceService<Invoice> _service;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化
|
|
|
/// </summary>
|
|
|
/// <param name="service"></param>
|
|
|
public InvoiceController(IInvoiceService<Invoice> service)
|
|
|
{
|
|
|
_service = service;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取列表
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <remarks>注意!!【申请编号】OtherQueryCondition 属性传入</remarks>
|
|
|
[HttpPost, Route("GetList")]
|
|
|
public async Task<DataResult<List<InvoiceDto>>> ListAsync([FromBody] PageRequest<string> request)
|
|
|
{
|
|
|
return await _service.GetListAsync(request);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 提交发票开票
|
|
|
/// </summary>
|
|
|
/// <param name="request">请求参数</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Save")]
|
|
|
public async Task<DataResult<Invoice>> SaveAsync(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("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);
|
|
|
}
|
|
|
}
|
|
|
}
|