xingzai 9 bulan lalu
induk
melakukan
aad8cec6be

+ 1 - 1
controllers/user.go

@@ -638,7 +638,7 @@ func (this *UserController) ApplyTryOut() {
 		go services.SendPermissionApplyTemplateMsgAdmin(req, mobile, applyMethod, isResearch)
 		if isResearch {
 			//如果是研选的报告走研选的类目模版消息
-			go services.SendPermissionApplyTemplateMsgAdminByYxCategory(req, mobile, applyMethod)
+			go services.SendPermissionApplyTemplateMsgAdminByYxCategory(req, mobile, applyMethod, user.CompanyId)
 		}
 	} else {
 		openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)

+ 3 - 4
controllers/yanxuan_special.go

@@ -497,8 +497,8 @@ func (this *YanxuanSpecialController) Save() {
 		go services.SendWxMsgSpecialAuthor(req.Id, 1)                  //研选专栏审核完成时,给提交人发送模板消息
 		go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量
 		go services.MakeYanxuanSpecialMomentsImg(specialId)            //  生成研选专栏分享到朋友圈的图片
-		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
-		go services.SendWxCategoryMsgSpecialFollow(req.Id) // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1)          //研选专栏审核完成时,给提交人发送类目模板消息
+		go services.SendWxCategoryMsgSpecialFollow(req.Id)             // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
 	} else {
 		if req.DoType == 2 {
 			go services.SendReviewTemplateMsgAdmin(specialId)
@@ -602,9 +602,8 @@ func (this *YanxuanSpecialController) Enable() {
 	}
 	if req.Status == 1 {
 		go services.SendWxMsgSpecialFollow(req.Id)
-
 		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
-		go services.SendWxCategoryMsgSpecialFollow(req.Id)	// 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+		go services.SendWxCategoryMsgSpecialFollow(req.Id)    // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
 	} else {
 		go services.SendWxCategoryMsgSpecialAuthor(req.Id, 2)
 	}

+ 45 - 15
services/user.go

@@ -4,6 +4,7 @@ import (
 	"errors"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -712,30 +713,59 @@ func SendPermissionApplyTemplateMsgAdmin(req models.ApplyTryReq, usermobile, app
 	return
 }
 
-// 研选模板消息
-func SendPermissionApplyTemplateMsgAdminByYxCategory(req models.ApplyTryReq, usermobile, applyMethod string) (err error) {
+// 研选类目模板消息
+func SendPermissionApplyTemplateMsgAdminByYxCategory(req models.ApplyTryReq, usermobile, applyMethod string, companyId int) (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("处理试用申请给王芳,汪洋发消息失败, ErrMsg: "+err.Error(), 3)
+			go utils.SendAlarmMsg("研选类目模板消息消息失败, SendPermissionApplyTemplateMsgAdminByYxCategoryErrMsg: "+err.Error(), 3)
 		}
 	}()
-	var configCode string
-	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
-	configCode = utils.TPL_MSG
-	cnf, e := models.GetConfigByCode(configCode)
+	mobile := utils.WxMsgTemplateIdAskMsgMobilePublic
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(mobile)
 	if e != nil {
-		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
+		err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
+		return err
+	}
+	if len(openIdList) == 0 {
 		return
 	}
-	var mobiles []string
-	mobiles = append(mobiles, cnf.ConfigValue)
-	openIdList, e := models.GetMfyxWxOpenIdByMobileArrList(mobiles)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
-		return err
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var keyword5 string
+	keyword1 = req.RealName
+	keyword2 = utils.TruncateActivityNameString(req.CompanyName)
+	keyword3 = "权限申请"
+	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
+	if companyId == 1 {
+		keyword5 = "潜在客户"
+	} else {
+		keyword5 = "FICC客户"
 	}
+	openIdArr := make([]string, 0)
 	for _, v := range openIdList {
-		go SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, usermobile, applyMethod, v)
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	detail, e := models.GetCygxApplyRecordByMobile(mobile)
+	if e != nil {
+		err = errors.New("GetActivitySignupNomeetingCountList" + e.Error())
+		return
 	}
+	redirectUrl := ""
+	//如果是潜在客户就推送可查看详情的模版消息
+	if detail.ApplyMethod == 2 {
+		redirectUrl = utils.WX_MSG_PATH_APPLY_DETAIL + strconv.Itoa(detail.ApplyRecordId)
+	}
+
+	keywords := []string{keyword1, keyword2, keyword3, keyword4, keyword5}
+	sendInfo := new(SendWxCategoryTemplate)
+	sendInfo.Keywords = keywords
+	sendInfo.TemplateId = utils.WxCategoryMsgTemplateIdApplyXzs
+	sendInfo.RedirectTarget = 4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	sendInfo.RedirectUrl = redirectUrl
+	err = SendCategoryTemplateMsg(sendInfo)
 	return
 }

+ 5 - 1
services/wechat_send_category_template_msg.go

@@ -26,6 +26,10 @@ type SendWxCategoryTemplate struct {
 
 // 推送类目模板消息
 func SendCategoryTemplateMsg(sendInfo *SendWxCategoryTemplate) (err error) {
+	//没有获取到openID不推送
+	if len(sendInfo.OpenIdArr) == 0 {
+		return
+	}
 	postData, err := json.Marshal(sendInfo)
 	if err != nil {
 		utils.SendAlarmMsg("SendCategoryTemplateMsg json.Marshal Err:"+err.Error(), 1)
@@ -92,7 +96,7 @@ func SendWxCategoryMsgSpecialAuthor(specialId, status int) (err error) {
 		return err
 	}
 
-	keyword1 = specialItem.Title
+	keyword1 = utils.TruncateActivityNameString(specialItem.Title)
 	keyword2 = specialItem.NickName
 	if status == 1 {
 		keyword3 = "文章已通过审核,点击查看详情"