瀏覽代碼

no message

zhangchuanxing 1 月之前
父節點
當前提交
5b0235981d

+ 131 - 0
controllers/cygx/report_article.go

@@ -6009,3 +6009,134 @@ func initActZHouqi() {
 	}
 	fmt.Println("end")
 }
+
+//func init() {
+//	initPointBill()
+//}
+
+// 研选扣点明细,与专项调研明细
+func initPointBill() {
+	//行业
+	var condition string
+	var pars []interface{}
+
+	activitySpecialPermissionPointsList, e := cygx.GetCygxActivitySpecialPermissionPointsList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	activityYxPermissionPointsList, e := cygx.GetCygxActivityPointsCompanyByCompanyList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	var companyIds []int
+	mapPointSpeial := make(map[int]float64)
+	mapPointYx := make(map[int]float64)
+	for _, v := range activitySpecialPermissionPointsList {
+		companyIds = append(companyIds, v.CompanyId)
+		mapPointSpeial[v.CompanyId] += v.Pointsf
+	}
+	for _, v := range activityYxPermissionPointsList {
+		companyIds = append(companyIds, v.CompanyId)
+		mapPointYx[v.CompanyId] += v.Points
+	}
+
+	listCompanyProduct, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyIds)
+	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()
+
+	cellB := rowTitle.AddCell()
+	cellB.Value = "客户名称"
+
+	cellPd := rowTitle.AddCell()
+	cellPd.Value = "销售"
+	//cellA := rowTitle.AddCell()
+	//cellA.Value = "系列"
+
+	cellAt := rowTitle.AddCell()
+	cellAt.Value = "服务销售"
+
+	cellUser := rowTitle.AddCell()
+	cellUser.Value = "客户状态"
+
+	cellCompany := rowTitle.AddCell()
+	cellCompany.Value = "研选点数"
+
+	cellTime := rowTitle.AddCell()
+	cellTime.Value = "专项调研点数"
+
+	for _, v := range listCompanyProduct {
+		if mapPointSpeial[v.CompanyId] == 0 && mapPointYx[v.CompanyId] == 0 {
+			continue
+		}
+		row := sheet.AddRow()
+		cellADatatitle := row.AddCell()
+		cellADatatitle.Value = v.CompanyName
+
+		cellADataPd := row.AddCell()
+
+		cellADataPd.Value = v.SellerName
+
+		cellBData := row.AddCell()
+		cellBData.Value = v.ShareSeller
+
+		cellUserData := row.AddCell()
+		cellUserData.Value = v.Status
+
+		cellCompanyData := row.AddCell()
+		cellCompanyData.Value = fmt.Sprint(mapPointYx[v.CompanyId])
+
+		cellTimeData := row.AddCell()
+		cellTimeData.Value = fmt.Sprint(mapPointSpeial[v.CompanyId])
+
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("end")
+}

+ 11 - 0
models/cygx/activity_points_company.go

@@ -29,3 +29,14 @@ func GetCompanyPoints(companyId int) (comapnyPointsNum float64, err error) {
 	err = o.Raw(sql, companyId).QueryRow(&comapnyPointsNum)
 	return
 }
+
+// 获取公司每个行业剩余研选点数列表
+func GetCygxActivityPointsCompanyByCompanyList(condition string, pars []interface{}) (items []*CygxActivityPointsCompany, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_activity_points_company WHERE 1 = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 2 - 1
models/cygx/activity_special_permission_points.go

@@ -11,6 +11,7 @@ type CygxActivitySpecialPermissionPoints struct {
 	Id                  int       `orm:"column(id);pk"`
 	CompanyId           int       `description:"公司ID"`
 	Points              int       `description:"剩余点数"`
+	Pointsf             float64   `description:"剩余点数"`
 	CompanyName         string    `description:"公司名称"`
 	ChartPermissionId   int       `description:"行业id"`
 	ChartPermissionName string    `description:"行业名称"`
@@ -81,7 +82,7 @@ func MultiAddCygxActivitySpecialPermissionPoints(items []*CygxActivitySpecialPer
 // 获取公司每个行业剩余研选点数列表
 func GetCygxActivitySpecialPermissionPointsList(condition string, pars []interface{}) (items []*CygxActivitySpecialPermissionPoints, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_activity_special_permission_points WHERE 1 = 1  `
+	sql := `SELECT * , points as pointsf FROM cygx_activity_special_permission_points WHERE 1 = 1  `
 	if condition != "" {
 		sql += condition
 	}