|
@@ -4,10 +4,12 @@ import cn.com.ctop.common.module.entity.MailLog;
|
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.mapper.MailLogMapper;
|
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
+import cn.com.ctop.common.module.utils.BigDecimalUtil;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.CorpWexinUtils;
|
|
|
import cn.com.ctop.common.module.utils.SendMailUtil;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
|
|
|
+import cn.com.ctop.toutiao.service.IByteDanceAdvertisePlanService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -18,6 +20,8 @@ import org.jeecg.modules.ctop.service.IBidWarningService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -36,6 +40,8 @@ public class BidWarningServiceImpl implements IBidWarningService {
|
|
|
private KuaiShouGroupMapper groupMapper;
|
|
|
@Autowired
|
|
|
private MailLogMapper mailLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -48,26 +54,38 @@ public class BidWarningServiceImpl implements IBidWarningService {
|
|
|
long l = System.currentTimeMillis();
|
|
|
try {
|
|
|
QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
|
|
|
- projectQueryWrapper.eq("media_id", "2");
|
|
|
+ // projectQueryWrapper.eq("media_id", "1");
|
|
|
List<Project> projects = projectMapper.selectList(projectQueryWrapper);
|
|
|
if (!Check.isNull(projects)) {
|
|
|
for (Project project : projects) {
|
|
|
+ if (Check.isNull(project)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Long maxBid = project.getMaxBid();
|
|
|
Long projectId = project.getId();
|
|
|
- QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
|
|
|
- userAllocationQueryWrapper.eq("project_id", projectId);
|
|
|
- List<UserAllocation> userAllocations = userAllocationMapper.selectList(userAllocationQueryWrapper);
|
|
|
+
|
|
|
+
|
|
|
+ List<UserAllocation> userAllocations = getUserAllocationsByProjectId(projectId);
|
|
|
if (!Check.isNull(userAllocations)) {
|
|
|
for (UserAllocation userAllocation : userAllocations) {
|
|
|
Long accountId = userAllocation.getAccountId();
|
|
|
- List<String> unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
|
|
|
+ List<String> unitWarning = new ArrayList<>();
|
|
|
+ if("1".equals(userAllocation.getMediaId())){
|
|
|
+ BigDecimal bid = new BigDecimal(maxBid);
|
|
|
+ BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
|
|
|
+ unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId,bigDecimal);
|
|
|
+ }else if("2".equals(userAllocation.getMediaId())){
|
|
|
+ unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
|
|
|
+ }
|
|
|
+
|
|
|
if (!Check.isNull(unitWarning)) {
|
|
|
- sendMessage(accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
|
|
|
+ sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
log.info("出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - l) / 1000);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -75,9 +93,15 @@ public class BidWarningServiceImpl implements IBidWarningService {
|
|
|
|
|
|
|
|
|
}
|
|
|
+ private List<UserAllocation> getUserAllocationsByProjectId(Long projectId) {
|
|
|
+ QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
|
|
|
+ userAllocationQueryWrapper.eq("project_id", projectId);
|
|
|
+ List<UserAllocation> userAllocations = userAllocationMapper.selectList(userAllocationQueryWrapper);
|
|
|
+ return userAllocations;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- private void sendMessage(Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
|
|
|
+ private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
|
|
|
|
|
|
String createTime = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
|
|
@@ -93,7 +117,14 @@ public class BidWarningServiceImpl implements IBidWarningService {
|
|
|
.append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
|
|
|
if (count < 3) {
|
|
|
List<String> mailList = mailLogMapper.selectMailList(projectId);
|
|
|
- String subject = "广告组出价预警";
|
|
|
+ String subject;
|
|
|
+ if ("1".equals(mediaId)) {
|
|
|
+ subject = "头条-广告计划出价预警";
|
|
|
+
|
|
|
+ } else {
|
|
|
+ subject = "快手-广告组出价预警";
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
SendMailUtil.sendMail(mailList, subject, text.toString());
|
|
|
MailLog mailLog = new MailLog();
|
|
@@ -113,4 +144,6 @@ public class BidWarningServiceImpl implements IBidWarningService {
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|