瀏覽代碼

no message

zhangchuanxing 1 月之前
父節點
當前提交
20c40430b5
共有 3 個文件被更改,包括 249 次插入3 次删除
  1. 193 3
      controllers/cygx/report_article.go
  2. 21 0
      models/company/company_contract.go
  3. 35 0
      models/cygx/cygx_user.go

+ 193 - 3
controllers/cygx/report_article.go

@@ -5245,9 +5245,10 @@ func initart121_1() {
 	}
 }
 
-//	func init() {
-//		initAct33()
-//	}
+//func init() {
+//	initContract()
+//}
+
 func initAct33() {
 	//行业
 	var condition string
@@ -5485,3 +5486,192 @@ func initart33() {
 	}
 	return
 }
+
+func initUserKw() {
+	listKw, e := cygx.GetCygxSearchKeyWordListInit()
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapCompanyIds := make(map[int]bool)
+	var companyids []int
+	for _, v := range listKw {
+		if mapCompanyIds[v.CompanyId] {
+			continue
+		}
+		companyids = append(companyids, v.CompanyId)
+		mapCompanyIds[v.CompanyId] = true
+
+	}
+
+	companyProductItems, err := company.GetCompanyProductByCompanyIdSAndProductId(companyids, 2)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	mapCompamyStatus := make(map[int]string)
+	for _, v := range companyProductItems {
+		mapCompamyStatus[v.CompanyId] = v.Status
+	}
+
+	//创建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
+
+	var sheetName string
+	sheetName = "关键词搜索统计"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "搜索词"
+	cellB8 := rowTitle.AddCell()
+	cellB8.Value = "手机号"
+
+	cellB9 := rowTitle.AddCell()
+	cellB9.Value = "姓名"
+
+	cellB10 := rowTitle.AddCell()
+	cellB10.Value = "公司"
+
+	cellB11 := rowTitle.AddCell()
+	cellB11.Value = "状态"
+
+	cellB12 := rowTitle.AddCell()
+	cellB12.Value = "搜索时间"
+
+	for _, vE := range listKw {
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = vE.KeyWord
+
+		cellBData8 := row.AddCell()
+		cellBData8.Value = vE.Mobile
+
+		cellBData9 := row.AddCell()
+		cellBData9.Value = vE.RealName
+
+		cellBData10 := row.AddCell()
+		cellBData10.Value = vE.CompanyName
+
+		cellBData11 := row.AddCell()
+		cellBData11.Value = mapCompamyStatus[vE.CompanyId]
+
+		cellBData12 := row.AddCell()
+		cellBData12.Value = vE.CreateTime
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}
+
+func initContract() {
+	listContractList, e := company.CompanyContractList()
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+
+	var companyContractIds []int
+	for _, v := range listContractList {
+		companyContractIds = append(companyContractIds, v.CompanyContractId)
+	}
+
+	//合并合同所对应的权限
+	mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
+	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
+
+	var sheetName string
+	sheetName = "35W公司统计"
+	sheet, err := xlsxFile.AddSheet(sheetName)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "客户名称"
+	cellB8 := rowTitle.AddCell()
+	cellB8.Value = "销售"
+
+	cellB9 := rowTitle.AddCell()
+	cellB9.Value = "服务销售"
+
+	cellB10 := rowTitle.AddCell()
+	cellB10.Value = "合同金额"
+
+	cellB11 := rowTitle.AddCell()
+	cellB11.Value = "签约套餐"
+
+	for _, vE := range listContractList {
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = vE.CompanyName
+
+		cellBData8 := row.AddCell()
+		cellBData8.Value = vE.SellerNameLast
+
+		cellBData9 := row.AddCell()
+		cellBData9.Value = vE.ShareSellerLast
+
+		cellBData10 := row.AddCell()
+		cellBData10.Value = fmt.Sprint(vE.Money)
+
+		cellBData11 := row.AddCell()
+		cellBData11.Value = mappermissionName[vE.CompanyContractId]
+
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}

+ 21 - 0
models/company/company_contract.go

@@ -13,6 +13,7 @@ type CompanyContract struct {
 	ProductId         int       `description:"产品id"`
 	ProductName       string    `description:"产品名称"`
 	CompanyId         int       `description:"客户id"`
+	CompanyName       string    `description:"客户id"`
 	CompanyProductId  int       `description:"客户产品id"`
 	ContractCode      string    `description:"合同编码"`
 	StartDate         string    `description:"合同开始时间"`
@@ -38,6 +39,26 @@ type CompanyContract struct {
 	ShareSellerIdLast int       `description:"合同到期之前最后所属共享销售员id"`
 }
 
+// GetCompanyContractPermissionByCompanyContractId 根据合同ID获取开通的权限
+func CompanyContractList() (items []*CompanyContract, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	a.company_name,
+	c.* 
+FROM
+	company_contract AS c
+	INNER JOIN company a ON a.company_id = c.company_id 
+WHERE
+	1 = 1 
+	AND c.company_id IN ( SELECT company_id FROM company_product WHERE 1 = 1 AND status = '正式' AND product_id = 2 ) 
+	AND c.status = 1
+	AND c.product_id = 2 
+	AND c.end_date > '2025-02-24' 
+	AND c.money >= '350000' `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 新增客户合同
 func AddCompanyContract(item *CompanyContract) (lastId int64, err error) {
 	o := orm.NewOrm()

+ 35 - 0
models/cygx/cygx_user.go

@@ -1460,3 +1460,38 @@ FROM
 	_, err = o.Raw(sql).QueryRows(&emails)
 	return
 }
+
+type CygxSearchKeyWord struct {
+	Id               int `orm:"column(id);" description:"id"`
+	KeyWord          string
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string `description:"手机号"`
+	Email            string `description:"邮箱"`
+	CompanyId        int    `description:"公司id"`
+	CompanyName      string `description:"公司名称"`
+	RealName         string `description:"用户实际名称"`
+	RegisterPlatform int    `description:"来源 1小程序,2:网页"`
+}
+
+// 用户搜索关键词列表
+func GetCygxSearchKeyWordListInit() (items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			key_word,
+			mobile,
+			real_name,
+			company_name,
+			company_id,
+			create_time 
+		FROM
+			cygx_search_key_word AS k 
+		WHERE
+			create_time > '2024-11-23' 
+			AND create_time < '2025-02-23' AND company_id > 0 
+		ORDER BY
+			k.create_time DESC 
+			LIMIT 100000 `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}