feat: 运单列表筛选补齐拦截/偏远/COD及处理状态等字段
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
ff9a3ae8be
commit
346f41c204
@ -470,15 +470,51 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
|
||||
q => q.Where(x => x.AllocationPendingReason == null || x.AllocationPendingReason == string.Empty),
|
||||
q => q.Where(x => x.AllocationPendingReason != null && x.AllocationPendingReason != string.Empty));
|
||||
}
|
||||
else if (string.Equals(field, "isPaid", StringComparison.OrdinalIgnoreCase))
|
||||
else if (string.Equals(field, "isPaid", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(field, "isIntercept", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(field, "isRemote", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(field, "isCod", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (byte.TryParse(value, out var paid) || TryParseBoolByte(value, out paid))
|
||||
query = ApplyByteFlagField(query, field, op, value, values);
|
||||
}
|
||||
else if (string.Equals(field, "handleStatus", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
query = ApplyStringField(query, op, value, values,
|
||||
(q, v) => q.Where(x => (x.HandleStatus ?? string.Empty).Contains(v)),
|
||||
(q, v) => q.Where(x => x.HandleStatus == v),
|
||||
(q, v) => q.Where(x => x.HandleStatus != v),
|
||||
(q, list) => q.Where(x => x.HandleStatus != null && list.Contains(x.HandleStatus)),
|
||||
(q, list) => q.Where(x => x.HandleStatus == null || !list.Contains(x.HandleStatus)),
|
||||
q => q.Where(x => x.HandleStatus == null || x.HandleStatus == string.Empty),
|
||||
q => q.Where(x => x.HandleStatus != null && x.HandleStatus != string.Empty));
|
||||
}
|
||||
else if (string.Equals(field, "previousOrderStatus", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
query = ApplyStringField(query, op, value, values,
|
||||
(q, v) => q.Where(x => (x.PreviousOrderStatus ?? string.Empty).Contains(v)),
|
||||
(q, v) => q.Where(x => x.PreviousOrderStatus == v),
|
||||
(q, v) => q.Where(x => x.PreviousOrderStatus != v),
|
||||
(q, list) => q.Where(x => x.PreviousOrderStatus != null && list.Contains(x.PreviousOrderStatus)),
|
||||
(q, list) => q.Where(x => x.PreviousOrderStatus == null || !list.Contains(x.PreviousOrderStatus)),
|
||||
q => q.Where(x => x.PreviousOrderStatus == null || x.PreviousOrderStatus == string.Empty),
|
||||
q => q.Where(x => x.PreviousOrderStatus != null && x.PreviousOrderStatus != string.Empty));
|
||||
}
|
||||
else if (string.Equals(field, "stockBindStatus", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var statusValue = values.Count == 1 ? values[0] : value;
|
||||
if (!string.IsNullOrWhiteSpace(statusValue)
|
||||
&& (op is "eq" or "in" or "like" || string.IsNullOrWhiteSpace(op)))
|
||||
{
|
||||
query = op switch
|
||||
{
|
||||
"ne" => query.Where(x => x.IsPaid != paid),
|
||||
_ => query.Where(x => x.IsPaid == paid)
|
||||
};
|
||||
query = ApplyStockBindStatusFilter(query, statusValue);
|
||||
}
|
||||
}
|
||||
else if (string.Equals(field, "fulfillProgress", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var progressValue = values.Count == 1 ? values[0] : value;
|
||||
if (!string.IsNullOrWhiteSpace(progressValue)
|
||||
&& (op is "eq" or "in" or "like" || string.IsNullOrWhiteSpace(op)))
|
||||
{
|
||||
query = ApplyFulfillProgressFilter(query, progressValue);
|
||||
}
|
||||
}
|
||||
else if (string.Equals(field, "payableAmount", StringComparison.OrdinalIgnoreCase))
|
||||
@ -557,6 +593,83 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<byte> ResolveBoolBytes(string value, List<string> values)
|
||||
{
|
||||
var raw = values.Count > 0
|
||||
? values
|
||||
: string.IsNullOrWhiteSpace(value)
|
||||
? []
|
||||
: value.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.ToList();
|
||||
var flags = new List<byte>();
|
||||
foreach (var item in raw)
|
||||
{
|
||||
if (byte.TryParse(item, out var flag) || TryParseBoolByte(item, out flag))
|
||||
{
|
||||
flags.Add(flag);
|
||||
}
|
||||
}
|
||||
|
||||
return flags.Distinct().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字节布尔标志筛选(0/1),支持 eq / ne / in / notIn。
|
||||
/// </summary>
|
||||
private static ISugarQueryable<Order> ApplyByteFlagField(
|
||||
ISugarQueryable<Order> query,
|
||||
string field,
|
||||
string op,
|
||||
string value,
|
||||
List<string> values)
|
||||
{
|
||||
var flags = ResolveBoolBytes(value, values);
|
||||
if (flags.Count == 0)
|
||||
{
|
||||
return query;
|
||||
}
|
||||
|
||||
var negate = op is "ne" or "notIn";
|
||||
var multi = op is "in" or "notIn" || flags.Count > 1;
|
||||
if (string.Equals(field, "isPaid", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return negate
|
||||
? query.Where(x => !flags.Contains(x.IsPaid))
|
||||
: multi
|
||||
? query.Where(x => flags.Contains(x.IsPaid))
|
||||
: query.Where(x => x.IsPaid == flags[0]);
|
||||
}
|
||||
|
||||
if (string.Equals(field, "isIntercept", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return negate
|
||||
? query.Where(x => !flags.Contains(x.IsIntercept))
|
||||
: multi
|
||||
? query.Where(x => flags.Contains(x.IsIntercept))
|
||||
: query.Where(x => x.IsIntercept == flags[0]);
|
||||
}
|
||||
|
||||
if (string.Equals(field, "isRemote", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return negate
|
||||
? query.Where(x => !flags.Contains(x.IsRemote))
|
||||
: multi
|
||||
? query.Where(x => flags.Contains(x.IsRemote))
|
||||
: query.Where(x => x.IsRemote == flags[0]);
|
||||
}
|
||||
|
||||
if (string.Equals(field, "isCod", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return negate
|
||||
? query.Where(x => !flags.Contains(x.IsCod))
|
||||
: multi
|
||||
? query.Where(x => flags.Contains(x.IsCod))
|
||||
: query.Where(x => x.IsCod == flags[0]);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
private static ISugarQueryable<Order> ApplyStringField(
|
||||
ISugarQueryable<Order> query,
|
||||
string op,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user