|
|
using DS.Module.Core;
|
|
|
using DS.Module.Core.Data;
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
using Mapster;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
namespace DS.WMS.FeeApi.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 费用记录服务
|
|
|
/// </summary>
|
|
|
public class FeeRecordController : ApiController
|
|
|
{
|
|
|
private readonly IFeeRecordService _invokeService;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
|
/// <param name="invokeService"></param>
|
|
|
public FeeRecordController(IFeeRecordService invokeService)
|
|
|
{
|
|
|
_invokeService = invokeService;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 列表
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("GetList")]
|
|
|
public DataResult<List<FeeRecordRes>> GetList([FromBody] PageRequest request)
|
|
|
{
|
|
|
var res = _invokeService.GetListByPage(request);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 提交费用
|
|
|
/// </summary>
|
|
|
/// <param name="recordSubmit">费用提交参数</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Submit")]
|
|
|
public DataResult Submit([FromBody] FeeRecordSubmit recordSubmit)
|
|
|
{
|
|
|
if (recordSubmit == null)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
if (recordSubmit.Items.Any(x => x.FeeStatus != FeeStatusEnum.Entering))
|
|
|
return DataResult.Failed("只能提交状态为‘录入’的费用", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var list = recordSubmit.Items.Select(x => x.Adapt<FeeRecord>());
|
|
|
return _invokeService.InsertOrUpdate(recordSubmit.BusinessId, list);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据一组模板ID创建费用记录(引入模板)
|
|
|
/// </summary>
|
|
|
/// <param name="request">请求参数</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("CreateByTemplate")]
|
|
|
public DataResult CreateByTemplate([FromBody] FeeRecordByTemplate request)
|
|
|
{
|
|
|
if (request == null || request.TemplateIdList.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var res = _invokeService.CreateByTemplate(request.BusinessId, request.TemplateIdList);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据费用记录ID删除
|
|
|
/// </summary>
|
|
|
/// <param name="model">费用记录ID</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("Delete")]
|
|
|
public DataResult Delete([FromBody] IdModel model)
|
|
|
{
|
|
|
if (model == null || model.Ids.Length == 0)
|
|
|
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
|
|
|
|
|
|
var res = _invokeService.Delete(model.Ids);
|
|
|
return res;
|
|
|
}
|
|
|
}
|
|
|
}
|