xingzai 3 yıl önce
ebeveyn
işleme
534f035b81
8 değiştirilmiş dosya ile 582 ekleme ve 33 silme
  1. 21 10
      controllers/activity.go
  2. 90 0
      controllers/user.go
  3. 2 4
      models/activity.go
  4. 1 0
      models/db.go
  5. 2 0
      models/user.go
  6. 112 0
      models/wx_user_white.go
  7. 6 2
      services/task.go
  8. 348 17
      services/user.go

+ 21 - 10
controllers/activity.go

@@ -1673,7 +1673,6 @@ func (this *ActivityCoAntroller) LabelList() {
 	var pars []interface{}
 	//活动可见限制
 	var sqlExport string
-
 	slicePer := strings.Split(permissionStr, ",")
 	var permissionSqlStr string
 	for _, v := range slicePer {
@@ -1689,8 +1688,8 @@ func (this *ActivityCoAntroller) LabelList() {
 		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
 	}
 	sqlExport += `) `
-
 	condition += ` AND art.publish_status = 1  AND art.label != '' `
+	condition += ` AND art.active_state = 1 `
 	var conditionOr string
 	if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
 		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
@@ -1701,10 +1700,10 @@ func (this *ActivityCoAntroller) LabelList() {
 	conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
 	condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
 	resp := new(models.GetCygxActivityLabelListRep)
-
+	//conditionLaable := condition
 	//主题
 	if label != "" {
-		condition += ` AND art.active_state = 1 `
+
 		listAll, errList := models.GetActivityLabelListAll(condition, pars, startSize, 32)
 		if errList != nil {
 			br.Msg = "获取失败"
@@ -1735,12 +1734,9 @@ func (this *ActivityCoAntroller) LabelList() {
 		return
 	} else {
 		//行业名称
-		if len(chartPermissionIds) > 0 {
-			condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
-		}
-		if activityTypeIds != "" {
-			condition += ` AND art.activity_type_id  IN (` + activityTypeIds + `)`
-		}
+		condition = ` AND art.publish_status = 1  AND art.label != '' `
+		var conditionOr string
+
 		if whichDay != "" {
 			var startDate string
 			var endDate string
@@ -1762,7 +1758,22 @@ func (this *ActivityCoAntroller) LabelList() {
 		} else {
 			condition += ` AND art.active_state  IN (1)`
 		}
+		if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
+			conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
+		}
+		if (userType == 5) && strings.Contains(permissionStr, "专家") {
+			conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
+		}
+		conditionOr += `	OR ( art.is_limit_people = 0 	  ` + condition + `) `
+		condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
+		if len(chartPermissionIds) > 0 {
+			condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+		}
+		if activityTypeIds != "" {
+			condition += ` AND art.activity_type_id  IN (` + activityTypeIds + `)`
+		}
 	}
+
 	list, errList := models.GetActivityLabelListAll(condition, pars, startSize, pageSize)
 	if errList != nil {
 		br.Msg = "获取失败"

+ 90 - 0
controllers/user.go

@@ -1158,3 +1158,93 @@ func (this *UserController) AddOutboundMobile() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title  白名单同步
+// @Description 获取是否需要填写区号接口
+// @Param   Keypd   query   string  false       "搜索主题 多个用 , 隔开 (空为活动主题,非空为更多主题)"
+// @Success 200 {object} models.CountryCode
+// @router /whiteUser [get]
+func (this *UserController) WhiteUser() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	uid := user.UserId
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	if uid == 0 {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	keypd := this.GetString("Keypd")
+
+	if keypd != "888" {
+		br.Msg = "密码错误"
+		return
+	}
+	item := new(models.WxUserWhite)
+	fmt.Println(item)
+	var fieldStr string
+	var condition string
+	fieldStr = ` u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,cp.seller_name,u.created_time,cp.status,`
+	condition = `  AND cp.status IN ( '正式', '试用' ) AND u.mobile != ''  `
+	list1, err := models.GetFormalUserWhiteList(fieldStr, condition)
+	if err != nil {
+		br.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,u.created_time,cp.status,`
+	condition = ` AND u.mobile != u.outbound_mobile AND cp.status IN ( '正式', '试用' ) AND u.outbound_mobile != ''  `
+	list2, err := models.GetFormalUserWhiteList(fieldStr, condition)
+	if err != nil {
+		br.Msg = "获取失败,Err:" + err.Error()
+		return
+	}
+	fmt.Println(len(list1))
+	for k, v := range list1 {
+		item.Mobile = v.Mobile
+		item.CountryCode = v.CountryCode
+		item.CompanyName = v.CompanyName
+		item.PermissionName = v.Permission
+		item.CreatedTime = time.Now()
+		item.UserCreatedTime = v.CreatedTime
+		item.RealName = v.RealName
+		item.SellerName = v.SellerName
+		item.Status = v.Status
+		_, err := models.AddWxUserWhite(item)
+		if err != nil {
+			br.Msg = "获取失败,Err:" + err.Error()
+			return
+		}
+		fmt.Println(k)
+	}
+	item = new(models.WxUserWhite)
+	fmt.Println(len(list2))
+	for _, v := range list2 {
+		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 {
+			br.Msg = "获取失败,Err:" + err.Error()
+			return
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 2 - 4
models/activity.go

@@ -1,7 +1,6 @@
 package models
 
 import (
-	"fmt"
 	"rdluck_tools/orm"
 	"rdluck_tools/paging"
 	"time"
@@ -428,13 +427,12 @@ type CygxActivityLabelList struct {
 //主题列表
 func GetActivityLabelListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT label 
+	sql := `SELECT	label, 	MAX( art.activity_time ) AS timesort 
 		FROM cygx_activity as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` GROUP BY art.label ORDER BY  art.activity_time DESC ,art.activity_id DESC  LIMIT ?,? `
-	fmt.Println(sql)
+	sql += ` GROUP BY art.label ORDER BY  timesort DESC ,art.activity_id DESC  LIMIT ?,? `
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 1 - 0
models/db.go

@@ -55,5 +55,6 @@ func init() {
 		new(CygxActivityMeetingReminder),
 		new(CygxActivityMeetingReminderLog),
 		new(CygxMySchedule),
+		new(WxUserWhite),
 	)
 }

+ 2 - 0
models/user.go

@@ -284,6 +284,8 @@ type UserWhiteList struct {
 	Permission  string `description:"拥有权限分类,多个用英文逗号分隔"`
 	CountryCode string `description:"区号"`
 	SellerName  string `description:"销售姓名"`
+	CreatedTime time.Time
+	Status      string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
 }
 
 type UserWhiteListRep struct {

+ 112 - 0
models/wx_user_white.go

@@ -0,0 +1,112 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type WxUserWhite struct {
+	Id                  int `orm:"column(id);pk"`
+	Mobile              string
+	CreatedTime         time.Time
+	UserCreatedTime     time.Time
+	OutboundMobile      string `description:"外呼手机号"`
+	Status              string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
+	CountryCode         string `description:"区号"`
+	OutboundCountryCode string `description:"外呼手机号区号"`
+	CompanyName         string `description:"公司名称"`
+	PermissionName      string `description:"拥有权限分类"`
+	RealName            string `description:"姓名"`
+	SellerName          string `description:"销售"`
+}
+
+//添加
+func AddWxUserWhite(item *WxUserWhite) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+//获取用户手机号白名单
+func GetWxUserWhiteMobile() (mobileStr string, err error) {
+	sql := ` SELECT
+			GROUP_CONCAT( DISTINCT u.mobile SEPARATOR ',' ) AS mobileStr 
+			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
+				1 = 1 
+				AND p.product_id = 2 
+				AND u.mobile NOT IN ( SELECT mobile FROM wx_user_white ) 
+				AND u.mobile != ''
+				AND cp.STATUS IN ( '正式', '试用' ) `
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&mobileStr)
+	return
+}
+
+//获取用户外呼手机号白名单
+func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
+	sql := ` SELECT
+			GROUP_CONCAT( DISTINCT u.outbound_mobile SEPARATOR ',' ) AS outboundmobileStr 
+			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
+				1 = 1 
+				AND p.product_id = 2 
+				AND u.outbound_mobile NOT IN ( SELECT outbound_mobile FROM wx_user_white ) 
+				AND u.outbound_mobile NOT IN ( SELECT mobile FROM wx_user_white ) 
+				AND cp.STATUS IN ( '正式', '试用' )
+				AND u.mobile != ''
+				AND u.mobile !=  u.outbound_mobile `
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&mobileStr)
+	return
+}
+
+//获取冻结用户白名单
+func GetFrozenUserWhiteList() (items []*WxUserWhite, err error) {
+	sql := `SELECT
+			* 
+		FROM
+			wx_user_white AS w 
+		WHERE
+			w.mobile NOT IN (
+			SELECT
+				mobile 
+			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
+				1 = 1 
+				AND p.product_id = 2 
+				AND cp.STATUS IN ( '正式', '试用' ) 
+			)
+	  OR w.outbound_mobile NOT IN ( SELECT outbound_mobile FROM wx_user )`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	return
+}
+
+//删除数据
+func DeleteWxUserWhite(item *WxUserWhite) (err error) {
+	o := orm.NewOrm()
+	if item.Mobile != "" {
+		sql := ` DELETE FROM wx_user_white WHERE mobile = ?`
+		_, err = o.Raw(sql, item.Mobile).Exec()
+	} else {
+		sql := ` DELETE FROM wx_user_white WHERE outbound_mobile = ?`
+		_, err = o.Raw(sql, item.OutboundMobile).Exec()
+	}
+
+	return
+}

+ 6 - 2
services/task.go

@@ -51,10 +51,14 @@ func Task() {
 	sendEmailFileToExpert := task.NewTask("sendEmailFileToExpert", "0 */5 8-22 * * *", SendEmailFileToExpert) //预约外呼名单,会前1小时自动发送邮件给专家组
 	task.AddTask("sendEmailFileToExpert", sendEmailFileToExpert)
 
-	//白名单发送
-	//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 35 16 * * *", SendEmailUserWhiteList) //预约外呼名单,会前1小时自动发送邮件给专家组
+	////白名单发送
+	//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //预约外呼名单,会前1小时自动发送邮件给专家组
 	//task.AddTask("sendEmailUserWhiteList", sendEmailUserWhiteList)
 
+	//白名单发送2
+	sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteList2", "0 01 05 * * *", SendEmailUserWhiteListChange) //预约外呼名单,会前1小时自动发送邮件给专家组
+	task.AddTask("sendEmailUserWhiteListChange", sendEmailUserWhiteListChange)
+
 	//editOutboundMobile := task.NewTask("editOutboundMobile", "0 */1 8-22 * * *", EditOutboundMobile) //同步外呼号码与手机号
 	//task.AddTask("sendEmailFileToExpert", editOutboundMobile)
 	//editUserOutboundMobile := task.NewTask("editUserOutboundMobile", "0 27 14 * * *   ", EditUserOutboundMobile) //同步外呼号码与手机号

+ 348 - 17
services/user.go

@@ -425,30 +425,213 @@ func SendEmailUserWhiteList(cont context.Context) (err error) {
 	}()
 	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 != ''  `
+	//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 != ''  `
+	//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)
+	//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
 	}
-	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 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
@@ -460,12 +643,6 @@ func SendEmailUserWhiteList(cont context.Context) (err error) {
 	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()
@@ -557,8 +734,8 @@ func SendEmailUserWhiteList(cont context.Context) (err error) {
 		msg = "保存文件失败Err:" + errFile.Error()
 		return
 	}
-	title := "用户白名单"
-	content := "用户白名单"
+	title := "新增用户白名单"
+	content := "新增用户白名单"
 	fileName := downLoadnFilePath
 	//if activityInfo.ChartPermissionName == "科技" {
 	//	touser = utils.EmailTechnology
@@ -574,7 +751,7 @@ func SendEmailUserWhiteList(cont context.Context) (err error) {
 	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) //延迟两秒,避免过多活动的时候邮件发送没有内容
+	time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
 	//errFile = models.UPdateActivityIdToSendFile(v.ActivityId)
 	//if errFile != nil {
 	//	msg = "获取失败,Err:" + errFile.Error()
@@ -583,6 +760,160 @@ func SendEmailUserWhiteList(cont context.Context) (err error) {
 	defer func() {
 		os.Remove(downLoadnFilePath)
 	}()
+	//创建冻结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 = "权限(消费,医药,智造,科技,策略)"
+	//手机号冻结
+	list3, err := models.GetFrozenUserWhiteList()
+	if err != nil {
+		msg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, item := range list3 {
+		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(downLoadnFilePath)
+	if errFile != nil {
+		msg = "保存文件失败Err:" + errFile.Error()
+		return
+	}
+	title = "冻结用户白名单"
+	content = "冻结用户白名单"
+	fileName = downLoadnFilePath
+	go utils.SendEmailHaveFile(title, content, fileName, "cxzhang@hzinsights.com;tshen@hzinsights.com")
+	time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
+	defer func() {
+		os.Remove(downLoadnFilePath)
+	}()
+
+	fmt.Println(len(list2))
+	if len(list2) > 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 list3 {
+		err = models.DeleteWxUserWhite(v)
+		if err != nil {
+			msg = "删除信息失败,Err:" + err.Error()
+			return
+		}
+	}
 	fmt.Println("发送附件完成", len(rep.List))
 	return
 }