package lingtao.net.util;

import java.util.ArrayList;
import java.util.List;

import lingtao.net.bean.Product;

public class CardPrice {
	int countArr[] = { 500, 1000, 2000, 3000, 5000, 10000};

	public List<Product> getCardPrice(int count, Double area, List<Product> list, Double[] priceArr, String kind) {
		Product pro = new Product();
		for (int i = 0; i < countArr.length; i++) {
			if (countArr[i] < count) {
				continue;
			}
			pro = new Product();
			pro.setCount(countArr[i]);
			if(kind.equals("1")) {
				priceArr[i] += 2;
			}
			if(area == 0.0012) {
				pro.setPrice(Math.ceil(area * countArr[i] * priceArr[i])+20);
			}else {
				pro.setPrice(Math.ceil(area * countArr[i] * priceArr[i]));
			}

			list.add(pro);
		}

		return list;
	}

	//1万以上报价
	public List<Product> getMorePrice(int count, Double area) {
		List<Product> list = new ArrayList<Product>();
		Product pro = new Product();
		double dj = 0;
		if (area <= 0.0016) {
			dj = 76.0;
		} else if (area <= 0.0024) {
			dj = 43.0;
		} else if (area <= 0.0028) {
			dj = 38.0;
		} else if (area <= 0.0032) {
			dj = 37.0;
		} else if (area <= 0.0036) {
			dj = 30.0;
		} else if (area <= 0.005) {
			dj = 29.0;
		} else if (area <= 0.006) {
			dj = 28.0;
		} else if (area <= 0.009) {
			dj = 27.0;
		} else if (area <= 0.014) {
			dj = 20.0;
		} else if (area <= 0.021) {
			dj = 20.0;
		} else if (area <= 0.025) {
			dj = 19.0;
		} else if (area <= 0.12) {
			dj = 17.0;
		}

		pro = new Product();
		pro.setCount(count);
		pro.setPrice(Math.ceil(dj * 10000 * area * 1.6));
		list.add(pro);
		return list;
	}

	// 1万以下报价
	public List<Product> getPrice(int count, Double area, String kind) {
		List<Product> list = new ArrayList<Product>();
		if (area <= 0.0009) {
			Double priceArrA[] = { 226.0, 142.0, 110.0, 86.0, 92.0, 76.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0016) {
			Double priceArrA[] = { 158.0, 106.0, 82.0, 86.0, 84.0, 76.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0024) {
			Double priceArrA[] = { 80.0, 56.0, 56.0, 45.0, 43.0, 43.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0028) {
			Double priceArrA[] = { 76.0, 52.0, 50.0, 45.0, 43.0, 38.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0032) {
			Double priceArrA[] = { 69.0, 51.0, 49.0, 44.0, 42.0, 37.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0036) {
			Double priceArrA[] = { 60.0, 48.0, 45.0, 40.0, 35.0, 35.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0039) {
			Double priceArrA[] = { 50.0, 45.0, 40.0, 35.0, 30.0, 30.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0044) {
			Double priceArrA[] = { 75.0, 70.0, 60.0, 58.0, 56.0, 55.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.0048) {
			Double priceArrA[] = { 48.0, 44.0, 34.0, 35.0, 30.0, 30.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.005) {
			Double priceArrA[] = { 45.0, 40.0, 34.0, 35.0, 30.0, 30.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.006) {
			Double priceArrA[] = { 40.0, 35.0, 33.0, 32.0, 28.0, 28.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.009) {
			Double priceArrA[] = { 39.0, 34.0, 32.0, 31.0, 27.0, 26.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.014) {
			Double priceArrA[] = { 33.0, 28.0, 25.0, 23.0, 20.0, 20.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.021) {
			Double priceArrA[] = { 32.0, 28.0, 24.0, 22.0, 20.0, 20.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.025) {
			Double priceArrA[] = { 30.0, 26.0, 22.0, 20.0, 19.0, 19.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		} else if (area <= 0.12) {
			Double priceArrA[] = { 26.0, 23.0, 20.0, 18.0, 17.0, 17.0};
			list = getCardPrice(count, area, list, priceArrA, kind);
		}
		return list;
	}

	/*菜单报价
	 * kind 材质
	 * size 尺寸
	 * count 数量
	 * number 款数
	 * craft 工艺
	 * */
	public List<Product> getMenuPrice(String kind, String size, int count, int number, String[] craft) {
		List<Product> list = new ArrayList<Product>();
		double price = 0;
		int type = 0;
		int num = count * number;
		for(int i = 0;i < craft.length; i++) {
			if(craft[i].equals("单面过塑")) {
				type = 1;
			}else if(craft[i].equals("双面过塑")) {
				type = 2;
			}
		}
		if(kind.equals("1")) {//300克铜版纸菜单
			if(size.equals("21*14")) {
				if(type == 1) {
					price = 110 + 15 * num;
				}else {
					price = 110 + 16 * num;
				}
			}else if(size.equals("21*28.5")) {
				if(type == 1) {
					price = 120 + 15 * num;
				}else {
					price = 120 + 16 * num;
				}
			}else {
				if(type == 1) {
					price = 130 + 20 * num;
				}else {
					price = 130 + 22 * num;
				}
			}
		}else {//pvc菜单
			if(size.equals("21*14")) {
				if(type == 1) {
					price = 120 + 18 * num;
				}else {
					price = 120 + 20 * num;
				}
			}else {
				if(type == 1) {
					price = 125 + 20 * num;
				}else {
					price = 125 + 30 * num;
				}
			}
		}
		Product pro = new Product();
		pro.setPrice(Math.ceil(price));
		pro.setCount(count);
		list.add(pro);
		return list;
	}
}
