UPDATE ht_plan_triptime ppt
SET ppt.lock_status = '1'
WHERE ppt.lock_status <> '1'
AND ppt.plan_id = ?
AND ppt.allowed_person > 0
AND ppt.allowed_person <= (SELECT
COUNT(*)
FROM ht_tourist_team_info ti
INNER JOIN ht_order_info oi ON oi.order_id = ti.order_id
INNER JOIN ht_order_team_relation otr ON otr.order_id = oi.order_id AND otr.del_flag = '1'
WHERE otr.trip_id = '2f2a83c4fa1749c0ac4ed00626eef91d'
AND ti.del_flag = '1'
AND oi.del_flag = '1'
AND oi.apply_status = '1'
)