Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.5

zhangchuanxing 3 months ago
parent
commit
f27ed718bf

+ 406 - 0
controllers/cygx/report_article.go

@@ -4321,3 +4321,409 @@ func initQuanyi() {
 	fmt.Println("end")
 
 }
+
+//func init() {
+//	initUserCompanybill()
+//}
+
+func initBeizhu() {
+
+	productList, err := company.GetCompanyHistoryRemarkListInit()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	var companyids []int
+	for _, v := range productList {
+		companyids = append(companyids, v.CompanyId)
+	}
+
+	listCompany, err := company.GetOverseasCompanysByCompanyIds(companyids)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	mapCompamyName := make(map[int]string)
+
+	for _, v := range listCompany {
+		mapCompamyName[v.CompanyId] = v.CompanyName
+	}
+
+	//创建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 = "客户名称"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "内容"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "类型"
+	cellCSeller := rowTitle.AddCell()
+	cellCSeller.Value = "创建人"
+	cellTime := rowTitle.AddCell()
+	cellTime.Value = "创建时间"
+
+	for _, vE := range productList {
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = mapCompamyName[vE.CompanyId]
+
+		cellBData := row.AddCell()
+		cellBData.Value = vE.Content
+
+		cellCData := row.AddCell()
+		switch vE.TableName {
+		case "company_service_record":
+			cellCData.Value = "沟通记录"
+		case "company_product_remark":
+			cellCData.Value = "备注"
+		case "company_no_renewed_note":
+			cellCData.Value = "未续约备注"
+		case "company_renewal_reason":
+			cellCData.Value = "未续约说明"
+		case "cygx_user_feedback":
+			cellCData.Value = "交流反馈(" + vE.RealName + ")"
+		default:
+			cellCData.Value = "备注"
+		}
+
+		cellNameData := row.AddCell()
+		cellNameData.Value = vE.SysAdminName
+
+		cellDData := row.AddCell()
+		cellDData.Value = vE.ShowTime.Format(utils.FormatDateTime)
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}
+
+func initUserbill() {
+
+	//研选阅读明细
+	var conditionBill string
+	var parsBill []interface{}
+	monthArr := []string{"08", "09", "10", "11", "12"}
+	conditionBill = "  AND  view_time > '2024-07-01'  AND  view_time < '2025-01-01'    "
+
+	listBill, e := cygx.GetCygxRaiCompanyUserBillListAll(conditionBill, parsBill)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapCompanyIds := make(map[int]bool)
+	mapSellerServerCountTotal := make(map[int]float64)
+	mapSellerServerCount := make(map[string]float64)
+	var companyids []int
+	for _, v := range listBill {
+		if mapCompanyIds[v.CompanyId] {
+			continue
+		}
+		companyids = append(companyids, v.CompanyId)
+		mapCompanyIds[v.CompanyId] = true
+
+	}
+
+	//listCompany, err := company.GetOverseasCompanysByCompanyIds(companyids)
+	//if err != nil {
+	//	fmt.Println(err)
+	//	return
+	//}
+
+	//mapCompamyName := make(map[int]string)
+	//
+	//for _, v := range listCompany {
+	//	mapCompamyName[v.CompanyId] = v.CompanyName
+	//}
+
+	companyProductItems, err := company.GetCompanyProductByCompanyIdSAndProductId(companyids, 2)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	mapCompamySeller := make(map[int]int)
+	for _, v := range companyProductItems {
+		mapCompamySeller[v.CompanyId] = v.ShareSellerId
+	}
+
+	for _, v := range listBill {
+		for _, m := range monthArr {
+			vM := v.ViewTime[5:7]
+			if m != vM {
+				continue
+			}
+			//fmt.Println(vM)
+			mapSellerServerCount[fmt.Sprint(mapCompamySeller[v.CompanyId], "_", m)] += v.ServeCount
+		}
+		mapSellerServerCountTotal[(mapCompamySeller[v.CompanyId])] += v.ServeCount
+	}
+
+	adminUserList, err := system.GetRaiAdminInit()
+	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 = "备注"
+	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 = "8月份服务量"
+
+	cellB9 := rowTitle.AddCell()
+	cellB9.Value = "9月份服务量"
+
+	cellB10 := rowTitle.AddCell()
+	cellB10.Value = "10月份服务量"
+
+	cellB11 := rowTitle.AddCell()
+	cellB11.Value = "11月份服务量"
+
+	cellB12 := rowTitle.AddCell()
+	cellB12.Value = "12月份服务量"
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "总服务量"
+
+	for _, vE := range adminUserList {
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = vE.RealName
+
+		cellBData8 := row.AddCell()
+		cellBData8.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_08")])
+
+		cellBData9 := row.AddCell()
+		cellBData9.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_09")])
+
+		cellBData10 := row.AddCell()
+		cellBData10.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_10")])
+
+		cellBData11 := row.AddCell()
+		cellBData11.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_11")])
+
+		cellBData12 := row.AddCell()
+		cellBData12.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_12")])
+
+		cellBData := row.AddCell()
+		cellBData.Value = fmt.Sprint(mapSellerServerCountTotal[vE.AdminId])
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}
+
+func initUserCompanybill() {
+
+	//研选阅读明细
+	var conditionBill string
+	var parsBill []interface{}
+	conditionBill = "  AND  view_time > '2024-07-01'  AND  view_time < '2025-01-01'  AND  company_id IN (98, 1444, 1585, 5332, 6351, 8354, 8683, 9310, 13500)   "
+
+	companyIdsArr := []int{98, 1444, 1585, 5332, 6351, 8354, 8683, 9310, 13500}
+
+	listBill, e := cygx.GetCygxRaiCompanyUserBillListAll(conditionBill, parsBill)
+	if e != nil {
+		fmt.Println(e)
+		return
+	}
+	mapCompanyIds := make(map[int]bool)
+	mapSellerServerCountTotal := make(map[int]float64)
+	mapSellerServerCount := make(map[string]float64)
+	var companyids []int
+	for _, v := range listBill {
+		if mapCompanyIds[v.CompanyId] {
+			continue
+		}
+		companyids = append(companyids, v.CompanyId)
+		mapCompanyIds[v.CompanyId] = true
+
+	}
+
+	listCompany, err := company.GetOverseasCompanysByCompanyIds(companyIdsArr)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	mapCompamyName := make(map[int]string)
+
+	for _, v := range listCompany {
+		mapCompamyName[v.CompanyId] = v.CompanyName
+	}
+	monthArr := []string{"08", "09", "10", "11", "12"}
+	companyProductItems, err := company.GetCompanyProductByCompanyIdSAndProductId(companyids, 2)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	mapCompamySeller := make(map[int]int)
+	for _, v := range companyProductItems {
+		mapCompamySeller[v.CompanyId] = v.ShareSellerId
+	}
+
+	//for _, v := range listBill {
+	//	mapSellerServerCount[v.CompanyId] += v.ServeCount
+	//}
+
+	for _, v := range listBill {
+		for _, m := range monthArr {
+			vM := v.ViewTime[5:7]
+			if m != vM {
+				continue
+			}
+			//fmt.Println(vM)
+			mapSellerServerCount[fmt.Sprint(v.CompanyId, "_", m)] += v.ServeCount
+		}
+		mapSellerServerCountTotal[v.CompanyId] += v.ServeCount
+	}
+	fmt.Println(mapSellerServerCount)
+	//
+	////ficc 研究员
+	//adminUserList, err := system.GetRaiAdminInit()
+	//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 = "公司互动统计"
+	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 = "8月份服务量"
+
+	cellB9 := rowTitle.AddCell()
+	cellB9.Value = "9月份服务量"
+
+	cellB10 := rowTitle.AddCell()
+	cellB10.Value = "10月份服务量"
+
+	cellB11 := rowTitle.AddCell()
+	cellB11.Value = "11月份服务量"
+
+	cellB12 := rowTitle.AddCell()
+	cellB12.Value = "12月份服务量"
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "总服务量"
+
+	for _, vE := range listCompany {
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = vE.CompanyName
+
+		cellBData8 := row.AddCell()
+		cellBData8.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_08")])
+
+		cellBData9 := row.AddCell()
+		cellBData9.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_09")])
+
+		cellBData10 := row.AddCell()
+		cellBData10.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_10")])
+
+		cellBData11 := row.AddCell()
+		cellBData11.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_11")])
+
+		cellBData12 := row.AddCell()
+		cellBData12.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_12")])
+
+		cellBData := row.AddCell()
+		cellBData.Value = fmt.Sprint(mapSellerServerCountTotal[vE.CompanyId])
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}

+ 8 - 0
models/company/company_history_remark.go

@@ -56,6 +56,14 @@ func GetCompanyHistoryRemarkList(CompanyId, ProductId string) (items []*CompanyH
 	return
 }
 
+// GetCompanyHistoryRemarkList 获取备注列表
+func GetCompanyHistoryRemarkListInit() (items []*CompanyHistoryRemark, err error) {
+	o := orm.NewOrm()
+	sql := "SELECT  * FROM  company_history_remark WHERE sys_admin_name LIKE  '%6%'  AND product_id = 2  ORDER BY show_time DESC  "
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 func GetCompanyHistoryRemarkListInitExport() (items []*CompanyHistoryRemark, err error) {
 	o := orm.NewOrm()
 	sql := "SELECT * FROM company_history_remark WHERE product_id=2      AND show_time >= '2024-07-24'    AND show_time < '2024-09-23'   AND  table_name  IN ('company_service_record','company_history_remark') ORDER BY show_time DESC "

+ 40 - 0
models/cygx/rai_serve_week_bill.go

@@ -25,3 +25,43 @@ func GetCygxRaiServeBillListWeek4(companyId int) (items []*CygxRaiServeWeekBill,
 	_, err = o.Raw(sql, companyId).QueryRows(&items)
 	return
 }
+
+// 权益服务明细表
+type CygxRaiCompanyUserBill struct {
+	BillId              int       `orm:"column(bill_id);pk" description:"服务明细主键ID"`
+	Content             string    `comment:"服务内容说明"`
+	ServeTypeId         int       `comment:"服务类型ID"`
+	ServeTypeName       string    `comment:"服务类型"`
+	UserId              int       `comment:"用户ID"`
+	Mobile              string    `comment:"手机号"`
+	Email               string    `comment:"邮箱"`
+	CompanyId           int       `comment:"公司ID"`
+	CompanyName         string    `comment:"公司名称"`
+	RealName            string    `comment:"用户实际名称"`
+	RegisterPlatform    int       `comment:"来源 1小程序,2:网页"`
+	ServeCount          float64   `comment:"服务量小计"`
+	IsKp                int       `comment:"是否是KP,1:是、0:否"`
+	SourceId            int       `comment:"来源ID"`
+	Source              string    `comment:"来源 "`
+	WeekStartDate       string    `comment:"周一开始日期"`
+	WeekEndDate         string    `comment:"周日结束日期"`
+	ChartPermissionId   int       `description:"行业id"`
+	ChartPermissionName string    `description:"行业名称"`
+	CreateTime          time.Time `comment:"创建时间"`
+	ViewTime            string    `comment:"浏览时间"`
+	ViewTimes           time.Time `comment:"浏览时间"`
+}
+
+// 列表
+func GetCygxRaiCompanyUserBillListAll(condition string, pars []interface{}) (items []*CygxRaiCompanyUserBill, err error) {
+	if condition == "" {
+		return
+	}
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT  company_id ,serve_count ,view_time as  view_time  FROM cygx_rai_company_user_bill   WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 8 - 0
models/system/sys_admin.go

@@ -550,3 +550,11 @@ type SyncGroupData struct {
 	Source  int `description:"来源: 1-CRM; 2-ETA"`
 	GroupId int `description:"分组ID"`
 }
+
+// GetRaiAdmin 获取权益内部人员(技术组+私募组)
+func GetRaiAdminInit() (items []*AdminItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM admin WHERE real_name LIKE '%6%'  AND group_name = '权益服务组'  	AND role_type_code = 'rai_seller' `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}