This commit is contained in:
laodaming 2023-07-21 17:31:28 +08:00
parent 001716785d
commit 91131161c9
3 changed files with 9 additions and 9 deletions

View File

@ -82,7 +82,7 @@ func (l *GetPriceByPidLogic) GetPriceByPid(req *types.GetPriceByPidReq, userinfo
*priceInfo.MinBuyNum++
}
//组装阶梯数量范围价格
stepListRsp := l.dealWithStepRange(stepNumSlice, stepPriceSlice, priceInfo)
stepRange := l.dealWithStepRange(stepNumSlice, stepPriceSlice, priceInfo)
//排序(必须放在其他逻辑之后)
sort.Ints(stepPriceSlice)
minPrice := float64(stepPriceSlice[0]) / 100
@ -92,17 +92,17 @@ func (l *GetPriceByPidLogic) GetPriceByPid(req *types.GetPriceByPidReq, userinfo
Items: itemList,
MinPrice: minPrice,
MaxPrice: maxPrice,
StepPrice: stepListRsp,
StepRange: stepRange,
}
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", mapRsp)
}
// 组装阶梯价格范围
func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []int, priceInfo gmodel.FsProductPrice) []types.StepPrice {
func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []int, priceInfo gmodel.FsProductPrice) []types.StepRange {
lenStepNum := len(stepNumSlice)
lenStepPrice := len(stepPriceSlice)
stepListRsp := make([]types.StepPrice, 0, lenStepNum)
stepListRsp := make([]types.StepRange, 0, lenStepNum)
for numKey, stepNum := range stepNumSlice {
//先取最后一个
tmpPrice := float64(stepPriceSlice[lenStepPrice-1]) / 100
@ -120,7 +120,7 @@ func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []in
rangeNum.Begin = num
rangeNum.End = -1
}
stepListRsp = append(stepListRsp, types.StepPrice{
stepListRsp = append(stepListRsp, types.StepRange{
RangeNum: rangeNum,
Price: tmpPrice,
})

View File

@ -309,10 +309,10 @@ type GetPriceByPidRsp struct {
Items []PriceItem `json:"items"`
MinPrice float64 `json:"min_price"`
MaxPrice float64 `json:"max_price"`
StepPrice []StepPrice `json:"step_price"`
StepRange []StepRange `json:"step_price"`
}
type StepPrice struct {
type StepRange struct {
RangeNum RangeNum `json:"range_num"`
Price float64 `json:"price"`
}

View File

@ -357,9 +357,9 @@ type GetPriceByPidRsp {
Items []PriceItem `json:"items"`
MinPrice float64 `json:"min_price"`
MaxPrice float64 `json:"max_price"`
StepPrice []StepPrice `json:"step_price"`
StepRange []StepRange `json:"step_price"`
}
type StepPrice {
type StepRange {
RangeNum RangeNum `json:"range_num"`
Price float64 `json:"price"`
}