|
|
@@ -144,9 +144,9 @@ public class MarketingCampaignServiceImpl
|
|
|
Map<Long, Long> firstSentMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
"count(*) as cnt", qw -> qw.eq("status", 1).eq("has_first", 1));
|
|
|
Map<Long, Long> openedEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
- "count(*) as cnt", qw -> qw.eq("has_reader", 1));
|
|
|
+ "count(*) as cnt", qw -> qw.eq("status", 1).eq("has_reader", 1));
|
|
|
Map<Long, Long> repliedEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
- "count(*) as cnt", qw -> qw.eq("has_reply", 1));
|
|
|
+ "count(*) as cnt", qw -> qw.eq("status", 1).eq("has_reply", 1));
|
|
|
Map<Long, Long> cancelledMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
"count(*) as cnt", qw -> qw.eq("status", -3));
|
|
|
Map<Long, Long> totalEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
@@ -326,6 +326,7 @@ public class MarketingCampaignServiceImpl
|
|
|
// Integer sendVolume = campaign.getSendVolume();
|
|
|
// stats.setSendVolume(sendVolume);
|
|
|
|
|
|
+ // emailCount:计划发送总数(hasFirst=1 的邮件数,用于展示)
|
|
|
Integer emailCountLong = marketEmailsService.lambdaQuery()
|
|
|
.eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
@@ -334,20 +335,28 @@ public class MarketingCampaignServiceImpl
|
|
|
Integer emailCount = emailCountLong == null ? 0 : emailCountLong.intValue();
|
|
|
stats.setEmailCount(emailCount);
|
|
|
|
|
|
+ // 已发送数(status=1,所有首封邮件,与 getList/getDashboardStats 口径一致)
|
|
|
Integer sentCountLong = marketEmailsService.lambdaQuery()
|
|
|
.eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
.eq(MarketEmailsEntity::getStatus, 1)
|
|
|
- .eq(MarketEmailsEntity::getHasFirst, 1)
|
|
|
.count();
|
|
|
Integer sentCount = sentCountLong == null ? 0 : sentCountLong.intValue();
|
|
|
stats.setSentCount(sentCount);
|
|
|
|
|
|
+ // emailCountAll:全部未删邮件总数(用于 achievementRate 分母,与 sentCount 口径对齐)
|
|
|
+ Integer emailCountAllLong = marketEmailsService.lambdaQuery()
|
|
|
+ .eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
+ .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
+ .count();
|
|
|
+ int emailCountAll = emailCountAllLong == null ? 0 : emailCountAllLong.intValue();
|
|
|
+
|
|
|
|
|
|
|
|
|
Integer openCountLong = marketEmailsService.lambdaQuery()
|
|
|
.eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
+ .eq(MarketEmailsEntity::getStatus, 1)
|
|
|
.eq(MarketEmailsEntity::getHasReader, 1)
|
|
|
.count();
|
|
|
Integer openCount = openCountLong == null ? 0 : openCountLong.intValue();
|
|
|
@@ -356,6 +365,7 @@ public class MarketingCampaignServiceImpl
|
|
|
Integer replyCountLong = marketEmailsService.lambdaQuery()
|
|
|
.eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
+ .eq(MarketEmailsEntity::getStatus, 1)
|
|
|
.eq(MarketEmailsEntity::getHasReply, 1)
|
|
|
.count();
|
|
|
Integer replyCount = replyCountLong == null ? 0 : replyCountLong.intValue();
|
|
|
@@ -365,13 +375,14 @@ public class MarketingCampaignServiceImpl
|
|
|
stats.setOpenRate(sentCount > 0 ? Math.round(openCount * 100f / sentCount) : 0);
|
|
|
// 回复率 = replyCount / sentCount
|
|
|
stats.setReplyRate(sentCount > 0 ? Math.round(replyCount * 100f / sentCount) : 0);
|
|
|
- // 达成率 = openCountLong / emailCount
|
|
|
- stats.setAchievementRate(sentCount > 0 ? Math.round(sentCount * 100f / emailCount) : 0);
|
|
|
+ // 达成率 = 已发送数 / 全部未删邮件数(与 getList sentRate 口径一致)
|
|
|
+ stats.setAchievementRate(emailCountAll > 0 ? Math.round(sentCount * 100f / emailCountAll) : 0);
|
|
|
|
|
|
// 已打开邮件的客户数(distinct customer_id where hasReader=1)
|
|
|
List<MarketEmailsEntity> openedEmailList = marketEmailsService.lambdaQuery()
|
|
|
.eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
+ .eq(MarketEmailsEntity::getStatus, 1)
|
|
|
.eq(MarketEmailsEntity::getHasReader, 1)
|
|
|
.isNotNull(MarketEmailsEntity::getCustomerId)
|
|
|
.select(MarketEmailsEntity::getCustomerId)
|
|
|
@@ -708,7 +719,7 @@ public class MarketingCampaignServiceImpl
|
|
|
.eq(MarketEmailsEntity::getHasReader, 1)
|
|
|
.count();
|
|
|
|
|
|
- // 本月回复数
|
|
|
+ // 本月回复数(仅已发送邮件中有回复的)
|
|
|
Integer replyCount = marketEmailsService.lambdaQuery()
|
|
|
.eq(MarketEmailsEntity::getStatus, 1)
|
|
|
.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|