|
@@ -2087,6 +2087,8 @@ func IncomeListExport(this *StatisticReportController, resp response.IncomeListR
|
|
|
// @Param DataType query string false "报表类型,枚举值:`新签客户`,`续约客户`,`未续约客户`"
|
|
|
// @Param TryOutType query string false " '试用', '非试用' 非试用即为冻结/流失"
|
|
|
// @Param IsExport query bool false "是否导出excel,默认是false"
|
|
|
+// @Param IsConfirm query int false "是否确认续约: -1-默认全部; 0-待确认; 1-已确认"
|
|
|
+// @Param CompanyAscribeId query int false "归因ID"
|
|
|
// @Success 200 {object} response.StackCompanyListResp
|
|
|
// @router /stack_company_list [get]
|
|
|
func (this *StatisticReportController) StackCompanyList() {
|
|
@@ -2122,6 +2124,10 @@ func (this *StatisticReportController) StackCompanyList() {
|
|
|
keyword := this.GetString("Keyword")
|
|
|
|
|
|
date := this.GetString("Date")
|
|
|
+
|
|
|
+ isConfirm, _ := this.GetInt("IsConfirm", -1) // CRM 13.9
|
|
|
+ companyAscribeId, _ := this.GetInt("CompanyAscribeId", -1) // CRM 13.9
|
|
|
+
|
|
|
if date == "" {
|
|
|
br.Msg = "获取失败,请选择日期"
|
|
|
br.ErrMsg = "获取失败,请选择日期"
|
|
@@ -2144,7 +2150,7 @@ func (this *StatisticReportController) StackCompanyList() {
|
|
|
var resp response.StackCompanyListResp
|
|
|
//历史统计数据
|
|
|
if dateTime < todayTimeNumber {
|
|
|
- tmpResp, err := getHistoryStackCompanyList(sysUser, currentIndex, pageSize, adminId, regionType, companyType, dataType, tryOutType, date, keyword)
|
|
|
+ tmpResp, err := getHistoryStackCompanyList(sysUser, currentIndex, pageSize, isConfirm, companyAscribeId, adminId, regionType, companyType, dataType, tryOutType, date, keyword)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -2153,7 +2159,7 @@ func (this *StatisticReportController) StackCompanyList() {
|
|
|
resp = tmpResp
|
|
|
} else {
|
|
|
//获取实时统计数据(今天数据)
|
|
|
- tmpResp, err := getTodayStackCompanyListV2(sysUser, currentIndex, pageSize, adminId, regionType, companyType, dataType, tryOutType, keyword)
|
|
|
+ tmpResp, err := getTodayStackCompanyListV2(sysUser, currentIndex, pageSize, isConfirm, companyAscribeId, adminId, regionType, companyType, dataType, tryOutType, keyword)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -2249,6 +2255,14 @@ func StackCompanyListExport(this *StatisticReportController, dataType string, re
|
|
|
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)
|
|
@@ -2294,6 +2308,18 @@ func StackCompanyListExport(this *StatisticReportController, dataType string, re
|
|
|
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 {
|
|
@@ -2313,7 +2339,7 @@ func StackCompanyListExport(this *StatisticReportController, dataType string, re
|
|
|
}
|
|
|
|
|
|
// 获取历史的数据
|
|
|
-func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize int, adminId, regionType, companyType, dataType, tryOutType, date, keyword string) (returnData response.StackCompanyListResp, err error) {
|
|
|
+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 == "" {
|
|
|
err = errors.New("请选择日期")
|
|
|
return
|
|
@@ -2335,6 +2361,57 @@ func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
condition += ` AND date = ? `
|
|
|
pars = append(pars, date)
|
|
|
|
|
|
+ var conditionAscribRai string // 处理权益未续约客户检索列表SQL查询条件
|
|
|
+ var parsAscribeRai []interface{}
|
|
|
+ //是否确认续约 CRM 13.9
|
|
|
+ if isConfirm != -1 {
|
|
|
+ var conditionConfirm string
|
|
|
+ var parsConfirm []interface{}
|
|
|
+
|
|
|
+ companyConfirmList, e := company.GetCompanyNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyNoRenewedAscribeList" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ if len(companyConfirmList) == 0 {
|
|
|
+ companyIds = append(companyIds, 0) // 给一个不存在的ID
|
|
|
+ } else {
|
|
|
+ for _, v := range companyConfirmList {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isConfirm == 0 {
|
|
|
+ conditionAscribRai += ` AND c.company_id NOT IN (` + utils.GetOrmInReplace(len(companyIds)) + `)` // 待确认
|
|
|
+ } else {
|
|
|
+ conditionAscribRai += ` AND c.company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)` // 已确认
|
|
|
+ }
|
|
|
+ parsAscribeRai = append(parsAscribeRai, companyIds)
|
|
|
+ }
|
|
|
+
|
|
|
+ //归因ID CRM 13.9
|
|
|
+ if companyAscribeId > 0 {
|
|
|
+ var conditionAscribe string
|
|
|
+ var parsAscribe []interface{}
|
|
|
+ conditionAscribe = " AND company_ascribe_id = ? "
|
|
|
+ parsAscribe = append(parsAscribe, companyAscribeId)
|
|
|
+ companyNoRenewedAscribeList, e := company.GetCompanyNoRenewedAscribeList(conditionAscribe, parsAscribe, 0, 0)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyNoRenewedAscribeList" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ if len(companyNoRenewedAscribeList) == 0 {
|
|
|
+ companyIds = append(companyIds, 0) // 给一个不存在的ID
|
|
|
+ } else {
|
|
|
+ for _, v := range companyNoRenewedAscribeList {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionAscribRai += ` AND c.company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
|
|
|
+ parsAscribeRai = append(parsAscribeRai, companyIds)
|
|
|
+ }
|
|
|
+
|
|
|
if adminId != "" {
|
|
|
condition += ` AND a.seller_id in (` + adminId + `) `
|
|
|
//pars = append(pars, adminId)
|
|
@@ -2428,7 +2505,8 @@ func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
return
|
|
|
}
|
|
|
notRenewalCompanyTotal = total
|
|
|
-
|
|
|
+ condition1 += conditionAscribRai
|
|
|
+ pars1 = append(pars1, parsAscribeRai)
|
|
|
if dataType == "未续约客户" {
|
|
|
//列表页数据总和
|
|
|
//统计数据
|
|
@@ -2493,12 +2571,17 @@ func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
//moreListMap := make(map[int][]*models.StackCompanyStatisticList)
|
|
|
if dataType == "续约客户" {
|
|
|
var ids []string
|
|
|
+ var ascribecompanyIds []int
|
|
|
oldCompanyMap := make(map[int]*models.IncrementalList)
|
|
|
oldMoneyMap := make(map[int]float64)
|
|
|
countMap := make(map[int]int)
|
|
|
for _, item := range list {
|
|
|
ids = append(ids, strconv.Itoa(item.CompanyId))
|
|
|
+ ascribecompanyIds = append(ascribecompanyIds, item.CompanyId)
|
|
|
}
|
|
|
+ //归因标签
|
|
|
+ mapGetCompanyAscribeContent, mapContent := services.GetCompanyAscribeContentMap(ascribecompanyIds)
|
|
|
+ mapNoRenewedNote := services.GetCompanyNoRenewedNoteMap(ascribecompanyIds)
|
|
|
if len(ids) > 0 {
|
|
|
idStr := strings.Join(ids, ",")
|
|
|
lists, contractErr := models.GetLastContractMoney(idStr)
|
|
@@ -2531,6 +2614,9 @@ func getHistoryStackCompanyList(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
item.PackageDifference = "维持套餐"
|
|
|
}
|
|
|
}
|
|
|
+ item.AscribeContent = mapGetCompanyAscribeContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ item.Content = mapContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ item.IsShowNoRenewedNote = mapNoRenewedNote[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2847,7 +2933,7 @@ func getTodayStackCompanyList(sysUser *system.Admin, currentIndex, pageSize int,
|
|
|
return resp, err
|
|
|
}
|
|
|
|
|
|
-func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize int, adminId, regionType, companyType, dataType, tryOutType, keyword string) (returnData response.StackCompanyListResp, err error) {
|
|
|
+func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize, isConfirm, companyAscribeId int, adminId, regionType, companyType, dataType, tryOutType, keyword string) (returnData response.StackCompanyListResp, err error) {
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
|
pageSize = utils.PageSize20
|
|
@@ -2862,6 +2948,56 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
|
|
|
today := utils.GetToday(utils.FormatDate)
|
|
|
//条件
|
|
|
+ var conditionAscribRai string // 处理权益未续约客户检索列表SQL查询条件
|
|
|
+ var parsAscribeRai []interface{}
|
|
|
+ //是否确认续约 CRM 13.9
|
|
|
+ if isConfirm != -1 {
|
|
|
+ var conditionConfirm string
|
|
|
+ var parsConfirm []interface{}
|
|
|
+
|
|
|
+ companyConfirmList, e := company.GetCompanyNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyNoRenewedAscribeList" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ if len(companyConfirmList) == 0 {
|
|
|
+ companyIds = append(companyIds, 0) // 给一个不存在的ID
|
|
|
+ } else {
|
|
|
+ for _, v := range companyConfirmList {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isConfirm == 0 {
|
|
|
+ conditionAscribRai += ` AND ( c.company_id NOT IN (` + utils.GetOrmInReplace(len(companyIds)) + `) AND c.product_id = 2 ) ` // 待确认
|
|
|
+ } else {
|
|
|
+ conditionAscribRai += ` AND ( c.company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `) OR c.product_id = 2 )` // 已确认
|
|
|
+ }
|
|
|
+ parsAscribeRai = append(parsAscribeRai, companyIds)
|
|
|
+ }
|
|
|
+
|
|
|
+ //归因ID CRM 13.9
|
|
|
+ if companyAscribeId > 0 {
|
|
|
+ var conditionAscribe string
|
|
|
+ var parsAscribe []interface{}
|
|
|
+ conditionAscribe = " AND company_ascribe_id = ? "
|
|
|
+ parsAscribe = append(parsAscribe, companyAscribeId)
|
|
|
+ companyNoRenewedAscribeList, e := company.GetCompanyNoRenewedAscribeList(conditionAscribe, parsAscribe, 0, 0)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyNoRenewedAscribeList" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ if len(companyNoRenewedAscribeList) == 0 {
|
|
|
+ companyIds = append(companyIds, 0) // 给一个不存在的ID
|
|
|
+ } else {
|
|
|
+ for _, v := range companyNoRenewedAscribeList {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionAscribRai += ` AND c.company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
|
|
|
+ parsAscribeRai = append(parsAscribeRai, companyIds)
|
|
|
+ }
|
|
|
|
|
|
if adminId != "" {
|
|
|
condition += ` AND c.seller_id in (` + adminId + `) `
|
|
@@ -2879,6 +3015,7 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
if keyword != "" {
|
|
|
condition += ` and b.company_name like "%` + keyword + `%" `
|
|
|
}
|
|
|
+
|
|
|
switch companyType {
|
|
|
case "ficc":
|
|
|
condition += ` AND a.product_id = ? `
|
|
@@ -2971,7 +3108,8 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
return
|
|
|
}
|
|
|
notRenewalCompanyTotal = total
|
|
|
-
|
|
|
+ condition1 += conditionAscribRai
|
|
|
+ pars1 = append(pars1, parsAscribeRai)
|
|
|
if dataType == "未续约客户" {
|
|
|
//页表页数据总和
|
|
|
//统计数据
|
|
@@ -3081,6 +3219,7 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
oldCompanyMap[item.CompanyId] = item
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//给list赋值
|
|
|
for _, item := range list {
|
|
|
if item.ProductName == "权益" {
|
|
@@ -3097,6 +3236,20 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ var ascribecompanyIds []int
|
|
|
+ for _, item := range list {
|
|
|
+ ascribecompanyIds = append(ascribecompanyIds, item.CompanyId)
|
|
|
+ }
|
|
|
+ //归因标签
|
|
|
+ mapGetCompanyAscribeContent, mapContent := services.GetCompanyAscribeContentMap(ascribecompanyIds)
|
|
|
+ mapNoRenewedNote := services.GetCompanyNoRenewedNoteMap(ascribecompanyIds)
|
|
|
+ for _, item := range list {
|
|
|
+ item.AscribeContent = mapGetCompanyAscribeContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ item.Content = mapContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ item.IsShowNoRenewedNote = mapNoRenewedNote[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ }
|
|
|
+
|
|
|
listLen := len(list)
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
item := list[i]
|
|
@@ -3134,12 +3287,15 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
EndDate: v.EndDate,
|
|
|
RegionType: v.RegionType,
|
|
|
//CreateTime :v.CreateTime,
|
|
|
- CreateTimeStr: v.CreateTime,
|
|
|
- ExpireDay: v.ExpireDay,
|
|
|
- RenewalReason: v.RenewalReason,
|
|
|
- RenewalTodo: v.RenewalTodo,
|
|
|
- Status: v.Status,
|
|
|
- PackageDifference: v.PackageDifference,
|
|
|
+ CreateTimeStr: v.CreateTime,
|
|
|
+ ExpireDay: v.ExpireDay,
|
|
|
+ RenewalReason: v.RenewalReason,
|
|
|
+ RenewalTodo: v.RenewalTodo,
|
|
|
+ Status: v.Status,
|
|
|
+ PackageDifference: v.PackageDifference,
|
|
|
+ AscribeContent: v.AscribeContent,
|
|
|
+ IsShowNoRenewedNote: v.IsShowNoRenewedNote,
|
|
|
+ Content: v.Content,
|
|
|
}
|
|
|
stackCompanyStatisticList = append(stackCompanyStatisticList, &stackCompanyStatistic)
|
|
|
}
|
|
@@ -3170,6 +3326,8 @@ func getTodayStackCompanyListV2(sysUser *system.Admin, currentIndex, pageSize in
|
|
|
// @Param DataType query string false "报表类型,枚举值:`新增试用`,`新签客户`,`续约客户`,`未续约客户`"
|
|
|
// @Param TryOutType query string false " '试用', '非试用' 非试用即为冻结/流失"
|
|
|
// @Param IsExport query bool false "是否导出excel,默认是false"
|
|
|
+// @Param IsConfirm query int false "是否确认续约: -1-默认全部; 0-待确认; 1-已确认"
|
|
|
+// @Param CompanyAscribeId query int false "归因ID"
|
|
|
// @Success 200 {object} response.IncrementalCompanyListResp
|
|
|
// @router /incremental_company_list [get]
|
|
|
func (this *StatisticReportController) IncrementalCompanyList() {
|
|
@@ -3199,6 +3357,9 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
|
+
|
|
|
+ isConfirm, _ := this.GetInt("IsConfirm", -1) // CRM 13.9
|
|
|
+ companyAscribeId, _ := this.GetInt("CompanyAscribeId", -1) // CRM 13.9
|
|
|
//if startDate == "" || endDate == "" {
|
|
|
// br.Msg = "获取失败,开始日期或结束日期未传"
|
|
|
// br.ErrMsg = "获取失败,开始日期或结束日期未传"
|
|
@@ -3248,6 +3409,64 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
if keyword != "" {
|
|
|
condition += ` and b.company_name like "%` + keyword + `%" `
|
|
|
}
|
|
|
+
|
|
|
+ var conditionAscribRai string // 处理权益未续约客户检索列表SQL查询条件
|
|
|
+ var conditionAscribRaiTotal string // 处理权益未续约客户总量查询条件
|
|
|
+ var parsAscribeRai []interface{}
|
|
|
+ var parsAscribeRaiTotal []interface{} // 处理权益未续约客户总量查询条件
|
|
|
+ var conditionConfirm string
|
|
|
+ var parsConfirm []interface{}
|
|
|
+
|
|
|
+ companyConfirmList, err := company.GetCompanyNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,GetCompanyNoRenewedAscribeList Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var noRenewedcompanyIds []int //已经确定未续约的公司ID
|
|
|
+ if len(companyConfirmList) == 0 {
|
|
|
+ noRenewedcompanyIds = append(noRenewedcompanyIds, 0) // 给一个不存在的ID
|
|
|
+ } else {
|
|
|
+ for _, v := range companyConfirmList {
|
|
|
+ noRenewedcompanyIds = append(noRenewedcompanyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //是否确认续约 CRM 13.9
|
|
|
+ conditionAscribRaiTotal += ` AND ( c.company_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyIds)) + `) OR c.product_id = 1 )` // 已确认
|
|
|
+ parsAscribeRaiTotal = append(parsAscribeRaiTotal, noRenewedcompanyIds)
|
|
|
+ if isConfirm != -1 {
|
|
|
+ if isConfirm == 0 {
|
|
|
+ conditionAscribRai += ` AND ( c.company_id NOT IN (` + utils.GetOrmInReplace(len(noRenewedcompanyIds)) + `) AND c.product_id = 2 ) ` // 待确认
|
|
|
+ } else {
|
|
|
+ conditionAscribRai += ` AND ( c.company_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyIds)) + `) OR c.product_id = 1 )` // 已确认
|
|
|
+ }
|
|
|
+ parsAscribeRai = append(parsAscribeRai, noRenewedcompanyIds)
|
|
|
+ }
|
|
|
+
|
|
|
+ //归因ID CRM 13.9
|
|
|
+ if companyAscribeId > 0 {
|
|
|
+ var conditionAscribe string
|
|
|
+ var parsAscribe []interface{}
|
|
|
+ conditionAscribe = " AND company_ascribe_id = ? "
|
|
|
+ parsAscribe = append(parsAscribe, companyAscribeId)
|
|
|
+ companyNoRenewedAscribeList, err := company.GetCompanyNoRenewedAscribeList(conditionAscribe, parsAscribe, 0, 0)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,GetCompanyNoRenewedAscribeList Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var companyIds []int
|
|
|
+ if len(companyNoRenewedAscribeList) == 0 {
|
|
|
+ companyIds = append(companyIds, 0) // 给一个不存在的ID
|
|
|
+ } else {
|
|
|
+ for _, v := range companyNoRenewedAscribeList {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ conditionAscribRai += ` AND c.company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
|
|
|
+ parsAscribeRai = append(parsAscribeRai, companyIds)
|
|
|
+ }
|
|
|
+
|
|
|
switch companyType {
|
|
|
case "ficc":
|
|
|
condition += ` AND c.product_id = ? `
|
|
@@ -3493,9 +3712,14 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
pars1 = append(pars1, startDate, tryOutEndDate)
|
|
|
condition1 += ` AND a.operation = ? `
|
|
|
pars1 = append(pars1, "try_out")
|
|
|
- condition1 += ` AND c.status not in ("永续","正式") `
|
|
|
-
|
|
|
- total, err := models.GetIncrementalCompanyCountByOperationRecord(condition1, pars1)
|
|
|
+ condition1 += ` AND c.status not in ("永续","正式","关闭") `
|
|
|
+
|
|
|
+ //未续约这里只统计已经确定的
|
|
|
+ notRenewalCondition := condition1
|
|
|
+ notRenewalPars := pars1
|
|
|
+ notRenewalCondition += conditionAscribRaiTotal
|
|
|
+ notRenewalPars = append(notRenewalPars, parsAscribeRaiTotal)
|
|
|
+ total, err := models.GetIncrementalCompanyCountByOperationRecord(notRenewalCondition, notRenewalPars)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -3503,6 +3727,8 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
}
|
|
|
notRenewalCompanyTotal = total
|
|
|
|
|
|
+ condition1 += conditionAscribRai
|
|
|
+ pars1 = append(pars1, parsAscribeRai)
|
|
|
if dataType == "未续约客户" {
|
|
|
//统计数据
|
|
|
for _, v := range []string{"试用", "非试用"} {
|
|
@@ -3546,6 +3772,13 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
// return
|
|
|
//}
|
|
|
|
|
|
+ //分页total单独计算
|
|
|
+ total, err = models.GetIncrementalCompanyProductCountByOperationRecord(condition1, pars1)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
//列表页数据
|
|
|
tmpList, err := models.GetIncrementalCompanyListByOperationRecord(condition1, pars1, startSize, pageSize)
|
|
|
if err != nil {
|
|
@@ -3553,9 +3786,21 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ var ascribecompanyIds []int
|
|
|
for _, item := range tmpList {
|
|
|
endDateTime, _ := time.Parse(utils.FormatDateTime, item.CreateTime)
|
|
|
item.EndDate = endDateTime.Format(utils.FormatDate)
|
|
|
+ ascribecompanyIds = append(ascribecompanyIds, item.CompanyId)
|
|
|
+ }
|
|
|
+ //归因标签
|
|
|
+ mapGetCompanyAscribeContent, mapContent := services.GetCompanyAscribeContentMap(ascribecompanyIds)
|
|
|
+ mapNoRenewedNote := services.GetCompanyNoRenewedNoteMap(ascribecompanyIds)
|
|
|
+
|
|
|
+ for _, item := range tmpList {
|
|
|
+ item.AscribeContent = mapGetCompanyAscribeContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ item.Content = mapContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
+ item.IsShowNoRenewedNote = mapNoRenewedNote[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
|
|
|
}
|
|
|
list = tmpList
|
|
|
dataTotal = total
|
|
@@ -3588,6 +3833,9 @@ func (this *StatisticReportController) IncrementalCompanyList() {
|
|
|
|
|
|
listLen := len(list)
|
|
|
|
|
|
+ if listLen == 0 {
|
|
|
+ list = make([]*models.IncrementalList, 0)
|
|
|
+ }
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
item := list[i]
|
|
|
|
|
@@ -3780,6 +4028,14 @@ func IncrementalCompanyListExport(this *StatisticReportController, dataType stri
|
|
|
cellTime.SetValue("续约时间")
|
|
|
case "未续约客户":
|
|
|
cellTime.SetValue("最近合同到期时间")
|
|
|
+
|
|
|
+ cellAscribeContent := titleRow.AddCell()
|
|
|
+ cellAscribeContent.SetStyle(style)
|
|
|
+ cellAscribeContent.SetValue("不续约归因")
|
|
|
+
|
|
|
+ cellContent := titleRow.AddCell()
|
|
|
+ cellContent.SetStyle(style)
|
|
|
+ cellContent.SetValue("详细原因")
|
|
|
}
|
|
|
|
|
|
for _, v := range resp.List {
|
|
@@ -3820,6 +4076,14 @@ func IncrementalCompanyListExport(this *StatisticReportController, dataType stri
|
|
|
cellDataTime.SetValue(v.StartDate)
|
|
|
case "未续约客户":
|
|
|
cellDataTime.SetValue(v.EndDate)
|
|
|
+
|
|
|
+ cellAscribeContent := dataRow.AddCell()
|
|
|
+ cellAscribeContent.SetStyle(style)
|
|
|
+ cellAscribeContent.SetValue(v.AscribeContent)
|
|
|
+
|
|
|
+ cellContent := dataRow.AddCell()
|
|
|
+ cellContent.SetStyle(style)
|
|
|
+ cellContent.SetValue(v.Content)
|
|
|
}
|
|
|
|
|
|
}
|