This commit is contained in:
laodaming 2023-07-21 17:20:46 +08:00
parent 53a4df065c
commit 133af63064
3 changed files with 28 additions and 16 deletions

View File

@ -108,21 +108,24 @@ func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []in
tmpPrice = float64(stepPriceSlice[numKey]) / 100 tmpPrice = float64(stepPriceSlice[numKey]) / 100
} }
num := int64(stepNum) * (*priceInfo.EachBoxNum) num := int64(stepNum) * (*priceInfo.EachBoxNum)
rangeNum := "" rangeNum := types.RangeNum{}
if numKey < lenStepNum-1 { //前面的 //只有1个
nextNum := int64(stepNumSlice[numKey+1]) * (*priceInfo.EachBoxNum) if lenStepNum == 1 {
//第一个 rangeNum.Begin = num
if numKey == 0 { rangeNum.End = 99999999999
rangeNum = fmt.Sprintf("%d-%dPCS", num, nextNum-1) } else {
} else { if numKey < lenStepNum-1 { //前面的
rangeNum = fmt.Sprintf("%d-%dPCS", num, nextNum-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{ stepListRsp = append(stepListRsp, types.StepPrice{
Range: rangeNum, RangeNum: rangeNum,
Price: tmpPrice, Price: tmpPrice,
}) })
} }
return stepListRsp return stepListRsp

View File

@ -313,8 +313,13 @@ type GetPriceByPidRsp struct {
} }
type StepPrice struct { type StepPrice struct {
Range string `json:"range"` RangeNum RangeNum `json:"range_num"`
Price float64 `json:"price"` Price float64 `json:"price"`
}
type RangeNum struct {
Begin int64 `json:"begin"`
End int64 `json:"end"`
} }
type PriceItem struct { type PriceItem struct {

View File

@ -360,8 +360,12 @@ type GetPriceByPidRsp {
StepPrice []StepPrice `json:"step_price"` StepPrice []StepPrice `json:"step_price"`
} }
type StepPrice { type StepPrice {
Range string `json:"range"` RangeNum RangeNum `json:"range_num"`
Price float64 `json:"price"` Price float64 `json:"price"`
}
type RangeNum {
Begin int64 `json:"begin"`
End int64 `json:"end"`
} }
type PriceItem { type PriceItem {
Num int64 `json:"num"` Num int64 `json:"num"`