- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
l.handler is null and
s.serialn = l.serialn and
n.serialn = s.serialn and
k.kid = s.id and
oc.id = k.cid and
o.id = oc.orderid and
c.id = d.country and
d.id = (
case
when ( o.qr_dealer is not null ) then
o.qr_dealer
when ( s.pid = any( %s::int[] ) ) then
( case when (
n.expires <= ( now() + '90 days'::interval )
) then (
select
c.dealer
from
table_name_hidden_1 c
where
s.serialn = any( c.serials ) and
c.dealer is not null and
c.status = any( %s::int[] )
limit 1
) else null end )
else
(
select
d2.id
from
table_name_hidden_2 d2
where
d2.id = any( array[ s.dealer, o.for_partner ] ) and
d2.active = true and
(
(
d2.role = any( %s::int[] ) and
(
(
exists((
select
1
from
table_name_hidden_3
where
table_name_hidden_3.dealer = d2.id
limit 1
))
) or (
o.for_partner is not null and
d2.id = o.for_partner and
exists((
select
1
from
table_name_hidden_2 d3
where
d3.id = s.dealer and
d3.role = any( %s::int[] )
))
)
)
) or (
d2.role = any( %s::int[] ) and
(
(
o.for_partner is null
) or (
o.for_partner = s.dealer
)
)
)
)
limit 1
)
end
)
Комментарии (0) RSS
Добавить комментарий