package lingtao.net.util;

import lingtao.net.bean.Product;

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

/*
 * 常规-树纹纸报价*/
public class SwzStickersPrice {
    int bigCountArr[] = {500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000,
            100000};

    /*
     * 根据供应商报价，按照利润算出报价*/
    public double setPrice(int count, double length, double width, int number, String kind) {
        double price = 0;
        if (kind.equals("浮雕烫金")) {
            double max = Math.max(length, width);
            double min = Math.min(length, width);
            if (max <= 6) {
                //长=length+0.3cm(间隔）+length+1cm(出血)
                price = (max * 2 + 1.3) * (min + 1) * 1.8;
            } else {
                //长=length+1cm(间隔）+length+1cm(出血)
                price = (max * 2 + 2) * (min + 1) * 1.8;
            }
            //20刀模费,5mm出血,9元/平方
            price += 20 + (length + 0.5) * (width + 0.5) * count / 10000 * 9;
            price = Math.ceil(2 * price * 2);//50%利润
            price = price < 480 ? 480 : price;
        } else if (kind.equals("彩色印刷")) {
            double l = 425;
            double w = 285;
            // 换成毫米每边+2
            length = length * 10 + 4;
            width = width * 10 + 4;
            if ((length > l || width > w) && (length > w || width > l))
                return 0;
            // 一张大纸能做多少个此类尺寸的不干胶
            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);
            price = 50 + (num - 1) * 5.5;
        } else {//激凸、烫金工艺一样价格
            //20刀模费,20版费,5mm出血,7.5元/平方
            price = (length + 0.5) * (width + 0.5) * count / 10000 * 7.5 + 40;
            price = Math.ceil(2 * price);
            price /= 0.4;//60%利润
        }


        return price;
    }

    public List<Product> getPrice(int count, double length, double width, int number, String craft) {
        List<Product> list = new ArrayList<Product>();
        Product pro = new Product();
        for (int i = 0; i < bigCountArr.length; i++) {
            if (bigCountArr[i] < count || list.size() > 3) {
                continue;
            }
            pro = new Product();
            pro.setCount(bigCountArr[i]);
            pro.setPrice(Math.ceil(setPrice(bigCountArr[i], length, width, number, craft)));
            list.add(pro);
        }
        return list;
    }
}
