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