opt:轨迹推送后更新订单合并到推送处理逻辑

This commit is contained in:
李鹏军 2024-04-10 15:27:52 +08:00
parent 636f189e50
commit 8e9f5931e4

View File

@ -1,50 +0,0 @@
using DotNetCore.CAP;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
using SJZY.Track.Domain.Consts;
using SJZY.Track.Domain.Enums;
using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.EventHandlers;
public class TrackPushAfterUpdateOrderEventHandler : ITransientDependency, ICapSubscribe
{
private readonly IOrderRepository _orderRepository;
public TrackPushAfterUpdateOrderEventHandler(IOrderRepository orderRepository)
{
_orderRepository = orderRepository;
}
[CapSubscribe(GlobalConst.TrackPushAfterUpdateOrderSubscribe)]
public async Task ConsumerAsync(TrackPushAfterUpdateOrderDto dto)
{
var order = await _orderRepository.GetFirstAsync(x => x.Id == dto.OrderId);
if (order == default) return;
/*
* 异常:最近一条推送是失败
*/
if (!dto.IsSuccess)
{
order.QuestionType = (int)TrackProblemType.Error;
order.LatestPushError = dto.Message;
}
else
{
order.QuestionType = (int)TrackProblemType.None;
order.LatestPushError = null;
if (dto.OptionType == OptionType.新增)
{
// tips:只有新增会影响推送进度
order.LatestPushTrackCode = dto.TrackCode;
order.LatestPushTime = DateTime.Now;
}
}
await _orderRepository.UpdateColumnAsync(order, x => new
{
x.LatestPushTrackCode, x.QuestionType, x.LatestPushError, x.LatestPushTime
});
}
}