|
@@ -114,7 +114,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
//新签部分的数据
|
|
|
var conditionRai string
|
|
|
var parsRai []interface{}
|
|
|
- conditionRai = " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
|
|
|
+ conditionRai = " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? AND a.rai_contract_type = '新签合同' "
|
|
|
parsRai = append(parsRai, startDate, endDate)
|
|
|
listRaiData, err := statistic_report.GetRaiDataSummaryList(conditionRai, parsRai)
|
|
|
if err != nil {
|
|
@@ -122,12 +122,17 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ var companyIds []int
|
|
|
+ for _, v := range listRaiData {
|
|
|
+ companyIds = append(companyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ companyIds = append(companyIds, 0)
|
|
|
|
|
|
//续约部分的数据
|
|
|
var conditionInherit string
|
|
|
var parsInherit []interface{}
|
|
|
- conditionInherit = " AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.rai_contract_type = '续约合同' "
|
|
|
- parsInherit = append(parsInherit, startDate, endDate)
|
|
|
+ conditionInherit = ` AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.rai_contract_type = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(len(companyIds)) + `) `
|
|
|
+ parsInherit = append(parsInherit, startDate, endDate, companyIds)
|
|
|
listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -229,31 +234,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
mapNewContractMoney[keyMapTtoal] += v.Money
|
|
|
mapNewContractNum[keyMapTtoal]++
|
|
|
}
|
|
|
- //else if v.RaiContractType == "续约合同" {
|
|
|
- // mapRenewedContractMoney[keyMap] += v.Money
|
|
|
- // mapRenewedContractNum[keyMap]++
|
|
|
- //
|
|
|
- // mapRenewedContractMoney[keyMapTtoal] += v.Money
|
|
|
- // mapRenewedContractNum[keyMapTtoal]++
|
|
|
- //}
|
|
|
|
|
|
- //if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
|
|
|
- // mapExpiredContractMoney[keyMap] += v.Money
|
|
|
- // mapExpiredContractNum[keyMap]++
|
|
|
- //
|
|
|
- // mapExpiredContractMoney[keyMapTtoal] += v.Money
|
|
|
- // mapExpiredContractNum[keyMapTtoal]++
|
|
|
- //}
|
|
|
- //
|
|
|
- //if mapNoRenewedcompanyContractIds[v.CompanyContractId] { // 确认不续约合同
|
|
|
- // confirmedNoRenewalContractMoney[keyMap] += v.Money
|
|
|
- // confirmedNoRenewalContractNum[keyMap]++
|
|
|
- //
|
|
|
- // confirmedNoRenewalContractMoney[keyMapTtoal] += v.Money
|
|
|
- // confirmedNoRenewalContractNum[keyMapTtoal]++
|
|
|
- //}
|
|
|
mapSignedClientMoney[keyMap] += v.Money
|
|
|
-
|
|
|
mapSignedClientMoney[keyMapTtoal] += v.Money
|
|
|
|
|
|
if !mapCompanyData[keySigned] && v.RaiContractType == "新签合同" {
|
|
@@ -811,6 +793,30 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
+
|
|
|
+ //新签合同的客户ID
|
|
|
+ var companyIdsNew []int
|
|
|
+ {
|
|
|
+ var conditionNew string
|
|
|
+ var parsNew []interface{}
|
|
|
+ if sellerId != "" {
|
|
|
+ conditionNew += ` AND a.sys_user_id IN (` + sellerId + `) `
|
|
|
+ }
|
|
|
+ conditionNew = " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? AND a.rai_contract_type = '新签合同' "
|
|
|
+ parsNew = append(parsNew, startDate, endDate)
|
|
|
+ listNewData, err := statistic_report.GetRaiDataSummaryList(conditionNew, parsNew)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range listNewData {
|
|
|
+ companyIdsNew = append(companyIdsNew, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ companyIdsNew = append(companyIdsNew, 0)
|
|
|
+ lenArrCompany := len(companyIdsNew)
|
|
|
+
|
|
|
switch popupType {
|
|
|
case "新增试用":
|
|
|
var parsTry []interface{}
|
|
@@ -968,8 +974,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
condition += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
}
|
|
|
|
|
|
- condition += ` AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.inherit_company_contract_id > 0 AND a.rai_contract_type = '续约合同' `
|
|
|
- pars = append(pars, startDate, endDate)
|
|
|
+ condition += ` AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.inherit_company_contract_id > 0 AND a.rai_contract_type = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ pars = append(pars, startDate, endDate, companyIdsNew)
|
|
|
|
|
|
total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
@@ -1025,8 +1031,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
conditionEnd += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
}
|
|
|
|
|
|
- condition += ` AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND inherit_company_contract_id > 0 AND a.rai_contract_type = '续约合同' `
|
|
|
- pars = append(pars, startDate, endDate)
|
|
|
+ condition += ` AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND inherit_company_contract_id > 0 AND a.rai_contract_type = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ pars = append(pars, startDate, endDate, companyIdsNew)
|
|
|
listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1253,14 +1259,15 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
}
|
|
|
|
|
|
//续约部分的数据
|
|
|
- conditionInherit += " AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.inherit_company_contract_id > 0 AND a.rai_contract_type = '续约合同' "
|
|
|
- parsInherit = append(parsInherit, startDate, endDate)
|
|
|
+ conditionInherit += ` AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.inherit_company_contract_id > 0 AND a.rai_contract_type = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ parsInherit = append(parsInherit, startDate, endDate, companyIdsNew)
|
|
|
listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
|
br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ fmt.Println("listInheritData", len(listInheritData))
|
|
|
|
|
|
var renewedContractCompany int // 续约客户数
|
|
|
var renewedContract int // 续约合同数
|
|
@@ -1310,7 +1317,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
condition += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
conditionInherit += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
}
|
|
|
- condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? "
|
|
|
+ condition += " AND a.product_id = 2 AND a.status = 1 AND a.start_date >= ? AND a.start_date <= ? AND a.rai_contract_type = '新签合同' "
|
|
|
pars = append(pars, startDate, endDate)
|
|
|
listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
if err != nil {
|
|
@@ -1333,8 +1340,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
mapCompany[v.CompanyId] = true
|
|
|
}
|
|
|
}
|
|
|
- conditionInherit += " AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.rai_contract_type = '续约合同' "
|
|
|
- parsInherit = append(parsInherit, startDate, endDate)
|
|
|
+ conditionInherit += ` AND a.product_id = 2 AND a.status = 1 AND a.inherit_end_date >= ? AND a.inherit_end_date <= ? AND a.rai_contract_type = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ parsInherit = append(parsInherit, startDate, endDate, companyIdsNew)
|
|
|
listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|