|
@@ -158,17 +158,17 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- var companyIds []int
|
|
|
+ var companyContractIds []int
|
|
|
for _, v := range listRaiData {
|
|
|
- companyIds = append(companyIds, v.CompanyId)
|
|
|
+ companyContractIds = append(companyContractIds, v.CompanyId)
|
|
|
}
|
|
|
- companyIds = append(companyIds, 0)
|
|
|
+ companyContractIds = append(companyContractIds, 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 = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(len(companyIds)) + `) `
|
|
|
- parsInherit = append(parsInherit, startDate, endDate, companyIds)
|
|
|
+ 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_contract_id NOT IN (` + utils.GetOrmInReplace(len(companyContractIds)) + `) `
|
|
|
+ parsInherit = append(parsInherit, startDate, endDate, companyContractIds)
|
|
|
listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -307,10 +307,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
if len(adminIdArr) > 0 && !utils.InArrayByStr(adminIdArr, strconv.Itoa(v.SellerIdLast)) {
|
|
|
continue
|
|
|
}
|
|
|
- if !mapsellerDevelop[v.SellerIdInit] {
|
|
|
+ if !mapsellerDevelop[v.SellerIdLast] {
|
|
|
continue
|
|
|
}
|
|
|
- yearStr := getYearStar(utils.StrDateToDate(v.StartDate), dataType)
|
|
|
+ yearStr := getYearStar(utils.StrDateToDate(v.InheritEndDate), dataType)
|
|
|
|
|
|
keyMap = fmt.Sprint(yearStr, "_", v.SellerIdLast)
|
|
|
keyMapCompany = fmt.Sprint(yearStr, "_", v.SellerIdLast, "_CID_", v.CompanyId)
|
|
@@ -349,7 +349,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
if !mapsellerService[v.ShareSellerIdLast] {
|
|
|
continue
|
|
|
}
|
|
|
- yearStr := getYearStar(utils.StrDateToDate(v.StartDate), dataType)
|
|
|
+ yearStr := getYearStar(utils.StrDateToDate(v.InheritEndDate), dataType)
|
|
|
|
|
|
keyMap = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdLast)
|
|
|
keyMapCompany = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdLast, "_CID_", v.CompanyId)
|
|
@@ -383,15 +383,15 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
//确认不续约、到期合同部分的数据
|
|
|
mapKeyMapCompanyEndData := make(map[string]bool)
|
|
|
mapKeyMapCompanyNoData := make(map[string]bool)
|
|
|
- //开拓组数据
|
|
|
+ //到期部分开拓组数据
|
|
|
for _, v := range listEndData {
|
|
|
if len(adminIdArr) > 0 && !utils.InArrayByStr(adminIdArr, strconv.Itoa(v.SellerIdLast)) {
|
|
|
continue
|
|
|
}
|
|
|
- if !mapsellerDevelop[v.SellerIdInit] {
|
|
|
+ if !mapsellerDevelop[v.SellerIdLast] {
|
|
|
continue
|
|
|
}
|
|
|
- yearStr := getYearStar(utils.StrDateToDate(v.StartDate), dataType)
|
|
|
+ yearStr := getYearStar(utils.StrDateToDate(v.EndDate), dataType)
|
|
|
|
|
|
keyMap = fmt.Sprint(yearStr, "_", v.SellerIdLast)
|
|
|
keyMapCompany = fmt.Sprint(yearStr, "_", v.SellerIdLast, "_CID_", v.CompanyId)
|
|
@@ -429,7 +429,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //服务组数据
|
|
|
+ //到期部分服务组数据
|
|
|
for _, v := range listEndData {
|
|
|
if len(serviceAdminIdArr) > 0 && !utils.InArrayByStr(serviceAdminIdArr, strconv.Itoa(v.ShareSellerIdLast)) {
|
|
|
continue
|
|
@@ -437,7 +437,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
if !mapsellerService[v.ShareSellerIdLast] {
|
|
|
continue
|
|
|
}
|
|
|
- yearStr := getYearStar(utils.StrDateToDate(v.StartDate), dataType)
|
|
|
+ yearStr := getYearStar(utils.StrDateToDate(v.EndDate), dataType)
|
|
|
|
|
|
keyMap = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdLast)
|
|
|
keyMapCompany = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdLast, "_CID_", v.CompanyId)
|
|
@@ -648,7 +648,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if len(sellerDevelop) > 0 {
|
|
|
+ if len(sellerDevelop) > 0 && adminId == "" {
|
|
|
sellerItem := new(statistic_report.RaiDataSummaryDetail)
|
|
|
sellerItem.SellerId = strings.Join(sellerIds, ",")
|
|
|
sellerItem.SellerName = "开拓组合计"
|
|
@@ -764,7 +764,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
item.DataList = append(item.DataList, sellerItem)
|
|
|
}
|
|
|
}
|
|
|
- if len(sellerService) > 0 {
|
|
|
+ if len(sellerService) > 0 && serviceAdminId == "" {
|
|
|
sellerItem := new(statistic_report.RaiDataSummaryDetail)
|
|
|
sellerItem.IsServerSeller = true
|
|
|
sellerItem.SellerId = strings.Join(sellerServiceIds, ",")
|
|
@@ -905,15 +905,16 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
|
- //新签合同的客户ID
|
|
|
- var companyIdsNew []int
|
|
|
+ //新签合同的ID
|
|
|
+ var companyContractIdsNew []int
|
|
|
{
|
|
|
var conditionNew string
|
|
|
var parsNew []interface{}
|
|
|
+ fmt.Println("sellerId", sellerId)
|
|
|
if sellerId != "" {
|
|
|
- conditionNew += ` AND a.sys_user_id IN (` + sellerId + `) `
|
|
|
+ conditionNew += ` AND a.seller_id_last 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 = '新签合同' "
|
|
|
+ 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 {
|
|
@@ -922,11 +923,11 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
return
|
|
|
}
|
|
|
for _, v := range listNewData {
|
|
|
- companyIdsNew = append(companyIdsNew, v.CompanyId)
|
|
|
+ companyContractIdsNew = append(companyContractIdsNew, v.CompanyId)
|
|
|
}
|
|
|
}
|
|
|
- companyIdsNew = append(companyIdsNew, 0)
|
|
|
- lenArrCompany := len(companyIdsNew)
|
|
|
+ companyContractIdsNew = append(companyContractIdsNew, 0)
|
|
|
+ lenArrCompany := len(companyContractIdsNew)
|
|
|
|
|
|
switch popupType {
|
|
|
case "新增试用":
|
|
@@ -1011,7 +1012,11 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
item.CompanyId = v.CompanyId
|
|
|
item.CompanyName = v.CompanyName
|
|
|
- item.SellerName = v.SellerNameInit
|
|
|
+ if isServerSeller {
|
|
|
+ item.SellerName = v.ShareSeller
|
|
|
+ } else {
|
|
|
+ item.SellerName = v.SellerNameInit
|
|
|
+ }
|
|
|
item.StartDate = v.StartDate
|
|
|
item.EndDate = v.EndDate
|
|
|
item.Money = v.Money
|
|
@@ -1039,7 +1044,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- condition += ` AND a.status = 1 AND a.end_date >= ? AND a.end_date <= ? AND a.end_date < ? `
|
|
|
+ condition += ` AND a.product_id = 2 AND a.status = 1 AND a.end_date >= ? AND a.end_date <= ? AND a.end_date < ? `
|
|
|
pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
|
|
|
|
|
|
total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
|
|
@@ -1073,7 +1078,11 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
item.CompanyId = v.CompanyId
|
|
|
item.CompanyName = v.CompanyName
|
|
|
- item.SellerName = v.SellerNameLast
|
|
|
+ if isServerSeller {
|
|
|
+ item.SellerName = v.ShareSellerLast
|
|
|
+ } else {
|
|
|
+ item.SellerName = v.SellerNameLast
|
|
|
+ }
|
|
|
item.StartDate = v.StartDate
|
|
|
item.EndDate = v.EndDate
|
|
|
item.Money = v.Money
|
|
@@ -1096,9 +1105,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 = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
- pars = append(pars, startDate, endDate, companyIdsNew)
|
|
|
+ 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_contract_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ pars = append(pars, startDate, endDate, companyContractIdsNew)
|
|
|
|
|
|
total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
@@ -1131,7 +1139,11 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
item := new(statistic_report.RaiDataSummaryDetailResp)
|
|
|
item.CompanyId = v.CompanyId
|
|
|
item.CompanyName = v.CompanyName
|
|
|
- item.SellerName = v.SellerNameLast
|
|
|
+ if isServerSeller {
|
|
|
+ item.SellerName = v.ShareSellerLast
|
|
|
+ } else {
|
|
|
+ item.SellerName = v.SellerNameLast
|
|
|
+ }
|
|
|
item.StartDate = v.StartDate
|
|
|
item.EndDate = v.EndDate
|
|
|
item.Money = v.Money
|
|
@@ -1150,13 +1162,17 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
var conditionEnd string
|
|
|
var parsEnd []interface{}
|
|
|
if sellerId != "" {
|
|
|
- condition += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
-
|
|
|
- conditionEnd += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
+ if isServerSeller {
|
|
|
+ condition += ` AND a.share_seller_id_last IN (` + sellerId + `) `
|
|
|
+ conditionEnd += ` AND a.share_seller_id_last IN (` + sellerId + `) `
|
|
|
+ } else {
|
|
|
+ condition += ` AND a.seller_id_last IN (` + sellerId + `) `
|
|
|
+ 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 = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
- pars = append(pars, startDate, endDate, companyIdsNew)
|
|
|
+ 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_contract_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ pars = append(pars, startDate, endDate, companyContractIdsNew)
|
|
|
listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1387,8 +1403,8 @@ 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 = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
- parsInherit = append(parsInherit, startDate, endDate, companyIdsNew)
|
|
|
+ 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_contract_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ parsInherit = append(parsInherit, startDate, endDate, companyContractIdsNew)
|
|
|
listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1467,8 +1483,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 = '续约合同' AND a.company_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
- parsInherit = append(parsInherit, startDate, endDate, companyIdsNew)
|
|
|
+ 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_contract_id NOT IN (` + utils.GetOrmInReplace(lenArrCompany) + `) `
|
|
|
+ parsInherit = append(parsInherit, startDate, endDate, companyContractIdsNew)
|
|
|
listInheritData, err := statistic_report.GetRaiDataSummaryInheritList(conditionInherit, parsInherit)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1495,6 +1511,13 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
}
|
|
|
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)
|
|
|
+ total, err := fms.GetContractInvoiceCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1540,6 +1563,13 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
}
|
|
|
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)
|
|
|
+ total, err := fms.GetContractInvoiceCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1608,6 +1638,13 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
}
|
|
|
condition += " AND a.is_deleted = 0 AND contract_type = 1 AND a.start_date >= ? AND a.start_date <= ? AND product_ids LIKE '%2%' "
|
|
|
pars = append(pars, startDate, endDate)
|
|
|
+ total, err := fms.GetContractInvoiceCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|
|
@@ -1653,6 +1690,13 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
|
|
|
}
|
|
|
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)
|
|
|
+ total, err := fms.GetContractInvoiceCount(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ trialTotal = total
|
|
|
listFmsData, err := fms.GetContractRegisterList(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据信息失败"
|