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
{
///
/// 标准(按申请)开票API
///
public class GeneralInvoiceController : ApiController
{
readonly IGeneralInvoiceService _service;
///
/// 初始化
///
///
public GeneralInvoiceController(IGeneralInvoiceService service)
{
_service = service;
}
///
/// 获取开票分页列表
///
///
///
/// 【编号检索】需通过 OtherQueryCondition 字段传入
[HttpPost, Route("GetList")]
public async Task> GetListAsync([FromBody] PageRequest request)
{
return await _service.GetListAsync(request);
}
///
/// 获取发票申请分页列表
///
///
///
[HttpPost, Route("GetApplicationList")]
public async Task>> GetApplicationListAsync([FromBody] PageRequest request)
{
return await _service.GetApplicationListAsync(request);
}
///
/// 获取发票申请明细
///
/// 一组申请单ID
///
[HttpPost, Route("GetApplicationDetails")]
public async Task>> GetApplicationDetailsAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult>.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.GetApplicationDetailsAsync(model.Ids);
}
///
/// 获取发票详情
///
/// 发票ID
///
[HttpGet, Route("Get")]
public async Task> GetAsync(long id)
{
return await _service.GetAsync(id);
}
///
/// 提交发票开票
///
/// 请求参数
///
[HttpPost, Route("Save")]
public async Task> SaveAsync([FromBody] InvoiceRequest request)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
request.Invoice.Mode = InvoiceMode.Applcation;
return await _service.SaveAsync(request);
}
///
/// 删除发票明细
///
/// 发票明细ID
///
[HttpPost, Route("DeleteInvoiceDetail")]
public async Task DeleteInvoiceDetailAsync([FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _service.DeleteInvoiceDetailAsync(model.Ids);
}
///
/// 删除费用明细
///
/// 发票明细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);
}
///
/// 发起开票请求
///
///
/// 开票的发票ID
///
//[HttpPost, Route("Initiate")]
//public async Task InitiateAsync([FromServices] IInvoiceIssuanceService issuanceService,
// [FromBody] IdModel idModel)
//{
// if (!ModelState.IsValid)
// return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
// return await issuanceService.InitiateAsync(idModel.Ids);
//}
///
/// 发起冲红
///
///
/// 请求参数
///
[HttpPost, Route("Reverse")]
public async Task ReverseAsync([FromServices] IInvoiceIssuanceService issuanceService,
[FromBody] InvoiceReversalRequest request)
{
return await issuanceService.ReverseAsync(request);
}
///
/// 添加租户信息
///
///
/// 租户信息
///
[HttpPost, Route("AddTenant")]
public async Task AddTenantAsync([FromServices] IInvoiceIssuanceService issuanceService, Tenant tenant)
{
return await issuanceService.AddTenantAsync(tenant);
}
}
}