我正在使用shippo API来使用交付,所以shippo提供了一些带有产品数量和产品长度、宽度和高度的盒子,所以他们有一些标准盒子,比如1个数量的物品,盒子尺寸为4 7 / 8 x 5 1/4 x 5 1/4" (L x W x H) 2 个数量的物品,盒子尺寸为 14 7/8 x 9 3/4 x 4 3/8" 3 个数量的物品,盒子尺寸为19 x 12 x 5 1/4" 4 件数量 盒子尺寸为 14 7/8 x 9 3/4 x 9" 6 件数量 盒子尺寸为 19 x 12 x 8 5/8" 12 件数量盒子尺寸为 19 x 12 x 13 3/4" 现在我所做的是基于数量我已经决定我需要多少盒子以及该盒子的数量
let availableBoxSizes = [12,6,4,3,2,1];
let boxesForShipment = [0,0,0,0,0,0];
let i = 0;
while(i <= availableBoxSizes.length){
if(noOfBottles / availableBoxSizes[i] >= 1){
let noOfbox = Math.floor(noOfBottles/availableBoxSizes[i]);
boxesForShipment[i] = noOfbox;
noOfBottles = noOfBottles - availableBoxSizes[i]*noOfbox;
if(noOfBottles < 12 && noOfBottles > 6 && i === 0){
boxesForShipment[i] = boxesForShipment[i] + 1;
i = i + 2;
break;
}else if(noOfBottles < 6 && noOfBottles > 4 && i === 1){
boxesForShipment[i] = boxesForShipment[i] + 1;
i = i + 2;
break;
}
}else{
if(noOfBottles < 12 && noOfBottles > 6 && i === 0){
boxesForShipment[i] = boxesForShipment[i] + 1;
i = i + 2;
break;
}else if(noOfBottles < 6 && noOfBottles > 4 && i === 1){
boxesForShipment[i] = boxesForShipment[i] + 1;
i = i + 2;
break;
}
}
i = i + 1;
}
return boxesForShipment;
}
现在我想要它,因为它根据产品数量重新调整所需的盒子数组,我希望它应该返回盒子的大小以及该类型所需的盒子数量。我不知道怎么做