package sendmessage import ( "fmt" "strconv" "github.com/flipped-aurora/gin-vue-admin/server/commonus" ) /* 发送文本 @sendUserList 接收信息人员 @Title 一级标题,建议不超过36个字 @Desc 标题辅助信息,建议不超过44个字 @Unit 考核计量单位 @Reason 考核原因 @handleUrl 访问Key @Type 1:加分;2:减分 @departmentId 执行考核部门 @userKey 执行考核人 @Score 考核分值 @keyNumber 任务卡ID */ func SendMsgPublic(sendUserList, Title, Desc, Unit, Reason, handleUrl string, Type int, departmentId, userKey, Score, keyNumber int64, msgTxt string) (callbakcMsg []byte, isTrueCall bool, callBackCont string) { var sendTextMsg TextNoticeTemplateMedium sendTextMsg.Inset(sendUserList, "template_card", "text_notice", keyNumber) //获取考核详情 sendTextMsg.TemplateCard.MainTitle.Title = Title sendTextMsg.TemplateCard.MainTitle.Desc = Desc var scoreReason string if Type == 1 { scoreReason = "增加:" + strconv.FormatInt(Score, 10) + Unit } else { scoreReason = "扣除:" + strconv.FormatInt(Score, 10) + Unit } //引用文献样式 sendTextMsg.TemplateCard.QuoteArea.Type = 0 sendTextMsg.TemplateCard.QuoteArea.Title = scoreReason sendTextMsg.TemplateCard.QuoteArea.QuoteText = "原因:\n" + Reason var htalConListStrMap []HorizontalContentListType var htalConListStrCon HorizontalContentListType //二级普通文本, sendTextMsg.TemplateCard.SubTitleText = "考核上报部门:" execDerpatCont := "" // execDerpatCont := "考核部门:" execDerpatErr, execDerpat := commonus.GetBranchFactory(departmentId) if execDerpatErr == true { execDerpatCont = execDerpatCont + execDerpat.Name } htalConListStrCon.KeyName = execDerpatCont //获取操作人 userFileStr := "wm_number,qywx_key,wx_key" //操作人条件 userWherAry := commonus.MapOut() // userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3" userWherAry["wm_key"] = userKey userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry) if userIsTrue == true { if userConting.WechatId != "" { userWechatErr, userWechat := commonus.GetUesrContForWechatID(userConting.WechatId) if userWechatErr == true { htalConListStrCon.Type = 3 htalConListStrCon.Value = userWechat.Name htalConListStrCon.UserId = userConting.WechatId // htalConListStrMap = append(htalConListStrMap, htalConListStrCon) // sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap } } if userConting.WorkWechatId != "" { userWechatErr, userWechat := commonus.GetUesrContForWechatID(userConting.WorkWechatId) if userWechatErr == true { htalConListStrCon.Type = 3 htalConListStrCon.Value = userWechat.Name htalConListStrCon.UserId = userConting.WorkWechatId // htalConListStrMap = append(htalConListStrMap, htalConListStrCon) // sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap } } } htalConListStrMap = append(htalConListStrMap, htalConListStrCon) sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap sendTextMsg.TemplateCard.CardAction.Type = 1 sendTextMsg.TemplateCard.CardAction.Url = handleUrl if msgTxt == "" { msgTxt = "请前往处理" } //地板处理 var jumpListStruct JumpListType jumpListStruct.Type = 1 jumpListStruct.Title = msgTxt jumpListStruct.Url = handleUrl sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct) callbakcMsg, isTrueCall, callBackCont = sendTextMsg.SendMessage("school") return } /* 发送按钮交互 @sendUserList 接收信息人员 @Title 一级标题,建议不超过36个字 @Desc 标题辅助信息,建议不超过44个字 @subtitle 二级文献标题 @reason 二级文献内容 @Type 1:加分;2:减分 @departmentId 执行考核部门 @userKey 执行考核人 @keyNumber 任务卡ID */ func SendButtonPublic(sendUserList, Title, Desc, subtitle, reason string, departmentId, userKey, keyNumber, orderId int64, buttonMap []ButtonListtype) (callbakcMsg []byte, isTrueCall bool, callBackCont string, send ButtonNoticeTemplateMedium) { var sendTextMsg ButtonNoticeTemplateMedium sendTextMsg.Inset(sendUserList, "template_card", "button_interaction", keyNumber) //获取考核详情 sendTextMsg.TemplateCard.MainTitle.Title = Title sendTextMsg.TemplateCard.MainTitle.Desc = Desc //引用文献样式 sendTextMsg.TemplateCard.QuoteArea.Type = 0 sendTextMsg.TemplateCard.QuoteArea.Title = subtitle sendTextMsg.TemplateCard.QuoteArea.QuoteText = reason var htalConListStrMap []HorizontalContentListType var htalConListStrCon HorizontalContentListType //二级普通文本, sendTextMsg.TemplateCard.SubTitleText = "责任部门:" execDerpatCont := "" // execDerpatCont := "考核部门:" execDerpatErr, execDerpat := commonus.GetBranchFactory(departmentId) if execDerpatErr == true { execDerpatCont = execDerpatCont + execDerpat.Name } htalConListStrCon.KeyName = execDerpatCont //获取操作人 userFileStr := "wm_number,qywx_key,wx_key" //操作人条件 userWherAry := commonus.MapOut() // userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3" userWherAry["wm_key"] = userKey userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry) if userIsTrue == true { if userConting.WechatId != "" { userWechatErr, userWechat := commonus.GetUesrContForWechatID(userConting.WechatId) if userWechatErr == true { htalConListStrCon.Type = 3 htalConListStrCon.Value = userWechat.Name htalConListStrCon.UserId = userConting.WechatId // htalConListStrMap = append(htalConListStrMap, htalConListStrCon) // sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap } } if userConting.WorkWechatId != "" { userWechatErr, userWechat := commonus.GetUesrContForWechatID(userConting.WorkWechatId) if userWechatErr == true { htalConListStrCon.Type = 3 htalConListStrCon.Value = userWechat.Name htalConListStrCon.UserId = userConting.WorkWechatId // htalConListStrMap = append(htalConListStrMap, htalConListStrCon) // sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap } } } htalConListStrMap = append(htalConListStrMap, htalConListStrCon) sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap sendTextMsg.TemplateCard.CardAction.Type = 1 sendTextMsg.TemplateCard.CardAction.Url = fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId) //按钮列表,列表长度不超过6(必填) sendTextMsg.TemplateCard.ButtonList = buttonMap send = sendTextMsg callbakcMsg, isTrueCall, callBackCont = sendTextMsg.SendMessage("school") return } /* 发送文本任务卡 @sendUserList 接收信息人员 @Title 一级标题,建议不超过36个字 @Desc 标题辅助信息,建议不超过44个字 @Unit 考核计量单位 @Reason 二级文本标题 @handleUrl 访问Key @Type 1:加分;2:减分 @departmentId 执行考核部门 @userKey 执行考核人 @Score 考核分值 @keyNumber 任务卡ID @scoreReason 二级文本描述 @subTitleText 下级 组件标题"考核上报部门:" */ func SendMsgTxtPublic(sendUserList, Title, Desc, Unit, Reason, handleUrl, scoreReason, subTitleText string, Type int, departmentId, userKey, Score, keyNumber int64, msgTxt string) (callbakcMsg []byte, isTrueCall bool, callBackCont string, sendTextMsg TextNoticeTemplateMedium) { // var sendTextMsg TextNoticeTemplateMedium sendTextMsg.Inset(sendUserList, "template_card", "text_notice", keyNumber) //获取考核详情 sendTextMsg.TemplateCard.MainTitle.Title = Title sendTextMsg.TemplateCard.MainTitle.Desc = Desc //引用文献样式 sendTextMsg.TemplateCard.QuoteArea.Type = 0 sendTextMsg.TemplateCard.QuoteArea.Title = scoreReason sendTextMsg.TemplateCard.QuoteArea.QuoteText = Reason var htalConListStrMap []HorizontalContentListType var htalConListStrCon HorizontalContentListType //二级普通文本, sendTextMsg.TemplateCard.SubTitleText = subTitleText execDerpatCont := "" // execDerpatCont := "考核部门:" execDerpatErr, execDerpat := commonus.GetBranchFactory(departmentId) if execDerpatErr == true { execDerpatCont = execDerpatCont + execDerpat.Name } htalConListStrCon.KeyName = execDerpatCont //获取操作人 userFileStr := "wm_number,qywx_key,wx_key" //操作人条件 userWherAry := commonus.MapOut() // userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3" userWherAry["wm_key"] = userKey userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry) if userIsTrue == true { if userConting.WechatId != "" { userWechatErr, userWechat := commonus.GetUesrContForWechatID(userConting.WechatId) if userWechatErr == true { htalConListStrCon.Type = 3 htalConListStrCon.Value = userWechat.Name htalConListStrCon.UserId = userConting.WechatId // htalConListStrMap = append(htalConListStrMap, htalConListStrCon) // sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap } } if userConting.WorkWechatId != "" { userWechatErr, userWechat := commonus.GetUesrContForWechatID(userConting.WorkWechatId) if userWechatErr == true { htalConListStrCon.Type = 3 htalConListStrCon.Value = userWechat.Name htalConListStrCon.UserId = userConting.WorkWechatId // htalConListStrMap = append(htalConListStrMap, htalConListStrCon) // sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap } } } htalConListStrMap = append(htalConListStrMap, htalConListStrCon) sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap sendTextMsg.TemplateCard.CardAction.Type = 1 sendTextMsg.TemplateCard.CardAction.Url = handleUrl if msgTxt == "" { msgTxt = "请前往处理" } //地板处理 var jumpListStruct JumpListType jumpListStruct.Type = 1 jumpListStruct.Title = msgTxt jumpListStruct.Url = handleUrl sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct) callbakcMsg, isTrueCall, callBackCont = sendTextMsg.SendMessage("school") return } //发送文本信息News /* @sendUserList 信息接收人 @taskId 任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填 @Title 一级标题,建议不超过36个字, @Desc 标题辅助信息,建议不超过44个字 @quoteAreaTitle 引用文献标题 @quoteAreaContent 引用文献内容 @twoLevelTitle 二级文本标题 @twoLevelKeyName 二级标题,建议不超过5个字 @twoLevelValue 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字, @twoLevelUserId 成员详情的userid,horizontal_content_list.type是3时必填 @jumpUrl 整体卡片跳转链接 @jumpUrlTitle 跳转链接文案 @sourceDesc 左上角标题 */ func (t *TextNoticeTemplateMedium) SendNewsMsgText(sendUserList, taskId, title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, jumpUrl, jumpUrlTitle, sourceDesc string) (callbakcMsg []byte, isTrueCall bool, callBackCont string) { if sourceDesc != "" { sourceDesc = fmt.Sprintf("知行学院 - %v", sourceDesc) } else { sourceDesc = "知行学院" } t.InsetContNew(sendUserList, "template_card", "text_notice", taskId, sourceDesc) //获取考核详情 t.TemplateCard.MainTitle.Title = title t.TemplateCard.MainTitle.Desc = desc //引用文献样式 t.TemplateCard.QuoteArea.Type = 0 t.TemplateCard.QuoteArea.Title = quoteAreaTitle t.TemplateCard.QuoteArea.QuoteText = quoteAreaContent var htalConListStrMap []HorizontalContentListType var htalConListStrCon HorizontalContentListType //二级普通文本, t.TemplateCard.SubTitleText = twoLevelTitle // 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 htalConListStrCon.Type = 3 //链接类型,0或不填代表不是链接,1 代表跳转url,2 代表下载附件,3 代表点击跳转成员详情 htalConListStrCon.KeyName = twoLevelKeyName //二级标题,建议不超过5个字 htalConListStrCon.Value = twoLevelKeyValue //二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,( htalConListStrCon.UserId = twoLevelUserId //成员详情的userid,horizontal_content_list.type是3时必填 htalConListStrMap = append(htalConListStrMap, htalConListStrCon) t.TemplateCard.HorizontalContentList = htalConListStrMap //整体卡片的点击跳转事件 t.TemplateCard.CardAction.Type = 1 t.TemplateCard.CardAction.Url = jumpUrl //地板处理 var jumpListStruct JumpListType jumpListStruct.Type = 1 jumpListStruct.Title = jumpUrlTitle //跳转链接样式的文案内容,建议不超过18个字 jumpListStruct.Url = jumpUrl t.TemplateCard.JumpList = append(t.TemplateCard.JumpList, jumpListStruct) callbakcMsg, isTrueCall, callBackCont = t.SendMessage("school") return }