|
@@ -1,13 +1,13 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"fmt"
|
|
|
"github.com/tealeg/xlsx"
|
|
|
"hongze/hongze_task/models"
|
|
|
"hongze/hongze_task/utils"
|
|
|
"os"
|
|
|
"time"
|
|
|
- "context"
|
|
|
)
|
|
|
|
|
|
//潜在客户回访记录
|
|
@@ -19,16 +19,15 @@ func FreeViewerDetail(cont context.Context) (err error) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
-
|
|
|
//endTime := time.Now().Format(utils.FormatDateTime)
|
|
|
startTime := time.Now().AddDate(0, 0, -7).Format(utils.FormatDateTime)
|
|
|
- endTime :=time.Now().Format(utils.FormatDateTime)
|
|
|
+ endTime := time.Now().Format(utils.FormatDateTime)
|
|
|
|
|
|
- items,err:=models.GetFreeViewerDetails(startTime,endTime)
|
|
|
- if err!=nil {
|
|
|
+ items, err := models.GetFreeViewerDetails(startTime, endTime)
|
|
|
+ if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- title:="潜在客户回访记录"
|
|
|
+ title := "潜在客户回访记录"
|
|
|
//创建excel
|
|
|
file := xlsx.NewFile()
|
|
|
sheet, err := file.AddSheet(title)
|
|
@@ -55,21 +54,23 @@ func FreeViewerDetail(cont context.Context) (err error) {
|
|
|
cellB := row.AddCell()
|
|
|
cellB.Value = item.Mobile
|
|
|
cellC := row.AddCell()
|
|
|
- cellC.Value=item.Note
|
|
|
+ cellC.Value = item.Note
|
|
|
cellD := row.AddCell()
|
|
|
cellD.Value = item.CreatedTime
|
|
|
cellE := row.AddCell()
|
|
|
cellE.Value = item.Email
|
|
|
+
|
|
|
+ models.DealWxUser(item.UserId)
|
|
|
}
|
|
|
|
|
|
- savePath := "free_viewer_details"+ time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
+ savePath := "free_viewer_details" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
err = file.Save("./" + savePath)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
//发送邮件
|
|
|
fmt.Println("start send email")
|
|
|
- sendResult := utils.SendEmailByHongze(title, "潜在客户回访记录',\"你好,上周潜在客户回访记录见附件。", utils.EmailSendToHzUsers, savePath,title+".xlsx")
|
|
|
+ sendResult := utils.SendEmailByHongze(title, "潜在客户回访记录',\"你好,上周潜在客户回访记录见附件。", utils.EmailSendToHzUsers, savePath, title+".xlsx")
|
|
|
//sendResult:=utils.SendEmailByHongze(title,"你好,上周研报阅读统计见附件。",utils.EmailSendToMe,savePath)
|
|
|
if sendResult {
|
|
|
os.Remove(savePath)
|
|
@@ -77,4 +78,4 @@ func FreeViewerDetail(cont context.Context) (err error) {
|
|
|
//fmt.Println("send result:", sendResult)
|
|
|
fmt.Println("end send email")
|
|
|
return nil
|
|
|
-}
|
|
|
+}
|