INSERT INTO tb_offer(id, displace_id, offer_users, offer_times, max_offer, show_status, offer_bj_status, offer_gj_status, agent_show, plat_show, gj_price, is_kxc, gj_desc, gj_push_id, is_push, push_content)
VALUES(#{offerId}, #{displaceId}, 1, 1, #{price}, 1, 0, 0, 1, 1, null, #{isKxc}, null, null, 0, null)
UPDATE tb_offer t, (
SELECT o.offer_id, o.price, o.is_kxc, (
SELECT COUNT(1)
FROM tb_offer_detail t1
WHERE t1.offer_id = #{existsOfferId}
) offer_times, (
SELECT COUNT(DISTINCT t1.da_id)
FROM tb_offer_detail t1
WHERE t1.offer_id = #{existsOfferId}
) offer_users
FROM tb_offer_detail o
WHERE o.price = (
SELECT MAX(d.price)
FROM tb_offer_detail d
WHERE d.offer_id = #{existsOfferId}
) AND o.offer_id = #{existsOfferId}
) a SET t.max_offer = a.price, t.is_kxc = a.is_kxc, t.offer_times = a.offer_times, t.offer_users = a.offer_users
WHERE t.id = a.offer_id