ziwen před 2 roky
rodič
revize
570280f1c8

+ 5 - 2
models/tables/wx_user/query.go

@@ -3,7 +3,6 @@ package wx_user
 import (
 	"errors"
 	"hongze/hongze_yb/global"
-	"hongze/hongze_yb/services/wechat"
 	"hongze/hongze_yb/utils"
 )
 
@@ -42,8 +41,12 @@ func GetByUserIds(userIds []uint64) (list []*WxUser, err error) {
 	return
 }
 
+type OpenIdList struct {
+	OpenID string
+	UserID int
+}
 
-func GetOpenIdList() (items []*wechat.OpenIdList, err error) {
+func GetOpenIdList() (items []*OpenIdList, err error) {
 	sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu 
           INNER JOIN company AS c ON c.company_id = wu.company_id 
           INNER JOIN company_product AS d ON c.company_id=d.company_id

+ 8 - 2
services/wechat/template_msg.go

@@ -246,11 +246,17 @@ func SendVoiceBroadcastWxMsg(broadcastId int, sectionName, broadcastName string)
 		}
 	}()
 
-	openIdList, err := wx_user.GetOpenIdList()
+	List, err := wx_user.GetOpenIdList()
 	if err != nil {
 		return
 	}
-
+	openIdList := make([]*OpenIdList, 0)
+	for _, item := range List {
+		openIdList = append(openIdList, &OpenIdList{
+			OpenId: item.OpenID,
+			UserId: item.UserID,
+		})
+	}
 	sendMap := make(map[string]interface{})
 	sendData := make(map[string]interface{})