package lingtao.net.util;

import lingtao.net.bean.Product;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 海报价格
 */
public class PosterPrice {

    /**
     * 裱板
     *
     * @param kind2
     * @param area
     * @param count
     * @param number
     * @return
     */
    public List<Product> acountPrice00(String kind2, Double area, int count, Integer number) {
        double danjia = 0.0;
        // 最低收费
        double price = 0.0;
        String weight = "0";
        DecimalFormat DecimalFormat = new DecimalFormat("#.#####");
        double areas = area;
        if (area < 40 * 50 / 10000.0) {
            areas = area * number;
        }
        double miniprice = 0;
        switch (kind2) {
            // 室内写真裱冷板
            case "0":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 64;
                } else if (area > 5 && area <= 10) {
                    danjia = 60;
                } else {
                    danjia = 52;
                }
                miniprice += 72;
                price = Math.max(areas * danjia, miniprice);

                break;
            // 室内写真对裱冷板
            case "1":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 90;
                } else if (area > 5 && area <= 10) {
                    danjia = 85;
                } else {
                    danjia = 80;
                }
                miniprice += 95;
                price = Math.max(areas * danjia, miniprice);
                break;
            // 室内写真裱冷板装小C边
            case "3":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 85;
                } else if (area > 5 && area <= 10) {
                    danjia = 80;
                } else {
                    danjia = 75;
                }
                miniprice += 90;
                price = Math.max(areas * danjia, miniprice);
                break;
            // 户外写真裱冷板
            case "6":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 85;
                } else if (area > 5 && area <= 10) {
                    danjia = 80;
                } else {
                    danjia = 75;
                }
                miniprice += 90;
                price = Math.max(areas * danjia, miniprice);
                break;
            // 户外写真对裱冷板
            case "7":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 95;
                } else if (area > 5 && area <= 10) {
                    danjia = 90;
                } else {
                    danjia = 85;
                }
                miniprice += 90;
                price = Math.max(areas * danjia, miniprice);
                break;
            // 户外写真裱冷板装小C边
            case "8":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 100;
                } else if (area > 5 && area <= 10) {
                    danjia = 95;
                } else {
                    danjia = 90;
                }
                miniprice += 90;
                price = Math.max(areas * danjia, miniprice);
                break;
            // 背胶单裱3mmPVC(户内高清）
            case "12":
                // 根据面积得到单价
                if (area > 0 && area <= 5) {
                    danjia = 105;
                } else if (area > 5 && area <= 10) {
                    danjia = 100;
                } else {
                    danjia = 95;
                }
                miniprice += 105;
                price = Math.max(areas * danjia, miniprice);
                break;
        }
        Product pro = new Product();
        List<Product> list = new ArrayList<Product>();
        weight = String.valueOf(DecimalFormat.format(area * 0.2 * number));
        pro.setWeight(weight);
        pro.setCount(count);
        // 价格 = 面积 * 单价 + (款数-1) * 40
        if (number > 1 && area >= 40 * 50 / 10000.0) {
            pro.setPrice(Math.ceil(price * number));
        } else {
            pro.setPrice(Math.ceil(price));
        }
        list.add(pro);
        return list;
    }

    /**
     * 室内写真
     *
     * @param kind2
     * @param area
     * @param count
     * @param number
     * @return
     */
    public List<Product> acountPrice01(String kind2, Double area, int count, Integer number, double width, double length) {
        // 最低收费
        double price = 0.0;
        // 单价
        double danjia = 0.0;
        String weight = "0";
        DecimalFormat DecimalFormat = new DecimalFormat("#.#####");
        double[] areas = {};
        double[] prices = {};
        double last_price = 0;
        double min_price = 0;
        switch (kind2) {
            // 高精室内写真
            case "2":
                areas = new double[]{2, 5, 10, 20, 50};
                prices = new double[]{50, 45, 32, 28, 25};
                last_price = 23;
                min_price += 50;
                // 根据面积得到单价
                break;
            // pp纸(室内)
            case "3":
                areas = new double[]{2, 5, 10};
                prices = new double[]{62, 45, 35};
                last_price = 28;
                min_price += 70;

                weight = String.valueOf(DecimalFormat.format(area * 0.113 * number));
                break;
            // 直喷PVC
            case "5":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10};
                prices = new double[]{70, 55, 45};
                last_price = 40;
                min_price += 100;
                weight = String.valueOf(DecimalFormat.format(area * 0.113 * number));
                break;
            // 高精室内相纸
            case "6":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10};
                prices = new double[]{70, 60, 45};
                last_price = 40;
                min_price += 90;
                break;
            // 单透
            case "7":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10};
                prices = new double[]{75, 65, 55};
                last_price = 45;
                min_price += 100;
                break;
            // 静电贴
            case "8":
                // 根据面积得到单价
                areas = new double[]{1, 2, 5, 10};
                prices = new double[]{80, 68, 65, 63};
                last_price = 60;
                min_price += 50;
                break;
            // 软膜
            case "14":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{70, 65};
                last_price = 60;
                min_price += 100;
                weight = String.valueOf(DecimalFormat.format(area * 0.113 * number));
                break;
            // 地贴（复防滑膜）
            case "15":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{75, 65};
                last_price = 55;
                min_price += 100;

                weight = String.valueOf(DecimalFormat.format(area * 0.113 * number));
                break;
            // UV高透车贴（含白墨）
            case "16":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{160, 150};
                last_price = 140;
                min_price += 160;

                break;
            // UV高透车贴（不含白墨）
            case "17":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{150, 140};
                last_price = 130;
                min_price += 160;

                break;
            // 高透贴
            case "18":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{110, 100};
                last_price = 90;
                min_price += 130;

                break;
            // 防撞条腰线UV透明喷膜（含白墨）
            case "19":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{130, 130};
                last_price = 110;
                min_price += 80;

                break;
            // 防撞条腰线UV磨砂贴（含白墨）
            case "20":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{140, 130};
                last_price = 120;
                min_price += 80;

                break;
            // 防撞条腰线粗哑膜磨砂贴（不含白墨）
            case "21":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{115, 105};
                last_price = 100;
                min_price += 80;

                break;
            // 防撞条腰线磨砂镂空（粗哑膜刻字）
            case "22":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{150, 140};
                last_price = 130;
                min_price += 100;

                break;
            // 防撞条腰线即时贴刻字
            case "23":
                // 根据面积得到单价
                areas = new double[]{5, 10};
                prices = new double[]{120, 110};
                last_price = 100;
                min_price += 70;

                break;
            case "24":
                price = area * 380 > 380 + 15 ? area * 380 : 380 + 15;
                break;
        }
        Product pro = new Product();
        List<Product> list = new ArrayList<Product>();
        pro.setCount(count);
        if ("15".equals(kind2)) {
            danjia = last_price;
            for (int i = 0; i < areas.length; i++) {
                if (area <= areas[i]) {
                    danjia = prices[i];
                    break;
                }
            }
            price = Math.max(area * danjia, min_price) * number;
            if (area < areas[0]) {
                area = area * number;
                for (int i = 0; i < areas.length; i++) {
                    if (area <= areas[i]) {
                        danjia = prices[i];
                        break;
                    }
                }
                price = Math.max(min_price, area * danjia) + 25 + 15 * (number - 1);
            }
            pro.setPrice(Math.ceil(price));
        } else {

            if (!"24".equals(kind2)) {
                double area_jis = area;

                if (width * length < 40 * 50) {
                    area_jis = area_jis * number;
                }

                danjia = last_price;
                for (int i = 0; i < areas.length; i++) {
                    if (area <= areas[i]) {
                        danjia = prices[i];
                        break;
                    }
                }
                price = Math.max(area_jis * danjia, min_price);
            }
            // 价格 = 面积 * 单价 + (款数-1) * 40
            if (number > 1 && width * length >= 40 * 50) {
                pro.setPrice(Math.ceil(price * number));
            } else {
                pro.setPrice(Math.ceil(price));
            }
        }

        pro.setWeight(weight);
        list.add(pro);
        return list;
    }

    /**
     * 户外写真
     *
     * @param kind2
     * @param area
     * @param count
     * @param number
     * @return
     */
    public List<Product> acountPrice02(String kind2, Double area, int count, Integer number, double width, double length) {
        double price = 0.0;
        double danjia = 0.0;
        String weight = "0";
        DecimalFormat DecimalFormat = new DecimalFormat("#.#####");
        double[] areas = {};
        double[] prices = {};
        double last_price = 0;
        double min_price = 0;

        switch (kind2) {
            // 户外写真白胶（国产）
            case "0":
                areas = new double[]{2, 5, 7, 8, 10, 20, 50};
                prices = new double[]{38, 38, 33, 30, 25, 23, 21};
                last_price = 19;
                min_price += 50 - 5;
                // 根据面积得到单价
                weight = String.valueOf(DecimalFormat.format(area * 0.24 * number));
                break;
            // 户外写真黑胶（国产）
            case "1":
                // 根据面积得到单价
                areas = new double[]{2, 5, 7, 8, 10, 20, 50};
                prices = new double[]{38, 38, 33, 30, 25, 23, 21};
                last_price = 19;
                min_price += 50 - 5;
                weight = String.valueOf(DecimalFormat.format(area * 0.25 * number));
                break;
            // 户外写真可移白胶、黑胶
            case "2":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{60, 55, 50};
                last_price = 35;
                min_price += 50 + 15;

                weight = String.valueOf(DecimalFormat.format(area * 0.14 * number));
                break;
            // 户外写真喷膜
            case "3":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{65, 50, 45};
                last_price = 35;
                min_price += 80;

                break;
            // 户外写真灯片
            case "5":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{68, 50, 40};
                last_price = 30;
                min_price += 90;


                break;
            // 车贴（白胶）
            case "6":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{50, 40, 30};
                last_price = 25;
                min_price += 80;

                weight = String.valueOf(DecimalFormat.format(area * 0.24 * number));
                break;
        }
        Product pro = new Product();
        List<Product> list = new ArrayList<Product>();
        pro.setCount(count);
        danjia = last_price;

        if ("0".equals(kind2) || "1".equals(kind2)) {
            for (int i = 0; i < areas.length; i++) {
                if (area <= areas[i]) {
                    danjia = prices[i];
                    break;
                }
            }
            price = Math.max(area * danjia, min_price) * number;
            if (area < areas[0]) {
                area = area * number;
                for (int i = 0; i < areas.length; i++) {
                    if (area <= areas[i]) {
                        danjia = prices[i];
                        break;
                    }
                }
                price = Math.max(min_price, area * danjia) + 25 + 15 * (number - 1);
            }
            pro.setPrice(Math.ceil(price));
        } else {
            if (width * length < 40 * 50) {
                price = new PriceUtils().getTestPrice(length, width, count, number, areas, prices, min_price, last_price);
            } else {
                for (int i = 0; i < areas.length; i++) {
                    if (area <= areas[i]) {
                        danjia = prices[i];
                        break;
                    }
                }
                price = Math.max(area * danjia, min_price);
            }

            // 价格 = 面积 * 单价 + (款数-1) * 40
            if (number > 1 && width * length >= 40 * 50) {
                pro.setPrice(Math.ceil(price * number));
            } else {
                pro.setPrice(Math.ceil(price));
            }
        }

        pro.setWeight(weight);
        list.add(pro);
        return list;
    }

    /**
     * 布
     *
     * @param kind2
     * @param area
     * @param length
     * @param width
     * @param count
     * @param number
     * @param craftBu
     * @return
     */
    public List<Product> acountPrice03(String kind2, Double length, Double width, Double area, int count,
                                       Integer number, String craftBu) {
        double price = 0.0;
        double danjia = 0.0;
        double[] areas = {};
        double[] prices = {};
        double last_price = 0;
        double min_price = 0;
        switch (kind2) {
            // 550灯布
            case "1":
                // 根据面积得到单价
                areas = new double[]{5, 10,};
                prices = new double[]{30, 28};
                last_price = 25;
                min_price = 60;

                break;
            // 黑底布
            case "2":
                // 根据面积得到单价
                areas = new double[]{5, 10,};
                prices = new double[]{40, 34};
                last_price = 30;
                min_price = 70;

                break;

            // 写真布
            case "6":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{30, 28, 25};
                last_price = 23;
                min_price = 50 + 15;

                break;
            // 双喷布
            case "7":
                Product pro = new Product();
                List<Product> list = new ArrayList<Product>();
                double minSize = Math.min(length, width);
                double maxSize = Math.max(length, width);
                area = length * width * count * number;
			/*if (count == 1) {
				if (minSize < 1.52) {
					minSize = 1.52;
					area = maxSize * minSize * count * number;
				}
			}*/

                // 根据宽得到单价
                if (minSize <= 1.52) {
                    danjia = 50;
                } else {
                    danjia = 65;
                }
                price = area * danjia > 50 + 15 ? area * danjia : 50 + 15;

                // 挂轴 每米12元
                if ("挂轴".equals(craftBu)) {
                    price = price + (maxSize * 12 > 12 ? maxSize * 12 : 12);
                }

                pro.setCount(count);
                // 价格 = 面积 * 单价 + 款数 * 20
                pro.setPrice(Math.ceil(price + number * 20));
                list.add(pro);
                return list;
            // 油画布
            case "8":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{80, 75, 60};
                last_price = 35;
                min_price = 130;

                break;
            // 墙纸
            case "9":
                // 根据面积得到单价
                areas = new double[]{2, 5, 10,};
                prices = new double[]{70, 60, 50};
                last_price = 35;
                min_price = 105;

                break;
            // 旗帜布
            case "10":
                // 根据面积得到单价
                if ("双喷".equals(craftBu)) {
                    if ((width == 50 && length == 300 || length == 50 && width == 300) && count == 1) {
                        price = 53;
                    } else if (area <= 1) {
                        price = 53;
                    } else if (area <= 2) {
                        price = 43 * area;
                    } else if (area <= 3) {
                        price = 38 * area;
                    } else if (area <= 4) {
                        price = 33 * area;
                    } else if (area <= 5) {
                        price = 31 * area;
                    } else if (area <= 10) {
                        price = 28 * area;
                    } else {
                        price = 25 * area;
                    }
                } else {
                    if ((width == 50 && length == 300) && (length == 50 && width == 300) && count == 1) {
                        price = 50;
                    } else if (area <= 1) {
                        price = 50;
                    } else if (area <= 2) {
                        price = 40 * area;
                    } else if (area <= 3) {
                        price = 35 * area;
                    } else if (area <= 4) {
                        price = 33 * area;
                    } else if (area <= 5) {
                        price = 28 * area;
                    } else if (area <= 10) {
                        price = 25 * area;
                    } else {
                        price = 23 * area;
                    }
                }
			
			/*if (area > 0 && area <= 3) {
				danjia = 20;
			} else if (area > 3 && area <= 5) {
				danjia = 19;
			} else if (area > 5 && area <= 10) {
				danjia = 18;
			} else {
				danjia = 17;
			}
			if(area < 1.5) {
				price = area * danjia + (count * 10) > 35 ? area * danjia + (count * 10) : 35;
			}else {
				price = area * danjia * count > 35 ? area * danjia * count : 35;
			}*/

                break;
        }
        if (!"7".equals(kind2) && !"10".equals(kind2)) {
            if (width * length < 40 * 50) {
                price = new PriceUtils().getTestPrice(length, width, count, number, areas, prices, min_price, last_price);
            } else {
                danjia = last_price;
                for (int i = 0; i < areas.length; i++) {
                    if (area <= areas[i]) {
                        danjia = prices[i];
                        break;
                    }
                }
                price = Math.max(area * danjia, min_price);
            }
        }


        Product pro = new Product();
        List<Product> list = new ArrayList<Product>();
        pro.setCount(count);
        if (!"7".equals(kind2) && !"10".equals(kind2)) {
            if (number > 1 && width * length >= 40 * 50) {
                pro.setPrice(Math.ceil(price * number));
            } else {
                pro.setPrice(Math.ceil(price));
            }
        } else {
            pro.setPrice(Math.ceil(price * number));
        }

        list.add(pro);
        return list;
    }

    /**
     * 展架
     *
     * @param kind2
     * @param count
     * @param number
     * @return
     */
    public List<Product> acountPrice04(String kind2, int count, Integer number) {
        double price = 0.0;
        String weight = "0";
        DecimalFormat DecimalFormat = new DecimalFormat("#.#####");
        switch (kind2) {
            // 直喷PVC装美式展架180*80
            case "0":
                price = 120;
                break;
            // 直喷PVC装美式展架160*60
            case "1":
                price = 115;
                break;
            // PP纸装美式展架180*80
            case "2":
                price = 115;
                break;
            // PP纸装美式展架160*60
            case "3":
                price = 110;
                break;
            // 直喷PVC装门型展架180*80
            case "4":
                price = 158;
                break;
            // PP纸装门型展架180*80
            case "6":
                price = 140;
                break;
            // PP纸装门型展架160*60
            case "7":
                price = 135;
                break;
            // X展架180*80(不含画面）
            case "8":
                price = 55;
                break;
            // X展架160*60(不含画面）
            case "9":
                price = 50;
                break;
            // 门型展架180*80(不含画面）
            case "10":
                price = 75;
                break;
            // 门型展架160*60(不含画面）
            case "11":
                price = 70;
                break;
            // 直喷pvc铝合金易拉宝
            case "12":
                price = 108;
                break;
            // 直喷pvc塑钢易拉宝
            case "13":
                price = 118;
                break;
        }
        Product pro = new Product();
        List<Product> list = new ArrayList<Product>();
        pro.setCount(count);
        // 价格 = 个数 * 款数 * 单价 ===================+ (款数-1) * 40
        pro.setPrice(Math.ceil(count * number * price));// + (number - 1) * 40
        list.add(pro);
        return list;
    }
}
