This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user