Merge branch 'develop' into feature/auth
This commit is contained in:
@@ -101,9 +101,39 @@ func (l *GetPriceByPidLogic) GetPriceByPid(req *types.GetPriceByPidReq, userinfo
|
||||
|
||||
// 组装阶梯价格范围
|
||||
func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []int, priceInfo gmodel.FsProductPrice) []types.StepRange {
|
||||
//要求写死不影响前端展示
|
||||
return []types.StepRange{
|
||||
{
|
||||
Begin: 1000,
|
||||
End: 2999,
|
||||
Price: 0.23,
|
||||
},
|
||||
{
|
||||
Begin: 3000,
|
||||
End: 4999,
|
||||
Price: 0.2,
|
||||
},
|
||||
{
|
||||
Begin: 5000,
|
||||
End: -1,
|
||||
Price: 0.1,
|
||||
},
|
||||
}
|
||||
//下面是正常的
|
||||
lenStepNum := len(stepNumSlice)
|
||||
lenStepPrice := len(stepPriceSlice)
|
||||
stepListRsp := make([]types.StepRange, 0, lenStepNum)
|
||||
//只有一个阶梯价格
|
||||
if lenStepPrice == 1 {
|
||||
stepListRsp = append(stepListRsp, types.StepRange{
|
||||
Begin: *priceInfo.MinBuyNum * (*priceInfo.EachBoxNum),
|
||||
End: -1,
|
||||
Price: float64(stepPriceSlice[0]) / 100,
|
||||
})
|
||||
return stepListRsp
|
||||
}
|
||||
begin := int64(0)
|
||||
end := int64(0)
|
||||
for numKey, stepNum := range stepNumSlice {
|
||||
//先取最后一个
|
||||
tmpPrice := float64(stepPriceSlice[lenStepPrice-1]) / 100
|
||||
@@ -111,23 +141,12 @@ func (l *GetPriceByPidLogic) dealWithStepRange(stepNumSlice, stepPriceSlice []in
|
||||
if numKey < lenStepPrice {
|
||||
tmpPrice = float64(stepPriceSlice[numKey]) / 100
|
||||
}
|
||||
num := int64(stepNum) * (*priceInfo.EachBoxNum)
|
||||
begin := int64(0)
|
||||
end := int64(0)
|
||||
if numKey == 0 { //第一个
|
||||
begin = *priceInfo.MinBuyNum * (*priceInfo.EachBoxNum)
|
||||
//只有一阶价格
|
||||
if lenStepPrice == 1 {
|
||||
end = -1
|
||||
} else {
|
||||
end = num - 1
|
||||
}
|
||||
} else if numKey < lenStepNum-1 { //中间的
|
||||
nextNum := int64(stepNumSlice[numKey+1]) * (*priceInfo.EachBoxNum)
|
||||
begin = num
|
||||
end = nextNum - 1
|
||||
} else { //最后的
|
||||
begin = num
|
||||
begin = int64(stepNum) * (*priceInfo.EachBoxNum)
|
||||
//不是最后一个
|
||||
if numKey < lenStepNum-1 {
|
||||
nextBegin := int64(stepNumSlice[numKey+1]) * (*priceInfo.EachBoxNum)
|
||||
end = nextBegin - 1
|
||||
} else {
|
||||
end = -1
|
||||
}
|
||||
stepListRsp = append(stepListRsp, types.StepRange{
|
||||
|
||||
Reference in New Issue
Block a user