新增查询字段
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-04-23 15:33:15 +08:00
parent 5442dcbeda
commit 37e113bbf4
3 changed files with 113 additions and 8 deletions

View File

@@ -124,11 +124,35 @@ func (s *OrderStore) List(ctx context.Context, opts *store.QueryOptions, filters
if v, ok := filters["purchase_role"]; ok {
query = query.Where("purchase_role = ?", v)
}
if v, ok := filters["iot_card_id"]; ok {
query = query.Where("iot_card_id = ?", v)
identifierValue, hasIdentifier := filters["identifier"]
iotCardIDValue, hasIotCardID := filters["iot_card_id"]
deviceIDValue, hasDeviceID := filters["device_id"]
if hasIdentifier || hasIotCardID || hasDeviceID {
assetQuery := s.db
hasAnyAssetCondition := false
if hasIdentifier {
assetQuery = assetQuery.Where("asset_identifier = ?", identifierValue)
hasAnyAssetCondition = true
}
if hasIotCardID {
if hasAnyAssetCondition {
assetQuery = assetQuery.Or("iot_card_id = ?", iotCardIDValue)
} else {
assetQuery = assetQuery.Where("iot_card_id = ?", iotCardIDValue)
hasAnyAssetCondition = true
}
}
if hasDeviceID {
if hasAnyAssetCondition {
assetQuery = assetQuery.Or("device_id = ?", deviceIDValue)
} else {
assetQuery = assetQuery.Where("device_id = ?", deviceIDValue)
}
}
query = query.Where(assetQuery)
}
if v, ok := filters["device_id"]; ok {
query = query.Where("device_id = ?", v)
if v, ok := filters["seller_shop_id"]; ok {
query = query.Where("seller_shop_id = ?", v)
}
if v, ok := filters["start_time"]; ok {
query = query.Where("created_at >= ?", v)
@@ -136,9 +160,6 @@ func (s *OrderStore) List(ctx context.Context, opts *store.QueryOptions, filters
if v, ok := filters["end_time"]; ok {
query = query.Where("created_at <= ?", v)
}
if v, ok := filters["identifier"]; ok {
query = query.Where("asset_identifier = ?", v)
}
if v, ok := filters["buyer_phone"]; ok {
query = query.Where("buyer_phone = ?", v)
}