Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.49 KB | None | 0 0
  1. select concat(so.suborder_id, "_", so.order_id) as orderId,
  2. ss.description, convert_tz(o.created_at, '+0:00', '+7:00') as created_at,
  3. o.confirmed_timestamp,
  4. so.created_at as subOrderDate, round(so.bookstore_sla_minute / 60, 2) as sla,
  5. dp.name, CAST(so.is_sameday as int) as sameDay,
  6. if(so.is_printed = true, 1, 0),
  7. if(wrap.suborder_id is null, (if(pick.suborder_id is null, '', 'Đã soạn')), 'Đã gói') as action,
  8. if(wrap.suborder_id is null, (if(pick.suborder_id is null, '', pick.created_by)), wrap.created_by) as user,
  9. if(wrap.suborder_id is null, (if(pick.suborder_id is null, '', pick.created_at)), wrap.created_at) as time
  10. from fahasa_suborder so
  11. join fahasa_suborder_status ss on ss.status = so.status
  12. left join fahasa_delivery_partner dp on dp.id = so.self_ship
  13. join fhs_sales_flat_order o on o.increment_id = so.order_id
  14. left join fahasa_suborder_log l on l.suborder_id = so.suborder_id and l.action = "packing" and duration is not null
  15. left join fahasa_suborder_log pick on pick.suborder_id = so.suborder_id and pick.action = "picking" and pick.duration is not null
  16. left join fahasa_suborder_log wrap on wrap.suborder_id = so.suborder_id and wrap.action = "wrapping" and wrap.duration is not null
  17. where so.status in ('confirmed')
  18. and so.parent_id is null
  19. and l.suborder_id is null
  20. and so.bookstore_id = 67
  21. and o.don_si is null
  22. and (so.bookstore_sla_minute / 60) >= [var="testvar";type="text";title="Thời Gian Trễ";default="0"]
  23. order by round(so.bookstore_sla_minute / 60, 2) desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement