|
@@ -1,10 +1,14 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
+ "os"
|
|
|
+ "path/filepath"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
|
@@ -401,3 +405,510 @@ func AddUserRecord(openId, unionId, nickName, realName, province, city, country,
|
|
|
userRecord.UserRecordId = int(recordId)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+//预约外呼名单,会前1小时自动发送邮件给专家组
|
|
|
+func SendEmailUserWhiteList(cont context.Context) (err error) {
|
|
|
+ var msg string
|
|
|
+ var fieldStr string
|
|
|
+ var condition string
|
|
|
+ //var touser string
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err:", err)
|
|
|
+ go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ utils.FileLog.Info("发送附件模版消息失败,Err:%s", err.Error())
|
|
|
+ }
|
|
|
+ if msg != "" {
|
|
|
+ fmt.Println(msg)
|
|
|
+ utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ fmt.Println("发送附件")
|
|
|
+ fieldStr = ` u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,cp.seller_name,`
|
|
|
+ //condition = ` AND u.mobile = u.outbound_mobile AND cp.status IN ( '正式', '试用' ) AND u.mobile != '' AND u.created_time > '2021-08-17 00:00:01' AND u.created_time < '2021-08-17 23:59:59' `
|
|
|
+ condition = ` AND u.mobile = u.outbound_mobile AND cp.status IN ( '冻结' ) AND u.mobile != '' AND u.company_id IN (6965,6965,5461,6167,6167,5461) `
|
|
|
+ list1, err := models.GetFormalUserWhiteList(fieldStr, condition)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fieldStr = ` u.outbound_mobile as mobile,u.outbound_country_code as country_code,u.real_name,c.company_name,u.company_id,`
|
|
|
+ //condition = ` AND u.mobile != u.outbound_mobile AND cp.status IN ( '正式', '试用' ) AND u.outbound_mobile != '' AND u.created_time > '2021-08-17 00:00:01' AND u.created_time < '2021-08-17 23:59:59' `
|
|
|
+ condition = ` AND u.mobile != u.outbound_mobile AND cp.status IN ( '冻结' ) AND u.outbound_mobile != '' AND u.company_id IN (6965,6965,5461,6167,6167,5461) `
|
|
|
+ list2, err := models.GetFormalUserWhiteList(fieldStr, condition)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //fieldStr = `u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,`
|
|
|
+ //condition = ` AND u.mobile = u.outbound_mobile AND cp.status IN ( '永续' ) AND u.mobile != '' `
|
|
|
+ //list3, err := models.GetSustainableUserWhiteList(fieldStr, condition)
|
|
|
+ //if err != nil {
|
|
|
+ // msg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //fieldStr = ` u.outbound_mobile as mobile,u.outbound_country_code as country_code,u.real_name,c.company_name,u.company_id,`
|
|
|
+ //condition = ` AND u.mobile != u.outbound_mobile AND cp.status IN ( '永续') AND u.outbound_mobile != '' `
|
|
|
+ //list4, err := models.GetSustainableUserWhiteList(fieldStr, condition)
|
|
|
+ //if err != nil {
|
|
|
+ // msg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ var rep models.UserWhiteListRep
|
|
|
+ for _, v := range list1 {
|
|
|
+ rep.List = append(rep.List, v)
|
|
|
+ }
|
|
|
+ for _, v := range list2 {
|
|
|
+ rep.List = append(rep.List, v)
|
|
|
+ }
|
|
|
+ //for _, v := range list3 {
|
|
|
+ // rep.List = append(rep.List, v)
|
|
|
+ //}
|
|
|
+ //for _, v := range list4 {
|
|
|
+ // rep.List = append(rep.List, v)
|
|
|
+ //}
|
|
|
+
|
|
|
+ //创建excel
|
|
|
+ dir, errFile := os.Executable()
|
|
|
+ exPath := filepath.Dir(dir)
|
|
|
+ downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".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, err := xlsxFile.AddSheet("白名单")
|
|
|
+ if err != nil {
|
|
|
+ msg = "新增Sheet失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //标头
|
|
|
+ rowTitle := sheet.AddRow()
|
|
|
+ cellA := rowTitle.AddCell()
|
|
|
+ cellA.Value = "姓名"
|
|
|
+ cellB := rowTitle.AddCell()
|
|
|
+ cellB.Value = "手机号"
|
|
|
+ cellC := rowTitle.AddCell()
|
|
|
+ cellC.Value = "国际代码"
|
|
|
+ cellD := rowTitle.AddCell()
|
|
|
+ cellD.Value = "公司"
|
|
|
+ cellE := rowTitle.AddCell()
|
|
|
+ cellE.Value = "职位"
|
|
|
+ cellF := rowTitle.AddCell()
|
|
|
+ cellF.Value = "邮箱"
|
|
|
+ cellG := rowTitle.AddCell()
|
|
|
+ cellG.Value = "客户类型"
|
|
|
+ cellH := rowTitle.AddCell()
|
|
|
+ cellH.Value = "对口销售"
|
|
|
+ cellI := rowTitle.AddCell()
|
|
|
+ cellI.Value = "有效开始时间"
|
|
|
+ cellJ := rowTitle.AddCell()
|
|
|
+ cellJ.Value = "有效结束时间"
|
|
|
+ cellK := rowTitle.AddCell()
|
|
|
+ cellK.Value = "归属部门"
|
|
|
+ cellL := rowTitle.AddCell()
|
|
|
+ cellL.Value = "备注"
|
|
|
+ cellM := rowTitle.AddCell()
|
|
|
+ cellM.Value = "权限(消费,医药,智造,科技,策略)"
|
|
|
+ for _, item := range rep.List {
|
|
|
+ row := sheet.AddRow()
|
|
|
+ cellA := row.AddCell()
|
|
|
+ cellA.Value = item.RealName
|
|
|
+ cellB := row.AddCell()
|
|
|
+ cellB.Value = item.Mobile
|
|
|
+ cellC := row.AddCell()
|
|
|
+ cellC.Value = item.CountryCode
|
|
|
+ if len(item.Mobile) >= 11 && item.CountryCode == "" {
|
|
|
+ cellC.Value = "86"
|
|
|
+ }
|
|
|
+ cellD := row.AddCell()
|
|
|
+ cellD.Value = item.CompanyName
|
|
|
+ cellE := row.AddCell()
|
|
|
+ cellE.Value = ""
|
|
|
+ cellF := row.AddCell()
|
|
|
+ cellF.Value = ""
|
|
|
+ cellG := row.AddCell()
|
|
|
+ cellG.Value = ""
|
|
|
+ cellH := row.AddCell()
|
|
|
+ cellH.Value = item.SellerName
|
|
|
+ cellI := row.AddCell()
|
|
|
+ cellI.Value = ""
|
|
|
+ cellJ := row.AddCell()
|
|
|
+ cellJ.Value = ""
|
|
|
+ cellK := row.AddCell()
|
|
|
+ cellK.Value = ""
|
|
|
+ cellL := row.AddCell()
|
|
|
+ cellL.Value = ""
|
|
|
+ cellM := row.AddCell()
|
|
|
+ if item.Permission == "" {
|
|
|
+ item.Permission = "专家/医药/智造/消费/研选/科技/策略/路演服务"
|
|
|
+ }
|
|
|
+ cellM.Value = item.Permission
|
|
|
+ }
|
|
|
+ errFile = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ if errFile != nil {
|
|
|
+ msg = "保存文件失败Err:" + errFile.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ title := "用户白名单"
|
|
|
+ content := "用户白名单"
|
|
|
+ fileName := downLoadnFilePath
|
|
|
+ //if activityInfo.ChartPermissionName == "科技" {
|
|
|
+ // touser = utils.EmailTechnology
|
|
|
+ //} else if activityInfo.ChartPermissionName == "医药" {
|
|
|
+ // touser = utils.EmailMedicine
|
|
|
+ //} else if activityInfo.ChartPermissionName == "消费" {
|
|
|
+ // touser = utils.EmailConsumption
|
|
|
+ //} else if activityInfo.ChartPermissionName == "智造" {
|
|
|
+ // touser = utils.EmailZhizao
|
|
|
+ //} else if activityInfo.ChartPermissionName == "策略" {
|
|
|
+ // touser = utils.EmailStrategy
|
|
|
+ //}
|
|
|
+ //go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com;tshen@hzinsights.com")
|
|
|
+ go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com")
|
|
|
+ //go utils.SendEmailHaveFile(title, content, fileName, "tshen@hzinsights.com")
|
|
|
+ time.Sleep(time.Duration(10) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
|
|
|
+ //errFile = models.UPdateActivityIdToSendFile(v.ActivityId)
|
|
|
+ //if errFile != nil {
|
|
|
+ // msg = "获取失败,Err:" + errFile.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ defer func() {
|
|
|
+ os.Remove(downLoadnFilePath)
|
|
|
+ }()
|
|
|
+ fmt.Println("发送附件完成", len(rep.List))
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+//预约外呼名单,会前1小时自动发送邮件给专家组
|
|
|
+func SendEmailUserWhiteListChange(cont context.Context) (err error) {
|
|
|
+ var msg string
|
|
|
+ var fieldStr string
|
|
|
+ var condition string
|
|
|
+ //var mobileStr string
|
|
|
+ //var touser string
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err:", err, time.Now())
|
|
|
+ go utils.SendEmail("发送附件模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
+ utils.FileLog.Info("发送附件模版消息失败,Err:%s", err.Error())
|
|
|
+ }
|
|
|
+ if msg != "" {
|
|
|
+ fmt.Println(msg)
|
|
|
+ utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ mobileStr, err := models.GetWxUserWhiteMobile()
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if mobileStr == "" {
|
|
|
+ mobileStr = "1"
|
|
|
+ }
|
|
|
+ fmt.Println("发送附件")
|
|
|
+ //手机号新增
|
|
|
+ fieldStr = ` u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,cp.seller_name,cp.status,`
|
|
|
+ condition = ` AND cp.status IN ( '正式', '试用' ) AND u.mobile IN (` + mobileStr + `) `
|
|
|
+ list1, err := models.GetFormalUserWhiteList(fieldStr, condition)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //外呼手机号新增
|
|
|
+ outboundMobileStr, err := models.GetWxUserWhiteOutboundMobile()
|
|
|
+ if outboundMobileStr == "" {
|
|
|
+ outboundMobileStr = "1"
|
|
|
+ }
|
|
|
+ fieldStr = ` u.outbound_mobile as mobile,u.outbound_country_code as country_code,u.real_name,c.company_name,u.company_id,cp.status,`
|
|
|
+ condition = ` AND cp.status IN ( '正式', '试用' ) AND u.outbound_mobile IN (` + outboundMobileStr + `) `
|
|
|
+ list2, err := models.GetFormalUserWhiteList(fieldStr, condition)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println("发送附件完成", len(list1))
|
|
|
+ var rep models.UserWhiteListRep
|
|
|
+ for _, v := range list2 {
|
|
|
+ list1 = append(list1, v)
|
|
|
+ }
|
|
|
+ rep.List = list1
|
|
|
+ //创建excel
|
|
|
+ dir, errFile := os.Executable()
|
|
|
+ exPath := filepath.Dir(dir)
|
|
|
+ downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".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, err := xlsxFile.AddSheet("白名单")
|
|
|
+ if err != nil {
|
|
|
+ msg = "新增Sheet失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //标头
|
|
|
+ rowTitle := sheet.AddRow()
|
|
|
+ cellA := rowTitle.AddCell()
|
|
|
+ cellA.Value = "姓名"
|
|
|
+ cellB := rowTitle.AddCell()
|
|
|
+ cellB.Value = "手机号"
|
|
|
+ cellC := rowTitle.AddCell()
|
|
|
+ cellC.Value = "国际代码"
|
|
|
+ cellD := rowTitle.AddCell()
|
|
|
+ cellD.Value = "公司"
|
|
|
+ cellE := rowTitle.AddCell()
|
|
|
+ cellE.Value = "职位"
|
|
|
+ cellF := rowTitle.AddCell()
|
|
|
+ cellF.Value = "邮箱"
|
|
|
+ cellG := rowTitle.AddCell()
|
|
|
+ cellG.Value = "客户类型"
|
|
|
+ cellH := rowTitle.AddCell()
|
|
|
+ cellH.Value = "对口销售"
|
|
|
+ cellI := rowTitle.AddCell()
|
|
|
+ cellI.Value = "有效开始时间"
|
|
|
+ cellJ := rowTitle.AddCell()
|
|
|
+ cellJ.Value = "有效结束时间"
|
|
|
+ cellK := rowTitle.AddCell()
|
|
|
+ cellK.Value = "归属部门"
|
|
|
+ cellL := rowTitle.AddCell()
|
|
|
+ cellL.Value = "备注"
|
|
|
+ cellM := rowTitle.AddCell()
|
|
|
+ cellM.Value = "权限(消费,医药,智造,科技,策略)"
|
|
|
+
|
|
|
+ if len(rep.List) > 0 {
|
|
|
+ for _, item := range rep.List {
|
|
|
+ row := sheet.AddRow()
|
|
|
+ cellA := row.AddCell()
|
|
|
+ cellA.Value = item.RealName
|
|
|
+ cellB := row.AddCell()
|
|
|
+ cellB.Value = item.Mobile
|
|
|
+ cellC := row.AddCell()
|
|
|
+ cellC.Value = item.CountryCode
|
|
|
+ if len(item.Mobile) >= 11 && item.CountryCode == "" {
|
|
|
+ cellC.Value = "86"
|
|
|
+ }
|
|
|
+ cellD := row.AddCell()
|
|
|
+ cellD.Value = item.CompanyName
|
|
|
+ cellE := row.AddCell()
|
|
|
+ cellE.Value = ""
|
|
|
+ cellF := row.AddCell()
|
|
|
+ cellF.Value = ""
|
|
|
+ cellG := row.AddCell()
|
|
|
+ cellG.Value = ""
|
|
|
+ cellH := row.AddCell()
|
|
|
+ cellH.Value = item.SellerName
|
|
|
+ cellI := row.AddCell()
|
|
|
+ cellI.Value = ""
|
|
|
+ cellJ := row.AddCell()
|
|
|
+ cellJ.Value = ""
|
|
|
+ cellK := row.AddCell()
|
|
|
+ cellK.Value = ""
|
|
|
+ cellL := row.AddCell()
|
|
|
+ cellL.Value = ""
|
|
|
+ cellM := row.AddCell()
|
|
|
+ if item.Permission == "" {
|
|
|
+ item.Permission = "专家/医药/智造/消费/研选/科技/策略/路演服务"
|
|
|
+ }
|
|
|
+ cellM.Value = item.Permission
|
|
|
+ }
|
|
|
+ }
|
|
|
+ errFile = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ if errFile != nil {
|
|
|
+ msg = "保存文件失败Err:" + errFile.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ title := time.Now().Format("2006-01-02") + "新增白名单用户"
|
|
|
+ content := time.Now().Format("2006-01-02") + "新增白名单用户"
|
|
|
+ fileName := downLoadnFilePath
|
|
|
+ go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com;tshen@hzinsights.com")
|
|
|
+ //go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com")
|
|
|
+ //go utils.SendEmailHaveFile(title, content, fileName, "tshen@hzinsights.com")
|
|
|
+ time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
|
|
|
+ defer func() {
|
|
|
+ os.Remove(downLoadnFilePath)
|
|
|
+ }()
|
|
|
+ //创建冻结excel
|
|
|
+ dir, errFile = os.Executable()
|
|
|
+ exPath = filepath.Dir(dir)
|
|
|
+ downLoadnFilePaths := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".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, err = xlsxFile.AddSheet("白名单")
|
|
|
+ if err != nil {
|
|
|
+ msg = "新增Sheet失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //标头
|
|
|
+ rowTitle = sheet.AddRow()
|
|
|
+ cellA = rowTitle.AddCell()
|
|
|
+ cellA.Value = "姓名"
|
|
|
+ cellB = rowTitle.AddCell()
|
|
|
+ cellB.Value = "手机号"
|
|
|
+ cellC = rowTitle.AddCell()
|
|
|
+ cellC.Value = "国际代码"
|
|
|
+ cellD = rowTitle.AddCell()
|
|
|
+ cellD.Value = "公司"
|
|
|
+ cellE = rowTitle.AddCell()
|
|
|
+ cellE.Value = "职位"
|
|
|
+ cellF = rowTitle.AddCell()
|
|
|
+ cellF.Value = "邮箱"
|
|
|
+ cellG = rowTitle.AddCell()
|
|
|
+ cellG.Value = "客户类型"
|
|
|
+ cellH = rowTitle.AddCell()
|
|
|
+ cellH.Value = "对口销售"
|
|
|
+ cellI = rowTitle.AddCell()
|
|
|
+ cellI.Value = "有效开始时间"
|
|
|
+ cellJ = rowTitle.AddCell()
|
|
|
+ cellJ.Value = "有效结束时间"
|
|
|
+ cellK = rowTitle.AddCell()
|
|
|
+ cellK.Value = "归属部门"
|
|
|
+ cellL = rowTitle.AddCell()
|
|
|
+ cellL.Value = "备注"
|
|
|
+ cellM = rowTitle.AddCell()
|
|
|
+ cellM.Value = "权限(消费,医药,智造,科技,策略)"
|
|
|
+ //手机号冻结
|
|
|
+ listFrozen, err := models.GetFrozenUserWhiteList() //手机号用户修改
|
|
|
+ listFrozenOutbound, err := models.GetFrozenUserWhiteListOutbound() //外呼手机号用户修改
|
|
|
+ if len(listFrozenOutbound) > 0 {
|
|
|
+ for _, v := range listFrozenOutbound {
|
|
|
+ listFrozen = append(listFrozen, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(listFrozen) > 0 {
|
|
|
+ for _, item := range listFrozen {
|
|
|
+ row := sheet.AddRow()
|
|
|
+ cellA := row.AddCell()
|
|
|
+ cellA.Value = item.RealName
|
|
|
+ cellB := row.AddCell()
|
|
|
+ if item.Mobile != "" {
|
|
|
+ cellB.Value = item.Mobile
|
|
|
+ } else {
|
|
|
+ cellB.Value = item.OutboundMobile
|
|
|
+ }
|
|
|
+ cellC := row.AddCell()
|
|
|
+ if item.CountryCode != "" {
|
|
|
+ cellC.Value = item.CountryCode
|
|
|
+ } else {
|
|
|
+ cellC.Value = item.OutboundCountryCode
|
|
|
+ }
|
|
|
+ cellD := row.AddCell()
|
|
|
+ cellD.Value = item.CompanyName
|
|
|
+ cellE := row.AddCell()
|
|
|
+ cellE.Value = ""
|
|
|
+ cellF := row.AddCell()
|
|
|
+ cellF.Value = ""
|
|
|
+ cellG := row.AddCell()
|
|
|
+ cellG.Value = ""
|
|
|
+ cellH := row.AddCell()
|
|
|
+ cellH.Value = item.SellerName
|
|
|
+ cellI := row.AddCell()
|
|
|
+ cellI.Value = ""
|
|
|
+ cellJ := row.AddCell()
|
|
|
+ cellJ.Value = ""
|
|
|
+ cellK := row.AddCell()
|
|
|
+ cellK.Value = ""
|
|
|
+ cellL := row.AddCell()
|
|
|
+ cellL.Value = ""
|
|
|
+ cellM := row.AddCell()
|
|
|
+ cellM.Value = item.PermissionName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ errFile = xlsxFile.Save(downLoadnFilePaths)
|
|
|
+ if errFile != nil {
|
|
|
+ msg = "保存文件失败Err:" + errFile.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ title = time.Now().Format("2006-01-02") + "删除白名单用户"
|
|
|
+ content = time.Now().Format("2006-01-02") + "删除白名单用户"
|
|
|
+ fileName = downLoadnFilePaths
|
|
|
+ go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com;tshen@hzinsights.com")
|
|
|
+ //go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com")
|
|
|
+ time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
|
|
|
+ defer func() {
|
|
|
+ os.Remove(downLoadnFilePaths)
|
|
|
+ }()
|
|
|
+ if len(list1) > 0 {
|
|
|
+ for _, v := range list1 {
|
|
|
+ item := new(models.WxUserWhite)
|
|
|
+ item.Mobile = v.Mobile
|
|
|
+ item.CountryCode = v.CountryCode
|
|
|
+ item.CreatedTime = time.Now()
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.PermissionName = v.Permission
|
|
|
+ item.UserCreatedTime = v.CreatedTime
|
|
|
+ item.RealName = v.RealName
|
|
|
+ item.SellerName = v.SellerName
|
|
|
+ item.Status = v.Status
|
|
|
+ _, err = models.AddWxUserWhite(item)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(list2) > 0 {
|
|
|
+ for _, v := range list2 {
|
|
|
+ item := new(models.WxUserWhite)
|
|
|
+ item.OutboundMobile = v.Mobile
|
|
|
+ item.OutboundCountryCode = v.CountryCode
|
|
|
+ item.CreatedTime = time.Now()
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.PermissionName = v.Permission
|
|
|
+ item.UserCreatedTime = v.CreatedTime
|
|
|
+ item.RealName = v.RealName
|
|
|
+ item.SellerName = v.SellerName
|
|
|
+ item.Status = v.Status
|
|
|
+ _, err = models.AddWxUserWhite(item)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFrozen {
|
|
|
+ err = models.DeleteWxUserWhite(v)
|
|
|
+ if err != nil {
|
|
|
+ msg = "删除信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println("发送附件完成", len(list1))
|
|
|
+ fmt.Println("发送附件完成", len(list2))
|
|
|
+ fmt.Println("发送附件完成", len(rep.List))
|
|
|
+ fmt.Println("发送附件完成", len(listFrozen))
|
|
|
+ return
|
|
|
+}
|