|
@@ -9,6 +9,7 @@ import (
|
|
|
"hongze/hz_crm_api/models/fms"
|
|
|
"hongze/hz_crm_api/models/statistic_report"
|
|
|
"hongze/hz_crm_api/models/system"
|
|
|
+ "hongze/hz_crm_api/services"
|
|
|
cygxService "hongze/hz_crm_api/services/cygx"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
"strconv"
|
|
@@ -151,22 +152,6 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
mapNewCustomerInvoicingMoney := make(map[string]float64) // 财务系统新客开票金额(金额)
|
|
|
mapNewCustomerPaymentsReceivedMoney := make(map[string]float64) // 财务系统新客到款金额(金额)
|
|
|
|
|
|
- //mapAddTrialNumTotal := make(map[string]float64) // 新增试用-(数据)_总计
|
|
|
- //mapNewContractMoneyTotal := make(map[string]float64) // 新签合同(金额)_总计
|
|
|
- //mapNewContractNumTotal := make(map[string]int) // 新签合同(数量)_总计
|
|
|
- //mapExpiredContractMoneyTotal := make(map[string]float64) // 到期合同(金额)_总计
|
|
|
- //mapExpiredContractNumTotal := make(map[string]int) // 到期合同(数量)_总计
|
|
|
- //mapRenewedContractMoneyTotal := make(map[string]float64) // 续约合同(金额)_总计
|
|
|
- //mapRenewedContractNumTotal := make(map[string]int) // 续约合同(数量)_总计
|
|
|
- //confirmedNoRenewalContractMoneyTotal := make(map[string]float64) // 确认不续约合同(金额)_总计
|
|
|
- //confirmedNoRenewalContractNumTotal := make(map[string]int) // 确认不续约合同(数量)_总计
|
|
|
- //mapSignedClientNumTotal := make(map[string]int) // 签约客户(数量)_总计
|
|
|
- //mapSignedClientMoneyTotal := make(map[string]float64) // 签约客户(金额)_总计
|
|
|
- //mapInvoiceAmountMoneyTotal := make(map[string]float64) // 财务系统开票金额(金额)_总计
|
|
|
- //mapPaymentAmountMoneyTotal := make(map[string]float64) // 财务系统到款金额(金额)_总计
|
|
|
- //mapNewCustomerInvoicingMoneyTotal := make(map[string]float64) // 财务系统新客开票金额(金额)_总计
|
|
|
- //mapNewCustomerPaymentsReceivedMoneyTotal := make(map[string]float64) // 财务系统新客到款金额(金额)_总计
|
|
|
-
|
|
|
var keyMap string
|
|
|
var keyMapTtoal string
|
|
|
var keyMapTtoalServer string
|
|
@@ -264,7 +249,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- keyMap := fmt.Sprint(yearStr, "_", v.RaiSellerId)
|
|
|
+ keyMap = fmt.Sprint(yearStr, "_", v.RaiSellerId)
|
|
|
|
|
|
if sellerDevelopIds[v.RaiSellerId] == true {
|
|
|
keyMapTtoal = fmt.Sprint(yearStr, "_Develop")
|
|
@@ -315,7 +300,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
yearStr += "H2"
|
|
|
}
|
|
|
}
|
|
|
- keyMap := fmt.Sprint(yearStr, "_", v.SysUserId)
|
|
|
+ keyMap = fmt.Sprint(yearStr, "_", v.SysUserId)
|
|
|
mapAddTrialNum[keyMap]++
|
|
|
|
|
|
//var keyMapTtoal string
|
|
@@ -632,10 +617,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
startDate = year + "-01-01"
|
|
|
endDate = year + "-12-31"
|
|
|
}
|
|
|
- fmt.Println(startDate)
|
|
|
- fmt.Println(endDate)
|
|
|
+
|
|
|
resp := new(statistic_report.RaiDataSummaryPopupTypeResp)
|
|
|
var listResp []*statistic_report.RaiDataSummaryDetailResp
|
|
|
+ var listGroup []*models.CompanyContractGroupList
|
|
|
var trialTotal int
|
|
|
|
|
|
var condition string
|
|
@@ -681,8 +666,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
listResp = append(listResp, item)
|
|
|
}
|
|
|
}
|
|
|
- case "新签合同":
|
|
|
|
|
|
+ case "新签合同":
|
|
|
if sellerId > 0 {
|
|
|
condition += ` AND a.seller_id_init = ? `
|
|
|
pars = append(pars, sellerId)
|
|
@@ -730,12 +715,508 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
item.PermissionName = mappermissionName[v.CompanyContractId]
|
|
|
listResp = append(listResp, item)
|
|
|
}
|
|
|
+
|
|
|
+ listGroup, err = models.GetCompanyContractGroupList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ case "到期合同":
|
|
|
+
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += ` AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? AND a.end_date < ? `
|
|
|
+ pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
|
|
|
+
|
|
|
+ total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
+ //列表页数据
|
|
|
+ tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(tmpList) > 0 {
|
|
|
+ var companyContractIds []int
|
|
|
+ for _, v := range tmpList {
|
|
|
+ companyContractIds = append(companyContractIds, v.CompanyContractId)
|
|
|
+ }
|
|
|
+
|
|
|
+ //合并合同所对应的权限
|
|
|
+ mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpList {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.SellerNameLast
|
|
|
+ item.StartDate = v.StartDate
|
|
|
+ item.EndDate = v.EndDate
|
|
|
+ item.Money = v.Money
|
|
|
+ item.PermissionName = mappermissionName[v.CompanyContractId]
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+ listGroup, err = models.GetCompanyContractGroupList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ case "续约合同":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += ` AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ condition += ` AND a.rai_contract_type = ? `
|
|
|
+ pars = append(pars, "续约合同")
|
|
|
+
|
|
|
+ total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
+ //列表页数据
|
|
|
+ tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(tmpList) > 0 {
|
|
|
+ var companyContractIds []int
|
|
|
+ for _, v := range tmpList {
|
|
|
+ companyContractIds = append(companyContractIds, v.CompanyContractId)
|
|
|
+ }
|
|
|
+
|
|
|
+ //合并合同所对应的权限
|
|
|
+ mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpList {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.SellerNameLast
|
|
|
+ item.StartDate = v.StartDate
|
|
|
+ item.EndDate = v.EndDate
|
|
|
+ item.Money = v.Money
|
|
|
+ item.PermissionName = mappermissionName[v.CompanyContractId]
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+ listGroup, err = models.GetCompanyContractGroupList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ case "续约率":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var renewedContractMoney float64 // 续约金额
|
|
|
+ var renewedContractCompany float64 // 续约客户数
|
|
|
+ maprenewedContractCompany := make(map[int]bool)
|
|
|
+
|
|
|
+ var expiredContractMoney float64 //到期金额
|
|
|
+ var expiredContractCompany float64 // 到期客户数
|
|
|
+ mapexpiredContractCompany := make(map[int]bool)
|
|
|
+
|
|
|
+ for _, v := range listRaiData {
|
|
|
+ renewedContractMoney += v.Money
|
|
|
+ if !maprenewedContractCompany[v.CompanyId] {
|
|
|
+ renewedContractCompany++
|
|
|
+ maprenewedContractCompany[v.CompanyId] = true
|
|
|
+ }
|
|
|
+ startDateTime := utils.StrDateToDate(v.StartDate)
|
|
|
+ if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
|
|
|
+ expiredContractMoney += v.Money
|
|
|
+ if !mapexpiredContractCompany[v.CompanyId] {
|
|
|
+ expiredContractCompany++
|
|
|
+ mapexpiredContractCompany[v.CompanyId] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(renewedContractMoney, 2))
|
|
|
+ item.ExpiredContractMoney = fmt.Sprint(renewedContractCompany)
|
|
|
+ if renewedContractMoney == 0 || expiredContractMoney == 0 {
|
|
|
+ item.RenewalRate = "0%"
|
|
|
+ } else {
|
|
|
+ item.RenewalRate = fmt.Sprint(utils.SubFloatToString(renewedContractMoney/expiredContractMoney*100, 2), "%")
|
|
|
+ }
|
|
|
+
|
|
|
+ listResp = append(listResp, item)
|
|
|
+
|
|
|
+ item2 := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item2.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(expiredContractMoney, 2))
|
|
|
+ item2.ExpiredContractMoney = fmt.Sprint(expiredContractCompany)
|
|
|
+ if renewedContractCompany == 0 || expiredContractCompany == 0 {
|
|
|
+ item2.RenewalRate = "0%"
|
|
|
+ } else {
|
|
|
+ item2.RenewalRate = fmt.Sprint(utils.SubFloatToString(renewedContractCompany/expiredContractCompany*100, 2), "%")
|
|
|
+ }
|
|
|
+
|
|
|
+ listResp = append(listResp, item2)
|
|
|
+
|
|
|
+ case "确认不续约合同":
|
|
|
+ noRenewedcompanyContractIds := services.GetCompanyContractNoRenewedAscribeListArr()
|
|
|
+ condition += ` AND a.company_contract_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `) ` // 已确认
|
|
|
+ pars = append(pars, noRenewedcompanyContractIds)
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += ` AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+
|
|
|
+ total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
+ //列表页数据
|
|
|
+ tmpList, err := models.GetIncrementalCompanyMergeList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(tmpList) > 0 {
|
|
|
+ var companyContractIds []int
|
|
|
+ for _, v := range tmpList {
|
|
|
+ companyContractIds = append(companyContractIds, v.CompanyContractId)
|
|
|
+ }
|
|
|
+
|
|
|
+ //合并合同所对应的权限
|
|
|
+ mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(companyContractIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpList {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.SellerNameInit
|
|
|
+ item.StartDate = v.StartDate
|
|
|
+ item.EndDate = v.EndDate
|
|
|
+ item.Money = v.Money
|
|
|
+ item.PermissionName = mappermissionName[v.CompanyContractId]
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ listGroup, err = models.GetCompanyContractGroupList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ case "确认不续约率":
|
|
|
+ noRenewedcompanyContractIdsMap := services.GetCompanyContractNoRenewedAscribeListMap()
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var norenewedContractMoney float64 // 不续约金额
|
|
|
+ var norenewedContractCompany float64 // 不续约客户数
|
|
|
+ mapnorenewedContractCompany := make(map[int]bool)
|
|
|
+
|
|
|
+ var expiredContractMoney float64 //到期金额
|
|
|
+ var expiredContractCompany float64 // 到期客户数
|
|
|
+ mapexpiredContractCompany := make(map[int]bool)
|
|
|
+
|
|
|
+ for _, v := range listRaiData {
|
|
|
+ if noRenewedcompanyContractIdsMap[v.CompanyContractId] {
|
|
|
+ norenewedContractMoney += v.Money
|
|
|
+ if !mapnorenewedContractCompany[v.CompanyId] {
|
|
|
+ norenewedContractCompany++
|
|
|
+ mapnorenewedContractCompany[v.CompanyId] = true
|
|
|
+ }
|
|
|
+ startDateTime := utils.StrDateToDate(v.StartDate)
|
|
|
+ if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
|
|
|
+ expiredContractMoney += v.Money
|
|
|
+ if !mapexpiredContractCompany[v.CompanyId] {
|
|
|
+ expiredContractCompany++
|
|
|
+ mapexpiredContractCompany[v.CompanyId] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(norenewedContractMoney, 2))
|
|
|
+ item.ExpiredContractMoney = fmt.Sprint(norenewedContractCompany)
|
|
|
+ if norenewedContractMoney == 0 || expiredContractMoney == 0 {
|
|
|
+ item.RenewalRate = "0%"
|
|
|
+ } else {
|
|
|
+ item.RenewalRate = fmt.Sprint(utils.SubFloatToString(norenewedContractMoney/expiredContractMoney*100, 2), "%")
|
|
|
+ }
|
|
|
+ listResp = append(listResp, item)
|
|
|
+
|
|
|
+ item2 := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item2.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(expiredContractMoney, 2))
|
|
|
+ item2.ExpiredContractMoney = fmt.Sprint(expiredContractCompany)
|
|
|
+ if norenewedContractCompany == 0 || expiredContractCompany == 0 {
|
|
|
+ item2.RenewalRate = "0%"
|
|
|
+ } else {
|
|
|
+ item2.RenewalRate = fmt.Sprint(utils.SubFloatToString(norenewedContractCompany/expiredContractCompany*100, 2), "%")
|
|
|
}
|
|
|
+ listResp = append(listResp, item2)
|
|
|
+
|
|
|
+ case "签约客户数量":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var renewedContractCompany int // 续约客户数
|
|
|
+ var renewedContract int // 续约合同数
|
|
|
+ maprenewedContractCompany := make(map[int]bool)
|
|
|
+
|
|
|
+ var newContractCompany int // 新签客户数
|
|
|
+ var newContract int // 新签合同数
|
|
|
+ mapenewContractCompany := make(map[int]bool)
|
|
|
+ for _, v := range listRaiData {
|
|
|
+ if v.RaiContractType == "新签合同" {
|
|
|
+ newContract++
|
|
|
+ if !mapenewContractCompany[v.CompanyId] {
|
|
|
+ newContractCompany++
|
|
|
+ mapenewContractCompany[v.CompanyId] = true
|
|
|
+ }
|
|
|
+ } else if v.RaiContractType == "续约合同" {
|
|
|
+ renewedContract++
|
|
|
+ if !maprenewedContractCompany[v.CompanyId] {
|
|
|
+ renewedContractCompany++
|
|
|
+ maprenewedContractCompany[v.CompanyId] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.RenewedContractCompany = renewedContractCompany
|
|
|
+ item.RenewedContract = renewedContract
|
|
|
+ item.NewContractCompany = newContractCompany
|
|
|
+ item.NewContract = newContract
|
|
|
+ listResp = append(listResp, item)
|
|
|
+
|
|
|
+ case "客单价":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.seller_id_last = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var ontractMoney float64 // 签约总金额
|
|
|
+ var contractNum int // 签约客户数
|
|
|
+
|
|
|
+ for _, v := range listRaiData {
|
|
|
+ ontractMoney += v.Money
|
|
|
+ contractNum++
|
|
|
+ }
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.ContractMoney = fmt.Sprint(utils.SubFloatToString(ontractMoney, 2))
|
|
|
+ item.ContractNum = contractNum
|
|
|
+ listResp = append(listResp, item)
|
|
|
+
|
|
|
+ case "开票金额":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.rai_seller_id = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.is_deleted = 0 AND a.start_date >= ? AND a.start_date <= ? AND invoiced_amount > 0 AND product_ids LIKE '%2%' "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFmsData {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.RaiSellerName
|
|
|
+ item.ContractCode = v.ContractCode
|
|
|
+ item.InvoicedAmount = v.InvoicedAmount
|
|
|
+ item.CreateTime = v.CreateTime.Format(utils.FormatDate)
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ case "到款金额":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.rai_seller_id = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.is_deleted = 0 AND a.start_date >= ? AND a.start_date <= ? AND payment_amount > 0 AND product_ids LIKE '%2%' "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFmsData {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.RaiSellerName
|
|
|
+ item.ContractCode = v.ContractCode
|
|
|
+ item.PaymentAmount = v.PaymentAmount
|
|
|
+ item.CreateTime = v.CreateTime.Format(utils.FormatDate)
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ case "未到款比例":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.rai_seller_id = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.is_deleted = 0 AND a.start_date >= ? AND a.start_date <= ? AND product_ids LIKE '%2%' "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listFmsData, err := fms.GetContractRegisterAmountList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFmsData {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.InvoicedAmount = v.InvoicedAmount
|
|
|
+ item.PaymentAmount = v.PaymentAmount
|
|
|
+ item.NotReceivedtAmount = v.InvoicedAmount - v.PaymentAmount
|
|
|
+ item.CreateTime = v.CreateTime.Format(utils.FormatDate)
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ case "新客开票":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.rai_seller_id = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.is_deleted = 0 AND contract_type = 1 AND a.start_date >= ? AND a.start_date <= ? AND payment_amount > 0 AND product_ids LIKE '%2%' "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFmsData {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.RaiSellerName
|
|
|
+ item.ContractCode = v.ContractCode
|
|
|
+ item.PaymentAmount = v.PaymentAmount
|
|
|
+ item.CreateTime = v.CreateTime.Format(utils.FormatDate)
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ case "新客到款":
|
|
|
+ if sellerId > 0 {
|
|
|
+ condition += ` AND a.rai_seller_id = ? `
|
|
|
+ pars = append(pars, sellerId)
|
|
|
+ }
|
|
|
+ condition += " AND a.is_deleted = 0 AND contract_type = 1 AND a.start_date >= ? AND a.start_date <= ? AND payment_amount > 0 AND product_ids LIKE '%2%' "
|
|
|
+ pars = append(pars, startDate, endDate)
|
|
|
+ listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFmsData {
|
|
|
+ item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SellerName = v.RaiSellerName
|
|
|
+ item.ContractCode = v.ContractCode
|
|
|
+ item.PaymentAmount = v.PaymentAmount
|
|
|
+ item.CreateTime = v.CreateTime.Format(utils.FormatDate)
|
|
|
+ listResp = append(listResp, item)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if len(listResp) == 0 {
|
|
|
listResp = make([]*statistic_report.RaiDataSummaryDetailResp, 0)
|
|
|
}
|
|
|
+ if len(listGroup) > 0 {
|
|
|
+ for _, v := range listGroup {
|
|
|
+ if v.CompanyCount > 1 {
|
|
|
+ resp.CompanyMultiple++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp.CompanyNum = len(listGroup)
|
|
|
+ }
|
|
|
resp.List = listResp
|
|
|
page := paging.GetPaging(currentIndex, pageSize, trialTotal)
|
|
|
resp.Paging = page
|