浏览代码

汾渭-网站响应格式变更

gmy 3 月之前
父节点
当前提交
67657179b9
共有 2 个文件被更改,包括 10 次插入5 次删除
  1. 1 1
      models/base_from_fenwei.go
  2. 9 4
      services/fenwei/processor_business_logic.go

+ 1 - 1
models/base_from_fenwei.go

@@ -110,7 +110,7 @@ type FenWeiNetResponse struct {
 	DailyConsumptionChnUnit    string      `json:"daily_consumption_chn_unit"`
 	DailyConsumption           string      `json:"daily_consumption"`
 	InventoryIndexChnUnit      string      `json:"inventory_index_chn_unit"`
-	InventoryIndex             float64     `json:"inventory_index"`
+	InventoryIndex             interface{} `json:"inventory_index"`
 	TonsChnUnit                string      `json:"tons_chn_unit"`
 	Tons                       string      `json:"tons"`
 	TransportVolumeChnUnit     string      `json:"transport_volume_chn_unit"`

+ 9 - 4
services/fenwei/processor_business_logic.go

@@ -871,14 +871,19 @@ func (p *CokeInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNe
 			}
 
 			var value float64
-			if data.InventoryIndex != 0 {
-				value = data.InventoryIndex
-			} else {
+			if data.InventoryIndex != nil && data.InventoryIndex != "" {
+				switch v := data.InventoryIndex.(type) {
+				case string:
+					value, _ = strconv.ParseFloat(v, 64)
+				case float64:
+					value = v
+				}
+			} else if data.Stock != nil && data.Stock != "" {
 				switch v := data.Stock.(type) {
 				case string:
 					value, _ = strconv.ParseFloat(v, 64)
 				case float64:
-					value = float64(v)
+					value = v
 				}
 			}