소스 검색

更多主题

xingzai 3 년 전
부모
커밋
6bfa00dbb9
5개의 변경된 파일143개의 추가작업 그리고 103개의 파일을 삭제
  1. 1 1
      controllers/activity.go
  2. 1 1
      models/user.go
  3. 48 21
      models/wx_user_white.go
  4. 1 1
      services/task.go
  5. 92 79
      services/user.go

+ 1 - 1
controllers/activity.go

@@ -1689,7 +1689,7 @@ func (this *ActivityCoAntroller) LabelList() {
 	}
 	sqlExport += `) `
 	condition += ` AND art.publish_status = 1  AND art.label != '' `
-	condition += ` AND art.active_state = 1 `
+	//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 + `) `

+ 1 - 1
models/user.go

@@ -303,7 +303,7 @@ func GetFormalUserWhiteList(fieldStr, condition string) (items []*UserWhiteList,
 		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.product_id = 2
 		AND u.company_id >1 ` + condition + `
 		GROUP BY u.user_id`
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)

+ 48 - 21
models/wx_user_white.go

@@ -39,10 +39,10 @@ func GetWxUserWhiteMobile() (mobileStr string, err error) {
 				INNER JOIN company_product AS cp ON cp.company_id = u.company_id 
 			WHERE
 				1 = 1 
-				AND p.product_id = 2 
+				AND cp.product_id = 2 
 				AND u.mobile NOT IN ( SELECT mobile FROM wx_user_white ) 
 				AND u.mobile != ''
-				AND cp.STATUS IN ( '正式', '试用' ) `
+				AND cp.status IN ( '正式', '试用' ) `
 	o := orm.NewOrm()
 	err = o.Raw(sql).QueryRow(&mobileStr)
 	return
@@ -60,10 +60,10 @@ func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
 				INNER JOIN company_product AS cp ON cp.company_id = u.company_id 
 			WHERE
 				1 = 1 
-				AND p.product_id = 2 
+				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 cp.status IN ( '正式', '试用' )
 				AND u.mobile != ''
 				AND u.mobile !=  u.outbound_mobile `
 	o := orm.NewOrm()
@@ -74,25 +74,52 @@ func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
 //获取冻结用户白名单
 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 
+				wx_user_white AS w 
 			WHERE
-				1 = 1 
-				AND p.product_id = 2 
-				AND cp.STATUS IN ( '正式', '试用' ) 
-			)
-	  OR w.outbound_mobile NOT IN ( SELECT outbound_mobile FROM wx_user )`
+				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
 }

+ 1 - 1
services/task.go

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

+ 92 - 79
services/user.go

@@ -636,14 +636,12 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 		msg = "获取失败,Err:" + err.Error()
 		return
 	}
+	fmt.Println("发送附件完成", len(list1))
 	var rep models.UserWhiteListRep
-	for _, v := range list1 {
-		rep.List = append(rep.List, v)
-	}
 	for _, v := range list2 {
-		rep.List = append(rep.List, v)
+		list1 = append(list1, v)
 	}
-
+	rep.List = list1
 	//创建excel
 	dir, errFile := os.Executable()
 	exPath := filepath.Dir(dir)
@@ -694,48 +692,51 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	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 = "专家/医药/智造/消费/研选/科技/策略/路演服务"
+
+	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
 		}
-		cellM.Value = item.Permission
 	}
 	errFile = xlsxFile.Save(downLoadnFilePath)
 	if errFile != nil {
 		msg = "保存文件失败Err:" + errFile.Error()
 		return
 	}
-	title := "新增用户白名单"
-	content := "新增用户白名单"
+	title := time.Now().Format("2006-01-02") + "新增白名单用户"
+	content := time.Now().Format("2006-01-02") + "新增白名单用户"
 	fileName := downLoadnFilePath
 	//if activityInfo.ChartPermissionName == "科技" {
 	//	touser = utils.EmailTechnology
@@ -811,57 +812,66 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	cellM = rowTitle.AddCell()
 	cellM.Value = "权限(消费,医药,智造,科技,策略)"
 	//手机号冻结
-	list3, err := models.GetFrozenUserWhiteList()
+	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
 	}
-	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
+	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
 		}
-		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 = "冻结用户白名单"
+	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")
 	time.Sleep(time.Duration(2) * time.Second) //延迟两秒,避免过多活动的时候邮件发送没有内容
 	defer func() {
 		os.Remove(downLoadnFilePath)
@@ -905,13 +915,16 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 		}
 	}
 
-	for _, v := range list3 {
+	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
 }