Browse Source

no message

zhangchuanxing 3 months ago
parent
commit
ae66566634
3 changed files with 139 additions and 1 deletions
  1. 105 1
      controllers/cygx/report_article.go
  2. 26 0
      models/statistic_report.go
  3. 8 0
      models/system/sys_admin.go

+ 105 - 1
controllers/cygx/report_article.go

@@ -4323,7 +4323,7 @@ func initQuanyi() {
 }
 
 //func init() {
-//	initUserCompanybill()
+//	initQuanyiXiaoShou()
 //}
 
 func initBeizhu() {
@@ -4727,3 +4727,107 @@ func initUserCompanybill() {
 	fmt.Println("end")
 
 }
+
+func initQuanyiXiaoShou() {
+
+	adminUserList, err := system.GetRaiAdminInitRai()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	adminMap := make(map[int]bool)
+	for _, vE := range adminUserList {
+		adminMap[vE.AdminId] = true
+	}
+
+	//研选阅读明细
+	var conditionBill string
+	var parsBill []interface{}
+
+	//列表页数据
+	tmpList, err := models.GetIncrementalCompanyListByOperationRecordIniut(conditionBill, parsBill, 0, 9999)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	mapOperationadd := make(map[int]int)
+	mapOperationreceive := make(map[int]int)
+
+	for _, v := range tmpList {
+		if !adminMap[v.SellerId] {
+			fmt.Println("v.CompanyId", v.CompanyId)
+			return
+		}
+
+		if v.Operation == "add" {
+			mapOperationadd[v.SellerId]++
+		} else {
+			mapOperationreceive[v.SellerId]++
+		}
+	}
+
+	//创建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 = "2023年2季度"
+	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 = "领取"
+
+	for _, vE := range adminUserList {
+		//if mapOperationadd[vE.AdminId]+mapOperationreceive[vE.AdminId] == 0 {
+		//	continue
+		//}
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = vE.RealName
+
+		cellBData8 := row.AddCell()
+		cellBData8.Value = fmt.Sprint(mapOperationadd[vE.AdminId] + mapOperationreceive[vE.AdminId])
+
+		cellBData9 := row.AddCell()
+		cellBData9.Value = fmt.Sprint(mapOperationadd[vE.AdminId])
+
+		cellBData10 := row.AddCell()
+		cellBData10.Value = fmt.Sprint(mapOperationreceive[vE.AdminId])
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+
+}

+ 26 - 0
models/statistic_report.go

@@ -414,6 +414,7 @@ type IncrementalList struct {
 	SellerIdInit    int    `description:"权益初始化销售ID"`
 	SellerIdLast    int    `description:"合同到期之前最后所属销售ID"`
 	ShareSellerInit string `description:"共享销售员"`
+	Operation       string `description:"共享销售员"`
 }
 
 // GetIncrementalNewCompanyCount 获取增量客户报表列表统计数据(根据合同来展示)
@@ -811,6 +812,31 @@ where a.id in (` + sql1 + `) order by  create_time DESC,company_id DESC limit ?,
 	return
 }
 
+// GetIncrementalCompanyListByOperationRecord 获取试用客户报表列表数据(根据新增客户时间来展示)
+func GetIncrementalCompanyListByOperationRecordIniut(condition string, pars []interface{}, startSize, pageSize int) (items []*IncrementalList, err error) {
+	o := orm.NewOrm()
+
+	//查询真正的数据
+	sql := `SELECT
+			a.*,
+			b.company_name 
+		FROM
+			company_operation_record a
+			RIGHT JOIN company b ON a.company_id = b.company_id
+			JOIN company_product c ON b.company_id = c.company_id 
+			AND a.product_id = c.product_id 
+		WHERE
+			1 = 1 
+			AND c.product_id = 2 
+			AND a.create_time >= '2024-10-01' 
+			AND a.create_time <= '2024-12-31' 
+			AND a.operation IN ( 'add', 'receive' ) 
+		GROUP BY
+			a.company_id, a.product_id`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // GetIncrementalCompanyListByOperationRecordLast 获取试用客户报表列表数据(根据新增客户时间来展示)
 func GetIncrementalCompanyListByOperationRecordLast(condition string, pars []interface{}, startSize, pageSize int) (items []*IncrementalList, err error) {
 	o := orm.NewOrm()

+ 8 - 0
models/system/sys_admin.go

@@ -558,3 +558,11 @@ func GetRaiAdminInit() (items []*AdminItem, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// GetRaiAdmin 获取权益内部人员(技术组+私募组)
+func GetRaiAdminInitRai() (items []*AdminItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM admin  WHERE  role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}