CaculateJxPriceByPricePack
This commit is contained in:
@@ -214,5 +214,60 @@ func TestGetPricePercentage(t *testing.T) {
|
||||
t.Errorf("price:%d, defPricePercentage:%d, expected pricePercentage:%d, priceAdd:%d, actual pricePercentage:%d, priceAdd:%d",
|
||||
v[2], v[3], v[0], v[1], pricePercentage, priceAdd)
|
||||
}
|
||||
t.Logf("%d %d,%d,%d\n", CaculateSkuVendorPrice(v[2], pricePercentage, priceAdd), v[2], pricePercentage, priceAdd)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCaculateJxPriceByPricePack(t *testing.T) {
|
||||
type tTestInfo struct {
|
||||
DesiredPrice int
|
||||
UnitPrice int
|
||||
SpecQuality float32
|
||||
SpecUnit string
|
||||
Unit string
|
||||
}
|
||||
|
||||
l := []*model.PricePercentageItem{
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 0,
|
||||
PricePercentage: 0,
|
||||
PriceAdd: 0,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 10,
|
||||
PricePercentage: 10,
|
||||
PriceAdd: 1,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 20,
|
||||
PricePercentage: 20,
|
||||
PriceAdd: 2,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 30,
|
||||
PricePercentage: 30,
|
||||
PriceAdd: 3,
|
||||
},
|
||||
&model.PricePercentageItem{
|
||||
BeginPrice: 60,
|
||||
PricePercentage: 60,
|
||||
PriceAdd: 6,
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range [][]int{
|
||||
[]int{1, 1, 88},
|
||||
[]int{1, 1, 0},
|
||||
[]int{40, 15, 0},
|
||||
[]int{25, 7, 0},
|
||||
[]int{10, 2, 0},
|
||||
[]int{60, 42, 0},
|
||||
[]int{1000, 606, 10},
|
||||
} {
|
||||
jxPrice := CaculateJxPriceByPricePack(l, v[2], v[1])
|
||||
if CaculatePriceByPricePack(l, v[2], jxPrice) != v[1] {
|
||||
t.Fatalf("vendorPrice:%d, defPercentage:%d, expected:%d, actual:%d", v[1], v[2], v[0], jxPrice)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user