From 133af63064d2da3542723aa1b195aceddd35a6ca Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 21 Jul 2023 17:20:46 +0800 Subject: [PATCH] fix --- .../internal/logic/getpricebypidlogic.go | 27 ++++++++++--------- server/product/internal/types/types.go | 9 +++++-- server_api/product.api | 8 ++++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/server/product/internal/logic/getpricebypidlogic.go b/server/product/internal/logic/getpricebypidlogic.go index 5319555f..6c76d77a 100644 --- a/server/product/internal/logic/getpricebypidlogic.go +++ b/server/product/internal/logic/getpricebypidlogic.go @@ -108,21 +108,24 @@ func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []in tmpPrice = float64(stepPriceSlice[numKey]) / 100 } num := int64(stepNum) * (*priceInfo.EachBoxNum) - rangeNum := "" - if numKey < lenStepNum-1 { //前面的 - nextNum := int64(stepNumSlice[numKey+1]) * (*priceInfo.EachBoxNum) - //第一个 - if numKey == 0 { - rangeNum = fmt.Sprintf("%d-%dPCS", num, nextNum-1) - } else { - rangeNum = fmt.Sprintf("%d-%dPCS", num, nextNum-1) + rangeNum := types.RangeNum{} + //只有1个 + if lenStepNum == 1 { + rangeNum.Begin = num + rangeNum.End = 99999999999 + } else { + if numKey < lenStepNum-1 { //前面的 + nextNum := int64(stepNumSlice[numKey+1]) * (*priceInfo.EachBoxNum) + rangeNum.Begin = num + rangeNum.End = nextNum - 1 + } else { //最后一个 + rangeNum.Begin = num + rangeNum.End = 99999999999 } - } else { //最后一个 - rangeNum = fmt.Sprintf(">=%dPCS", num) } stepListRsp = append(stepListRsp, types.StepPrice{ - Range: rangeNum, - Price: tmpPrice, + RangeNum: rangeNum, + Price: tmpPrice, }) } return stepListRsp diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index d073cec1..7df0dbda 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -313,8 +313,13 @@ type GetPriceByPidRsp struct { } type StepPrice struct { - Range string `json:"range"` - Price float64 `json:"price"` + RangeNum RangeNum `json:"range_num"` + Price float64 `json:"price"` +} + +type RangeNum struct { + Begin int64 `json:"begin"` + End int64 `json:"end"` } type PriceItem struct { diff --git a/server_api/product.api b/server_api/product.api index 26d504cd..7382f386 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -360,8 +360,12 @@ type GetPriceByPidRsp { StepPrice []StepPrice `json:"step_price"` } type StepPrice { - Range string `json:"range"` - Price float64 `json:"price"` + RangeNum RangeNum `json:"range_num"` + Price float64 `json:"price"` +} +type RangeNum { + Begin int64 `json:"begin"` + End int64 `json:"end"` } type PriceItem { Num int64 `json:"num"`