瀏覽代碼

EDIT: cron-job, округление ДШВ

portowyi 1 年之前
父節點
當前提交
ce06b8a42e
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      cron-job/cronJobs.go

+ 7 - 6
cron-job/cronJobs.go

@@ -7,6 +7,7 @@ import (
 	"kng_feed_api/helper"
 	"kng_feed_api/model"
 	"log"
+	"math"
 	"os"
 	"path/filepath"
 	"strconv"
@@ -171,23 +172,23 @@ func CreateXMLFeed() {
 			Name: "deficit",
 		})
 		offer.Param = append(offer.Param, Param{
-			Text: strconv.FormatFloat(value.Width, 'f', 6, 64),
+			Text: strconv.FormatFloat(math.Round(value.Width*100)/100, 'f', 6, 64),
 			Name: "width",
 		})
 		offer.Param = append(offer.Param, Param{
-			Text: strconv.FormatFloat(value.Height, 'f', 6, 64),
+			Text: strconv.FormatFloat(math.Round(value.Height*100)/100, 'f', 6, 64),
 			Name: "height",
 		})
 		offer.Param = append(offer.Param, Param{
-			Text: strconv.FormatFloat(value.Weight, 'f', 6, 64),
+			Text: strconv.FormatFloat(math.Round(value.Weight*100)/100, 'f', 6, 64),
 			Name: "weight",
 		})
 		offer.Param = append(offer.Param, Param{
-			Text: strconv.FormatFloat(value.Length, 'f', 6, 64),
+			Text: strconv.FormatFloat(math.Round(value.Length*100)/100, 'f', 6, 64),
 			Name: "length",
 		})
 		offer.Param = append(offer.Param, Param{
-			Text: strconv.FormatFloat(value.Multiple, 'f', 6, 64),
+			Text: strconv.FormatFloat(math.Round(value.Multiple*100)/100, 'f', 6, 64),
 			Name: "multiple",
 		})
 
@@ -202,7 +203,7 @@ func CreateXMLFeed() {
 		}
 
 		if value.Certificates != nil {
-			certificates := strings.Split(*value.IdNumbers, ";")
+			certificates := strings.Split(*value.Certificates, ";")
 			for idx, cert := range certificates {
 				offer.Param = append(offer.Param, Param{
 					Text: cert,