using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
{
///
/// 费用审核服务
///
public class FeeAuditController : ApiController
{
readonly IFeeAuditService _auditService;
///
/// 初始化
///
///
public FeeAuditController(IFeeAuditService auditService)
{
_auditService = auditService;
}
///
/// 获取待审核列表
///
///
///
[HttpPost, Route("GetList")]
public async Task>> ListAsync([FromBody] PageRequest request)
{
return await _auditService.GetListAsync(request);
}
///
/// 根据查询条件获取费用明细
///
///
///
[HttpPost, Route("GetFees")]
public async Task>> GetFeesAsync([FromBody] AuditDetailRequest request)
{
return await _auditService.GetFeesAsync(request.Id, request.BusinessType, request.QueryCondition);
}
///
/// 获取整票待审核列表
///
///
///
[HttpPost, Route("GetBizList")]
public async Task>> BizListAsync([FromBody] PageRequest request)
{
return await _auditService.GetBizListAsync(request);
}
///
/// 按费用审核
///
///
///
[HttpPost, Route("Audit")]
public async Task AuditAsync(AuditRequest request)
{
if (request == null || request.Ids.Length == 0 || (request.Result != 1 && request.Result != 2))
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditAsync(request.Result, request.Remark, request.Ids);
}
///
/// 按业务审核
///
///
///
[HttpPost, Route("AuditByBiz")]
public async Task AuditAsync(BizAuditRequest request)
{
if (request == null || (request.Result != 1 && request.Result != 2) || request.Items == null || request.Items.Count == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditAsync(request);
}
///
/// 本票审核(一键审核当前登录用户的所有待审核项)
///
/// 审批结果: 1=通过 2=驳回
/// 审批备注
///
[HttpPost, Route("OneClickAudit")]
public async Task OneClickAuditAsync(int status, string remark)
{
if (status != 1 && status != 2)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditAsync(status, remark);
}
///
/// 整票审核
///
///
///
[HttpPost, Route("BusinessAudit")]
public async Task AuditBusinessAsync(BizAuditRequest request)
{
if (request == null || (request.Result != 1 && request.Result != 2) || request.Items == null || request.Items.Count == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditBusinessAsync(request);
}
///
/// 设置业务锁定状态
///
/// 请求信息
///
[HttpPost, Route("SetLocking")]
public async Task SetLockingAsync(BizOperation operation)
{
bool? isLocked = null;
try
{
isLocked = Convert.ToBoolean(operation.Value);
}
catch
{
return DataResult.Failed($"参数{nameof(operation.Value)}无效", MultiLanguageConst.IllegalRequest);
}
return await _auditService.SetFeeLockingAsync(operation.Items.Select(x => new Core.Op.Entity.BusinessFeeStatus
{
BusinessId = x.Id,
BusinessType = x.BusinessType,
IsFeeLocking = isLocked
}));
}
///
/// 变更费用审批状态(用于工作流框架的回调)
///
/// 回调信息
///
[HttpPost, Route("ChangeStatus")]
public async Task ChangeStatusAsync([FromBody] FlowCallback callback)
{
if (callback == null)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.UpdateStatusAsync(callback);
}
}
}