|
@@ -0,0 +1,80 @@
|
|
|
+package com.fdkankan.manage.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.extra.mail.MailAccount;
|
|
|
+import cn.hutool.extra.mail.MailUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.response.PageInfo;
|
|
|
+import com.fdkankan.manage.entity.AgentAudit;
|
|
|
+import com.fdkankan.manage.entity.MailTemplate;
|
|
|
+import com.fdkankan.manage.entity.SceneApply;
|
|
|
+import com.fdkankan.manage.mapper.ISceneApplyMapper;
|
|
|
+import com.fdkankan.manage.service.IMailTemplateService;
|
|
|
+import com.fdkankan.manage.service.ISceneApplyService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage.util.SendMailUtils;
|
|
|
+import com.fdkankan.manage.vo.request.AgentAuditListParam;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2022-09-22
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class SceneApplyServiceImpl extends ServiceImpl<ISceneApplyMapper, SceneApply> implements ISceneApplyService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IMailTemplateService mailTemplateService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo pageList(AgentAuditListParam param) {
|
|
|
+ LambdaQueryWrapper<SceneApply> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(StringUtils.isNotBlank(param.getCompanyName())){
|
|
|
+ wrapper.like(SceneApply::getName,param.getCompanyName());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(param.getStartTime())&& StringUtils.isNotBlank(param.getEndTime()) ) {
|
|
|
+ wrapper.between(SceneApply::getCreateTime,param.getStartTime(),param.getEndTime());
|
|
|
+ }
|
|
|
+ if(param.getHandleState() == 1){
|
|
|
+ wrapper.in(SceneApply::getState, Arrays.asList(1,2));
|
|
|
+ }else {
|
|
|
+ wrapper.eq(SceneApply::getState, 0);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(SceneApply::getCreateTime);
|
|
|
+ Page<SceneApply> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
+
|
|
|
+ return PageInfo.PageInfo(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendEmail(Integer sceneApplyId, Integer emailTemplateId) {
|
|
|
+ SceneApply sceneApply = this.getById(sceneApplyId);
|
|
|
+ if(sceneApply == null){
|
|
|
+ throw new BusinessException(-1,"场景申请不存在");
|
|
|
+ }
|
|
|
+ MailTemplate mailTemplate = mailTemplateService.getById(emailTemplateId);
|
|
|
+ if(mailTemplate == null){
|
|
|
+ throw new BusinessException(-1,"邮件发送模板不存在");
|
|
|
+ }
|
|
|
+ boolean flag = SendMailUtils.sendMail(mailTemplate.getSendMail(), mailTemplate.getSendPassword(), mailTemplate.getSendHost(),
|
|
|
+ sceneApply.getEmail(), mailTemplate.getSubject(), mailTemplate.getMsg(), null);
|
|
|
+
|
|
|
+ if(flag){
|
|
|
+ sceneApply.setState(1);
|
|
|
+ }else {
|
|
|
+ sceneApply.setState(2);
|
|
|
+ }
|
|
|
+ this.updateById(sceneApply);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|