|
@@ -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
|
|
|
}
|
|
|
|