|
@@ -33,18 +33,16 @@
|
|
cec.id,
|
|
cec.id,
|
|
cec.company_id,
|
|
cec.company_id,
|
|
c.company_name,
|
|
c.company_name,
|
|
- listagg(cec.email,',') as email,
|
|
|
|
- DATE_FORMAT(max(cesh.send_time),'%Y-%m-%d %H:%i:%s') as send_time,
|
|
|
|
- cesh.send_remark,
|
|
|
|
- cesh.send_status
|
|
|
|
|
|
+ cec.email,
|
|
|
|
+ maxce.send_time,
|
|
|
|
+ maxce.send_remark,
|
|
|
|
+ maxce.send_status
|
|
FROM
|
|
FROM
|
|
PPW_EMAIL.company_email_config cec
|
|
PPW_EMAIL.company_email_config cec
|
|
JOIN PPW_EMAIL.pvn_company_info c
|
|
JOIN PPW_EMAIL.pvn_company_info c
|
|
ON cec.company_id = c.company_id
|
|
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
|
|
|
|
- LEFT JOIN (select me.email as email,max(me.send_time) as send_time from PPW_EMAIL.company_email_send_history me where isvalid =1 group by me.email) maxce
|
|
|
|
- ON cesh.email = maxce.email
|
|
|
|
|
|
+ LEFT JOIN (select me.email as email,max(me.send_time) as send_time,me.company_id,me.send_remark,me.send_status from PPW_EMAIL.company_email_send_history me where isvalid =1 group by me.email,me.company_id) maxce
|
|
|
|
+ ON cec.email = maxce.email and cec.company_id = maxce.company_id
|
|
WHERE cec.isvalid = 1 and c.isvalid=1
|
|
WHERE cec.isvalid = 1 and c.isvalid=1
|
|
<if test="companyName != null and companyName !=''">
|
|
<if test="companyName != null and companyName !=''">
|
|
and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
|
|
and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
|
|
@@ -53,9 +51,8 @@
|
|
and cec.email like concat('%',#{email},'%')
|
|
and cec.email like concat('%',#{email},'%')
|
|
</if>
|
|
</if>
|
|
<if test="sendStatus != null">
|
|
<if test="sendStatus != null">
|
|
- and cesh.send_status=#{sendStatus}
|
|
|
|
|
|
+ and maxce.send_status=#{sendStatus}
|
|
</if>
|
|
</if>
|
|
- group by cec.company_id
|
|
|
|
limit #{offset},#{pageSize}
|
|
limit #{offset},#{pageSize}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
@@ -64,14 +61,12 @@
|
|
select count(*) from (
|
|
select count(*) from (
|
|
SELECT
|
|
SELECT
|
|
count(cec.company_id)
|
|
count(cec.company_id)
|
|
- FROM
|
|
|
|
|
|
+ from
|
|
PPW_EMAIL.company_email_config cec
|
|
PPW_EMAIL.company_email_config cec
|
|
JOIN PPW_EMAIL.pvn_company_info c
|
|
JOIN PPW_EMAIL.pvn_company_info c
|
|
ON cec.company_id = c.company_id
|
|
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
|
|
|
|
- LEFT JOIN (select me.email as email,max(me.send_time) as send_time from PPW_EMAIL.company_email_send_history me where isvalid =1 group by me.email) maxce
|
|
|
|
- ON cesh.email = maxce.email
|
|
|
|
|
|
+ LEFT JOIN (select me.email as email,max(me.send_time) as send_time,me.company_id,me.send_remark,me.send_status from PPW_EMAIL.company_email_send_history me where isvalid =1 group by me.email,me.company_id) maxce
|
|
|
|
+ ON cec.email = maxce.email and cec.company_id = maxce.company_id
|
|
WHERE cec.isvalid = 1 and c.isvalid=1
|
|
WHERE cec.isvalid = 1 and c.isvalid=1
|
|
<if test="companyName != null and companyName !=''">
|
|
<if test="companyName != null and companyName !=''">
|
|
and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
|
|
and (c.company_name like concat('%',#{companyName},'%') or c.company_short_name like concat('%',#{companyName},'%') or c.register_number like concat('%',#{companyName},'%'))
|
|
@@ -80,9 +75,8 @@
|
|
and cec.email like concat('%',#{email},'%')
|
|
and cec.email like concat('%',#{email},'%')
|
|
</if>
|
|
</if>
|
|
<if test="sendStatus != null">
|
|
<if test="sendStatus != null">
|
|
- and cesh.send_status=#{sendStatus}
|
|
|
|
- </if>
|
|
|
|
- group by cec.company_id) a
|
|
|
|
|
|
+ and maxce.send_status=#{sendStatus}
|
|
|
|
+ </if>) a
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="searchEmailHistory" resultMap="BaseResultMap">
|
|
<select id="searchEmailHistory" resultMap="BaseResultMap">
|