Browse Source

Merge branch 'dev/v2.4.21_rjj' of jianyu/qmx_admin into feature/v2.4.21

renjiaojiao 2 years ago
parent
commit
437f20ed57

+ 3 - 0
src/customerService/customService.go

@@ -25,6 +25,7 @@ func CustomSendMsgService(param *customMsg, sendStatus int, loginUserName string
 	if param.SendMode == 2 {
 		param.SendTime = time.Now().Format(qutil.Date_Full_Layout)
 	}
+	groupId := public.MsgTypeToGroupId[param.MsgType]
 	fields := []string{"user_id", "register_phone", "call_center_company", "call_center_phone", "createtime", "msg_id"}
 	// 更新消息
 	if param.Id != 0 {
@@ -61,6 +62,7 @@ func CustomSendMsgService(param *customMsg, sendStatus int, loginUserName string
 				"template_name":       param.TemplateName,
 				"update_user":         loginUserName,
 				"menu_name":           param.MenuName,
+				"group_id":            groupId,
 			})
 			return ok1 && ok && count > 0
 		})
@@ -113,6 +115,7 @@ func CustomSendMsgService(param *customMsg, sendStatus int, loginUserName string
 				"template_name":       param.TemplateName,
 				"update_user":         loginUserName,
 				"menu_name":           param.MenuName,
+				"group_id":            groupId,
 			})
 			var args []interface{}
 			log.Println("前端传入用户数量:", len(param.UserArr))

+ 1 - 1
src/customerService/newsController.go

@@ -197,7 +197,7 @@ func SendMessageApi(context *admin.Context) (interface{}, error) {
 }
 
 func GetMsgType(context *admin.Context) (interface{}, error) {
-	types := util.MessageDB.SelectBySql("SELECT * FROM `message_column` WHERE msg_type > 0 AND display_platform like '%admin%' ORDER BY sequence ASC")
+	types := util.MessageDB.SelectBySql("SELECT msg_type,msg_name AS name,group_id FROM `message_class` WHERE background_send = 1 ")
 	if types != nil && len(*types) > 0 {
 		return types, nil
 	}

+ 15 - 3
src/customerService/newsService.go

@@ -78,7 +78,7 @@ func MsgDetail(id int) (*map[string]interface{}, error) {
 }
 
 // MsgList 消息列表查询
-func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int, loginUserName string) (*[]map[string]interface{}, int) {
+func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int, loginUserName string) ([]map[string]interface{}, int) {
 	sql := "SELECT DISTINCT(a.id)," + Str + " FROM message_send_log as a LEFT JOIN sendmsg_customer_info as b on a.id = b.msg_id "
 	str := ""
 	sqlc := "SELECT COUNT(DISTINCT a.id) FROM message_send_log as a  LEFT JOIN sendmsg_customer_info as b on a.id = b.msg_id "
@@ -90,7 +90,7 @@ func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int, loginUserName s
 		}
 	}
 	if param.MsgType != 0 {
-		str += " a.msg_type = " + strconv.Itoa(param.MsgType) + " and"
+		str += " a.group_id = " + strconv.Itoa(param.MsgType) + " and"
 	}
 	if param.Title != "" {
 		str += " a.title like " + "'%" + param.Title + "%' and"
@@ -136,9 +136,16 @@ func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int, loginUserName s
 	}
 	sql += page
 	//sql += " ORDER BY id DESC"
+	list := []map[string]interface{}{}
 	data := util.JysqlDB.SelectBySql(sql)
+	if data != nil && len(*data) > 0 {
+		for _, v := range *data {
+			v["msg_type"] = v["group_id"]
+			list = append(list, v)
+		}
+	}
 	count := util.JysqlDB.CountBySql(sqlc)
-	return data, int(count)
+	return list, int(count)
 
 }
 
@@ -164,6 +171,7 @@ func SendMsg(param *public.Message, sendStatus int, loginUserName string, loginU
 	if param.SendMode == 2 {
 		param.SendTime = time.Now().Format(qutil.Date_Full_Layout)
 	}
+	groupId := public.MsgTypeToGroupId[param.MsgType]
 	// 更新消息 新用户注册消息不能更新
 	if param.Id != 0 && param.Sign != 4 {
 		msgLogId = strconv.Itoa(param.Id)
@@ -185,6 +193,7 @@ func SendMsg(param *public.Message, sendStatus int, loginUserName string, loginU
 			"show_content":        param.ShowContent,
 			"Sign":                param.Sign,
 			"menu_name":           param.MenuName,
+			"group_id":            groupId,
 		})
 		if !ok {
 			return 0, errors.New("发送消息出错")
@@ -232,6 +241,7 @@ func SendMsg(param *public.Message, sendStatus int, loginUserName string, loginU
 			"show_buoy":           param.ShowBuoy,
 			"show_content":        param.ShowContent,
 			"menu_name":           param.MenuName,
+			"group_id":            groupId,
 		})
 		//立即发送 新用户发送消息走nsq通知  直接返回
 		if param.Sign == 4 {
@@ -281,6 +291,7 @@ func pushMsg(param *SendMessage, sendStatus int) (int, error) {
 	if param.CallPlatform == "" {
 		param.CallPlatform = "hjzx"
 	}
+	groupId := public.MsgTypeToGroupId[param.MsgType]
 	//保存发送的消息
 	log.Println("发送消息发送时间:", param.SendTime)
 	msgId := util.JysqlDB.Insert("message_send_log", map[string]interface{}{
@@ -299,6 +310,7 @@ func pushMsg(param *SendMessage, sendStatus int) (int, error) {
 		"send_userid":         param.CallPlatform, //呼叫中心
 		"sign":                3,
 		"menu_name":           param.MenuName,
+		"group_id":            groupId,
 	})
 	msgLogId = strconv.FormatInt(msgId, 10)
 	//立即发送

+ 6 - 1
src/public/message.go

@@ -22,6 +22,7 @@ const AllUserCode = "all_user"
 var BlackClassMap map[int]string
 var WxBlackPush map[int]bool
 var BlackNameType map[string]int
+var MsgTypeToGroupId map[int]int
 
 var MsgUserInfoField = `"s_name":1,"s_opushid":1,"s_jpushid":1,"s_appponetype":1,"s_appversion":1,"o_pushset":1`
 
@@ -246,12 +247,15 @@ func GetMegType() {
 	nameTypeMap := map[string]int{}
 	wxBlackPush := map[int]bool{}
 	blackClassMap := map[int]string{}
-	types := util.MessageDB.SelectBySql("SELECT g.switch,c.wxtmpl_Id,c.msg_type,g.switch FROM message_class c INNER JOIN message_group g on c.group_id =g.group_id WHERE c.background_send=1")
+	msgTypeToGroupIdMap := map[int]int{}
+	types := util.MessageDB.SelectBySql("SELECT g.switch,c.wxtmpl_Id,c.msg_type,g.group_id FROM message_class c INNER JOIN message_group g on c.group_id =g.group_id WHERE c.background_send=1")
 	if types != nil && len(*types) > 0 {
 		for _, v := range *types {
 			name := qutil.ObjToString(v["name"])
 			msg_type := qutil.IntAll(v["msg_type"])
 			switchVal := qutil.ObjToString(v["switch"])
+			groupId := qutil.IntAll(v["group_id"])
+			msgTypeToGroupIdMap[msg_type] = groupId
 			nameTypeMap[name] = msg_type
 			blackClassMap[msg_type] = switchVal
 			if wxtmpl_Id := qutil.ObjToString(v["wxtmpl_Id"]); wxtmpl_Id != "" {
@@ -262,4 +266,5 @@ func GetMegType() {
 	BlackClassMap = blackClassMap
 	WxBlackPush = wxBlackPush
 	BlackNameType = nameTypeMap
+	MsgTypeToGroupId = msgTypeToGroupIdMap
 }