浏览代码

公司调研】系列纪要发布/更新后模板消息推送

xingzai 2 年之前
父节点
当前提交
adaa019e38
共有 2 个文件被更改,包括 67 次插入7 次删除
  1. 2 2
      models/activity_appointment.go
  2. 65 5
      services/article.go

+ 2 - 2
models/activity_appointment.go

@@ -136,7 +136,7 @@ type CygxAppointmentAndActivity struct {
 }
 
 //通过活动ID获取预约列表
-func GetAppointmentListByActivityId(activityIds string) (items []*CygxAppointmentAndActivity, err error) {
+func GetAppointmentListByActivityId(activityIds, activityTypeIds string) (items []*CygxAppointmentAndActivity, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			m.*,a.activity_name
@@ -145,7 +145,7 @@ func GetAppointmentListByActivityId(activityIds string) (items []*CygxAppointmen
 			INNER JOIN cygx_activity AS a ON a.activity_id = m.activity_id 
 		WHERE
 			a.activity_id IN ( ` + activityIds + ` ) 
-			AND a.activity_type_id IN ( 1, 2, 5 ) 
+			AND a.activity_type_id IN (` + activityTypeIds + `) 
 			AND DATE_SUB( CURDATE(), INTERVAL 14 DAY ) <= date( a.activity_time ) 
 			AND a.active_state = 3`
 	_, err = o.Raw(sql).QueryRows(&items)

+ 65 - 5
services/article.go

@@ -693,14 +693,12 @@ func GetArticleListByApi(cont context.Context) (err error) {
 								activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
 							}
 							activityIdStr = strings.TrimRight(activityIdStr, ",")
-							fmt.Println(activityIdStr)
 							if activityIdStr != "" {
-								appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr)
+								appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "1,2,5")
 								if err != nil {
 									fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
 									return err
 								}
-								fmt.Println("预约", appointmentList)
 								if len(appointmentList) > 0 {
 									for _, vApp := range appointmentList {
 
@@ -722,13 +720,11 @@ func GetArticleListByApi(cont context.Context) (err error) {
 												fmt.Println(err)
 												return err
 											}
-
 											keyword1 := "您预约的调研,有关联的纪要发布/更新了"
 											keyword2 := appointmentActivityName
 											keyword3 := v.Title
 											keyword4 := v.PublishDate.Format(utils.FormatDateTime)
 											SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, articleIdInt)
-											fmt.Println(openIdListByAppointment)
 										}
 									}
 								}
@@ -736,8 +732,72 @@ func GetArticleListByApi(cont context.Context) (err error) {
 						}
 					}
 				}
+			}
+			//【公司调研】系列纪要发布/更新后
+			if v.CategoryId == 45 || v.CategoryId == 74 || v.CategoryId == 86 || v.CategoryId == 88 {
+				sliceSubjects := strings.Split(v.Stock, "/")
+				if len(sliceSubjects) > 0 {
+					var subjectStr string
+					for _, vSubject := range sliceSubjects {
+						sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
+						sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
+						subject := sliceXiahuaxian[0]
+						subjectStr += "'" + subject + "',"
+					}
+					if subjectStr != "" {
+						subjectStr = strings.TrimRight(subjectStr, ",")
+						activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
+						if err != nil {
+							fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
+							return err
+						}
+						if len(activityIdList) > 0 {
+							var activityIdStr string
+							for _, vAct := range activityIdList {
+								activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
+							}
+							activityIdStr = strings.TrimRight(activityIdStr, ",")
+							if activityIdStr != "" {
+								appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "3,4")
+								if err != nil {
+									fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
+									return err
+								}
+								if len(appointmentList) > 0 {
+									for _, vApp := range appointmentList {
+										appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
+										if err != nil {
+											fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
+											return err
+										}
+										var appointmentActivityName string
+										if len(appointmentByMobileList) > 0 {
+											for _, vAppM := range appointmentByMobileList {
+												appointmentActivityName += vAppM.ActivityName + ","
+											}
+										}
+										appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
+										if vApp.Mobile != "" {
+											openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
+											if err != nil {
+												fmt.Println(err)
+												return err
+											}
+											keyword1 := "您预约的调研,有关联的纪要发布/更新了"
+											keyword2 := appointmentActivityName
+											keyword3 := v.Title
+											keyword4 := v.PublishDate.Format(utils.FormatDateTime)
+											SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, articleIdInt)
 
+										}
+									}
+								}
+							}
+						}
+					}
+				}
 			}
+			//【公司调研】系列纪要发布/更新后 end
 		}
 	}
 	return