fix
This commit is contained in:
parent
9400fcfaeb
commit
80a94de6df
|
@ -73,13 +73,14 @@ func (l *GetPriceByPidLogic) GetPriceByPid(req *types.GetPriceByPidReq, userinfo
|
|||
}
|
||||
lenStepNum := len(stepNumSlice)
|
||||
itemList := make([]types.PriceItem, 0, 10)
|
||||
for *priceInfo.MinBuyNum < (int64(stepNumSlice[lenStepNum-1]) + 5) {
|
||||
tmpMinBuyNum := *priceInfo.MinBuyNum
|
||||
for tmpMinBuyNum < (int64(stepNumSlice[lenStepNum-1]) + 5) {
|
||||
itemList = append(itemList, types.PriceItem{
|
||||
Num: *priceInfo.MinBuyNum,
|
||||
TotalNum: (*priceInfo.MinBuyNum) * (*priceInfo.EachBoxNum),
|
||||
Price: step_price.GetCentStepPrice(int(*priceInfo.MinBuyNum), stepNumSlice, stepPriceSlice),
|
||||
Num: tmpMinBuyNum,
|
||||
TotalNum: tmpMinBuyNum * (*priceInfo.EachBoxNum),
|
||||
Price: step_price.GetCentStepPrice(int(tmpMinBuyNum), stepNumSlice, stepPriceSlice),
|
||||
})
|
||||
*priceInfo.MinBuyNum++
|
||||
tmpMinBuyNum++
|
||||
}
|
||||
//组装阶梯数量范围价格
|
||||
stepRange := l.dealWithStepRange(stepNumSlice, stepPriceSlice, priceInfo)
|
||||
|
@ -111,18 +112,23 @@ func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []in
|
|||
tmpPrice = float64(stepPriceSlice[numKey]) / 100
|
||||
}
|
||||
num := int64(stepNum) * (*priceInfo.EachBoxNum)
|
||||
rangeNum := types.RangeNum{}
|
||||
if numKey < lenStepNum-1 { //前面的
|
||||
begin := int64(0)
|
||||
end := int64(0)
|
||||
if numKey == 0 { //第一个
|
||||
begin = *priceInfo.MinBuyNum * (*priceInfo.EachBoxNum)
|
||||
end = num - 1
|
||||
} 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 = -1
|
||||
begin = num
|
||||
end = nextNum - 1
|
||||
} else { //最后的
|
||||
begin = num
|
||||
end = -1
|
||||
}
|
||||
stepListRsp = append(stepListRsp, types.StepRange{
|
||||
RangeNum: rangeNum,
|
||||
Price: tmpPrice,
|
||||
Begin: begin,
|
||||
End: end,
|
||||
Price: tmpPrice,
|
||||
})
|
||||
}
|
||||
return stepListRsp
|
||||
|
|
|
@ -313,13 +313,9 @@ type GetPriceByPidRsp struct {
|
|||
}
|
||||
|
||||
type StepRange struct {
|
||||
RangeNum RangeNum `json:"range_num"`
|
||||
Price float64 `json:"price"`
|
||||
}
|
||||
|
||||
type RangeNum struct {
|
||||
Begin int64 `json:"begin"`
|
||||
End int64 `json:"end"`
|
||||
Begin int64 `json:"begin"`
|
||||
End int64 `json:"end"`
|
||||
Price float64 `json:"price"`
|
||||
}
|
||||
|
||||
type PriceItem struct {
|
||||
|
|
|
@ -360,12 +360,9 @@ type GetPriceByPidRsp {
|
|||
StepRange []StepRange `json:"step_range"`
|
||||
}
|
||||
type StepRange {
|
||||
RangeNum RangeNum `json:"range_num"`
|
||||
Price float64 `json:"price"`
|
||||
}
|
||||
type RangeNum {
|
||||
Begin int64 `json:"begin"`
|
||||
End int64 `json:"end"`
|
||||
Begin int64 `json:"begin"`
|
||||
End int64 `json:"end"`
|
||||
Price float64 `json:"price"`
|
||||
}
|
||||
type PriceItem {
|
||||
Num int64 `json:"num"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user