Browse Source

fix:商品期货指标刷新添加默认开始日期

Roc 2 years ago
parent
commit
3947416112
1 changed files with 5 additions and 1 deletions
  1. 5 1
      controllers/future_good/future_good_edb_info.go

+ 5 - 1
controllers/future_good/future_good_edb_info.go

@@ -155,7 +155,6 @@ func (this *FutureGoodEdbInfoController) Refresh() {
 	}
 
 	//期货数据,就默认到今天,特殊处理下
-	//endDate := utils.BASE_END_DATE
 	endDateTime := time.Now()
 	//每天下午三点之前刷新数据的话,截止日期就到昨天,三点之后才刷新到今天的日期
 	if endDateTime.Hour() < 15 {
@@ -163,6 +162,11 @@ func (this *FutureGoodEdbInfoController) Refresh() {
 	}
 	endDate := endDateTime.Format(utils.FormatDate)
 
+	// 数据开始日期
+	startDate := req.StartDate
+	if startDate == `` { // 如果传入的日期为空的话,那么就默认兼容一周的数据吧
+		startDate = endDateTime.AddDate(0, 0, -7).Format(utils.FormatDate)
+	}
 	dataItem, err := services.GetFutureGoodDataFromThs(req.FutureGoodEdbCode, req.StartDate, endDate, 0)
 	if err != nil {
 		br.Msg = "获取指标信息失败!"