WH01243 4 년 전
부모
커밋
b740a197f5
2개의 변경된 파일22개의 추가작업 그리고 25개의 파일을 삭제
  1. 17 21
      invoice/src/service/InvoiceService.go
  2. 5 4
      invoice/src/util/push.go

+ 17 - 21
invoice/src/service/InvoiceService.go

@@ -62,9 +62,7 @@ func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice, resType string, isLo
 		util.Loger.Println("开票服有问题", err)
 		if isLoop == 0 {
 			arr := strings.Split(entity.WarningEmail, ",")
-			for _, value := range arr {
-				util.SendPdf(value, true, solgan.Swno, "发票开具时服务出现问题")
-			}
+			util.SendPdf(arr, true, solgan.Swno, "发票开具时服务出现问题")
 			solgan.ResType = resType
 			solgan.IsRed = isRed
 			u.OpeningTimer(solgan)
@@ -103,9 +101,7 @@ func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice, resType string, isLo
 		return msg, code, data1
 	} else {
 		arr := strings.Split(entity.WarningEmail, ",")
-		for _, value := range arr {
-			util.SendPdf(value, true, solgan.Swno, "发票开具时出现问题")
-		}
+		util.SendPdf(arr, true, solgan.Swno, "发票开具时出现问题")
 		fmt.Println("用时:", fmt.Sprint(time.Now().Unix()-starTime))
 		return fmt.Sprintln(data["returnMsg"]), 1, data
 	}
@@ -113,7 +109,6 @@ func (u *InvoiceService) InvoiceAdd(solgan *entity.Invoice, resType string, isLo
 
 // 发票下载
 func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed string, isLoop int, isfeedback int, changed string, resType string, orderCode string) (map[string]interface{}, int, string) {
-	starTime:=time.Now().Unix()
 	song := make(map[string]interface{})
 	song["swno"] = swno
 	song["saleTax"] = saleTax
@@ -132,18 +127,19 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed stri
 	var err error
 	err = nil
 	//正常
-	//if (err != nil) {
-	if (err == nil) {
+	if (err != nil) {
+	//if (err == nil) {
 		data1 := make(map[string]interface{})
 		data1["fpdm"] = ""
 		data1["fphm"] = ""
 		data1["swno"] = ""
 		data1["path"] = ""
+		starTime := time.Now().Unix()
 		if isLoop == 0 {
 			arr := strings.Split(entity.WarningEmail, ",")
-			for _, value := range arr {
-				util.SendPdf(value, true, swno, "发票下载时服务出现问题")
-			}
+
+			util.SendPdf(arr, true, swno, "发票下载时服务出现问题")
+
 			solgan := entity.Invoice{
 				Swno:    swno,
 				SaleTax: saleTax,
@@ -201,9 +197,9 @@ func (u *InvoiceService) InvoiceDownload(swno string, saleTax string, isRed stri
 		return nil, 2, dat.ReturnMsg.Msg
 	} else {
 		arr := strings.Split(entity.WarningEmail, ",")
-		for _, value := range arr {
-			util.SendPdf(value, true, swno, "发票下载时出现问题,"+dat.ReturnMsg.Msg)
-		}
+
+		util.SendPdf(arr, true, swno, "发票下载时出现问题,"+dat.ReturnMsg.Msg)
+
 		return nil, 1, dat.ReturnMsg.Msg
 	}
 }
@@ -265,9 +261,9 @@ func (u *InvoiceService) InvoiceRedSubmit(fpdm string, fphm string, orderCode st
 		data1["path"] = ""
 		if isLoop == 0 {
 			arr := strings.Split(entity.WarningEmail, ",")
-			for _, value := range arr {
-				util.SendPdf(value, true, solgan.Swno, "发票退票时服务出现问题")
-			}
+
+			util.SendPdf(arr, true, solgan.Swno, "发票退票时服务出现问题")
+
 			u.OpeningTimer(solgan)
 		}
 		if (model == "2") {
@@ -398,9 +394,9 @@ func (u *InvoiceService) Timer(swno string, saleTax string, isRed string, isfeed
 			fmt.Sprint("numb", "执行次数")
 			if numb == entity.Frequency {
 				arr := strings.Split(entity.WarningEmail, ",")
-				for _, value := range arr {
-					util.SendPdf(value, false, swno, "排队中签章失败定时任务出现问题")
-				}
+
+				util.SendPdf(arr, false, swno, "排队中签章失败定时任务出现问题")
+
 				numb++
 				util.Callback(swno, saleTax, "", "", "", changed, isRed, resType, "true", "", orderCode)
 			}

+ 5 - 4
invoice/src/util/push.go

@@ -54,7 +54,8 @@ func ImgHandle(imgBase64 string, swno string, saleTax string, swno1 string) stri
 }
 
 //pdf邮箱发送
-func SendPdf(name string,fool bool,orderCode string,msg string) (bool) {
+func SendPdf(emailArr []string,fool bool,orderCode string,msg string) (bool) {
+	startTime:=time.Now().Unix()
 	var mailConf entity.MailboxConf
 	if fool{
 		mailConf.Body = "流水号:"+orderCode+","+entity.Body+","+msg
@@ -62,7 +63,7 @@ func SendPdf(name string,fool bool,orderCode string,msg string) (bool) {
 		mailConf.Body = "流水号:"+orderCode+","+"开票失败"+","+msg
 	}
 	mailConf.Title = entity.Title
-	mailConf.RecipientList = []string{name}
+	mailConf.RecipientList =emailArr
 	mailConf.Sender = entity.Sender
 	mailConf.SPassword = entity.SPassword
 	mailConf.SMTPAddr = entity.SMTPAddr
@@ -72,13 +73,13 @@ func SendPdf(name string,fool bool,orderCode string,msg string) (bool) {
 	m.SetHeader(`To`, mailConf.RecipientList...)
 	m.SetHeader(`Subject`, entity.Title)
 	m.SetBody(`text/html`, mailConf.Body)
-
 	err := gomail.NewDialer(mailConf.SMTPAddr, mailConf.SMTPPort, mailConf.Sender, mailConf.SPassword).DialAndSend(m)
 	if err != nil {
 		fmt.Println("Send Email Fail, %s", err.Error())
 	}
 	fmt.Println("Send Email Success")
-	return false
+	fmt.Println("用时:", fmt.Sprint(time.Now().Unix()-startTime))
+	return true
 }
 func SafeConvert2Int(obj interface{}) int {
 	if obj != nil {