log.sql 771 B

12345678910111213141516171819202122232425262728
  1. select * from message m join message_type mt
  2. on m.sys_name=mt.sys_name and m.pasture_id=mt.pasture_id and m.service_id=mt.service_id
  3. where m.status=0 and (
  4. mt.remind_type=1
  5. or
  6. (
  7. mt.remind_type=2 and
  8. timestampdiff(minute,m.created_at,now())>mt.delay_time and
  9. date_format(now(),'%H:%i')>mt.push_time and
  10. (
  11. cycle_type=1 or cycle_type=3 or
  12. (
  13. cycle_type=2 and timestampdiff(minute,m.updated_at,now()) >mt.interval_time
  14. and m.push_count<mt.push_limit
  15. )
  16. )
  17. )
  18. or
  19. (
  20. mt.remind_type=3 and
  21. (
  22. mt.date_type=1
  23. or (mt.date_type=2 and weekday(now() ) +1 =mt.push_date)
  24. or (mt.date_type=3 and (day(now()) =mt.push_date or DAYOFMONTH(now())<mt.push_date))
  25. )
  26. and date_format(now(),'%H:%i')>mt.push_time
  27. )
  28. )