订单列表优化
This commit is contained in:
parent
ee2b14ad12
commit
79d07c92be
@ -1671,11 +1671,12 @@ public class EventClientController : IDynamicApiController
|
||||
};
|
||||
await _orderRepository.InsertAsync(refundOrder);
|
||||
|
||||
// 更新原订单状态
|
||||
originalOrder.OrderStatus = OrderStatus.Refunded;
|
||||
originalOrder.UpdatedTime = now;
|
||||
originalOrder.UpdatedUserId = userId;
|
||||
await _orderRepository.UpdateAsync(originalOrder);
|
||||
// 不更新原订单状态,保持原订单状态不变
|
||||
// // 更新原订单状态
|
||||
// originalOrder.OrderStatus = OrderStatus.Refunded;
|
||||
// originalOrder.UpdatedTime = now;
|
||||
// originalOrder.UpdatedUserId = userId;
|
||||
// await _orderRepository.UpdateAsync(originalOrder);
|
||||
|
||||
// 更新报名状态,清空订单号,确保下次重新报名时创建新订单
|
||||
registration.PaymentStatus = 3;
|
||||
|
||||
@ -517,23 +517,62 @@ public class MyController : IDynamicApiController
|
||||
public async Task<PageResult<MyOrderDto>> GetOrders([FromQuery] MyPageInput input)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
var query = _orderRepository.AsQueryable()
|
||||
|
||||
// 先查询所有订单
|
||||
var orders = await _orderRepository.AsQueryable()
|
||||
.LeftJoin<EventInfo>((o, e) => o.EventId == e.Id)
|
||||
.Where((o, e) => o.CreatedUserId == userId && !o.DeleteMark && o.OrderStatus != OrderStatus.Cancelled)
|
||||
.Select((o, e) => new MyOrderDto
|
||||
.Select((o, e) => new
|
||||
{
|
||||
Id = o.Id,
|
||||
OrderNo = o.OrderNo,
|
||||
o.Id,
|
||||
o.OrderNo,
|
||||
EventName = e.EventName,
|
||||
ActualAmount = o.ActualAmount,
|
||||
RefundAmount = o.OrderType == 2 ? o.ActualAmount : null,
|
||||
OrderStatus = o.OrderStatus,
|
||||
PaymentTime = o.PaymentTime,
|
||||
CreatedTime = o.CreatedTime
|
||||
o.ActualAmount,
|
||||
o.OrderType,
|
||||
o.RelatedOrderId,
|
||||
o.OrderStatus,
|
||||
o.PaymentTime,
|
||||
o.CreatedTime
|
||||
})
|
||||
.OrderByDescending(o => o.CreatedTime);
|
||||
|
||||
return await query.ToPagedListAsync(input);
|
||||
.OrderByDescending(o => o.CreatedTime)
|
||||
.ToPagedListAsync(input);
|
||||
|
||||
// 处理退款订单的金额显示
|
||||
var resultList = new List<MyOrderDto>();
|
||||
foreach (var order in orders.Rows)
|
||||
{
|
||||
var dto = new MyOrderDto
|
||||
{
|
||||
Id = order.Id,
|
||||
OrderNo = order.OrderNo,
|
||||
EventName = order.EventName,
|
||||
ActualAmount = order.ActualAmount,
|
||||
RefundAmount = order.OrderType == 2 ? order.ActualAmount : null,
|
||||
OrderStatus = order.OrderStatus,
|
||||
PaymentTime = order.PaymentTime,
|
||||
CreatedTime = order.CreatedTime
|
||||
};
|
||||
|
||||
// 如果是退款订单,查找关联的原始订单,显示原始支付金额
|
||||
if (order.OrderType == 2 && order.RelatedOrderId > 0)
|
||||
{
|
||||
var originalOrder = await _orderRepository.GetByIdAsync(order.RelatedOrderId);
|
||||
if (originalOrder != null)
|
||||
{
|
||||
dto.ActualAmount = originalOrder.ActualAmount;
|
||||
}
|
||||
}
|
||||
|
||||
resultList.Add(dto);
|
||||
}
|
||||
|
||||
return new PageResult<MyOrderDto>
|
||||
{
|
||||
PageNo = orders.PageNo,
|
||||
PageSize = orders.PageSize,
|
||||
Total = orders.Total,
|
||||
Rows = resultList
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -578,12 +617,23 @@ public class MyController : IDynamicApiController
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
// 如果是退款订单,查找关联的原始订单,显示原始支付金额
|
||||
decimal displayAmount = order.ActualAmount;
|
||||
if (order.OrderType == 2 && order.RelatedOrderId > 0)
|
||||
{
|
||||
var originalOrder = await _orderRepository.GetByIdAsync(order.RelatedOrderId);
|
||||
if (originalOrder != null)
|
||||
{
|
||||
displayAmount = originalOrder.ActualAmount;
|
||||
}
|
||||
}
|
||||
|
||||
return new MyOrderDetailDto
|
||||
{
|
||||
Id = order.Id,
|
||||
OrderNo = order.OrderNo,
|
||||
EventName = eventName,
|
||||
ActualAmount = order.ActualAmount,
|
||||
ActualAmount = displayAmount,
|
||||
RefundAmount = order.OrderType == 2 ? order.ActualAmount : null,
|
||||
RefundTime = order.OrderType == 2 ? order.PaymentTime : null,
|
||||
OrderStatus = order.OrderStatus,
|
||||
|
||||
@ -3728,11 +3728,12 @@ public class UnifiedRegistrationService : ITransient
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPartialCancel || registration.PaymentStatus == 3 || registration.PaymentStatus == 4)
|
||||
{
|
||||
var orderStatus = registration.PaymentMethod == 1 ? OrderStatus.Cancelled : OrderStatus.Refunded;
|
||||
await UpdateOrderStatusAsync(registration.OrderNo, orderStatus, operatorUserId);
|
||||
}
|
||||
// 不修改原订单状态,只创建退款订单记录
|
||||
// if (!isPartialCancel || registration.PaymentStatus == 3 || registration.PaymentStatus == 4)
|
||||
// {
|
||||
// var orderStatus = registration.PaymentMethod == 1 ? OrderStatus.Cancelled : OrderStatus.Refunded;
|
||||
// await UpdateOrderStatusAsync(registration.OrderNo, orderStatus, operatorUserId);
|
||||
// }
|
||||
|
||||
_logger.LogInformation("统一取消报名完成:报名ID={RegistrationId}, 操作人={UserId}, 退款金额={RefundAmount}, 成功={Success}",
|
||||
registration.Id, operatorUserId, actualRefundAmount, output.Success);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user