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