zwxi 1 year ago
parent
commit
f6ce91e4da
1 changed files with 27 additions and 22 deletions
  1. 27 22
      controller/census/invoice_payment.go

+ 27 - 22
controller/census/invoice_payment.go

@@ -1055,28 +1055,7 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 		historyCond += ` AND new_company = 0 `
 	}
 
-	// 套餐筛选
-	if req.ServiceTypes != "" {
-		serviceTypes := strings.Split(req.ServiceTypes, ",")
-		registerIds, e := fms.GetContractRegisterIdsByTempId(serviceTypes)
-		if e != nil {
-			err = fmt.Errorf("获取合同登记IDs失败, Err: %s", e.Error())
-			return
-		}
-		if len(registerIds) > 0 {
-			cond += ` AND b.contract_register_id IN ?`
-			pars = append(pars, registerIds)
-		} else {
-			cond += ` AND 1 = 2`
-		}
-		// 勾选套餐筛选时忽略导入的历史数据
-		if req.StartDate == "" {
-			req.StartDate = "2023-04"
-			req.EndDate = "3023-04"
-		} else {
-			req.StartDate = "2023-04"
-		}
-	}
+
 
 
 	var latestTime time.Time
@@ -1110,6 +1089,32 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 	var reqStartDate, reqEndDate time.Time
 	historyTime, _ := time.Parse(utils.FormatDate, "2023-04-01")
 
+	// 套餐筛选
+	if req.ServiceTypes != "" {
+		serviceTypes := strings.Split(req.ServiceTypes, ",")
+		registerIds, e := fms.GetContractRegisterIdsByTempId(serviceTypes)
+		if e != nil {
+			err = fmt.Errorf("获取合同登记IDs失败, Err: %s", e.Error())
+			return
+		}
+		if len(registerIds) > 0 {
+			cond += ` AND b.contract_register_id IN ?`
+			pars = append(pars, registerIds)
+		} else {
+			cond += ` AND 1 = 2`
+		}
+		// 勾选套餐筛选时忽略导入的历史数据
+		if req.StartDate == "" {
+			startDateTime,_ := time.Parse(utils.FormatDate, req.StartDate)
+			if startDateTime.Before(historyTime) {
+				req.StartDate = "2023-04"
+			}
+			req.EndDate = "3023-04"
+		} else {
+			req.StartDate = "2023-04"
+		}
+	}
+
 	if req.StartDate != "" && req.EndDate != "" {
 		st := fmt.Sprint(req.StartDate, "-01 00:00:00")
 		ed := fmt.Sprint(req.EndDate, "-01 23:59:59")