begin
declare debug int;
set @debug = 0;
if @debug = 1 then
insert into task_monitor(info) values('start');
end if;
update get_moneys a, user_get_moneys u
set a.status=1, a.brought_number=0, a.periods = a.periods+1, u.status=0
where
a.end_time >now() and a.status=0 and a.each_starttime <=now() and u.get_money_id=a.id;
update get_moneys set status = 0
where end_time<=now() and status=1;
delete from user_get_moneys where
get_money_id in ( select id from get_moneys where status=0 and end_time<=now() );
if @debug = 1 then
insert into task_monitor(info) values('end');
end if;
end
![]()