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.

139 lines
4.7 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Enums;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Settlement.Dtos;
using DS.WMS.Core.Settlement.Entity;
using DS.WMS.Core.Settlement.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
{
/// <summary>
/// 自由结算API
/// </summary>
public class PaymentFreeSettlementController : ApiController
{
readonly IFreeSettlementService _service;
/// <summary>
/// 初始化
/// </summary>
/// <param name="service"></param>
public PaymentFreeSettlementController(IFreeSettlementService service)
{
_service = service;
}
/// <summary>
/// 获取待结算业务分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetBizList")]
public async Task<DataResult<List<SettlementBiz>>> GetBizListAsync([FromBody] PageRequest request)
{
return await _service.GetBizListAsync(request);
}
/// <summary>
/// 根据业务编号及类型获取关联费用记录
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
[HttpPost, Route("GetFees")]
public async Task<DataResult<FeeForm>> GetFeesAsync([FromBody] FeeClient[] items)
{
return await _service.GetFeesAsync(items);
}
/// <summary>
/// 获取自由结算单
/// </summary>
/// <param name="id">结算单ID</param>
/// <returns></returns>
[HttpGet, Route("Get")]
public async Task<DataResult<ApplicationSettlementDto>> GetAsync(long id)
{
return await _service.GetAsync(id);
}
/// <summary>
/// 获取自由结算明细
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <remarks>注意需要指定结算单ID通过 OtherQueryCondition 传入</remarks>
[HttpPost, Route("GetDetails")]
public async Task<DataResult<FreeSettlement>> GetDetailsAsync(PageRequest<long> request)
{
return await _service.GetDetailsAsync(request);
}
/// <summary>
/// 根据费用申请创建结算单
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("Save")]
public async Task<DataResult<ApplicationSettlement>> SaveAsync([FromBody] SettlementRequest<ApplicationSettlement> request)
{
request.Settlement.Mode = SettlementMode.FreeSettlement;
return await _service.SaveAsync(request);
}
/// <summary>
/// 根据业务编号及类型获取该票业务的币别
/// </summary>
/// <param name="items">业务ID与业务类型</param>
/// <returns></returns>
[HttpPost, Route("GetCurrencies")]
public async Task<DataResult<List<FeeClient>>> GetCurrenciesAsync([FromBody] FeeClient[] items)
{
return await _service.GetCurrenciesAsync(items);
}
/// <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>
/// <returns></returns>
[HttpPost, Route("SetLock")]
public async Task<DataResult> SetLockAsync(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);
}
}
}