package lingtao.net.util; import java.util.ArrayList; import java.util.List; import lingtao.net.bean.Product; /** * 哑金/哑银不干胶价格 */ public class YaJinStickersPrice { int countArr[] = { 500, 1000, 2000, 3000, 4000, 5000, 10000 }; // 根据尺寸计算价格 public List accountPriceBySize(Double width, Double length, int count, int[] priceArr1, int[] priceArr2, int[] priceArr3) { List list = new ArrayList(); if ((length <= 6 && width <= 5) || (length <= 5 && width <= 6) || (length <= 10 && width <= 3) || (length <= 3 && width <= 10)) { list = getPrice(count, priceArr1); } else if ((length <= 8 && width <= 8) || (length <= 10 && width <= 6) || (length <= 6 && width <= 10)) { list = getPrice(count, priceArr2); } else if ((length <= 11 && width <= 11) || (length <= 12 && width <= 8) || (length <= 8 && width <= 12) || (length <= 20) && (width <= 4) || (width <= 20) && (length <= 4)) { list = getPrice(count, priceArr3); } else { return null; } return list; } // 6*5cm以下及10*3cm以下 // 6*5cm-8*8cm;10-3cm-10*6cm以内 // 8*8cm-11*11cm;10*6-12*8CM;20*4以内 private List getPrice(int count, int[] priceArr) { Product pro = new Product(); List list = new ArrayList(); // 数量大于10000 if (count > countArr[countArr.length - 1]) { pro.setCount(count); // 10000个的单价*数量 pro.setPrice(Math.ceil(count * priceArr[countArr.length - 1] / countArr[countArr.length - 1])); list.add(pro); } for (int i = 0; i < countArr.length; i++) { if (countArr[i] < count) { continue; } pro = new Product(); pro.setCount(countArr[i]); pro.setPrice(Math.ceil(priceArr[i])); list.add(pro); } return list; } // 哑金不干胶不带凹凸 public List getPriceNoAoTu(Double length, Double width, int count) { double l = 404; double w = 289; double price = 0.0; List list = new ArrayList(); Product pro = new Product(); // 换成毫米每边+2 length = length * 10 + 4; width = width * 10 + 4; if ((length > l || width > w) && (length > w || width > l)) return null; // 一张A4纸 大的400*285 能做多少个此类尺寸的不干胶 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); // 报的数量需要多少张大纸 int num = (int) Math.ceil(count / max); if (max <= 20) { price = 65; } else if (max <= 50) { price = 75; } else if (max <= 100) { price = 85; } else if (max <= 200) { price = 100; } else if (max <= 300) { price = 110; } else { price = 150; } if (max <= 200) { /*price = price + (num - 1) * 12; // if (num > 10) { // price = price + (num - 1) * 10; // } else { // price = price + (num - 1) * 20; // }*/ if(num < 50) { price = price + (num - 1 ) * 12; }else if(num <= 100) { price = price + (num - 1 ) * 10; }else { price = price + (num - 1 ) * 6; } } else { if (num > 10) { price = price + (num - 1) * 10; } else { price = price + (num - 1) * 30; } } pro.setCount(count); pro.setPrice(price); list.add(pro); return list; } }