浏览代码

no message

zhangchuanxing 1 周之前
父节点
当前提交
c1853b1ab1
共有 3 个文件被更改,包括 423 次插入0 次删除
  1. 332 0
      controllers/cygx/report_article.go
  2. 12 0
      models/company/company_product.go
  3. 79 0
      models/cygx/activity_signup_detail.go

+ 332 - 0
controllers/cygx/report_article.go

@@ -7256,3 +7256,335 @@ func initActComapny() {
 	}
 
 }
+
+func initexcel() {
+	path := "./007.xlsx"
+	xlFile, err := xlsx.OpenFile(path)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var companyName string
+	var name string
+	var phone string
+	var phone2 string
+	var mobiles []string
+	for _, sheet := range xlFile.Sheets {
+		maxRow := sheet.MaxRow
+		for i := 0; i < maxRow; i++ {
+			if i >= 1 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				for k, cell := range cells {
+					if k == 1 {
+						companyName = cell.String()
+					}
+					if k == 4 {
+						name = cell.String()
+					}
+					if k == 11 {
+						phone = cell.String()
+					}
+					if k == 13 {
+						phone2 = cell.String()
+					}
+					mobiles = append(mobiles, phone, phone2)
+				}
+				fmt.Println(fmt.Sprint("公司名称", companyName, "_姓名", name, "_手机号", phone, "_手机号2", phone2))
+			}
+		}
+	}
+
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+
+	redStyle := xlsx.NewStyle()
+	redStyle.Alignment = alignment
+	redStyle.ApplyAlignment = true
+	redStyle.Font.Color = "ff0000"
+	//定义底色需要标黄的 单元格颜色
+	redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
+	redStyle.Fill = redFill
+	//redStyle.Border = *border
+
+	var sheetName string
+	sheetName = "到会信息"
+	sheetF, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheetF.AddRow()
+
+	cellMobile := rowTitle.AddCell()
+	cellMobile.Value = "手机号"
+
+	cellAct := rowTitle.AddCell()
+	cellAct.Value = "姓名"
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "公司名"
+
+	cellActime := rowTitle.AddCell()
+	cellActime.Value = "活动名称"
+
+	cellD := rowTitle.AddCell()
+	cellD.Value = "活动类型"
+
+	cellE := rowTitle.AddCell()
+	cellE.Value = "活动时间"
+
+	cellCom := rowTitle.AddCell()
+	cellCom.Value = "首次入会时间"
+
+	cellComL := rowTitle.AddCell()
+	cellComL.Value = "最后退出时间"
+
+	cellComDu := rowTitle.AddCell()
+	cellComDu.Value = "参与时长"
+
+	listData, err := cygx.GetSignupDetailListinit(mobiles)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	mobileItems := make(map[string][]*cygx.CygxActivitySignupDetailInit)
+
+	for _, v := range listData {
+		mobileItems[v.OutboundMobile] = append(mobileItems[v.OutboundMobile], v)
+	}
+
+	for _, sheet := range xlFile.Sheets {
+		maxRow := sheet.MaxRow
+		for i := 0; i < maxRow; i++ {
+			if i >= 1 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				for k, cell := range cells {
+					if k == 1 {
+						companyName = cell.String()
+					}
+					if k == 4 {
+						name = cell.String()
+					}
+					if k == 11 {
+						phone = cell.String()
+					}
+					if k == 13 {
+						phone2 = cell.String()
+					}
+				}
+				if len(mobileItems[phone]) == 0 {
+					continue
+				}
+				for _, vD := range mobileItems[phone] {
+
+					rowD := sheetF.AddRow()
+					cellActData := rowD.AddCell()
+					cellActData.Value = phone
+
+					cellNameData := rowD.AddCell()
+					cellNameData.Value = name
+
+					cellComNameData := rowD.AddCell()
+					cellComNameData.Value = companyName
+
+					cellActNameData := rowD.AddCell()
+					cellActNameData.Value = vD.ActivityName
+
+					cellActivityTypeNameData := rowD.AddCell()
+					cellActivityTypeNameData.Value = vD.ActivityTypeName
+
+					cellActivityTimeData := rowD.AddCell()
+					cellActivityTimeData.Value = vD.ActivityTime
+
+					cellActivityTimeFData := rowD.AddCell()
+					cellActivityTimeFData.Value = vD.FirstMeetingTime
+
+					cellActivityTimeLData := rowD.AddCell()
+					cellActivityTimeLData.Value = vD.LastMeetingTime
+
+					cellActivityTimeDuData := rowD.AddCell()
+					cellActivityTimeDuData.Value = vD.Duration
+				}
+			}
+		}
+	}
+
+	for _, sheet := range xlFile.Sheets {
+		maxRow := sheet.MaxRow
+		for i := 0; i < maxRow; i++ {
+			if i >= 1 {
+				row := sheet.Row(i)
+				cells := row.Cells
+				for k, cell := range cells {
+					if k == 1 {
+						companyName = cell.String()
+					}
+					if k == 4 {
+						name = cell.String()
+					}
+					//if k == 11 {
+					//	phone = cell.String()
+					//}
+					if k == 13 {
+						phone = cell.String()
+					}
+				}
+				if len(mobileItems[phone]) == 0 {
+					continue
+				}
+				for _, vD := range mobileItems[phone] {
+
+					rowD := sheetF.AddRow()
+					cellActData := rowD.AddCell()
+					cellActData.Value = phone
+
+					cellNameData := rowD.AddCell()
+					cellNameData.Value = name
+
+					cellComNameData := rowD.AddCell()
+					cellComNameData.Value = companyName
+
+					cellActNameData := rowD.AddCell()
+					cellActNameData.Value = vD.ActivityName
+
+					cellActivityTypeNameData := rowD.AddCell()
+					cellActivityTypeNameData.Value = vD.ActivityTypeName
+
+					cellActivityTimeData := rowD.AddCell()
+					cellActivityTimeData.Value = vD.ActivityTime
+
+					cellActivityTimeFData := rowD.AddCell()
+					cellActivityTimeFData.Value = vD.FirstMeetingTime
+
+					cellActivityTimeLData := rowD.AddCell()
+					cellActivityTimeLData.Value = vD.LastMeetingTime
+
+					cellActivityTimeDuData := rowD.AddCell()
+					cellActivityTimeDuData.Value = vD.Duration
+				}
+			}
+		}
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+}
+
+// 固收类型互动记录
+func initgggg() {
+	listDataAct, err := cygx.GetSignupDetailListGushou()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	listDataArt, err := cygx.GetSignupDetailListGushouArt()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	companyids := make(map[int]bool)
+	for _, v := range listDataAct {
+		companyids[v.CompanyId] = true
+	}
+
+	for _, v := range listDataArt {
+		companyids[v.CompanyId] = true
+	}
+	fmt.Println(companyids)
+
+	listComapny, err := company.GetCompanyProductsByCompanyIds508()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+
+	redStyle := xlsx.NewStyle()
+	redStyle.Alignment = alignment
+	redStyle.ApplyAlignment = true
+	redStyle.Font.Color = "ff0000"
+	//定义底色需要标黄的 单元格颜色
+	redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
+	redStyle.Fill = redFill
+	//redStyle.Border = *border
+
+	var sheetName string
+	sheetName = "固收公司状态"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+
+	cellDCreatedTime := rowTitle.AddCell()
+	cellDCreatedTime.Value = "状态"
+
+	cellDCreatedTimeS := rowTitle.AddCell()
+	cellDCreatedTimeS.Value = "所属销售"
+
+	for _, v := range listComapny {
+		if !companyids[v.CompanyId] {
+			continue
+		}
+		row := sheet.AddRow()
+		cellADatatitle := row.AddCell()
+		cellADatatitle.Value = v.CompanyName
+
+		cellADataPd := row.AddCell()
+		cellADataPd.Value = v.Status
+
+		cellADataPds := row.AddCell()
+		cellADataPds.Value = v.SellerName
+	}
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	return
+}

+ 12 - 0
models/company/company_product.go

@@ -133,6 +133,18 @@ WHERE
 	return
 }
 
+func GetCompanyProductsByCompanyIds508() (items []*CompanyProductDetail, err error) {
+	sql := `SELECT
+	a.status,c.company_name ,c.company_id,a.seller_name
+FROM company_product AS a 
+	INNER JOIN company AS c ON c.company_id = a.company_id 
+WHERE
+	 a.product_id = 2  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 func GetCompanyProductById(companyProductId int) (item *CompanyProduct, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM company_product WHERE company_product_id=? `

+ 79 - 0
models/cygx/activity_signup_detail.go

@@ -2,6 +2,7 @@ package cygx
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hz_crm_api/utils"
 	"time"
 )
 
@@ -156,3 +157,81 @@ func UpdateActivitySignupDetailMultiByYiDong(items []*CygxActivitySignupDetail)
 	}
 	return
 }
+
+type CygxActivitySignupDetailInit struct {
+	ActivityTypeName string `description:"活动类型名称"`
+	ActivityName     string `description:"活动名称"`
+	ActivityTime     string `description:"活动时间"`
+	OutboundMobile   string `description:"外呼手机号"`
+	FirstMeetingTime string `description:"首次入会时间"`
+	LastMeetingTime  string `description:"最后退出时间"`
+	Duration         string `description:"参会时长"`
+}
+
+// 获取参会记录表列表
+func GetSignupDetailListinit(mobiles []string) (list []*CygxActivitySignupDetailInit, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			a.activity_name,
+			a.activity_type_name,
+			a.activity_time,
+			b.first_meeting_time,
+			b.last_meeting_time,
+			b.duration,
+			b.outbound_mobile 
+		FROM
+			cygx_activity AS a
+			INNER JOIN cygx_activity_signup_detail AS b ON a.activity_id = b.activity_id 
+			AND a.publish_status = 1 
+			AND a.activity_time > '2024-11-01' 
+			AND ( b.is_meeting = 1 OR duration != '' )  AND  b.outbound_mobile  IN (` + utils.GetOrmInReplace(len(mobiles)) + `)  	ORDER BY a.activity_time  ASC  `
+	_, err = o.Raw(sql, mobiles).QueryRows(&list)
+	return
+}
+
+// 获取参会记录表列表
+func GetSignupDetailListGushou() (list []*CygxActivitySignupDetail, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+	company_id
+FROM
+	cygx_activity_signup_detail 
+WHERE
+	activity_id IN (
+	SELECT
+		activity_id 
+	FROM
+		cygx_activity 
+	WHERE
+	chart_permission_id = 53 
+	AND publish_status = 1)
+		AND company_id > 1 
+	GROUP   BY company_id  
+  `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+// 获取参会记录表列表
+func GetSignupDetailListGushouArt() (list []*CygxActivitySignupDetail, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+	company_id
+FROM
+	cygx_article_history_record_all 
+WHERE
+	article_id IN (
+	SELECT
+		article_id  
+	FROM
+		cygx_article
+	WHERE
+	chart_permission_id = 53 
+	AND publish_status = 1)
+		AND company_id > 1 
+	GROUP   BY company_id  
+	LIMIT 1000  
+  `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}