|
@@ -1,9 +1,7 @@
|
|
|
package com.citu.module.menduner.system.task;
|
|
|
|
|
|
-import cn.hutool.core.map.MapUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.citu.framework.common.util.validation.ValidationUtils;
|
|
|
-import com.citu.module.menduner.system.controller.base.enterprise.bind.EnterpriseUserBindReqVO;
|
|
|
import com.citu.module.menduner.system.controller.base.enterprise.vip.EnterpriseEntitlementRespVO;
|
|
|
import com.citu.module.menduner.system.dal.dataobject.enterprise.EnterpriseDO;
|
|
|
import com.citu.module.menduner.system.dal.dataobject.enterprise.EnterpriseEntitlementDO;
|
|
@@ -14,7 +12,9 @@ import com.citu.module.menduner.system.service.enterprise.bind.EnterpriseUserBin
|
|
|
import com.citu.module.menduner.system.service.enterprise.vip.EnterpriseEntitlementService;
|
|
|
import com.citu.module.system.api.mail.MailSendApi;
|
|
|
import com.citu.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.StopWatch;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
@@ -26,26 +26,25 @@ import java.util.stream.Collectors;
|
|
|
* 企业邮箱通知任务
|
|
|
* 该业务用于春节前,免费赠送3个
|
|
|
**/
|
|
|
+@Slf4j
|
|
|
@Component
|
|
|
public class EnterpriseEmailNoticeTask {
|
|
|
|
|
|
+ private static final Integer JOB_NUM = 3;
|
|
|
@Resource
|
|
|
private EnterpriseMapper enterpriseMapper;
|
|
|
-
|
|
|
@Resource
|
|
|
private EnterpriseUserBindService enterpriseUserBindService;
|
|
|
-
|
|
|
@Resource
|
|
|
private EnterpriseEntitlementService enterpriseEntitlementService;
|
|
|
-
|
|
|
@Resource
|
|
|
private MailSendApi mailSendApi;
|
|
|
|
|
|
- private static final Integer JOB_NUM = 3;
|
|
|
-
|
|
|
@DSTransactional
|
|
|
public void sendEmailNotice() {
|
|
|
// 获取企业邮箱通知开关状态
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ stopWatch.start("企业邮箱通知任务");
|
|
|
List<EnterpriseDO> enterpriseList = enterpriseMapper.getNoVipEnterpriseList();
|
|
|
List<Long> entId = enterpriseList.stream().map(EnterpriseDO::getId).collect(Collectors.toList());
|
|
|
// 企业用户绑定列表
|
|
@@ -64,15 +63,16 @@ public class EnterpriseEmailNoticeTask {
|
|
|
}
|
|
|
if (null == enterprise.getBizFlag() || !enterprise.getBizFlag()) {
|
|
|
// 没有发送过就发送邮件
|
|
|
- sendEmail(mapList,enterprise);
|
|
|
+ sendEmail(mapList, enterprise);
|
|
|
enterprise.setBizFlag(true);
|
|
|
enterpriseMapper.updateById(enterprise);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ stopWatch.prettyPrint();
|
|
|
}
|
|
|
|
|
|
- private void sendEmail(List<EnterpriseUserBindDO> mapList,EnterpriseDO enterprise) {
|
|
|
+ private void sendEmail(List<EnterpriseUserBindDO> mapList, EnterpriseDO enterprise) {
|
|
|
for (EnterpriseUserBindDO userBindDO : mapList) {
|
|
|
// 发送邮件
|
|
|
if (null == userBindDO.getEmail()) {
|
|
@@ -81,13 +81,14 @@ public class EnterpriseEmailNoticeTask {
|
|
|
if (!ValidationUtils.isEmail(userBindDO.getEmail())) {
|
|
|
return;
|
|
|
}
|
|
|
+ log.info("id({}),企业:({})-用户:({})发送邮件", enterprise.getId(), enterprise.getName(), userBindDO.getName());
|
|
|
|
|
|
MailSendSingleToUserReqDTO reqDTO = new MailSendSingleToUserReqDTO();
|
|
|
reqDTO.setMail(userBindDO.getEmail());
|
|
|
reqDTO.setTemplateCode(CommonConstants.EMAIL_ENTERPRISE_PUBLISH_JOB_QUOTA);
|
|
|
- Map<String, Object> templateParamMap=new HashMap<>();
|
|
|
- templateParamMap.put("enterpriseName",enterprise.getName());
|
|
|
- templateParamMap.put("jobNum",JOB_NUM);
|
|
|
+ Map<String, Object> templateParamMap = new HashMap<>();
|
|
|
+ templateParamMap.put("enterpriseName", enterprise.getName());
|
|
|
+ templateParamMap.put("jobNum", JOB_NUM);
|
|
|
reqDTO.setTemplateParams(templateParamMap);
|
|
|
mailSendApi.sendSingleMailToMember(reqDTO).getCheckedData();
|
|
|
|
|
@@ -97,6 +98,7 @@ public class EnterpriseEmailNoticeTask {
|
|
|
|
|
|
if (entitlement.getPublishJobCount() <= JOB_NUM) {
|
|
|
// 小于等于3不做处理,同时规避已经加过发布数量的情况
|
|
|
+ log.info("id({}),企业:({}),额度小于等于3,不做增加额度", enterprise.getId(), enterprise.getName());
|
|
|
return;
|
|
|
}
|
|
|
// 设置为三个发布职位额度
|
|
@@ -104,6 +106,7 @@ public class EnterpriseEmailNoticeTask {
|
|
|
.id(entitlement.getId())
|
|
|
.publishJobCount(JOB_NUM)
|
|
|
.build());
|
|
|
+ log.info("id({}),企业:({}),用户({}),额度({}),增加发布职位额度", enterprise.getId(), entitlement.getUserId(), enterprise.getName(), 3);
|
|
|
|
|
|
}
|
|
|
|