update PPW_EMAIL.company_email_send_history set isvalid =0,updatetime=sysdate() where email in
#{email}
update PPW_EMAIL.company_email_send_history set isvalid =0,updatetime=sysdate() where id in
#{id}
SELECT
cec.id,
cec.company_id,
c.company_name,
listagg(cec.email,',') as email,
max(cesh.send_time) as send_time,
cesh.send_remark,
cesh.send_status
FROM
PPW_EMAIL.company_email_config cec
JOIN PPW_EMAIL.pvn_company_info c
ON cec.company_id = c.company_id
LEFT JOIN PPW_EMAIL.company_email_send_history cesh
ON cec.email = cesh.email AND cesh.isvalid = 1
WHERE cec.isvalid = 1 and c.isvalid=1
and (c.company_name like concat('',#{companyName},'') or c.company_short_name like concat('',#{companyName},''))
and cec.email like concat('',#{email},'')
and cesh.send_status=#{sendStatus}
group by cec.company_id
SELECT
cec.id,
cec.company_id,
c.company_name,
cec.email,
cesh.send_time,
cesh.send_remark,
cesh.send_status
FROM
PPW_EMAIL.company_email_send_history cesh
JOIN PPW_EMAIL.company_email_config cec
JOIN PPW_EMAIL.pvn_company_info c
ON cec.company_id = c.company_id
ON cec.email = cesh.email
WHERE cec.isvalid = 1
AND cesh.isvalid = 1 and c.isvalid =1
and c.company_id=#{companyId}