|
@@ -12,6 +12,7 @@ import com.storlead.trade.dto.MarketingCampaignDTO;
|
|
|
import com.storlead.trade.entity.*;
|
|
import com.storlead.trade.entity.*;
|
|
|
import com.storlead.trade.mapper.MarketingCampaignEntityMapper;
|
|
import com.storlead.trade.mapper.MarketingCampaignEntityMapper;
|
|
|
import com.storlead.trade.service.*;
|
|
import com.storlead.trade.service.*;
|
|
|
|
|
+import com.storlead.trade.vo.CampaignStatsVO;
|
|
|
import com.storlead.trade.vo.MarketingCampaignDetailVO;
|
|
import com.storlead.trade.vo.MarketingCampaignDetailVO;
|
|
|
import com.storlead.trade.vo.MarketingCampaignVO;
|
|
import com.storlead.trade.vo.MarketingCampaignVO;
|
|
|
import com.storlead.framework.common.constant.CommonConstant;
|
|
import com.storlead.framework.common.constant.CommonConstant;
|
|
@@ -165,6 +166,46 @@ public class MarketingCampaignServiceImpl
|
|
|
detailVO.setSopDetailList(relationList);
|
|
detailVO.setSopDetailList(relationList);
|
|
|
detailVO.setCustomerList(customerEntityList);
|
|
detailVO.setCustomerList(customerEntityList);
|
|
|
|
|
|
|
|
|
|
+ // 4. 计算达成率统计(从 market_emails 表取实际数据)
|
|
|
|
|
+ CampaignStatsVO stats = new CampaignStatsVO();
|
|
|
|
|
+ Integer sendVolume = campaign.getSendVolume();
|
|
|
|
|
+ stats.setSendVolume(sendVolume);
|
|
|
|
|
+
|
|
|
|
|
+ Integer sentCountLong = marketEmailsService.lambdaQuery()
|
|
|
|
|
+ .eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
|
|
+ .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
|
|
+ .eq(MarketEmailsEntity::getStatus, 1)
|
|
|
|
|
+ .count();
|
|
|
|
|
+ Integer sentCount = sentCountLong == null ? 0 : sentCountLong.intValue();
|
|
|
|
|
+ stats.setSentCount(sentCount);
|
|
|
|
|
+
|
|
|
|
|
+ Integer openCountLong = marketEmailsService.lambdaQuery()
|
|
|
|
|
+ .eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
|
|
+ .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
|
|
+ .eq(MarketEmailsEntity::getHasReader, 1)
|
|
|
|
|
+ .count();
|
|
|
|
|
+ Integer openCount = openCountLong == null ? 0 : openCountLong.intValue();
|
|
|
|
|
+ stats.setOpenCount(openCount);
|
|
|
|
|
+
|
|
|
|
|
+ Integer replyCountLong = marketEmailsService.lambdaQuery()
|
|
|
|
|
+ .eq(MarketEmailsEntity::getMarketingCampaignId, id)
|
|
|
|
|
+ .eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
|
|
+ .eq(MarketEmailsEntity::getHasReply, 1)
|
|
|
|
|
+ .count();
|
|
|
|
|
+ Integer replyCount = replyCountLong == null ? 0 : replyCountLong.intValue();
|
|
|
|
|
+ stats.setReplyCount(replyCount);
|
|
|
|
|
+
|
|
|
|
|
+ // 打开率 = openCount / sentCount
|
|
|
|
|
+ stats.setOpenRate(sentCount > 0 ? Math.round(openCount * 100f / sentCount) : 0);
|
|
|
|
|
+ // 回复率 = replyCount / sentCount
|
|
|
|
|
+ stats.setReplyRate(sentCount > 0 ? Math.round(replyCount * 100f / sentCount) : 0);
|
|
|
|
|
+ // 达成率 = sentCount / sendVolume
|
|
|
|
|
+ stats.setAchievementRate(sendVolume != null && sendVolume > 0
|
|
|
|
|
+ ? Math.min(Math.round(sentCount * 100f / sendVolume), 100)
|
|
|
|
|
+ : 0);
|
|
|
|
|
+
|
|
|
|
|
+ detailVO.setStats(stats);
|
|
|
|
|
+
|
|
|
return Result.result(detailVO);
|
|
return Result.result(detailVO);
|
|
|
}
|
|
}
|
|
|
|
|
|