|
@@ -407,7 +407,7 @@ func GetHavePower(activityInfo *models.ActivityDetail, permissionStr, companyDet
|
|
|
//研选系列专家电话会,会前1小时将问题列表发送给邮箱
|
|
|
func SendEmailFileForAskMsgResearch(cont context.Context) (err error) {
|
|
|
var msg string
|
|
|
- var touser string
|
|
|
+ //var touser string
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("err:", err)
|
|
@@ -446,78 +446,29 @@ func SendEmailFileForAskMsgResearch(cont context.Context) (err error) {
|
|
|
msg = "获取失败,Err:" + errFile.Error()
|
|
|
return
|
|
|
}
|
|
|
- //创建excel
|
|
|
- dir, errFile := os.Executable()
|
|
|
- exPath := filepath.Dir(dir)
|
|
|
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + utils.GetRandDigit(5) + ".xlsx"
|
|
|
- xlsxFile := xlsx.NewFile()
|
|
|
- if errFile != nil {
|
|
|
- msg = "生成文件失败Err:" + errFile.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- style := xlsx.NewStyle()
|
|
|
- alignment := xlsx.Alignment{
|
|
|
- Horizontal: "center",
|
|
|
- Vertical: "center",
|
|
|
- WrapText: true,
|
|
|
- }
|
|
|
- style.Alignment = alignment
|
|
|
- style.ApplyAlignment = true
|
|
|
- sheet, errFile := xlsxFile.AddSheet("外呼名单")
|
|
|
- if errFile != nil {
|
|
|
- msg = "新增Sheet失败,Err:" + errFile.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- //设置宽度
|
|
|
- _ = sheet.SetColWidth(1, 1, 30)
|
|
|
- _ = sheet.SetColWidth(2, 2, 60)
|
|
|
- //标头
|
|
|
- rowTitle := sheet.AddRow()
|
|
|
- cellA := rowTitle.AddCell()
|
|
|
- cellA.Value = "姓名"
|
|
|
- cellB := rowTitle.AddCell()
|
|
|
- cellB.Value = "公司名称"
|
|
|
- cellC := rowTitle.AddCell()
|
|
|
- cellC.Value = "问题"
|
|
|
- cellD := rowTitle.AddCell()
|
|
|
- cellD.Value = "提交时间"
|
|
|
|
|
|
- for _, item := range list {
|
|
|
- row := sheet.AddRow()
|
|
|
- cellA := row.AddCell()
|
|
|
- cellA.Value = item.RealName
|
|
|
- cellB := row.AddCell()
|
|
|
- cellB.Value = item.CompanyName
|
|
|
- cellC := row.AddCell()
|
|
|
- cellC.Value = item.Content
|
|
|
- cellD := row.AddCell()
|
|
|
- cellD.Value = item.CreateTime
|
|
|
+ for _, v2 := range list {
|
|
|
+ user, err := models.GetUserDetailByUserId(v2.UserId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ openIpItem, _ := models.GetUserRecordByMobile(4, utils.ActSendMsgMobile)
|
|
|
+ if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
+ //获取销售信息
|
|
|
+ sellerItem, err := models.GetSellerByCompanyIdCheckFicc(v2.CompanyId, 2)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if sellerItem != nil {
|
|
|
+ SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RoleName+")", time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem.OpenId, activityInfo.ActivityId)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- errFile = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ errFile = models.UPdateActivityMsgToSendFile(v.ActivityId)
|
|
|
if errFile != nil {
|
|
|
- msg = "保存文件失败Err:" + errFile.Error()
|
|
|
+ msg = "获取失败,Err:" + errFile.Error()
|
|
|
return
|
|
|
}
|
|
|
- title := activityInfo.ActivityName + "-活动带问"
|
|
|
- content := "活动带问详情"
|
|
|
- fileName := downLoadnFilePath
|
|
|
- if utils.RunMode == "release" {
|
|
|
- touser = "cxzhang@hzinsights.com;ywang@hzinsights.com;tshen@hzinsights.com"
|
|
|
- } else {
|
|
|
- touser = "cxzhang@hzinsights.com;jhwang@hzinsights.com;tshen@hzinsights.com"
|
|
|
- }
|
|
|
- sendResult := utils.SendEmailByHongze(title, content, touser, fileName, title+".xlsx")
|
|
|
- if sendResult {
|
|
|
- errFile = models.UPdateActivityMsgToSendFile(v.ActivityId)
|
|
|
- if errFile != nil {
|
|
|
- msg = "获取失败,Err:" + errFile.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- os.Remove(downLoadnFilePath)
|
|
|
- } else {
|
|
|
- go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.RunMode), msg+";Err:"+activityInfo.ActivityName, utils.EmailSendToUsers)
|
|
|
- utils.FileLog.Info("发送附件模版消息失败,Err:%s", activityInfo.ActivityName)
|
|
|
- }
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -525,7 +476,7 @@ func SendEmailFileForAskMsgResearch(cont context.Context) (err error) {
|
|
|
//非研选系列专家电话会,根据主持人姓名,会前15分钟将问题列表发送给至该主持人对应邮箱
|
|
|
func SendEmailFileForAskMsg(cont context.Context) (err error) {
|
|
|
var msg string
|
|
|
- var touser string
|
|
|
+ //var touser string
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
@@ -556,6 +507,100 @@ func SendEmailFileForAskMsg(cont context.Context) (err error) {
|
|
|
msg = "获取失败,Err:" + errEmail.Error()
|
|
|
return
|
|
|
}
|
|
|
+ //for _, v := range listActivity {
|
|
|
+ // activityInfo, _ := models.GetAddActivityInfoById(v.ActivityId)
|
|
|
+ // if activityInfo == nil {
|
|
|
+ // msg = "活动不存在,Err:activityId:" + strconv.Itoa(v.ActivityId)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // list, errFile := models.GetActivityMsgExport(v.ActivityId)
|
|
|
+ // if errFile != nil {
|
|
|
+ // msg = "获取失败,Err:" + errFile.Error()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // for _, v := range listEmail {
|
|
|
+ // if strings.Index(activityInfo.Host, v.Name) > 0 {
|
|
|
+ // touser += v.Email + ";"
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if touser == "" {
|
|
|
+ // msg = "没有对应的邮箱"
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if utils.RunMode == "release" {
|
|
|
+ // touser += "tshen@hzinsights.com;cxzhang@hzinsights.com"
|
|
|
+ // } else {
|
|
|
+ // touser = "tshen@hzinsights.com;cxzhang@hzinsights.com"
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //创建excel
|
|
|
+ // dir, errFile := os.Executable()
|
|
|
+ // exPath := filepath.Dir(dir)
|
|
|
+ // downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + utils.GetRandDigit(5) + ".xlsx"
|
|
|
+ // xlsxFile := xlsx.NewFile()
|
|
|
+ // if errFile != nil {
|
|
|
+ // msg = "生成文件失败Err:" + errFile.Error()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // style := xlsx.NewStyle()
|
|
|
+ // alignment := xlsx.Alignment{
|
|
|
+ // Horizontal: "center",
|
|
|
+ // Vertical: "center",
|
|
|
+ // WrapText: true,
|
|
|
+ // }
|
|
|
+ // style.Alignment = alignment
|
|
|
+ // style.ApplyAlignment = true
|
|
|
+ // sheet, errFile := xlsxFile.AddSheet("外呼名单")
|
|
|
+ // if errFile != nil {
|
|
|
+ // msg = "新增Sheet失败,Err:" + errFile.Error()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // //设置宽度
|
|
|
+ // _ = sheet.SetColWidth(1, 1, 30)
|
|
|
+ // _ = sheet.SetColWidth(2, 2, 60)
|
|
|
+ // //标头
|
|
|
+ // rowTitle := sheet.AddRow()
|
|
|
+ // cellA := rowTitle.AddCell()
|
|
|
+ // cellA.Value = "姓名"
|
|
|
+ // cellB := rowTitle.AddCell()
|
|
|
+ // cellB.Value = "公司名称"
|
|
|
+ // cellC := rowTitle.AddCell()
|
|
|
+ // cellC.Value = "问题"
|
|
|
+ // cellD := rowTitle.AddCell()
|
|
|
+ // cellD.Value = "提交时间"
|
|
|
+ // for _, item := range list {
|
|
|
+ // row := sheet.AddRow()
|
|
|
+ // cellA := row.AddCell()
|
|
|
+ // cellA.Value = item.RealName
|
|
|
+ // cellB := row.AddCell()
|
|
|
+ // cellB.Value = item.CompanyName
|
|
|
+ // cellC := row.AddCell()
|
|
|
+ // cellC.Value = item.Content
|
|
|
+ // cellD := row.AddCell()
|
|
|
+ // cellD.Value = item.CreateTime
|
|
|
+ // }
|
|
|
+ // errFile = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ // if errFile != nil {
|
|
|
+ // msg = "保存文件失败Err:" + errFile.Error()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // title := activityInfo.ActivityName + "-活动带问"
|
|
|
+ // content := "活动带问详情"
|
|
|
+ // fileName := downLoadnFilePath
|
|
|
+ // sendResult := utils.SendEmailByHongze(title, content, touser, fileName, title+".xlsx")
|
|
|
+ // if sendResult {
|
|
|
+ // errFile = models.UPdateActivityMsgToSendFile(v.ActivityId)
|
|
|
+ // if errFile != nil {
|
|
|
+ // msg = "获取失败,Err:" + errFile.Error()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // os.Remove(downLoadnFilePath)
|
|
|
+ // } else {
|
|
|
+ // go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), msg+";Err:"+activityInfo.ActivityName, utils.EmailSendToUsers)
|
|
|
+ // utils.FileLog.Info("发送附件模版消息失败,Err:%s", activityInfo.ActivityName)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
for _, v := range listActivity {
|
|
|
activityInfo, _ := models.GetAddActivityInfoById(v.ActivityId)
|
|
|
if activityInfo == nil {
|
|
@@ -567,87 +612,35 @@ func SendEmailFileForAskMsg(cont context.Context) (err error) {
|
|
|
msg = "获取失败,Err:" + errFile.Error()
|
|
|
return
|
|
|
}
|
|
|
- for _, v := range listEmail {
|
|
|
- if strings.Index(activityInfo.Host, v.Name) > 0 {
|
|
|
- touser += v.Email + ";"
|
|
|
- }
|
|
|
- }
|
|
|
- if touser == "" {
|
|
|
- msg = "没有对应的邮箱"
|
|
|
- return
|
|
|
- }
|
|
|
- if utils.RunMode == "release" {
|
|
|
- touser += "tshen@hzinsights.com;cxzhang@hzinsights.com"
|
|
|
- } else {
|
|
|
- touser = "tshen@hzinsights.com;cxzhang@hzinsights.com"
|
|
|
- }
|
|
|
|
|
|
- //创建excel
|
|
|
- dir, errFile := os.Executable()
|
|
|
- exPath := filepath.Dir(dir)
|
|
|
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + utils.GetRandDigit(5) + ".xlsx"
|
|
|
- xlsxFile := xlsx.NewFile()
|
|
|
- if errFile != nil {
|
|
|
- msg = "生成文件失败Err:" + errFile.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- style := xlsx.NewStyle()
|
|
|
- alignment := xlsx.Alignment{
|
|
|
- Horizontal: "center",
|
|
|
- Vertical: "center",
|
|
|
- WrapText: true,
|
|
|
- }
|
|
|
- style.Alignment = alignment
|
|
|
- style.ApplyAlignment = true
|
|
|
- sheet, errFile := xlsxFile.AddSheet("外呼名单")
|
|
|
- if errFile != nil {
|
|
|
- msg = "新增Sheet失败,Err:" + errFile.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- //设置宽度
|
|
|
- _ = sheet.SetColWidth(1, 1, 30)
|
|
|
- _ = sheet.SetColWidth(2, 2, 60)
|
|
|
- //标头
|
|
|
- rowTitle := sheet.AddRow()
|
|
|
- cellA := rowTitle.AddCell()
|
|
|
- cellA.Value = "姓名"
|
|
|
- cellB := rowTitle.AddCell()
|
|
|
- cellB.Value = "公司名称"
|
|
|
- cellC := rowTitle.AddCell()
|
|
|
- cellC.Value = "问题"
|
|
|
- cellD := rowTitle.AddCell()
|
|
|
- cellD.Value = "提交时间"
|
|
|
- for _, item := range list {
|
|
|
- row := sheet.AddRow()
|
|
|
- cellA := row.AddCell()
|
|
|
- cellA.Value = item.RealName
|
|
|
- cellB := row.AddCell()
|
|
|
- cellB.Value = item.CompanyName
|
|
|
- cellC := row.AddCell()
|
|
|
- cellC.Value = item.Content
|
|
|
- cellD := row.AddCell()
|
|
|
- cellD.Value = item.CreateTime
|
|
|
+ for _, v2 := range list {
|
|
|
+ user, err := models.GetUserDetailByUserId(v2.UserId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var sendMobile string
|
|
|
+ for _, vEmail := range listEmail {
|
|
|
+ if strings.Index(activityInfo.Host, vEmail.Name) > 0 {
|
|
|
+ sendMobile = vEmail.Mobile
|
|
|
+ }
|
|
|
+ }
|
|
|
+ openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
|
|
|
+ if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
+ //获取销售信息
|
|
|
+ sellerItem, err := models.GetSellerByCompanyIdCheckFicc(v2.CompanyId, 2)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if sellerItem != nil {
|
|
|
+ SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RoleName+")", time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem.OpenId, activityInfo.ActivityId)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- errFile = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ errFile = models.UPdateActivityMsgToSendFile(v.ActivityId)
|
|
|
if errFile != nil {
|
|
|
- msg = "保存文件失败Err:" + errFile.Error()
|
|
|
+ msg = "获取失败,Err:" + errFile.Error()
|
|
|
return
|
|
|
}
|
|
|
- title := activityInfo.ActivityName + "-活动带问"
|
|
|
- content := "活动带问详情"
|
|
|
- fileName := downLoadnFilePath
|
|
|
- sendResult := utils.SendEmailByHongze(title, content, touser, fileName, title+".xlsx")
|
|
|
- if sendResult {
|
|
|
- errFile = models.UPdateActivityMsgToSendFile(v.ActivityId)
|
|
|
- if errFile != nil {
|
|
|
- msg = "获取失败,Err:" + errFile.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- os.Remove(downLoadnFilePath)
|
|
|
- } else {
|
|
|
- go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), msg+";Err:"+activityInfo.ActivityName, utils.EmailSendToUsers)
|
|
|
- utils.FileLog.Info("发送附件模版消息失败,Err:%s", activityInfo.ActivityName)
|
|
|
- }
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -881,3 +874,69 @@ func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+//活动带问提醒
|
|
|
+func SendActivityAskApplyTemplateMsg(applyName, applyTime, askContent, activityName, openId string, activityId int) (err error) {
|
|
|
+ var msg string
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ }
|
|
|
+ if msg != "" {
|
|
|
+ utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ var accessToken string
|
|
|
+ if utils.RunMode == "release" {
|
|
|
+ accessToken, err = models.GetWxAccessTokenByXzs()
|
|
|
+ if err != nil {
|
|
|
+ msg = "GetWxAccessToken Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if accessToken == "" {
|
|
|
+ msg = "accessToken is empty"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ accessToken, err = models.GetWxAccessToken()
|
|
|
+ if err != nil {
|
|
|
+ msg = "GetWxAccessToken Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if accessToken == "" {
|
|
|
+ msg = "accessToken is empty"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
|
|
|
+
|
|
|
+ sendMap := make(map[string]interface{})
|
|
|
+ sendData := make(map[string]interface{})
|
|
|
+
|
|
|
+ first := "有新的客户提问"
|
|
|
+ keyword1 := applyName
|
|
|
+ keyword2 := "-"
|
|
|
+ keyword3 := applyTime
|
|
|
+ keyword4 := askContent
|
|
|
+ remark := activityName
|
|
|
+ fontColor := "#D9001B"
|
|
|
+ sendData["first"] = map[string]interface{}{"value": first, "color": fontColor}
|
|
|
+ sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": fontColor}
|
|
|
+ sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": fontColor}
|
|
|
+ sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": fontColor}
|
|
|
+ sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": fontColor}
|
|
|
+ sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": fontColor}
|
|
|
+ sendData["remark"] = map[string]interface{}{"value": remark, "color": fontColor}
|
|
|
+ if utils.RunMode == "release" {
|
|
|
+ sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
|
|
|
+ } else {
|
|
|
+ sendMap["template_id"] = utils.WxMsgTemplateIdApply
|
|
|
+ }
|
|
|
+ sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "activityPages/activityDetail/activityDetail?id=" + strconv.Itoa(activityId)}
|
|
|
+ sendMap["data"] = sendData
|
|
|
+ sendTemplateMsg(sendUrl, openId, sendMap)
|
|
|
+ fmt.Println("send end")
|
|
|
+ return
|
|
|
+}
|