소스 검색

发送发票管理模版

lyhzzz 2 년 전
부모
커밋
9584fe6ca7

+ 1 - 1
src/main/java/com/fdkankan/sale/common/FilePath.java

@@ -2,6 +2,6 @@ package com.fdkankan.sale.common;
 
 public class FilePath {
 
-    public static String file_path = "/home/backend/4dkankan/sale/file/%s/%s";
+    public static String file_path = "/home/backend/4dkankan/sale/file/";
     public static String oss_file_path = "sale/file/%s/%s";
 }

+ 3 - 3
src/main/java/com/fdkankan/sale/exception/GlobalExceptionHandler.java

@@ -21,9 +21,6 @@ public class GlobalExceptionHandler {
     @ResponseBody
     @ExceptionHandler(value = Exception.class)
     public ResultData exceptionHandler(Exception e) throws Exception {
-        if(e.getCause().getMessage().contains("Data truncation: Out of range value")){
-            return ResultData.error( ResultCode.MATH_TO_MAX);
-        }
         log.error("服务错误:", e);
         return ResultData.error( 500, e.getCause().getMessage());
     }
@@ -47,6 +44,9 @@ public class GlobalExceptionHandler {
         if(e.getCause().getMessage().contains("Data too long")){
             return ResultData.error(ResultCode.DATA_TOO_LONG);
         }
+        if(e.getCause().getMessage().contains("Out of range value")){
+            return ResultData.error( ResultCode.MATH_TO_MAX);
+        }
         return ResultData.error( 500, e.getCause().getMessage());
     }
 }

+ 20 - 6
src/main/java/com/fdkankan/sale/service/impl/RepairInvoiceServiceImpl.java

@@ -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())){

+ 3 - 2
src/main/java/com/fdkankan/sale/vo/response/RepairInvoiceVo.java

@@ -111,8 +111,6 @@ public class RepairInvoiceVo  {
     /**
      * 企业电话
      */
-    @ExcelIgnore
-    private String eInvoiceImg;
 
     @ExcelIgnore
     private String updateTime;
@@ -126,6 +124,9 @@ public class RepairInvoiceVo  {
     @ExcelProperty("收货地址")
     private String getAddress;
 
+    @ExcelProperty("发票图片")
+    private String invoiceImg;
+
 
     public String getStatusStr() {
         if(status == null){