浏览代码

no message

xingzai 7 月之前
父节点
当前提交
38b0792bce
共有 2 个文件被更改,包括 328 次插入1 次删除
  1. 309 1
      controllers/cygx/report_article.go
  2. 19 0
      models/cygx/summary_manage.go

+ 309 - 1
controllers/cygx/report_article.go

@@ -1978,7 +1978,7 @@ func (this *IndustrialSubjectController) ReportMappingAdd() {
 }
 
 //func init() {
-//	initAct()
+//	initOrderArticle()
 //}
 
 func initart() {
@@ -2548,3 +2548,311 @@ func initarta() {
 	}
 
 }
+
+func initActList() {
+	var condition string
+	var pars []interface{}
+	condition = " AND chart_permission_id = 31 AND activity_time >= '2024-03-01' AND activity_time <= '2024-09-21' AND activity_type_id = 3 AND publish_status = 1 AND yidong_activity_id = ''  ORDER  BY  activity_time  ASC  "
+	list, errList := cygx.GetActivityListAll(condition, pars, 0, 999)
+	if errList != nil {
+		fmt.Println(errList)
+		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()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "活动名称"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "活动时间"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "活动标签"
+
+	for _, item := range list {
+
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = item.ActivityName
+
+		cellBData := row.AddCell()
+		cellBData.Value = item.ActivityTime
+		cellCData := row.AddCell()
+		cellCData.Value = item.Label
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+}
+
+func initOrder() {
+	var condition string
+	var pars []interface{}
+	//condition = " WHERE 1 = 1  AND  source In ('article','yanxuanspecial') AND order_status = 2    GROUP BY  order_id ASC    "
+	condition = "  AND  source In ('activity') AND order_status = 2    GROUP BY  order_id DESC    "
+	list, errList := cygx.GetCygxOrderList(condition, pars, 0, 9999)
+	if errList != nil {
+		fmt.Println(errList)
+		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()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "姓名"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "手机号"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+
+	cellMoney := rowTitle.AddCell()
+	cellMoney.Value = "金额"
+
+	cellname := rowTitle.AddCell()
+	cellname.Value = "活动名称"
+
+	cellTime := rowTitle.AddCell()
+	cellTime.Value = "支付时间"
+
+	for _, item := range list {
+
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = item.RealName
+
+		cellBData := row.AddCell()
+		cellBData.Value = item.Mobile
+		cellCData := row.AddCell()
+		cellCData.Value = item.CompanyName
+
+		cellCMoneyData := row.AddCell()
+		cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
+
+		cellCnameData := row.AddCell()
+		cellCnameData.Value = item.SourceTitle
+
+		cellTimeata := row.AddCell()
+		cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+}
+
+func initOrderArticle() {
+	var condition string
+	var pars []interface{}
+	condition = " AND  source In ('article','yanxuanspecial') AND order_status = 2    GROUP BY  order_id DESC    "
+	list, errList := cygx.GetCygxOrderList(condition, pars, 0, 9999)
+	if errList != nil {
+		fmt.Println(errList)
+		return
+	}
+
+	var articleIds []int
+	var yanxuanArticleids []int
+
+	for _, v := range list {
+		if v.Source == "article" {
+			articleIds = append(articleIds, v.SourceId)
+		}
+		if v.Source == "yanxuanspecial" {
+			yanxuanArticleids = append(yanxuanArticleids, v.SourceId)
+		}
+	}
+
+	pars = make([]interface{}, 0)
+	condition = " AND art.article_id IN (" + utils.GetOrmInReplace(len(articleIds)) + ")  GROUP BY  art.article_id "
+	pars = append(pars, articleIds)
+	mapArtcileNickName := make(map[int]string)
+	listartcile, errList := cygx.GetSummaryManageListInit(condition, pars, 0, 999)
+	if errList != nil {
+		fmt.Println(errList)
+		return
+	}
+	for _, v := range listartcile {
+		mapArtcileNickName[v.ArticleId] = v.NickName
+	}
+	//fmt.Println(mapArtcileNickName)
+	//return
+
+	pars = make([]interface{}, 0)
+	condition = " AND a.id IN (" + utils.GetOrmInReplace(len(yanxuanArticleids)) + ")  "
+	pars = append(pars, yanxuanArticleids)
+	mapArtcileNickNameYx := make(map[int]string)
+	listartcileYx, errList := cygx.GetYanxuanSpecialList(condition, pars, 0, 999)
+	if errList != nil {
+		fmt.Println(errList)
+		return
+	}
+	for _, v := range listartcileYx {
+		mapArtcileNickNameYx[v.Id] = v.NickName
+	}
+
+	//创建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()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "姓名"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "手机号"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "公司名称"
+
+	cellMoney := rowTitle.AddCell()
+	cellMoney.Value = "金额"
+
+	cellname := rowTitle.AddCell()
+	cellname.Value = "报告标题"
+
+	cellNickename := rowTitle.AddCell()
+	cellNickename.Value = "作者"
+
+	cellTime := rowTitle.AddCell()
+	cellTime.Value = "支付时间"
+
+	for _, item := range list {
+
+		row := sheet.AddRow()
+		cellAData := row.AddCell()
+		cellAData.Value = item.RealName
+
+		cellBData := row.AddCell()
+		cellBData.Value = item.Mobile
+		cellCData := row.AddCell()
+		cellCData.Value = item.CompanyName
+
+		cellCMoneyData := row.AddCell()
+		cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
+
+		cellCnameData := row.AddCell()
+		cellCnameData.Value = item.SourceTitle
+
+		cellNickenameData := row.AddCell()
+		if item.Source == "article" {
+			fmt.Println(mapArtcileNickName[item.SourceId])
+			cellNickenameData.Value = mapArtcileNickName[item.SourceId]
+		}
+		if item.Source == "yanxuanspecial" {
+			cellNickenameData.Value = mapArtcileNickNameYx[item.SourceId]
+		}
+
+		cellTimeata := row.AddCell()
+		cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
+	}
+
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+}

+ 19 - 0
models/cygx/summary_manage.go

@@ -320,6 +320,25 @@ func GetSummaryManageList(condition string, pars []interface{}, startSize, pageS
 	return
 }
 
+// 列表
+func GetSummaryManageListInit(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleList, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+	art.title,
+	art.article_id,
+	dm.nick_name,
+	art.top_time 
+FROM
+	cygx_article AS art
+	INNER JOIN cygx_article_department AS dm ON dm.department_id = art.department_id`
+	if condition != "" {
+		sql += condition
+	}
+	sql += `   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 // 列表
 func GetCygxArticleList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportArticle, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")