浏览代码

wip:邮件内容修改

wangkaiyue 1 年之前
父节点
当前提交
18847a00c6
共有 1 个文件被更改,包括 12 次插入5 次删除
  1. 12 5
      internal/service/sendMail.go

+ 12 - 5
internal/service/sendMail.go

@@ -27,6 +27,7 @@ type (
 		Url              string `json:"url"`
 		OrderCode        string `json:"order_code"`
 		InvoiceVariety   string `json:"invoice_variety"`
+		InvoiceContent   string `json:"invoice_content"`
 	}
 )
 
@@ -92,7 +93,7 @@ const (
 								</p>
 								<p class="item">
 									<span class="label">发票内容:</span>
-									<span class="value">信息技术服务-技术服务费</span>
+									<span class="value">%s</span>
 								</p>`
 
 	emailHtml_gs = `<p class="item">
@@ -177,7 +178,7 @@ func SendInvoiceSuccessMail(ctx context.Context, callBackId string) error {
 		return err
 	}
 
-	res, err := g.DB().GetOne(ctx, fmt.Sprintf("SELECT invoice_type,mail,taxpayer_identnum,company_name,phone,url,order_code,invoice_variety FROM invoice WHERE %s = ? ", queryItem), queryValue)
+	res, err := g.DB().GetOne(ctx, fmt.Sprintf("SELECT invoice_type,mail,taxpayer_identnum,company_name,phone,url,order_code,invoice_variety,invoice_content FROM invoice WHERE %s = ? ", queryItem), queryValue)
 	if err != nil {
 		return gerror.Wrapf(err, "未查询到订单发票信息 %s:%s", queryItem, queryValue)
 	}
@@ -194,16 +195,22 @@ func SendInvoiceSuccessMail(ctx context.Context, callBackId string) error {
 }
 
 func (ir *invoiceRecord) GetMailHtmlContext() string {
-	tType := "电子普通发票"
+	var (
+		tType          = "电子普通发票"
+		invoiceContext = "信息技术服务-技术服务费"
+	)
 	if strings.Contains(ir.InvoiceVariety, "专用") {
 		tType = "电子专用发票"
 	}
+	if ir.InvoiceContent != "" {
+		invoiceContext = ir.InvoiceContent
+	}
 	g.Dump(ir, strings.Contains(ir.InvoiceVariety, "专用"))
 	switch ir.InvoiceType {
 	case "单位":
-		return fmt.Sprintf(emailHtml_header+emailHtml_gs, ir.OrderCode, tType, fmt.Sprintf("<a href=\"%s\" download class=\"download\">查看发票</a>", ir.Url), tType, ir.CompanyName, ir.TaxpayerIdentnum, ir.Phone, ir.Mail)
+		return fmt.Sprintf(emailHtml_header+emailHtml_gs, ir.OrderCode, tType, invoiceContext, fmt.Sprintf("<a href=\"%s\" download class=\"download\">查看发票</a>", ir.Url), tType, ir.CompanyName, ir.TaxpayerIdentnum, ir.Phone, ir.Mail)
 	case "个人":
-		return fmt.Sprintf(emailHtml_header+emailHtml_gr, ir.OrderCode, tType, fmt.Sprintf("<a href=\"%s\" download class=\"download\">查看发票</a>", ir.Url), tType, ir.Phone, ir.Mail)
+		return fmt.Sprintf(emailHtml_header+emailHtml_gr, ir.OrderCode, tType, invoiceContext, fmt.Sprintf("<a href=\"%s\" download class=\"download\">查看发票</a>", ir.Url), tType, ir.Phone, ir.Mail)
 	}
 	return ""
 }