12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- select
- -- m.*
- m.id,
- m.created_at,
- m.updated_at,
- timestampdiff(minute,m.updated_at,now()) dif,
- mt.interval_time ,
- date_format(now(),'%H:%i') now_time,
- push_time
- from message m join message_type mt
- on m.sys_name=mt.sys_name and m.pasture_id=mt.pasture_id and m.service_id=mt.service_id
- where
- -- m.status=0
- m.id =1407
- and (
- mt.remind_type=1
- or
- (
- mt.remind_type=2 and
- timestampdiff(minute,m.created_at,now())>=mt.delay_time and
- (date_format(now(),'%H:%i')>=mt.push_time or mt.push_time='') and
- (
- cycle_type=1 or cycle_type=3 or
- (
- cycle_type=2 and timestampdiff(minute,m.updated_at,now()) >=mt.interval_time
- and m.push_count<mt.push_limit
- )
- )
- )
- or
- (
- mt.remind_type=3 and
- (
- mt.date_type=1
- or (mt.date_type=2 and weekday(now() ) +1 =mt.push_date)
- or (mt.date_type=3 and (day(now()) =mt.push_date or DAYOFMONTH(now())<mt.push_date))
- )
- and date_format(now(),'%H:%i')>=mt.push_time
- and
- (
- push_count=0
- or
- ( day(now())> day(mt.updated_at) and push_count>0)
- )
- )
- )
|