/**
 * 计费泡重
 * @param {*} data
 * @param {*} customerVolumnWeightFactor jip
 * @returns
 */
export function calculate_VolumeWeight(Length, Width, Height, SourceVolumeWeight, CustomerVolumnWeightFactor) {
  // 计费泡重(VolumeWeight)的计算公式就是，长(OpLength)*宽(OpWidth)*高(OpHeight)/CustomerVolumnWeightFactor
  const oldVolumeWeight = Number(Length) * Number(Width) * Number(Height) / CustomerVolumnWeightFactor
  const VolumeWeight = formatPrice(oldVolumeWeight, 2)
  return Number(VolumeWeight) > 0 ? VolumeWeight : Number(SourceVolumeWeight)
}

/**
 * 四舍五入保留两位数（缺点：）
 * @param {*} num
 * @returns
 */
export function formatPrice(price, digit) {
  const accuracyNum = Math.pow(10, digit);
  return parseFloat(Math.round((price + Number.EPSILON) * accuracyNum) / accuracyNum).toFixed(digit);
}
