package services

import (
	"encoding/json"
	"eta/eta_index_lib/models"
	"eta/eta_index_lib/utils"
	"fmt"
	"github.com/rdlucklib/rdluck_tools/http"
)

const (
	FuBaoQueryDataUrl     = "http://data.f139.com/cooperation/wande/queryData.do?pid=%s"
	FuBaoQueryLastDataUrl = "http://data.f139.com/cooperation/wande/queryLastData.do"
)

// GetEdbDataFromLt 获取路透数据
func GetEdbDataFromFuBao(edbCode, startDate, endDate string) (item *models.FuBaoData, err error) {
	sbUrl := fmt.Sprintf(FuBaoQueryDataUrl, edbCode)
	utils.FileLog.Info("sbUrl:%s", sbUrl)
	body, err := http.Get(sbUrl)
	utils.FileLog.Info("fubao result:%s", string(body))

	if err != nil {
		return
	}
	item = new(models.FuBaoData)
	err = json.Unmarshal(body, &item)
	return
}
