|
@@ -172,23 +172,26 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("err:", err)
|
|
|
- go utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组失败"+msg, 2)
|
|
|
+ go utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组失败"+err.Error()+msg, 2)
|
|
|
}
|
|
|
}()
|
|
|
endDate := time.Now().Add(+time.Minute * 60).Format(utils.FormatDateTime)
|
|
|
- total, err := models.GetCountActivityIdToSendFile(endDate)
|
|
|
-
|
|
|
+ total, e := models.GetCountActivityIdToSendFile(endDate)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCountActivityIdToSendFile" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
if total == 0 {
|
|
|
fmt.Println("发送附件完成0")
|
|
|
return nil
|
|
|
}
|
|
|
- if err != nil {
|
|
|
- msg = "发送附件模版消息失败 Err:" + err.Error()
|
|
|
+
|
|
|
+ listActivity, e := models.GetActivityIdToSendFile(endDate)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetActivityIdToSendFile" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- listActivity, err := models.GetActivityIdToSendFile(endDate)
|
|
|
- if err != nil {
|
|
|
- msg = "发送附件模版消息失败 Err:" + err.Error()
|
|
|
+ if len(listActivity) == 0 {
|
|
|
return
|
|
|
}
|
|
|
var activityIds []int
|
|
@@ -196,22 +199,23 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
|
|
|
activityIds = append(activityIds, v.ActivityId)
|
|
|
}
|
|
|
|
|
|
- //{
|
|
|
- // utils.SendAlarmMsg("预约外呼名单,会前1小时自动发送邮件给专家组 监控日志,监控使用无需处理,活动ID:"+fmt.Sprint(activityIds), 2)
|
|
|
- //}
|
|
|
-
|
|
|
for _, v := range listActivity {
|
|
|
//time.Sleep(30 * time.Second) //延时30秒,避免邮件发送不成功
|
|
|
- activityInfo, _ := models.GetAddActivityInfoById(v.ActivityId)
|
|
|
- if activityInfo == nil {
|
|
|
- msg = "活动不存在,Err:activityId:" + strconv.Itoa(v.ActivityId)
|
|
|
+ activityInfo, e := models.GetAddActivityInfoById(v.ActivityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetAddActivityInfoById" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- list, errFile := models.GetSignupExport(v.ActivityId)
|
|
|
- if errFile != nil {
|
|
|
- msg = "获取失败,Err:" + errFile.Error()
|
|
|
+ list, e := models.GetSignupExport(v.ActivityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetSignupExport" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ var companyIds []int
|
|
|
+ for _, vSin := range list {
|
|
|
+ companyIds = append(companyIds, vSin.CompanyId)
|
|
|
+ }
|
|
|
+ sellNameMap := GetSellNameMapByCompanyIds(companyIds)
|
|
|
//创建excel
|
|
|
dir, errFile := os.Executable()
|
|
|
exPath := filepath.Dir(dir)
|
|
@@ -265,8 +269,9 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
|
|
|
cellD := row.AddCell()
|
|
|
cellD.Value = item.CompanyName
|
|
|
cellE := row.AddCell()
|
|
|
- cellE.Value = item.SellerName
|
|
|
+ cellE.Value = sellNameMap[item.CompanyId]
|
|
|
}
|
|
|
+
|
|
|
errFile = xlsxFile.Save(downLoadnFilePath)
|
|
|
if errFile != nil {
|
|
|
msg = "保存文件失败Err:" + errFile.Error()
|
|
@@ -297,9 +302,9 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
|
|
|
}
|
|
|
}
|
|
|
os.Remove(downLoadnFilePath)
|
|
|
- err = models.UPdateActivityIdToSendFile(v.ActivityId)
|
|
|
- if err != nil {
|
|
|
- go utils.SendAlarmMsg("UPdateActivityIdToSendFile err"+msg, 2)
|
|
|
+ e = models.UPdateActivityIdToSendFile(v.ActivityId)
|
|
|
+ if e != nil {
|
|
|
+ go utils.SendAlarmMsg("UPdateActivityIdToSendFile err"+e.Error(), 2)
|
|
|
}
|
|
|
|
|
|
//sendResult := utils.SendEmailByHongze(title, content, touser, fileName, title+".xlsx")
|