|
@@ -1,8 +1,12 @@
|
|
|
package com.fdkankan.sale.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.sale.common.CacheUtil;
|
|
|
+import com.fdkankan.sale.common.FilePath;
|
|
|
import com.fdkankan.sale.common.ResultCode;
|
|
|
import com.fdkankan.sale.entity.MailTemplate;
|
|
|
import com.fdkankan.sale.entity.RepairInvoice;
|
|
@@ -18,6 +22,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -33,6 +39,8 @@ public class RepairInvoiceServiceImpl extends ServiceImpl<IRepairInvoiceMapper,
|
|
|
IMailTemplateService mailTemplateService;
|
|
|
@Autowired
|
|
|
IRepairService repairService;
|
|
|
+ @Autowired
|
|
|
+ FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -64,6 +72,18 @@ public class RepairInvoiceServiceImpl extends ServiceImpl<IRepairInvoiceMapper,
|
|
|
if(StringUtils.isBlank(param.getInvoiceNo()) || StringUtils.isBlank(param.getInvoiceImg())){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
+
|
|
|
+ MailTemplate mailTemplate = this.setMailMsg(repairInvoice.getRepairId(),repairInvoice.getInvoiceEmail());
|
|
|
+
|
|
|
+ String imagePath = param.getInvoiceImg().replaceAll(CacheUtil.host,"");
|
|
|
+ String localPath = FilePath.file_path + imagePath;
|
|
|
+ fYunFileServiceInterface.downloadFile(imagePath,localPath);
|
|
|
+
|
|
|
+ Boolean mail = mailTemplateService.sendMail(repairInvoice.getInvoiceEmail(), mailTemplate,localPath);
|
|
|
+ if(!mail){
|
|
|
+ throw new BusinessException(ResultCode.MAIL_SEND_ERROR);
|
|
|
+ }
|
|
|
+ FileUtil.del(localPath);
|
|
|
LambdaUpdateWrapper<RepairInvoice> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.eq(RepairInvoice::getInvoiceId,param.getInvoiceId());
|
|
|
wrapper.set(RepairInvoice::getInvoiceNo,param.getInvoiceNo());
|
|
@@ -72,12 +92,6 @@ public class RepairInvoiceServiceImpl extends ServiceImpl<IRepairInvoiceMapper,
|
|
|
wrapper.set(RepairInvoice::getSysUserId,userId);
|
|
|
this.update(wrapper);
|
|
|
|
|
|
- MailTemplate mailTemplate = this.setMailMsg(repairInvoice.getRepairId(),repairInvoice.getInvoiceEmail());
|
|
|
- Boolean mail = mailTemplateService.sendMail(repairInvoice.getInvoiceEmail(), mailTemplate,param.getInvoiceImg());
|
|
|
- if(!mail){
|
|
|
- throw new BusinessException(ResultCode.MAIL_SEND_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
if(repairInvoice.getInvoiceType() == 1){ //普通发票邮件发送,专用发票邮寄
|
|
|
if(StringUtils.isBlank(param.getInvoiceNo()) || StringUtils.isBlank(param.getTrackingNum())){
|