jimmyyem 1 месяц назад
Родитель
Сommit
e1147908e6
2 измененных файлов с 47 добавлено и 0 удалено
  1. 23 0
      crontask/send_wx.go
  2. 24 0
      internal/logic/sop_task/publish_sop_task_logic.go

+ 23 - 0
crontask/send_wx.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"encoding/json"
 	"regexp"
+	"strconv"
 	"strings"
 	"time"
 	"wechat-api/ent"
@@ -178,9 +179,31 @@ func containsPlaceholder(s string) bool {
 
 func varReplace(s string, contactInfo *ent.Contact) string {
 	nickname := ""
+	var cname, carea, cbirthday, cbirtharea, cidcard_no, ctitle, csex, cage string
 	if contactInfo != nil {
 		nickname = contactInfo.Nickname
+		carea = contactInfo.Carea
+		cname = contactInfo.Cname
+		cbirthday = contactInfo.Cbirthday
+		cbirtharea = contactInfo.Cbirtharea
+		cidcard_no = contactInfo.CidcardNo
+		ctitle = contactInfo.Ctitle
+		if contactInfo.Sex == 1 {
+			csex = "男"
+		} else if contactInfo.Sex == 2 {
+			csex = "女"
+		}
+		age := contactInfo.Cage
+		cage = strconv.Itoa(age)
 	}
 	s = strings.Replace(s, "${nickname}", nickname, -1)
+	s = strings.Replace(s, "${cname}", cname, -1)
+	s = strings.Replace(s, "${carea}", carea, -1)
+	s = strings.Replace(s, "${cbirthday}", cbirthday, -1)
+	s = strings.Replace(s, "${cbirtharea}", cbirtharea, -1)
+	s = strings.Replace(s, "${cidcard_no}", cidcard_no, -1)
+	s = strings.Replace(s, "${ctitle}", ctitle, -1)
+	s = strings.Replace(s, "${csex}", csex, -1)
+	s = strings.Replace(s, "${cage}", cage, -1)
 	return s
 }

+ 24 - 0
internal/logic/sop_task/publish_sop_task_logic.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"regexp"
+	"strconv"
 	"strings"
 	"wechat-api/ent"
 	"wechat-api/ent/contact"
@@ -435,9 +436,32 @@ func splitString(input string) []string {
 
 func varReplace(s string, contactInfo *ent.Contact) string {
 	nickname := ""
+	var cname, carea, cbirthday, cbirtharea, cidcard_no, ctitle, csex, cage string
 	if contactInfo != nil {
 		nickname = contactInfo.Nickname
+		carea = contactInfo.Carea
+		cname = contactInfo.Cname
+		cbirthday = contactInfo.Cbirthday
+		cbirtharea = contactInfo.Cbirtharea
+		cidcard_no = contactInfo.CidcardNo
+		ctitle = contactInfo.Ctitle
+		if contactInfo.Sex == 1 {
+			csex = "男"
+		} else if contactInfo.Sex == 2 {
+			csex = "女"
+		}
+		age := contactInfo.Cage
+		cage = strconv.Itoa(age)
 	}
+
 	s = strings.Replace(s, "${nickname}", nickname, -1)
+	s = strings.Replace(s, "${cname}", cname, -1)
+	s = strings.Replace(s, "${carea}", carea, -1)
+	s = strings.Replace(s, "${cbirthday}", cbirthday, -1)
+	s = strings.Replace(s, "${cbirtharea}", cbirtharea, -1)
+	s = strings.Replace(s, "${cidcard_no}", cidcard_no, -1)
+	s = strings.Replace(s, "${ctitle}", ctitle, -1)
+	s = strings.Replace(s, "${csex}", csex, -1)
+	s = strings.Replace(s, "${cage}", cage, -1)
 	return s
 }