Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select concat(so.suborder_id, "_", so.order_id) as orderId,
- ss.description, convert_tz(o.created_at, '+0:00', '+7:00') as created_at,
- o.confirmed_timestamp,
- so.created_at as subOrderDate, round(so.bookstore_sla_minute / 60, 2) as sla,
- dp.name, CAST(so.is_sameday as int) as sameDay,
- if(so.is_printed = true, 1, 0),
- if(wrap.suborder_id is null, (if(pick.suborder_id is null, '', 'Đã soạn')), 'Đã gói') as action,
- if(wrap.suborder_id is null, (if(pick.suborder_id is null, '', pick.created_by)), wrap.created_by) as user,
- if(wrap.suborder_id is null, (if(pick.suborder_id is null, '', pick.created_at)), wrap.created_at) as time
- from fahasa_suborder so
- join fahasa_suborder_status ss on ss.status = so.status
- left join fahasa_delivery_partner dp on dp.id = so.self_ship
- join fhs_sales_flat_order o on o.increment_id = so.order_id
- left join fahasa_suborder_log l on l.suborder_id = so.suborder_id and l.action = "packing" and duration is not null
- left join fahasa_suborder_log pick on pick.suborder_id = so.suborder_id and pick.action = "picking" and pick.duration is not null
- left join fahasa_suborder_log wrap on wrap.suborder_id = so.suborder_id and wrap.action = "wrapping" and wrap.duration is not null
- where so.status in ('confirmed')
- and so.parent_id is null
- and l.suborder_id is null
- and so.bookstore_id = 67
- and o.don_si is null
- and (so.bookstore_sla_minute / 60) >= [var="testvar";type="text";title="Thời Gian Trễ";default="0"]
- order by round(so.bookstore_sla_minute / 60, 2) desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement