package lingtao.net.Factory;

import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;

public class PosterPricingStrategy implements PricingStrategy {
    @Override
    public PricingListVo calculatePrice(Product dto, String role) {
        String plantName = dto.getPlantName();
        String kindValue = dto.getKindValue();
        String kinde2Value = dto.getKind2Value();
        double width = dto.getWidth();
        double length = dto.getLength();
        int count = dto.getCount();
        int number = dto.getNumber();
        List<ProductVo> resultList = new ArrayList<>();

        double price = 0;
        double basePrice = 0;

        if ("佳达".equals(plantName)) {
            //制度牌
            if ("0".equals(kindValue)) {
                //室内写真裱冷板
                if ("0".equals(kinde2Value)) {
                    basePrice = 20;
                }
                //室内写真裱冷板装小C边(小金边/银边)
                if ("3".equals(kinde2Value)) {
                    basePrice = 11;
                }
                //户外写真裱冷板装小C边(小金边/银边)
                if ("8".equals(kinde2Value)) {
                    basePrice = 11;
                }
            }
            //室内写真
            if ("1".equals(kindValue)) {
                //pp纸(室内)
                if ("3".equals(kinde2Value)) {
                    basePrice = 12;
                }
                //直喷PVC
                if ("5".equals(kinde2Value)) {
                    basePrice = 11;
                }
                //软膜
                if ("14".equals(kinde2Value)) {
                    basePrice = 15;
                }
                //地贴（复防滑膜）
                if ("15".equals(kinde2Value)) {
                    basePrice = 25;
                }
            }
            //户外写真
            if ("2".equals(kindValue)) {
                //户外写真白胶（国产）
                if ("0".equals(kinde2Value)) {
                    basePrice = 11;
                }
                //户外写真黑胶（国产）
                if ("1".equals(kinde2Value)) {
                    basePrice = 11;
                }
                //户外写真可移白胶、黑胶
                if ("2".equals(kinde2Value)) {
                    basePrice = 12;
                }
                //车贴（白胶）
                if ("6".equals(kinde2Value)) {
                    basePrice = 22;
                }
                //摆摊软膜灯箱
                if ("24".equals(kinde2Value)) {
                    basePrice = 190;
                }
            }
            //布
            if ("3".equals(kindValue)) {
                //黑底布
                if ("2".equals(kinde2Value)) {
                    basePrice = 8;
                }
                //写真布
                if ("6".equals(kinde2Value)) {
                    basePrice = 0;
                }
                //油画布
                if ("8".equals(kinde2Value)) {
                    basePrice = 22;
                }
                //550灯布
                if ("11".equals(kinde2Value)) {
                    basePrice = 6.5;
                }
                //550黑底灯布
                if ("13".equals(kinde2Value)) {
                    basePrice = 8;
                }
            }
            //展架
            if ("4".equals(kindValue)) {
                //直喷PVC装美式展架180*80cm
                if ("0".equals(kinde2Value)) {
                    basePrice = 28;
                }
                //直喷PVC装美式展架160*60cm
                if ("1".equals(kinde2Value)) {
                    basePrice = 21;
                }
                //PP纸装美式展架180*80cm
                if ("2".equals(kinde2Value)) {
                    basePrice = 28;
                }
                //PP纸装美式展架160*60cm
                if ("3".equals(kinde2Value)) {
                    basePrice = 21;
                }
                //直喷PVC装门型展架180*80cm
                if ("4".equals(kinde2Value)) {
                    basePrice = 40.5;
                }

                //PP纸装门型展架180*80cm
                if ("6".equals(kinde2Value)) {
                    basePrice = 40.5;
                }
                //PP纸装门型展架160*60cm
                if ("7".equals(kinde2Value)) {
                    basePrice = 37;
                }
                //X展架180*80cm(不含画面）
                if ("8".equals(kinde2Value)) {
                    basePrice = 12;
                }
                //X展架160*60cm(不含画面）
                if ("9".equals(kinde2Value)) {
                    basePrice = 10;
                }
                //门型展架180*80cm(不含画面）
                if ("10".equals(kinde2Value)) {
                    basePrice = 30;
                }
                //门型展架160*60cm(不含画面）
                if ("11".equals(kinde2Value)) {
                    basePrice = 27;
                }
                //直喷pvc铝合金易拉宝202*78cm
                if ("12".equals(kinde2Value)) {
                    basePrice = 40;
                }
                //直喷pvc塑钢易拉宝200*80cm
                if ("13".equals(kinde2Value)) {
                    basePrice = 47;
                }
            }
            if (basePrice == 0) {
                return new PricingListVo(100, "暂无报价。");
            }

            if (!"4".equals(kindValue)) {
                price = new BigDecimal(basePrice * count * number * width * length / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue();
            } else {
                price = new BigDecimal(basePrice * count * number).setScale(2, RoundingMode.HALF_UP).doubleValue();
            }
        }
        if ("领鸿".equals(plantName)) {
            //旗帜布
            if ("6".equals(dto.getKindValue())) {
                basePrice = 6.5;
            }
            //贡缎布
            if ("7".equals(dto.getKindValue())) {
                basePrice = 15;
            }
            if (basePrice == 0) {
                return new PricingListVo(100, "暂无报价。");
            }
            double area = Math.max(count * number * width * length / 10000, 0.3);
            price = new BigDecimal(basePrice * area).setScale(2, RoundingMode.HALF_UP).doubleValue();
            //旗杆
            if (dto.getYaheng() != null && dto.getYaheng() > 0) {
                price = BigDecimal.valueOf(price).add(BigDecimal.valueOf(dto.getYaheng() * 15.0)).setScale(2, RoundingMode.HALF_UP).doubleValue();
            }
        }
        ProductVo pro = new ProductVo();
        pro.setCount(count);
        pro.setPrice(price);
        pro.setNumber(number);
        resultList.add(pro);
        return new PricingListVo(resultList);
    }
}
