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
{
///
/// 标准(按申请)开票API
///
public class GeneralInvoiceController : ApiController
{
readonly IGeneralInvoiceService _service;
///
/// 初始化
///
///
public GeneralInvoiceController(IGeneralInvoiceService service)
{
_service = service;
}
///
/// 获取发票详情
///
/// 发票ID
///
[HttpGet, Route("Get")]
public async Task> GetAsync(long id)
{
return await _service.GetAsync(id);
}
///
/// 提交发票开票
///
/// 请求参数
///
[HttpPost, Route("Save")]
public async Task> SaveAsync(InvoiceRequest request)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.SaveAsync(request);
}
///
/// 删除发票明细
///
/// 发票明细ID
///
[HttpPost, Route("DeleteDetail")]
public async Task DeleteDetailAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.DeleteDetailAsync(model.Ids);
}
///
/// 删除发票
///
/// 发票ID
///
[HttpPost, Route("Delete")]
public async Task DeleteAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.DeleteAsync(model.Ids);
}
///
/// 设置发票的锁定状态
///
/// 发票ID
///
[HttpPost, Route("SetLock")]
public async Task 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);
}
}
}