Browse Source

发送模板消息

rdluck 4 years ago
parent
commit
c33442c724
2 changed files with 20 additions and 13 deletions
  1. 19 12
      controllers/user.go
  2. 1 1
      services/wechat_send_msg.go

+ 19 - 12
controllers/user.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
@@ -855,20 +856,26 @@ func (this *UserController) ApplyTryOut() {
 		if mobile == "" {
 			mobile = user.Email
 		}
-		applyMethod := ""
-		if req.ApplyMethod == 1 {
-			applyMethod = "已有客户申请"
-		} else {
-			applyMethod = "潜在客户申请"
-		}
-		cnf, _ := models.GetConfigByCode("tpl_msg")
-		if cnf != nil {
-			openIpItem, _ := models.GetUserRecordByUserId(user.UserId, 1)
-			if openIpItem != nil && openIpItem.OpenId != "" {
-				go services.SendPermissionApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, openIpItem.OpenId, applyMethod)
-			}
+	}
+
+	applyMethod := ""
+	if req.ApplyMethod == 1 {
+		applyMethod = "已有客户申请"
+	} else {
+		applyMethod = "潜在客户申请"
+	}
+	cnf, _ := models.GetConfigByCode("tpl_msg")
+	fmt.Println("cnf", cnf)
+	if cnf != nil {
+		openIpItem, _ := models.GetUserRecordByUserId(user.UserId, 1)
+		fmt.Println("openIpItem", openIpItem)
+		fmt.Println("OpenId", openIpItem.OpenId)
+		if openIpItem != nil && openIpItem.OpenId != "" {
+			fmt.Println("send:", user.RealName, user.CompanyName, mobile, openIpItem.OpenId, applyMethod)
+			go services.SendPermissionApplyTemplateMsg(user.RealName, user.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 		}
 	}
+
 	err = models.AddApplyRecord(&req, user.Mobile, user.CompanyName, user.UserId, user.CompanyId)
 	if err != nil {
 		br.Msg = "申请失败"

+ 1 - 1
services/wechat_send_msg.go

@@ -98,7 +98,7 @@ func SendInterviewApplyCancelTemplateMsg(realName, companyName, mobile, articleT
 	return
 }
 
-
+//权限申请
 func SendPermissionApplyTemplateMsg(realName, companyName, mobile, openId,applyMethod string) (err error) {
 	var msg string
 	defer func() {