xingzai %!s(int64=3) %!d(string=hai) anos
pai
achega
8d708caccc
Modificáronse 4 ficheiros con 118 adicións e 113 borrados
  1. 1 1
      controllers/activity.go
  2. 6 6
      models/user.go
  3. 1 0
      services/task.go
  4. 110 106
      services/user.go

+ 1 - 1
controllers/activity.go

@@ -1684,7 +1684,7 @@ func (this *ActivityCoAntroller) LabelList() {
 	conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
 	condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 
-	condition += `	GROUP BY art.label ORDER BY art.active_state ASC, art.activity_time ASC  `
+	condition += `	GROUP BY art.label ORDER BY art.active_state ASC, art.activity_time DESC  `
 	list, errList := models.GetActivityLabelListAll(condition, pars, startSize, pageSize)
 	if errList != nil {
 		br.Msg = "获取失败"

+ 6 - 6
models/user.go

@@ -211,21 +211,21 @@ func AddCountryCode(CountryCode string, userId int) (err error) {
 	return
 }
 
-func GetUser(startSize, pageSize, userId int) (items []*ArticleInterviewApplyList, err error) {
-	sql := `SELECT u.real_name ,u.mobile,u.country_code,c.company_name,cp.seller_name,
+//获取用户白名单
+func GetUserWhiteList(fieldStr, condition string) (items []*ArticleInterviewApplyList, err error) {
+	sql := `SELECT ` + fieldStr + `
 		GROUP_CONCAT( DISTINCT b.chart_permission_name SEPARATOR '/' ) AS permission
 		FROM wx_user AS u
 		INNER JOIN company as c ON c.company_id = u.company_id
 		INNER JOIN company_report_permission AS p ON p.company_id = u.company_id
 		INNER JOIN chart_permission AS b ON b.chart_permission_id=p.chart_permission_id
 		INNER JOIN company_product AS cp ON cp.company_id = u.company_id
-		WHERE p.status IN('正式','试用')
+		WHERE 1= 1
 		AND p.product_id = 2
 		AND cp.product_id = 2
 		AND u.company_id >1 
-		AND u.mobile = u.outbound_mobile
-		AND u.mobile != ''
+		AND u.mobile = u.outbound_mobile ` + condition + `
 		GROUP BY u.user_id`
-	_, err = orm.NewOrm().Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }

+ 1 - 0
services/task.go

@@ -249,6 +249,7 @@ func CreateIndex() {
  }
 }`
 	EsCreateIndex(indexName, mappingJson)
+	AddAllArticle()
 }
 
 func AddAllArticle() {

+ 110 - 106
services/user.go

@@ -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"
 )
@@ -397,109 +401,109 @@ func AddUserRecord(openId, unionId, nickName, realName, province, city, country,
 }
 
 //预约外呼名单,会前1小时自动发送邮件给专家组
-//func SendEmailUserInfoTo(cont context.Context) (err error) {
-//	var msg 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("发送附件")
-//
-//	list, err := models.GetSignupExport(v.ActivityId)
-//	if err != nil {
-//		msg = "获取失败,Err:" + err.Error()
-//		return
-//	}
-//	//创建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 = "所属销售"
-//
-//	for _, item := range list {
-//		row := sheet.AddRow()
-//		cellA := row.AddCell()
-//		cellA.Value = item.RealName
-//		cellB := row.AddCell()
-//		cellB.Value = item.OutboundMobile
-//		cellC := row.AddCell()
-//		if item.CountryCode == "" {
-//			cellC.Value = "86"
-//		} else {
-//			cellC.Value = item.CountryCode
-//		}
-//		cellD := row.AddCell()
-//		cellD.Value = item.CompanyName
-//		cellE := row.AddCell()
-//		cellE.Value = item.SellerName
-//	}
-//	errFile = xlsxFile.Save(downLoadnFilePath)
-//	if errFile != nil {
-//		msg = "保存文件失败Err:" + errFile.Error()
-//		return
-//	}
-//	//title := activityInfo.ActivityName + "外呼名单"
-//	//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, touser)
-//	defer func() {
-//		//os.Remove(downLoadnFilePath)
-//	}()
-//	time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
-//	errFile = models.UPdateActivityIdToSendFile(v.ActivityId)
-//	if errFile != nil {
-//		msg = "获取失败,Err:" + errFile.Error()
-//		return
-//	}
-//
-//	fmt.Println("发送附件完成")
-//	return
-//}
+func SendEmailUserInfoTo(cont context.Context) (err error) {
+	var msg 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("发送附件")
+
+	list, err := models.GetUserFormalTrial()
+	if err != nil {
+		msg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//创建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 = "所属销售"
+
+	for _, item := range list {
+		row := sheet.AddRow()
+		cellA := row.AddCell()
+		cellA.Value = item.RealName
+		cellB := row.AddCell()
+		cellB.Value = item.OutboundMobile
+		cellC := row.AddCell()
+		if item.CountryCode == "" {
+			cellC.Value = "86"
+		} else {
+			cellC.Value = item.CountryCode
+		}
+		cellD := row.AddCell()
+		cellD.Value = item.CompanyName
+		cellE := row.AddCell()
+		cellE.Value = item.SellerName
+	}
+	errFile = xlsxFile.Save(downLoadnFilePath)
+	if errFile != nil {
+		msg = "保存文件失败Err:" + errFile.Error()
+		return
+	}
+	//title := activityInfo.ActivityName + "外呼名单"
+	//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, touser)
+	defer func() {
+		//os.Remove(downLoadnFilePath)
+	}()
+	time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
+	errFile = models.UPdateActivityIdToSendFile(v.ActivityId)
+	if errFile != nil {
+		msg = "获取失败,Err:" + errFile.Error()
+		return
+	}
+
+	fmt.Println("发送附件完成")
+	return
+}