UPDATE `zh_stage_pay` sp
  LEFT JOIN `zh_stage` s ON sp.sid = s.id
  LEFT JOIN `zh_pay` p ON sp.pid = p.id
  SET sp.`pre_used` = 1
  WHERE (sp.`start_stage_order` < s.`order` OR ((not IsNULL(sp.pre_tp)) AND sp.pre_tp) AND sp.`pre_used` = 0 AND p.`ptype` = 1;