Browse Source

确定行程的活动,有客户报名时,推送给对口销售和王芳

xingzai 2 years ago
parent
commit
b2da4adc62
3 changed files with 76 additions and 1 deletions
  1. 1 0
      controllers/activity_special.go
  2. 74 0
      services/activity_special_trip.go
  3. 1 1
      utils/config.go

+ 1 - 0
controllers/activity_special.go

@@ -247,6 +247,7 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 			itemBill.ChartPermissionId = activityInfo.ChartPermissionId
 
 			go services.ActivitySpecialUserRmind(user, activityId, 2)
+			go services.ActivitySpecialUserAddTrip(user, activityId)
 			//判断是删除还是添加
 			if total == 0 {
 				//获取销售信息

+ 74 - 0
services/activity_special_trip.go

@@ -210,3 +210,77 @@ func ActivitySpecialUserRmind(user *models.WxUserItem, activityId, TripStatus in
 	}
 	return
 }
+
+// 确定行程用户报名模版消息推送
+func ActivitySpecialUserAddTrip(user *models.WxUserItem, activityId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("确定行程用户报名模版消息推送,模板消息推送失败"+err.Error(), 2)
+		}
+	}()
+	countUser, err := models.GetUserRemind(user.UserId)
+	if err != nil {
+		return err
+	}
+	if countUser == 0 {
+		return err
+	}
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	//获取销售手机号
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	cnf, _ := models.GetConfigByCode("tpl_msg")
+
+	if cnf != nil && sellerItemQy != nil {
+		openIdList, e := models.GetWxOpenIdByMobileList(cnf.ConfigValue + "," + sellerItemQy.Mobile)
+		if e != nil {
+			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+			return
+		}
+		activityInfo, e := models.GetCygxActivitySpecialDetailById(user.UserId, activityId)
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error())
+			return
+		}
+		if activityInfo == nil {
+			return
+		}
+
+		first = fmt.Sprint("【", activityInfo.ResearchTheme, "】", "有客户报名")
+		keyword1 = fmt.Sprint(user.RealName, "--", user.CompanyName, "(所属销售:)", sellerItemQy.RealName)
+		keyword2 = user.Mobile
+		keyword3 = time.Now().Format(utils.FormatDateTime)
+		keyword4 = activityInfo.ResearchTheme
+		remark = ""
+		openIdArr := make([]string, 0)
+		for _, v := range openIdList {
+			openIdArr = append(openIdArr, v.OpenId)
+		}
+		redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId)
+		sendInfo := new(SendWxTemplate)
+		sendInfo.First = first
+		sendInfo.Keyword1 = keyword1
+		sendInfo.Keyword2 = keyword2
+		sendInfo.Keyword3 = keyword3
+		sendInfo.Keyword4 = keyword4
+		sendInfo.Remark = remark
+		sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
+		sendInfo.RedirectUrl = redirectUrl
+		sendInfo.RedirectTarget = 3
+		sendInfo.Resource = strconv.Itoa(activityId)
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		err = PublicSendTemplateMsg(sendInfo)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 1 - 1
utils/config.go

@@ -142,7 +142,7 @@ func init() {
 	YanxSummaryPermissionId = 1001     //研选纪要分类ID
 	YanxViewpointPermissionId = 1002   //研选观点分类ID
 	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,18955528215"
-	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829"
+	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829" // 沈涛:18767183922、 王芳:18621268829
 	HtgjDefaultSaleName = "王芳"
 	HtgjSalt = "HTGJ&HZ"
 	HtgjName = "海通国际"