浏览代码

no message

zhangchuanxing 4 月之前
父节点
当前提交
83bd4fab2e
共有 2 个文件被更改,包括 166 次插入6 次删除
  1. 6 4
      controllers/statistic_company_merge.go
  2. 160 2
      controllers/statistic_report.go

+ 6 - 4
controllers/statistic_company_merge.go

@@ -598,7 +598,7 @@ func MergeCompanyListListExport(this *StatisticCompanyMergerController, dataType
 	case "续约客户":
 		cellTime.SetValue("续约时间")
 	case "未续约客户":
-		cellTime.SetValue("最近合同到期时间")
+		cellTime.SetValue("合同期限")
 
 		cellAscribeContent := titleRow.AddCell()
 		cellAscribeContent.SetStyle(style)
@@ -1930,7 +1930,7 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 
 	//权益有效合同
 	condition += ` AND c.product_id = 2   AND  a.status = 1 `
-
+	condition += ` AND c.status not in ("永续","正式","关闭")  `
 	//var list []*models.IncrementalList
 
 	condition1 := condition
@@ -1948,8 +1948,6 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 		return
 	}
 
-	//}
-
 	conditionEnd1 := condition
 	parsEnd1 := pars
 
@@ -2044,6 +2042,8 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 			cellB.Value = "客户状态"
 			cellC := rowTitle.AddCell()
 			cellC.Value = "所属销售"
+			cellCSeller := rowTitle.AddCell()
+			cellCSeller.Value = "服务销售"
 			cellD := rowTitle.AddCell()
 			cellD.Value = "合同期限"
 			cellE := rowTitle.AddCell()
@@ -2064,6 +2064,8 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 				cellBData.Value = item.ProductStatus
 				cellCData := row.AddCell()
 				cellCData.Value = item.SellerName
+				cellCSellerData := row.AddCell()
+				cellCSellerData.Value = item.ShareSeller
 				cellDData := row.AddCell()
 				cellDData.Value = item.StartDate + "~" + item.EndDate
 				cellEData := row.AddCell()

+ 160 - 2
controllers/statistic_report.go

@@ -2340,6 +2340,164 @@ func StackCompanyListExport(this *StatisticReportController, dataType string, re
 	br.Msg = "导出成功"
 }
 
+// StackCompanyListExportRai 获取存量客户数据报表导出
+func StackCompanyListExportRai(this *StatisticReportController, dataType string, resp response.StackCompanyListResp, br *models.BaseResponse) {
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		br.Msg = "生成文件失败"
+		br.ErrMsg = "生成文件失败"
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+
+	sheel, err := xlsxFile.AddSheet("存量客户数据")
+	if err != nil {
+		br.Msg = "新增Sheet失败"
+		br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
+		return
+	}
+	sheel.SetColWidth(0, 0, 30)
+	sheel.SetColWidth(1, 1, 15)
+	sheel.SetColWidth(2, 2, 15)
+	sheel.SetColWidth(3, 3, 18)
+
+	//统计数据
+	statisticRow := sheel.AddRow()
+
+	cell1 := statisticRow.AddCell()
+	cell1.SetStyle(style)
+	cell1.SetValue(fmt.Sprint("新签客户数:", resp.NewCompanyTotal))
+
+	cell2 := statisticRow.AddCell()
+	cell2.SetStyle(style)
+	cell2.SetValue(fmt.Sprint("续约客户数:", resp.RenewalCompanyTotal))
+
+	cell3 := statisticRow.AddCell()
+	cell3.SetStyle(style)
+	cell3.SetValue(fmt.Sprint("未续约客户数:", resp.NotRenewalCompanyTotal))
+	//表头
+
+	titleRow := sheel.AddRow()
+
+	cellName := titleRow.AddCell()
+	cellName.SetStyle(style)
+	cellName.SetValue("客户名称")
+
+	cellProName := titleRow.AddCell()
+	cellProName.SetStyle(style)
+	cellProName.SetValue("客户类型")
+
+	cellSellerName := titleRow.AddCell()
+	cellSellerName.SetStyle(style)
+	cellSellerName.SetValue("所属销售")
+
+	switch dataType {
+	case "未续约客户":
+		cellTime := titleRow.AddCell()
+		cellTime.SetStyle(style)
+		cellTime.SetValue("最近合同到期时间")
+
+		cellRemark := titleRow.AddCell()
+		cellRemark.SetStyle(style)
+		cellRemark.SetValue("未续约说明")
+
+		cellDay := titleRow.AddCell()
+		cellDay.SetStyle(style)
+		cellDay.SetValue("超出过期天数")
+
+		cellAscribeContent := titleRow.AddCell()
+		cellAscribeContent.SetStyle(style)
+		cellAscribeContent.SetValue("不续约归因")
+
+		cellContent := titleRow.AddCell()
+		cellContent.SetStyle(style)
+		cellContent.SetValue("详细原因")
+	default:
+		cellTime := titleRow.AddCell()
+		cellTime.SetStyle(style)
+		cellTime.SetValue("服务期限")
+
+		cellDay := titleRow.AddCell()
+		cellDay.SetStyle(style)
+		cellDay.SetValue("剩余天数")
+	}
+
+	for _, v := range resp.List {
+		dataRow := sheel.AddRow()
+		dataRow.SetHeight(20)
+
+		cellDataName := dataRow.AddCell()
+		cellDataName.SetStyle(style)
+		cellDataName.SetValue(v.CompanyName)
+
+		cellDataProName := dataRow.AddCell()
+		cellDataProName.SetStyle(style)
+		cellDataProName.SetValue(v.ProductName)
+
+		cellDataSellerName := dataRow.AddCell()
+		cellDataSellerName.SetStyle(style)
+		cellDataSellerName.SetValue(v.SellerName)
+
+		cellDataTime := dataRow.AddCell()
+		cellDataTime.SetStyle(style)
+		switch dataType {
+		case "新签客户":
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
+		case "续约客户":
+			cellDataTime.SetValue(fmt.Sprint(v.StartDate, " ~  ", v.EndDate))
+		case "未续约客户":
+			cellDataTime.SetValue(v.EndDate)
+
+			//未续约说明
+			cellDataRemark := dataRow.AddCell()
+			cellDataRemark.SetStyle(style)
+			cellDataRemark.SetValue(v.RenewalReason)
+		}
+
+		cellDay := dataRow.AddCell()
+		cellDay.SetStyle(style)
+		cellDay.SetValue(v.ExpireDay)
+
+		switch dataType {
+		case "未续约客户":
+			cellAscribeContent := dataRow.AddCell()
+			cellAscribeContent.SetStyle(style)
+			cellAscribeContent.SetValue(v.AscribeContent)
+
+			cellContent := dataRow.AddCell()
+			cellContent.SetStyle(style)
+			cellContent.SetValue(v.Content)
+		}
+
+	}
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		br.Msg = "保存文件失败"
+		br.ErrMsg = "保存文件失败"
+		return
+	}
+	randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
+	downloadFileName := "存量客户数据_" + randStr + ".xlsx"
+	this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
+	defer func() {
+		os.Remove(downLoadnFilePath)
+	}()
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "导出成功"
+}
+
 // 获取历史的数据
 func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize, isConfirm, companyAscribeId int, adminId, regionType, companyType, dataType, tryOutType, date, keyword string) (returnData response.StackCompanyListResp, err error) {
 	if date == "" {
@@ -5738,7 +5896,7 @@ func (this *StatisticReportController) InvoicePaymentList() {
 	}
 	if sellerIdstr != "" {
 		//sellerIds := strings.Split(sellerIdstr, ",")
-		cond += ` AND (c.seller_id in (` +sellerIdstr+ `) OR d.seller_id in  (` +sellerIdstr+ `))`
+		cond += ` AND (c.seller_id in (` + sellerIdstr + `) OR d.seller_id in  (` + sellerIdstr + `))`
 		//pars = append(pars, sellerIds, sellerIds)
 	}
 	// 套餐筛选
@@ -6596,7 +6754,7 @@ func (this *StatisticReportController) StackCompanyListRai() {
 
 	//导出excel
 	if isExport {
-		StackCompanyListExport(this, dataType, resp, br)
+		StackCompanyListExportRai(this, dataType, resp, br)
 		return
 	}