|
@@ -139,12 +139,19 @@ public class MarketingCampaignServiceImpl
|
|
|
"count(*) as cnt", qw -> qw.eq("status", -1));
|
|
"count(*) as cnt", qw -> qw.eq("status", -1));
|
|
|
Map<Long, Long> sentMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
Map<Long, Long> sentMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
"count(*) as cnt", qw -> qw.eq("status", 1));
|
|
"count(*) as cnt", qw -> qw.eq("status", 1));
|
|
|
- Map<Long, Long> sentCustomerMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
|
|
- "count(distinct customer_id) as cnt", qw -> qw.eq("status", 1));
|
|
|
|
|
|
|
+ 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));
|
|
|
|
|
+ Map<Long, Long> repliedEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
|
|
+ "count(*) as cnt", qw -> qw.eq("has_reply", 1));
|
|
|
Map<Long, Long> cancelledMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
Map<Long, Long> cancelledMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
"count(*) as cnt", qw -> qw.eq("status", -3));
|
|
"count(*) as cnt", qw -> qw.eq("status", -3));
|
|
|
Map<Long, Long> totalEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
Map<Long, Long> totalEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
"count(*) as cnt", qw -> { });
|
|
"count(*) as cnt", qw -> { });
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, Long> firstTotalEmailMap = countEmailsByCampaign(marketingCampaignIdList,
|
|
|
|
|
+ "count(*) as cnt", qw -> qw.eq("has_first", 1));
|
|
|
for (MarketingCampaignVO vo : marketingCampaignVOList) {
|
|
for (MarketingCampaignVO vo : marketingCampaignVOList) {
|
|
|
Long id = vo.getId();
|
|
Long id = vo.getId();
|
|
|
vo.setOpenedCustomerCount(toInt(openedMap.get(id)));
|
|
vo.setOpenedCustomerCount(toInt(openedMap.get(id)));
|
|
@@ -152,17 +159,18 @@ public class MarketingCampaignServiceImpl
|
|
|
vo.setProtectWhitelistCount(toInt(protectMap.get(id)));
|
|
vo.setProtectWhitelistCount(toInt(protectMap.get(id)));
|
|
|
int pending = toInt(pendingMap.get(id));
|
|
int pending = toInt(pendingMap.get(id));
|
|
|
int sent = toInt(sentMap.get(id));
|
|
int sent = toInt(sentMap.get(id));
|
|
|
|
|
+ int firstSent = toInt(firstSentMap.get(id));
|
|
|
int cancelled = toInt(cancelledMap.get(id));
|
|
int cancelled = toInt(cancelledMap.get(id));
|
|
|
vo.setPendingEmailCount(pending);
|
|
vo.setPendingEmailCount(pending);
|
|
|
vo.setSentEmailCount(sent);
|
|
vo.setSentEmailCount(sent);
|
|
|
vo.setCancelledEmailCount(cancelled);
|
|
vo.setCancelledEmailCount(cancelled);
|
|
|
vo.setEmailCountStats(pending + sent + cancelled);
|
|
vo.setEmailCountStats(pending + sent + cancelled);
|
|
|
int totalEmail = toInt(totalEmailMap.get(id));
|
|
int totalEmail = toInt(totalEmailMap.get(id));
|
|
|
- vo.setSentRate(totalEmail > 0 ? (double) vo.getOpenedCustomerCount() / totalEmail : 0.0);
|
|
|
|
|
- int sentCustomer = toInt(sentCustomerMap.get(id));
|
|
|
|
|
- vo.setSentCustomerCount(sentCustomer);
|
|
|
|
|
- vo.setOpenRateText(buildRate(toInt(openedMap.get(id)), sentCustomer));
|
|
|
|
|
- vo.setReplyRateText(buildRate(toInt(repliedMap.get(id)), sentCustomer));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int firstTotalEmail = toInt(firstTotalEmailMap.get(id));
|
|
|
|
|
+ vo.setSentRate(totalEmail > 0 ? (double) firstSent / firstTotalEmail : 0.0);
|
|
|
|
|
+ vo.setOpenRateText(buildRate(toInt(openedEmailMap.get(id)), sent));
|
|
|
|
|
+ vo.setReplyRateText(buildRate(toInt(repliedEmailMap.get(id)), sent));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -183,6 +191,7 @@ public class MarketingCampaignServiceImpl
|
|
|
qw.select("marketing_campaign_id, " + selectExpr);
|
|
qw.select("marketing_campaign_id, " + selectExpr);
|
|
|
qw.in("marketing_campaign_id", campaignIds);
|
|
qw.in("marketing_campaign_id", campaignIds);
|
|
|
qw.eq("is_delete", CommonConstant.DEL_FLAG_0);
|
|
qw.eq("is_delete", CommonConstant.DEL_FLAG_0);
|
|
|
|
|
+// qw.eq("has_first", 1);
|
|
|
if (extra != null) {
|
|
if (extra != null) {
|
|
|
extra.accept(qw);
|
|
extra.accept(qw);
|
|
|
}
|
|
}
|
|
@@ -318,7 +327,7 @@ public class MarketingCampaignServiceImpl
|
|
|
// 回复率 = replyCount / sentCount
|
|
// 回复率 = replyCount / sentCount
|
|
|
stats.setReplyRate(sentCount > 0 ? Math.round(replyCount * 100f / sentCount) : 0);
|
|
stats.setReplyRate(sentCount > 0 ? Math.round(replyCount * 100f / sentCount) : 0);
|
|
|
// 达成率 = openCountLong / emailCount
|
|
// 达成率 = openCountLong / emailCount
|
|
|
- stats.setAchievementRate(openCountLong > 0 ? Math.round(openCountLong * 100f / emailCount) : 0);
|
|
|
|
|
|
|
+ stats.setAchievementRate(sentCount > 0 ? Math.round(sentCount * 100f / emailCount) : 0);
|
|
|
|
|
|
|
|
detailVO.setStats(stats);
|
|
detailVO.setStats(stats);
|
|
|
|
|
|