Browse Source

Merge branch 'cygx_3.3.1' of hongze/hongze_cygx into master

hongze 3 years ago
parent
commit
17b659322e

+ 387 - 2
controllers/activity.go

@@ -3,8 +3,11 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/tealeg/xlsx"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"os"
+	"path/filepath"
 	"rdluck_tools/paging"
 	"strconv"
 	"strings"
@@ -61,6 +64,7 @@ func (this *ActivityCoAntroller) List() {
 // @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
 // @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
 // @Param   IsShowJurisdiction   query   int  false       "是否仅展示有权限的,1是,2否 默认为零"
+// @Param   Label   query   string  false       "搜索主题 多个用 , 隔开"
 // @Success 200 {object} models.GetCygxActivityListRep
 // @router /list [get]
 func (this *ActivityCoAntroller) ActivityList() {
@@ -69,14 +73,12 @@ func (this *ActivityCoAntroller) ActivityList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	user := this.User
 	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		return
 	}
-	fmt.Println(user.Mobile)
 	uid := user.UserId
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
@@ -87,6 +89,7 @@ func (this *ActivityCoAntroller) ActivityList() {
 
 	keyWord := this.GetString("KeyWord")
 	activeState := this.GetString("ActiveState")
+	label := this.GetString("Label")
 
 	itemSearch := new(models.CygxActivityUserSearchContent)
 	itemSearch.UserId = uid
@@ -231,6 +234,17 @@ func (this *ActivityCoAntroller) ActivityList() {
 			condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' )`
 		}
 	}
+	//主题
+	if label != "" {
+		sliceLabel := strings.Split(label, ",")
+		var labelSqlStr string
+		for _, v := range sliceLabel {
+			labelSqlStr += "'" + v + "',"
+		}
+		labelSqlStr = strings.TrimRight(labelSqlStr, ",")
+		condition = ` AND art.label  IN (` + labelSqlStr + `)`
+	}
+
 	//行业名称
 	if len(chartPermissionIds) > 0 {
 		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
@@ -603,6 +617,9 @@ func (this *ActivityCoAntroller) Detail() {
 		if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
 			activityInfo.SignupNum = activityInfo.LimitPeopleNum
 		}
+		if activityInfo.ChartPermissionNames != "" {
+			activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
+		}
 		resp.Detail = activityInfo
 	}
 	resp.HasPermission = hasPermission
@@ -1555,3 +1572,371 @@ func (this *ActivityABaseController) FastSearch() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 主题列表
+// @Description 获取活动主题列表接口
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   ActivityTypeIds   query   string  false     "活动类型id 多个用 , 隔开"
+// @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
+// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
+// @Param   Label   query   string  false       "搜索主题 多个用 , 隔开 (空为活动主题,非空为更多主题)"
+// @Success 200 {object} models.GetCygxActivityLabelListRep
+// @router /labelList [get]
+func (this *ActivityCoAntroller) LabelList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	//currentIndex, _ := this.GetInt("CurrentIndex")
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	activityTypeIds := this.GetString("ActivityTypeIds")
+	whichDay := this.GetString("WhichDay")
+	isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
+	activeState := this.GetString("ActiveState")
+	label := this.GetString("Label")
+	var userType int
+	var permissionStr string
+	if user.CompanyId <= 1 {
+		userType = 0
+	} else {
+		total, err := models.GetCountCompanyDetailByIdGroup(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		if total == 0 {
+			userType = 0
+		} else {
+			companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败!"
+				br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+				return
+			}
+			if companyDetail == nil {
+				br.Msg = "获取信息失败!"
+				br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
+				return
+			}
+			permissionStr, err = models.GetCompanyPermission(user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				return
+			}
+			//1、永续客户
+			//2、大套餐客户(4个行业全开通的正式客户)
+			//3、分行业套餐客户(开通对应行业的正式客户)
+			//4、仅开通专家套餐的正式客户
+			//5、开通对应行业套餐或专家套餐的试用客户
+			if companyDetail.Status == "永续" {
+				userType = 1
+			} else if companyDetail.Status == "试用" {
+				userType = 5
+			} else if companyDetail.Status == "正式" {
+				if permissionStr == "专家" {
+					userType = 4
+				} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
+					userType = 2
+				} else {
+					userType = 3
+				}
+				if userType == 3 {
+					if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
+						userType = 4
+					}
+				}
+			}
+		}
+	}
+	if isShowJurisdiction == 1 && chartPermissionIds == "" && userType == 4 {
+		activityTypeIds = "1,3"
+	}
+	var startSize int
+	//if pageSize <= 0 {
+	//	pageSize = utils.PageSize20
+	//}
+	//currentIndex = 1
+	pageSize = 16
+	//startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	//活动可见限制
+	var sqlExport string
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		permissionSqlStr += "'" + v + "',"
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
+	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	if userType == 2 {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%3%' `
+	}
+	if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
+		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 + `) `
+	}
+	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
+	resp := new(models.GetCygxActivityLabelListRep)
+	//conditionLaable := condition
+	//主题
+	if label != "" {
+
+		listAll, errList := models.GetActivityLabelListAll(condition, pars, startSize, 32)
+		if errList != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errList.Error()
+			return
+		}
+		list1, errList := models.GetActivityLabelListAll(condition, pars, startSize, 16)
+		if errList != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errList.Error()
+			return
+		}
+		for _, v := range listAll {
+			var isHAve bool
+			for _, v2 := range list1 {
+				if v2.KeyWord == v.KeyWord {
+					isHAve = true
+				}
+			}
+			if !isHAve {
+				resp.List = append(resp.List, v)
+			}
+		}
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	} else {
+		//行业名称
+		condition = ` AND art.publish_status = 1  AND art.label != '' `
+		if len(chartPermissionIds) > 0 {
+			condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+		}
+		if activityTypeIds != "" {
+			condition += ` AND art.activity_type_id  IN (` + activityTypeIds + `)`
+		}
+		var conditionOr string
+
+		if whichDay != "" {
+			var startDate string
+			var endDate string
+			if whichDay == "1" {
+				startDate = time.Now().Format(utils.FormatDate)
+				endDate = startDate
+			} else if whichDay == "2" {
+				startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+				endDate = startDate
+			} else {
+				startDate = time.Now().Format(utils.FormatDate)
+				endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+			}
+			condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+			condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+		}
+		if activeState != "" {
+			condition += ` AND art.active_state  IN (` + activeState + `)`
+		} 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
+	}
+	list, errList := models.GetActivityLabelListAll(condition, pars, startSize, pageSize)
+	if errList != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + errList.Error()
+		return
+	}
+	//resp := new(models.GetCygxActivityLabelListRep)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 上传公司名称excel
+// @Description 上传参会表格数据
+// @Param   File   query   file  true       "文件"
+// @Success 200 Ret=200 导入成功
+// @router /activityMeet/import [post]
+func (this *ActivityCoAntroller) Import() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请重新登录"
+		return
+	}
+	file, h, err := this.GetFile("File")
+	if err != nil {
+		br.Msg = "获取文件失败"
+		br.ErrMsg = "获取文件失败,Err:" + err.Error()
+		return
+	}
+
+	uploadDir := "static/xls"
+	err = os.MkdirAll(uploadDir, 766)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+	path := uploadDir + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + h.Filename
+	defer file.Close()
+	err = this.SaveToFile("File", path)
+	if err != nil {
+		br.Msg = "文件保存失败"
+		br.ErrMsg = "文件保存失败,Err:" + err.Error()
+		return
+	}
+	xlFile, err := xlsx.OpenFile(path)
+	if err != nil {
+		br.Msg = "文件导入失败"
+		br.ErrMsg = "文件导入失败,Err:" + err.Error()
+		return
+	}
+	//允许添加的联系人
+	needAddAttendanc := make([]*models.UserWhiteList, 0)
+
+	// 遍历sheet页读取
+	for _, sheet := range xlFile.Sheets {
+		//遍历行读取
+		maxRow := sheet.MaxRow
+		for i := 0; i < maxRow; i++ {
+			if i >= 1 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				var companyName, permission string
+				for k, cell := range cells {
+					if k == 0 {
+						companyName = cell.String()
+					}
+					if k == 2 {
+						permission = cell.String()
+					}
+
+				}
+				//这些字段都没有的话,系统认为excel到底了
+				if companyName == "" {
+					break
+				}
+				item := new(models.UserWhiteList)
+				item.CompanyName = companyName
+				item.Permission = permission
+				needAddAttendanc = append(needAddAttendanc, item)
+			}
+		}
+	}
+	//var mobileStr string
+	var permissionStr string
+	for k, v := range needAddAttendanc {
+		if k > 0 && v.CompanyName != needAddAttendanc[k-1].CompanyName {
+			permissionStr, err = models.GetCompanyPermissionByName(v.CompanyName)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				return
+			}
+		}
+		if k == 0 {
+			permissionStr, err = models.GetCompanyPermissionByName(v.CompanyName)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				return
+			}
+		}
+		needAddAttendanc[k].Permission = permissionStr
+		fmt.Println(permissionStr)
+	}
+
+	defer func() {
+		os.Remove(path)
+	}()
+
+	//创建excel
+	dir, errFile := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if errFile != nil {
+		br.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 {
+		br.Msg = "新增Sheet失败,Err:" + err.Error()
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = ""
+	cellB := rowTitle.AddCell()
+	cellB.Value = "公司"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "权限"
+	for _, item := range needAddAttendanc {
+		row := sheet.AddRow()
+		cellA := row.AddCell()
+		cellA.Value = item.CompanyName
+		cellB := row.AddCell()
+		if item.Permission == "" {
+			//item.Permission = "专家/医药/智造/消费/研选/科技/策略/路演服务"
+		}
+		cellB.Value = item.Permission
+	}
+	errFile = xlsxFile.Save(downLoadnFilePath)
+	if errFile != nil {
+		br.Msg = "保存文件失败Err:" + errFile.Error()
+		return
+	}
+
+	br.Msg = "导入成功"
+	br.Ret = 200
+	br.Success = true
+}

+ 1 - 0
controllers/article.go

@@ -473,6 +473,7 @@ func (this *ArticleCommonController) Detail() {
 			}
 		}
 	}
+	detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
 	detail.SellerList = sellerList
 	resp.Detail = detail
 	br.Ret = 200

+ 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 = "获取成功"
+}

+ 24 - 0
models/activity.go

@@ -57,6 +57,7 @@ type ActivityDetail struct {
 	ActivityTypeName        string `description:"活动类型名称"`
 	ChartPermissionId       int    `description:"行业id"`
 	ChartPermissionName     string `description:"行业名称"`
+	ChartPermissionNames    string `description:"行业名称辅助字段,区分研选子分类"`
 	Body                    string `description:"内容"`
 	CreateTime              string `description:"创建时间"`
 	IsLimitPeople           int    `description:"是否限制人数 1是,0否"`
@@ -144,6 +145,7 @@ type CygxActivityList struct {
 	ActiveState             string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
 	IsCancelMeetingReminder int    `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
 	IsBrackets              int    `description:"是否有方括号 1是 ,0 否"`
+	Label                   string `description:"主题标签"`
 }
 
 type GetCygxActivityListRep struct {
@@ -417,3 +419,25 @@ func UPdateActivityIdToSendFile(activityId int) (err error) {
 	_, err = o.Raw(sql, activityId).Exec()
 	return
 }
+
+//活动详情
+type CygxActivityLabelList struct {
+	KeyWord string `orm:"column(label)";description:"主题"`
+}
+
+//主题列表
+func GetActivityLabelListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
+	o := orm.NewOrm()
+	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  timesort DESC ,art.activity_id DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxActivityLabelListRep struct {
+	List []*CygxActivityLabelList
+}

+ 2 - 2
models/chart_permission.go

@@ -50,7 +50,7 @@ func GetChartPermissionById(chartPermissionId int) (item *ChartPermission, err e
 
 func GetChartPermissionActivity() (items []*ActivityChartPermission, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (19,20,21,22,23) ORDER BY sort ASC `
+	sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (19,20,21,22,23,31) ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -67,7 +67,7 @@ func GetUserCompanyPermission(companyId int) (items []*ActivityChartPermission,
             AND b.is_other=0
 			AND c.status IN('正式','试用','永续')
 			AND a.status IN('正式','试用','永续') 
-			AND b.chart_permission_id IN (19,20,21,22,23) 
+			AND b.chart_permission_id IN (19,20,21,22,23,31) 
 			ORDER BY b.sort ASC `
 	o := orm.NewOrm()
 	_, err = o.Raw(sql, companyId).QueryRows(&items)

+ 14 - 0
models/company.go

@@ -65,6 +65,7 @@ func GetCompanyPermission(companyId int) (permission string, err error) {
 			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
 			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
 			WHERE  a.company_id=?
+			AND c.product_id = 2
 			AND c.is_suspend=0
             AND b.cygx_auth=1
 			AND c.status IN('正式','试用','永续')
@@ -74,6 +75,19 @@ func GetCompanyPermission(companyId int) (permission string, err error) {
 	return
 }
 
+func GetCompanyPermissionByName(name string) (permission string, err error) {
+	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name  ORDER BY b.sort ASC SEPARATOR '/') AS permission
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
+			INNER JOIN company AS cm ON cm.company_id=c.company_id 
+			WHERE  cm.company_name=?
+			AND b.product_id = 2 `
+	o := orm.NewOrm()
+	err = o.Raw(sql, name).QueryRow(&permission)
+	return
+}
+
 func GetCompanyDetailAllById(companyId int) (item *CompanyDetail, err error) {
 	sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile 
             FROM company AS a

+ 1 - 0
models/db.go

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

+ 1 - 1
models/tactics.go

@@ -90,7 +90,7 @@ func GetTacticsList2(endDate string) (list []*Tactics2, err error) {
 			INNER JOIN article_content AS b ON a.id=b.article_id
 			INNER JOIN article_category AS c ON a.id=c.article_id
 			INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
-			WHERE a.publish_status=1  AND a.publish_date>=? AND d.id IN (7,9,11,28,32,45,51,52,57,62,64,65,66,67,69,71,72,74,79,80,84,85,86,87,88,89,90,93,95,96,98,100) `
+			WHERE a.publish_status=1  AND a.publish_date>=? AND d.id IN (7,9,11,28,32,45,51,52,57,62,64,65,66,67,69,71,72,74,79,80,84,85,86,87,88,89,90,93,95,96,98,100,102)`
 	//AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
 	//IN(85,71)
 	_, err = o.Raw(sql, endDate).QueryRows(&list)

+ 60 - 0
models/user.go

@@ -276,3 +276,63 @@ func ChangeUserOutboundMobileByMobile(userId int) (err error) {
 	_, err = o.Raw(sql, userId).Exec()
 	return
 }
+
+type UserWhiteList struct {
+	Mobile      string `description:"手机号码"`
+	RealName    string `description:"用户实际名称"`
+	CompanyName string `description:"公司名称"`
+	Permission  string `description:"拥有权限分类,多个用英文逗号分隔"`
+	CountryCode string `description:"区号"`
+	SellerName  string `description:"销售姓名"`
+	CreatedTime time.Time
+	Status      string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
+}
+
+type UserWhiteListRep struct {
+	List []*UserWhiteList
+}
+
+//获取正式试用用户白名单
+func GetFormalUserWhiteList(fieldStr, condition string) (items []*UserWhiteList, err error) {
+	sql := `SELECT ` + fieldStr + `
+		(SELECT cp.seller_name FROM company_product  AS cp WHERE cp.company_id = u.company_id ORDER BY cp.product_id DESC  LIMIT 0,1 ) as seller_name,
+		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 1= 1
+		AND cp.product_id = 2
+		AND b.product_id = 2
+		AND u.company_id >1 ` + condition + `
+		GROUP BY u.user_id`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	return
+}
+
+//获取永续用户白名单
+func GetSustainableUserWhiteList(fieldStr, condition string) (items []*UserWhiteList, err error) {
+	sql := `SELECT ` + fieldStr + `
+			(SELECT cp.seller_name FROM company_product  AS cp WHERE cp.company_id = u.company_id ORDER BY cp.product_id DESC  LIMIT 0,1 ) as seller_name,
+			(SELECT
+				GROUP_CONCAT( DISTINCT b.chart_permission_name SEPARATOR '/' ) 
+			FROM
+				company_report_permission AS p
+				INNER JOIN chart_permission AS b ON b.chart_permission_id = p.chart_permission_id 
+			WHERE
+				p.company_id = u.company_id 
+				AND p.status IN ( '永续' ) 
+				AND p.product_id = 2 
+			) 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 1 = 1
+			AND u.company_id > 1  ` + condition + `
+			GROUP BY u.user_id `
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	return
+}

+ 139 - 0
models/wx_user_white.go

@@ -0,0 +1,139 @@
+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 cp.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 cp.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 cp.product_id = 2 
+					AND cp.STATUS IN ( '正式', '试用' ) 
+					AND mobile != '' 
+				) 
+				AND w.outbound_mobile = '' ` //OR w.outbound_mobile NOT IN ( SELECT outbound_mobile FROM wx_user )`
+	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
+	return
+}
+
+//获取冻结用户白名单外呼号
+func GetFrozenUserWhiteListOutbound() (items []*WxUserWhite, err error) {
+	sql := `SELECT
+				* 
+			FROM
+				wx_user_white AS w 
+			WHERE
+				w.outbound_mobile NOT IN (
+				SELECT
+					outbound_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 cp.product_id = 2 
+					AND cp.STATUS IN ( '正式', '试用' ) 
+					AND outbound_mobile != '') 
+            AND w.mobile = ''`
+	_, 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
+}

+ 5 - 5
services/activity.go

@@ -229,15 +229,15 @@ func SendEmailFileToExpert(cont context.Context) (err error) {
 		title := activityInfo.ActivityName + "外呼名单"
 		content := "外呼名单详情"
 		fileName := downLoadnFilePath
-		if activityInfo.ChartPermissionName == "科技" {
+		if activityInfo.ChartPermissionName == "科技" || activityInfo.ChartPermissionNames == "研选(科技)" {
 			touser = utils.EmailTechnology
-		} else if activityInfo.ChartPermissionName == "医药" {
+		} else if activityInfo.ChartPermissionName == "医药" || activityInfo.ChartPermissionNames == "研选(医药)" {
 			touser = utils.EmailMedicine
-		} else if activityInfo.ChartPermissionName == "消费" {
+		} else if activityInfo.ChartPermissionName == "消费" || activityInfo.ChartPermissionNames == "研选(消费)" {
 			touser = utils.EmailConsumption
-		} else if activityInfo.ChartPermissionName == "智造" {
+		} else if activityInfo.ChartPermissionName == "智造" || activityInfo.ChartPermissionNames == "研选(智造)" {
 			touser = utils.EmailZhizao
-		} else if activityInfo.ChartPermissionName == "策略" {
+		} else if activityInfo.ChartPermissionName == "策略" || activityInfo.ChartPermissionNames == "研选" {
 			touser = utils.EmailStrategy
 		}
 		go utils.SendEmailHaveFile(title, content, fileName, touser)

+ 9 - 0
services/task.go

@@ -51,6 +51,14 @@ func Task() {
 	sendEmailFileToExpert := task.NewTask("sendEmailFileToExpert", "0 */5 8-22 * * *", SendEmailFileToExpert) //预约外呼名单,会前1小时自动发送邮件给专家组
 	task.AddTask("sendEmailFileToExpert", sendEmailFileToExpert)
 
+	////白名单发送
+	//sendEmailUserWhiteList := task.NewTask("sendEmailUserWhiteList", "0 27 17 * * *", SendEmailUserWhiteList) //预约外呼名单,会前1小时自动发送邮件给专家组
+	//task.AddTask("sendEmailUserWhiteList", sendEmailUserWhiteList)
+
+	//白名单发送2
+	sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteListChange", "0 00 17 * * *", SendEmailUserWhiteListChange) //新增 和冻结的客户白名单
+	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) //同步外呼号码与手机号
@@ -250,6 +258,7 @@ func CreateIndex() {
  }
 }`
 	EsCreateIndex(indexName, mappingJson)
+	AddAllArticle()
 }
 
 func AddAllArticle() {

+ 511 - 0
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"
 )
@@ -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
+}