fix: 删除订单只改状态,已删除 Tab 可查
All checks were successful
Build and Deploy / deploy (push) Successful in 1m12s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m12s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6be97e7232
commit
fef409a4ce
@ -108,7 +108,10 @@ public partial class OrderService : ApplicationService
|
|||||||
StringComparer.OrdinalIgnoreCase);
|
StringComparer.OrdinalIgnoreCase);
|
||||||
var output = new OrderStatusCountsOutput
|
var output = new OrderStatusCountsOutput
|
||||||
{
|
{
|
||||||
Total = rows.Sum(x => x.Count),
|
// 「全部」不含已删除;已删除单独走 deleted Tab
|
||||||
|
Total = rows
|
||||||
|
.Where(x => !string.Equals(x.Status, OrderStatusCodes.Deleted, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Sum(x => x.Count),
|
||||||
Counts = counts,
|
Counts = counts,
|
||||||
HandleCounts = handleCounts
|
HandleCounts = handleCounts
|
||||||
};
|
};
|
||||||
@ -441,6 +444,7 @@ public partial class OrderService : ApplicationService
|
|||||||
throw new BusinessException("仅草稿或已预报订单可删除");
|
throw new BusinessException("仅草稿或已预报订单可删除");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 业务删除:只改 OrderStatus=deleted,不做 IsDeleted 软删,否则「已删除」Tab 因全局软删过滤永远查不到。
|
||||||
order.OrderStatus = OrderStatusCodes.Deleted;
|
order.OrderStatus = OrderStatusCodes.Deleted;
|
||||||
if (order.IsPaid > 0 && order.CustomerId.HasValue)
|
if (order.IsPaid > 0 && order.CustomerId.HasValue)
|
||||||
{
|
{
|
||||||
@ -460,7 +464,6 @@ public partial class OrderService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
await OrderRepository.UpdateAsync(order);
|
await OrderRepository.UpdateAsync(order);
|
||||||
await OrderRepository.DeleteAsync(order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -48,8 +48,18 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
var status = filter.Status?.Trim();
|
var status = filter.Status?.Trim();
|
||||||
if (!string.IsNullOrWhiteSpace(status)
|
var isDeletedTab = string.Equals(status, OrderStatusCodes.Deleted, StringComparison.OrdinalIgnoreCase);
|
||||||
&& !string.Equals(status, "all", StringComparison.OrdinalIgnoreCase))
|
if (isDeletedTab)
|
||||||
|
{
|
||||||
|
// 历史删除曾同时软删(IsDeleted=true),需清过滤才能在「已删除」看到
|
||||||
|
query = query.ClearFilter().Where(x => x.OrderStatus == OrderStatusCodes.Deleted);
|
||||||
|
}
|
||||||
|
else if (string.Equals(status, "all", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// 列表「全部」不含已删除;status 为空时留给 status-counts 聚合(需含 deleted 桶)
|
||||||
|
query = query.Where(x => x.OrderStatus != OrderStatusCodes.Deleted);
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrWhiteSpace(status))
|
||||||
{
|
{
|
||||||
query = query.Where(x => x.OrderStatus == status);
|
query = query.Where(x => x.OrderStatus == status);
|
||||||
}
|
}
|
||||||
@ -1352,7 +1362,12 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
|
|||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var db = await GetDbContextAsync(cancellationToken);
|
var db = await GetDbContextAsync(cancellationToken);
|
||||||
var query = ApplyListFilter(db.Queryable<Order>(), filter);
|
// 含历史「状态=deleted 且已软删」的单据,保证已删除 Tab 角标可见
|
||||||
|
var query = ApplyListFilter(
|
||||||
|
db.Queryable<Order>()
|
||||||
|
.ClearFilter()
|
||||||
|
.Where(x => !x.IsDeleted || x.OrderStatus == OrderStatusCodes.Deleted),
|
||||||
|
filter);
|
||||||
|
|
||||||
return await query
|
return await query
|
||||||
.GroupBy(x => x.OrderStatus)
|
.GroupBy(x => x.OrderStatus)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user