|
|
|
|
using System.Net;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.FeeApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 往来单位费用模板API
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FeeCustTemplateController : ApiController
|
|
|
|
|
{
|
|
|
|
|
readonly IFeeCustTemplateService _invokeService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造函数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="invokeService"></param>
|
|
|
|
|
public FeeCustTemplateController(IFeeCustTemplateService invokeService)
|
|
|
|
|
{
|
|
|
|
|
_invokeService = invokeService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成订单费用
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="etd">开船日期</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("GenerateFees")]
|
|
|
|
|
public async Task<IActionResult> GenerateFeesAsync(DateTime? etd)
|
|
|
|
|
{
|
|
|
|
|
HttpStatusCode httpStatusCode;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await _invokeService.GenerateFeesAsync(etd ?? DateTime.Now.Date);
|
|
|
|
|
httpStatusCode = HttpStatusCode.NoContent;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
httpStatusCode = HttpStatusCode.InternalServerError;
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new StatusCodeResult((int)httpStatusCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("GetList")]
|
|
|
|
|
public async Task<DataResult<List<FeeCustTemplate>>> GetListAsync([FromBody] PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
return await _invokeService.GetListAsync(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("Edit")]
|
|
|
|
|
public async Task<DataResult> EditAsync([FromBody] FeeCustTemplate model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
|
|
|
|
return await _invokeService.EditAsync(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet, Route("Edit")]
|
|
|
|
|
public async Task<DataResult<FeeCustTemplate>> GetAsync([FromQuery] long id)
|
|
|
|
|
{
|
|
|
|
|
return await _invokeService.GetAsync(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据ID删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></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 _invokeService.DeleteAsync(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据ID删除明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("DeleteDetails")]
|
|
|
|
|
public async Task<DataResult> DeleteAsync([FromServices] IFeeCustTemplateDetailService detailService, [FromBody] IdModel model)
|
|
|
|
|
{
|
|
|
|
|
if (!ModelState.IsValid)
|
|
|
|
|
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
|
|
|
|
return await detailService.DeleteAsync(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|