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.

221 lines
7.8 KiB
C#

using System.Net;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
{
/// <summary>
/// 费用审核服务
/// </summary>
public class FeeAuditController : ApiController
{
readonly IFeeAuditService _auditService;
/// <summary>
/// 初始化
/// </summary>
/// <param name="auditService"></param>
public FeeAuditController(IFeeAuditService auditService)
{
_auditService = auditService;
}
/// <summary>
/// 获取待审核列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <remarks>注意!!【仅看待审批】需要通过 OtherQueryCondition 属性传入</remarks>
[HttpPost, Route("GetList")]
public async Task<DataResult<List<FeeAuditBusiness>>> ListAsync([FromBody] PageRequest<bool> request)
{
return await _auditService.GetListAsync(request);
}
/// <summary>
/// 根据查询条件获取费用明细
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetFees")]
public async Task<DataResult<PendingAuditFee>> GetFeesAsync([FromBody] AuditDetailRequest request)
{
return await _auditService.GetFeesAsync(request);
}
/// <summary>
/// 获取业务相关联的费用统计
/// </summary>
/// <param name="request">查询条件</param>
/// <returns></returns>
[HttpPost, Route("GetStat")]
public async Task<DataResult<FeeAuditStatistics>> GetStatAsync([FromBody] FeeStatisticsRequestV2 request)
{
return await _auditService.GetStatAsync(request.Id, request.BusinessType, request.FeeId);
}
/// <summary>
/// 获取整票待审核列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetBizList")]
public async Task<DataResult<List<FeeAuditBusiness>>> BizListAsync([FromBody] PageRequest<bool> request)
{
return await _auditService.GetBizListAsync(request);
}
/// <summary>
/// 按费用审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("Audit")]
public async Task<DataResult> AuditAsync([FromBody] 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);
}
/// <summary>
/// 按业务审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("AuditByBiz")]
public async Task<DataResult> AuditAsync([FromBody] 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);
}
/// <summary>
/// 一键审核当前登录用户的所有待审核项
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("OneClickAudit")]
public async Task<DataResult> OneClickAuditAsync([FromBody] AuditConditionRequest request)
{
if (request.Result != 1 && request.Result != 2)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditAsync(request);
}
/// <summary>
/// 整票审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("BusinessAudit")]
public async Task<DataResult> AuditBillAsync([FromBody] TaskAuditRequest request)
{
if (request == null || (request.Result != 1 && request.Result != 2))
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditBillAsync(request);
}
/// <summary>
/// 锁单审核
/// </summary>
/// <param name="service"></param>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("BusinessLockAudit")]
public async Task<DataResult> AuditBillLockAsync([FromServices] IFeeBillTaskService service, [FromBody] TaskAuditRequest request)
{
if (request == null || (request.Result != 1 && request.Result != 2))
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await service.AuditAsync(request);
}
/// <summary>
/// 设置业务锁定状态
/// </summary>
/// <param name="operation">请求信息</param>
/// <returns></returns>
[HttpPost, Route("SetLocking")]
public async Task<DataResult> SetLockingAsync([FromBody] 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
}));
}
/// <summary>
/// 设置费用状态
/// </summary>
/// <param name="idModel"></param>
/// <returns></returns>
[HttpPost, Route("SetFeeStatus")]
public async Task<DataResult> SetFeeStatusAsync([FromBody] IdModel<FeeStatus> idModel)
{
return await _auditService.SetFeeStatusAsync(idModel.Value, idModel.Ids);
}
/// <summary>
/// 变更费用审核状态
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpPost, Route("ChangeStatus")]
public async Task<DataResult> ChangeStatusAsync([FromBody] FlowCallback callback)
{
if (callback == null)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.UpdateStatusAsync(callback);
}
/// <summary>
/// 整票审核回调
/// </summary>
/// <param name="service"></param>
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpPost, Route("BillCallback")]
public async Task<IActionResult> BillCallbackAsync([FromServices] IFeeBillTaskService service, [FromBody] FlowCallback callback)
{
if (callback == null)
return BadRequest("参数无效");
try
{
await service.UpdateBusinessAsync(callback);
return Ok();
}
catch (Exception ex)
{
return StatusCode((int)HttpStatusCode.InternalServerError, ex.Message);
}
}
}
}