diff --git a/pom.xml b/pom.xml index 84ae8fe..23020fb 100644 --- a/pom.xml +++ b/pom.xml @@ -190,6 +190,12 @@ UserAgentUtils 1.20 + + + com.squareup.okhttp3 + okhttp + 3.12.13 + com.alibaba fastjson @@ -207,6 +213,17 @@ system ${project.basedir}/src/main/resources/lib/jep-java-3.5-trial.jar + + + org.springframework.data + spring-data-redis + 1.8.17.RELEASE + + + redis.clients + jedis + 2.9.3 + diff --git a/src/main/java/lingtao/net/bean/Product.java b/src/main/java/lingtao/net/bean/Product.java index 87f4f8e..52f807a 100644 --- a/src/main/java/lingtao/net/bean/Product.java +++ b/src/main/java/lingtao/net/bean/Product.java @@ -177,5 +177,7 @@ public class Product { private String ui_menu_size; private String address; + private Double lengthVU; + private Double widthUV; } \ No newline at end of file diff --git a/src/main/java/lingtao/net/controller/ProductController.java b/src/main/java/lingtao/net/controller/ProductController.java index 6b246bf..1c8f82d 100644 --- a/src/main/java/lingtao/net/controller/ProductController.java +++ b/src/main/java/lingtao/net/controller/ProductController.java @@ -11,6 +11,7 @@ import lingtao.net.bean.SysUser; import lingtao.net.service.PriceService; import lingtao.net.service.ProductService; import lingtao.net.service.QuoteLogService; +import lingtao.net.util.HuaFangPriceUtil; import lingtao.net.vo.PricingListVo; import lingtao.net.vo.ProductVo; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/lingtao/net/service/ProductService.java b/src/main/java/lingtao/net/service/ProductService.java index 3ee427e..98a7310 100644 --- a/src/main/java/lingtao/net/service/ProductService.java +++ b/src/main/java/lingtao/net/service/ProductService.java @@ -8,6 +8,9 @@ import lingtao.net.dao.ProductMapper; import lingtao.net.dao.QuoteLogMapper; import lingtao.net.util.*; import lingtao.net.vo.FunReturnVo; +import lingtao.net.vo.HuaFangPriceProcessItemsVo; +import lingtao.net.vo.HuaFangPriceRequstVo; +import lingtao.net.vo.HuaFangPriceResultVo; import org.apache.commons.collections.map.HashedMap; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -243,6 +246,7 @@ public class ProductService { Double height = null; Double area = null; String oldKind = ""; + double wei = 0; /* * if(proType.equals("帆布")){ String sizeList[] = size.split(","); size = sizeList[1]; }else */ @@ -1045,6 +1049,13 @@ public class ProductService { dto.setLengthTang(length); dto.setWidthTang(width); } + List containList = new ArrayList<>(Arrays.asList("单面星光膜", "双面星光膜", "单面镭射膜", "双面镭射膜", "单面触感膜", "双面触感膜", "单面雪花膜", "双面雪花膜", "单面局部UV", "双面局部UV")); + if ("3".equals(dto.getKind()) && "2".equals(dto.getKindValue2()) && craft_list != null && !Collections.disjoint(craft_list, containList)) { + + priceList = gethuafangApiPrice(dto, craft_list, width, length); + + } + getCraft(dto, priceList, length * 10, width * 10, min); // 刮刮膜增加价格 if (dto.getKind().equals("13")) { @@ -1976,134 +1987,7 @@ public class ProductService { return priceList; // 彩色信封 case "9": - // 120克双胶牛皮 - String kindValue9 = ""; - if ("10".equals(kind)) { - dto.setKindValue("0"); - priceList = productMapper.getThanPrice(dto); - } else if ("11".equals(kind)) {// 100克双胶牛皮 - dto.setKindValue("1"); - priceList = productMapper.getThanPrice(dto); - } else if ("3".equals(kind)) {// 200克珠光冰白彩色信封 - // 200克珠光冰白彩色信封报价:140克的基础上每个+*元 - dto.setKindValue("2");// 140克的value值 - priceList = productMapper.getThanPrice(dto); - for (Product product : priceList) { - if ("2".equals(kind2)) { - product.setPrice(product.getPrice() + product.getCount() * 0.12); - } else if ("3".equals(kind2)) { - product.setPrice(product.getPrice() + product.getCount() * 0.15); - } else if ("4".equals(kind2)) { - product.setPrice(product.getPrice() + product.getCount() * 0.16); - } else if ("5".equals(kind2)) { - product.setPrice(product.getPrice() + product.getCount() * 0.32); - } else { - product.setPrice(product.getPrice() + product.getCount() * 0.11); - } - } - } else {// 120/100克牛皮纸/ 140克珠光冰白彩色信封/高端珠光冰白烫金信封 - kindValue9 = dto.getKindValue(); - if ("12".equals(dto.getKindValue())) { - dto.setKindValue("4"); - } - priceList = productMapper.getThanPrice(dto); - } - // 保留4个价格 - if (priceList.size() >= 4) { - priceList = priceList.subList(0, 4); - } - List carft_list = dto.getCraft() != null ? Arrays.asList(dto.getCraft()) : new ArrayList<>(); - // 产品价格倍数 - for (Product product : priceList) { - product.setPrice(Math.ceil(product.getPrice() * product.getPriceMultiple())); - if ("4".equals(kindValue9)) { - if (carft_list.contains("烫金")) { - if (carft_list.contains("2处")) { - product.setPrice(product.getPrice() + 100); - } - if (carft_list.contains("3处")) { - product.setPrice(product.getPrice() + 200); - } - } - } - if ("12".equals(kindValue9)) { - if (carft_list.contains("烫金")) { - if (carft_list.contains("1处")) { - product.setPrice(product.getPrice() + 150); - } - if (carft_list.contains("2处")) { - product.setPrice(product.getPrice() + 300); - } - if (carft_list.contains("3处")) { - product.setPrice(product.getPrice() + 450); - } - } - } - - } - // 根据款数重新算重量(重量在数据库中) - /* - * if (!StringUtils.isEmpty(priceList.get(0).getWeight())) { for (Product product : priceList) { product.setWeight(df.format(Double.valueOf(product.getWeight()) * number)); } } - */ - // 根据款数重新算价格 - double wei = 0.0; - if (kind.equals("0") || kind.equals("10")) { - wei = 0.12; - } else if (kind.equals("1") || kind.equals("11")) { - wei = 0.1; - } else if (kind.equals("2")) { - wei = 0.14; - } else if (kind.equals("3")) { - wei = 0.2; - } else { - wei = 0.15; - } - - if (kind.equals("0") || kind.equals("10") || kind.equals("1") || kind.equals("11")) { - if (dto.getKind2Value().equals("0")) { - area = 0.176 * 0.125; - } else if (dto.getKind2Value().equals("1")) { - area = 0.22 * 0.11; - } else if (dto.getKind2Value().equals("2")) { - area = 0.23 * 0.12; - } else if (dto.getKind2Value().equals("3")) { - area = 0.229 * 0.162; - } else if (dto.getKind2Value().equals("4")) { - area = 0.25 * 0.162; - } else { - area = 0.324 * 0.229; - } - } else if (kind.equals("2") || kind.equals("3")) { - if (dto.getKind2Value().equals("0")) { - area = 0.165 * 0.1; - } else if (dto.getKind2Value().equals("1")) { - area = 0.175 * 0.11; - } else if (dto.getKind2Value().equals("2")) { - area = 0.176 * 0.125; - } else if (dto.getKind2Value().equals("3")) { - area = 0.22 * 0.11; - } else if (dto.getKind2Value().equals("4")) { - area = 0.23 * 0.12; - } else if (dto.getKind2Value().equals("5")) { - area = 0.229 * 0.162; - } else if (dto.getKind2Value().equals("6")) { - area = 0.25 * 0.162; - } else { - area = 0.324 * 0.229; - } - } else { - if (dto.getKind2Value().equals("0")) { - area = 0.22 * 0.11; - } else { - area = 0.094 * 0.064; - } - } - for (Product product : priceList) { - product.setWeight(df.format(area * product.getCount() * number * wei)); - product.setPrice(Math.floor(product.getPrice() * number)); - } - - return priceList; + return getXinFengPrice(dto, width, length, kind, kind2); // 杯套 case "10": if ("5".equals(kind)) { @@ -4253,162 +4137,7 @@ public class ProductService { } return priceList; case "杯垫": - // 单个产品的面积 - area = length * width / 10000; - carft_list = dto.getCraft() != null ? Arrays.asList(dto.getCraft()) : new ArrayList<>(); - double rate = 1; - if ("烫黄金".equals(kind2)) { - if (carft_list.contains("单面烫黄金")) { - kind2 = "单面烫黄金"; - } - if (carft_list.contains("双面烫黄金")) { - kind2 = "双面烫黄金"; - } - } - if ("烫镭射银".equals(kind2)) { - if (carft_list.contains("单面烫镭射银")) { - kind2 = "单面烫镭射银"; - } - if (carft_list.contains("双面烫镭射银")) { - kind2 = "双面烫镭射银"; - } - rate = 1.2; - } - // 300克 - if ("3".equals(kind)) { - // 异形模切价格 - priceList = new PriceUtils().tagClothes300PriceCraftMo(dto, number, width, length, area, count, priceList); - if ("单面烫金".equals(dto.getCraftTang())) { - // 有2个尺寸带烫金 - if (!StringUtils.isEmpty(dto.getSize1())) { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 * 2 > 85 * 2 ? product.getPrice() * 0.09 * 2 : 85 * 2))); - } - } else { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 > 85 ? product.getPrice() * 0.09 : 85))); - } - } - } else if ("双面烫金".equals(dto.getCraftTang())) { - // 有2个尺寸带烫金 - if (!StringUtils.isEmpty(dto.getSize1())) { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 * 2 * 2 > 170 * 2 ? product.getPrice() * 0.09 * 2 * 2 : 170 * 2))); - } - } else { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 * 2 > 170 ? product.getPrice() * 0.09 * 2 : 170))); - } - } - } - } else if ("6".equals(kind)) { - - priceList = new PriceUtils().tags600Price(dto, kind, kind2, area, count); - for (Product product : priceList) { - product.setPrice(Math.ceil(product.getPrice() * rate)); - } - } else if ("10".equals(kind) || "11".equals(kind)) { - int[] count_list = {50, 100, 200, 500, 1000}; - double[] jitu = {}; - double[] jitu_add = {}; - double[] tang = {}; - double[] yaao = {}; - double[] tanglei = {}; - if ("10".equals(kind)) { - jitu = new double[]{267, 317, 450, 733, 1200}; - jitu_add = new double[]{190, 210, 250, 320, 440}; - tang = new double[]{250, 283, 383, 650, 980}; - tanglei = new double[]{300, 340, 460, 780, 1176}; - yaao = new double[]{250, 267, 383, 617, 950}; - } else if ("11".equals(kind)) { - jitu = new double[]{267, 317, 417, 667, 1080}; - jitu_add = new double[]{95, 105, 125, 160, 220}; - tang = new double[]{250, 300, 350, 583, 930}; - tanglei = new double[]{300, 360, 420, 700, 1116}; - yaao = new double[]{250, 283, 317, 533, 900}; - } - craft_list = Arrays.asList(dto.getCraft()); - for (int i = 0; i < count_list.length; i++) { - if (priceList.size() > 2) { - break; - } - int count_item = count_list[i]; - if (count > count_item) { - continue; - } - Product product = new Product(); - product.setCount(count_item); - if (craft_list.contains("击凸")) { - product.setPrice(jitu[i]); - if (dto.getJtcolor() != null && dto.getJtcolor().length > 1) { - product.setPrice(jitu[i] + jitu_add[i]); - } - } - if (craft_list.contains("烫金")) { - product.setPrice(tang[i]); - } - if (craft_list.contains("烫镭射银")) { - product.setPrice(tanglei[i]); - if (dto.getTcolor().contains("双面烫镭射银")) { - product.setPrice(Math.ceil(tanglei[i] * 1.5)); - } - } - if (craft_list.contains("无色压凹")) { - product.setPrice(yaao[i]); - } - - priceList.add(product); - } - - } else if ("12".equals(kind)) { - double basePrice = 0; - if ("2mm".equals(dto.getSize1())) { - basePrice = 5; - } - if ("3mm".equals(dto.getSize1())) { - basePrice = 7; - } - if ("5mm".equals(dto.getSize1())) { - basePrice = 9; - } - pro = new Product(); - pro.setCount(count); - pro.setPrice(Math.max(Math.ceil(basePrice * count * number), 30) + 8 * (number - 1)); - priceList.add(pro); - return priceList; - - } else { - priceList = new PriceUtils().tags600Price(dto, kind, kind2, area, count); - // 服装吊牌里面的900克吊牌把价格*1.3倍 - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * 1.3)); - if (product.getCount() <= 2000) { - product.setPrice(Math.floor(product.getPrice() * 1.1)); - } - if (product.getCount() > 2000 && product.getCount() <= 5000) { - product.setPrice(Math.floor(product.getPrice() * 1.08)); - } - if (product.getCount() > 5000) { - product.setPrice(Math.floor(product.getPrice() * 1.06)); - } - } - for (int i = 0; i < priceList.size(); i++) { - if (priceList.get(i).getCount() == 500) { - priceList.get(i).setPrice(Math.floor(priceList.get(i + 1).getPrice() - 5)); - } - } - } - // 根据款数重新算价格 - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - if ("3".equals(kind)) { - wei = 0.3; - } else { - wei = 0.6; - } - product.setWeight(df.format(wei * area * product.getCount() * number)); - } - return priceList; + return getBeiDianPrice(dto, width, length, role, kind2, kind); case "锦旗": // 单价*产品数量*款数 priceList = new PriceUtils().getJQPrice(kind3, number, width, length, count, priceList); @@ -4422,59 +4151,7 @@ public class ProductService { priceList = new PriceUtils().getCQPrice(number, width, length, count, priceList); return priceList; case "硫酸纸": - // 单价*产品数量*款数 - if (dto.getStickerKind().equals("常用")) { - if (dto.getKindValue().equals("2")) { -// if ((length <= 9 && width <= 5.4) || (length <= 5.4 && width <= 9)) { -// if ("直角".equals(dto.getCraft()[0])) { -// if ("彩色".equals(dto.getKind())) { -// dto.setKind1Value("2"); -// } else { -// dto.setKind1Value("1"); -// } -// } else { -// if ("彩色".equals(dto.getKind())) { -// dto.setKind1Value("4"); -// } else { -// dto.setKind1Value("3"); -// } -// } -// if ((length <= 5 && width <= 3) || (length <= 3 && width <= 5)) { -// dto.setKindValue("1"); -// } else if ((length <= 6.8 && width <= 3) || (length <= 3 && width <= 6.8)) { -// dto.setKindValue("2"); -// } else if ((length <= 8 && width <= 3) || (length <= 3 && width <= 8)) { -// dto.setKindValue("3"); -// } else if ((length <= 7 && width <= 3.5) || (length <= 3.5 && width <= 7)) { -// dto.setKindValue("4"); -// } else { -// dto.setKindValue("5"); -// } -// priceList = productMapper.getThanPrice(dto); -// } else { - priceList = new PriceUtils().get80LszPrice(dto, width, length, count, priceList); -// } - } else { - priceList = new PriceUtils().get80LszPrice(dto, width, length, count, priceList); - } - // 款数计算 - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - } - } else {// 打印的价格和pvc不干胶打印价格一样--23.8.17更新后取消这个 - priceList = lessSticker(dto, proType, number, width, length, count, priceList, role); - return priceList; - } - // 重量 - for (Product product : priceList) { - if (dto.getKindValue().equals("1")) { - wei = 0.08; - } else { - wei = 0.135; - } - product.setWeight(df.format(number * length * width * product.getCount() / 10000 * wei)); - } - return priceList; + return getLiuSuanzhiPrice(dto, width, length, role, proType); case "亚克力": priceList = new PriceUtils().getYklPrice(dto, number, width, length, count, priceList); for (Product product : priceList) { @@ -4565,45 +4242,7 @@ public class ProductService { } return priceList; case "手拉旗": - /* - * if(kind.equals("1")) { if(length == 70 && width == 24) { priceList = new FgqPrice().getSlqSpeicPrice(count, priceList, 1); }else if(length == 50 && width == 17) { priceList = new FgqPrice().getSlqSpeicPrice(count, priceList, 2); }else { priceList = new FgqPrice().getSlqPrice(count, priceList); } }else { - */ - if ("常规".equals(dto.getStickerKind())) { - priceList = new FgqPrice().getSlqPrice(count, priceList); - } - if ("伸缩手拉旗".equals(dto.getStickerKind())) { - double base_price = 0; - if ((length == 24 && width == 70) || (length == 70 && width == 24)) { - base_price = 30; - } - if ((length == 24 && width == 50) || (length == 50 && width == 24)) { - base_price = 30; - } - if ((length == 24 && width == 100) || (length == 100 && width == 24)) { - base_price = 35; - } - if ((length == 17 && width == 70) || (length == 70 && width == 17)) { - base_price = 30; - } - if ((length == 17 && width == 50) || (length == 50 && width == 17)) { - base_price = 30; - } - if ((length == 17 && width == 100) || (length == 100 && width == 17)) { - base_price = 35; - } - Product product = new Product(); - product.setCount(dto.getCount()); - product.setNumber(number); - product.setPrice(Math.ceil(base_price * dto.getCount())); - priceList.add(product); - - } - /* } */ - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - product.setWeight(df.format(length * width * product.getCount() / 10000 * number * 0.075)); - } - return priceList; + return getShouLaQiPrice(dto, width, length); case "筷子套": priceList = new KztPrice().getPrice(count, length, priceList); for (Product product : priceList) { @@ -4667,48 +4306,7 @@ public class ProductService { } return priceList; case "卡贴": - int min = getNum(length, width); - dto.setProTypeValue("4"); - priceList = getHekaPrice(min, dto, priceList, count); - for (Product product : priceList) { - double dNum = 1; - if (product.getCount() / 1000 > 1) { - dNum = Math.floor(product.getCount() / 1000); - } - product.setPrice(Math.ceil(product.getPrice() + dNum * 3)); - } - //工艺计算 - if (!StringUtils.isEmpty(dto.getCraft())) { - List craList = Arrays.asList(dto.getCraft()); -// if (craList.contains("双面覆哑膜")) { -// for (Product product : priceList) { -// product.setPrice(Math.ceil(product.getPrice() * 1.3)); -// } -// } - - if (craList.contains("模切")) { - if (min < 3) { - for (Product product : priceList) { - product.setPrice(Math.ceil(product.getPrice() + 25 + 0.04 * product.getCount())); - } - } else if (min < 16) { - for (Product product : priceList) { - product.setPrice(Math.ceil(product.getPrice() + 50 + 0.04 * product.getCount())); - } - } else { - for (Product product : priceList) { - product.setPrice(Math.ceil(product.getPrice() + 30 + 50 + 0.04 * product.getCount())); - } - } - } - } - - // 根据款数重新算价格/计算重量 - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - product.setWeight(df.format(number * length / 100 * width / 100 * product.getCount() * 0.3 * 0.86)); - } - return priceList; + return getkaTiePrice(dto, width, length); case "会员卡卡套": priceList = new FerruleUtil().getPrice(length, count, priceList); if (number > 1) { @@ -4718,60 +4316,11 @@ public class ProductService { } return priceList; case "手提杯托": - area = length * width / 10000; - if ("250克白卡纸".equals(dto.getKind())) { - priceList = CupHolderUtil.getPrice(area, count, priceList); - for (Product product : priceList) { - product.setWeight(df.format(number * length / 100 * width / 100 * product.getCount() * 0.25)); - } - - } else { - priceList = CupHolderUtil.getPvcPrice(size, dto.getKind(), count, priceList); - for (Product product : priceList) { - product.setWeight(df.format(0.38 * 0.0855 * 1.3 * 0.054 * product.getCount() * number)); - } - } - if (number > 1) { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - } - } - - return priceList; + return getTuoBeiPrice(dto, width, length); case "天幕": - area = length * width / 10000; - if (dto.getCraftShua().contains("空白") && dto.getCraftQie() != null && dto.getCraftQie().contains("模切")) { - dto.setCraftShua("定制"); - } - priceList = CanopyUtil.getPrice(area, count, priceList, dto.getKindValue(), dto.getCraftShua()); - if (number > 1) { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - } - } - if (dto.getShuliang() != null) { - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() + dto.getShuliang() * 50)); - product.setWeight(String.valueOf(Double.parseDouble(product.getWeight()) + dto.getShuliang() * 3.3)); - } - } - - return priceList; + return getTianMuPrice(dto, width, length); case "挂布": - area = length * width / 10000; - - priceList = AngClothUtil.getPrice(area, count, priceList, dto.getCraft()); - for (Product product : priceList) { - product.setPrice(Math.floor(product.getPrice() * number)); - double other_price = 0; - if (area <= 0.25) { - other_price = (count) * 5 * number; - product.setPrice(Math.floor(45 + other_price)); - } - product.setWeight(df.format(area * product.getCount() * number * 0.06)); - } - - return priceList; + return getGuaBuPrice(dto, width, length); case "定制衫": return getClotherPrice(dto, width, length); case "手绘": @@ -4824,12 +4373,665 @@ public class ProductService { return getWrappingPaper(dto, width, length); case "撕撕乐": return getTearingJoyPrice(dto, width, length); + case "哑粉纸": + return getYaFenPrice(dto, width, length); default: break; } return null; } + private List getYaFenPrice(Product dto, Double width, Double length) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + List paperCode = Arrays.asList("157克哑粉纸", "200克哑粉纸", "250克哑粉纸"); + HuaFangPriceRequstVo requstVo = new HuaFangPriceRequstVo(); + requstVo.setProductName("精品单页"); + requstVo.setProductPaperCode(paperCode.get(Integer.parseInt(dto.getKind()) - 1)); + requstVo.setProductPrintColor("彩色"); + requstVo.setProductPrintFace("双面"); + requstVo.setNum(dto.getCount()); + requstVo.setStyleNum(dto.getNumber()); + requstVo.setSizes(Arrays.asList(width * 10, length * 10)); + List list = new ArrayList<>(); + List yahen = Arrays.asList("压一道痕", "压二道痕", "压三道痕"); + List dianxian = Arrays.asList("压一道齿线", "压二道齿线", "压三道齿线"); + if (craft_list.contains("双面哑膜")) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("覆膜"); + item.setProcessValue("双面哑膜"); + list.add(item); + } + if (craft_list.contains("双面亮膜")) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("覆膜"); + item.setProcessValue("双面亮膜"); + list.add(item); + } + if (craft_list.contains("压痕")) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("压痕"); + item.setProcessValue(yahen.get(dto.getYaheng() - 1)); + list.add(item); + } + if (craft_list.contains("点线")) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("齿线"); + item.setProcessValue(dianxian.get(dto.getDadianxian() - 1)); + list.add(item); + } + if (craft_list.contains("折页")) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("折页"); + item.setProcessValue(dto.getBianma()); + list.add(item); + } + if (craft_list.contains("异形模切") || width < 5.4 || length < 5.4) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("模切"); + item.setProcessValue("模切"); + list.add(item); + } + + requstVo.setCalcProcess(list); + HuaFangPriceResultVo result = HuaFangPriceUtil.getPrice(requstVo); + Product product = new Product(); + product.setPrice(Math.ceil(result.getAmount() / (1 - 0.55))); + product.setCount(dto.getCount()); + product.setNumber(dto.getNumber()); + priceList.add(product); + return priceList; + } + + private List gethuafangApiPrice(Product dto, List craft_list, Double width, Double length) { + List priceList = new ArrayList<>(); + HuaFangPriceRequstVo requstVo = new HuaFangPriceRequstVo(); + requstVo.setProductName("精品单页"); + requstVo.setProductPaperCode("300克铜版纸"); + requstVo.setProductPaperName("300-铜版(厚度31丝)"); + requstVo.setProductPrintColor("彩色"); + requstVo.setProductPrintFace("双面"); + requstVo.setNum(dto.getCount()); + requstVo.setStyleNum(dto.getNumber()); + requstVo.setSizes(Arrays.asList(width * 10, length * 10)); + List list = new ArrayList<>(); + List fumo = new ArrayList<>(Arrays.asList("单面星光膜", "双面星光膜", "单面镭射膜", "双面镭射膜", "单面触感膜", "双面触感膜", "单面雪花膜", "双面雪花膜")); + List uv = new ArrayList<>(Arrays.asList("单面局部UV", "双面局部UV")); + for (String s : craft_list) { + if (fumo.contains(s)) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("覆膜"); + item.setProcessValue(s); + list.add(item); + } + if (uv.contains(s)) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("UV"); + item.setProcessValue(s); + item.setSizes(Arrays.asList(dto.getWidthUV() * 10, dto.getLengthVU() * 10)); + list.add(item); + } + } + if (width < 5.4 || length < 5.4) { + HuaFangPriceProcessItemsVo item = new HuaFangPriceProcessItemsVo(); + item.setProcessName("模切"); + item.setProcessValue("模切"); + list.add(item); + } + requstVo.setCalcProcess(list); + HuaFangPriceResultVo result = HuaFangPriceUtil.getPrice(requstVo); + Product product = new Product(); + product.setPrice(Math.ceil(result.getAmount() / (1 - 0.5))); + product.setCount(dto.getCount()); + product.setNumber(dto.getNumber()); + priceList.add(product); + return priceList; + } + + private List getXinFengPrice(Product dto, Double width, Double length, String kind, String kind2) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + // 120克双胶牛皮 + String kindValue9 = ""; + if ("10".equals(kind)) { + dto.setKindValue("0"); + priceList = productMapper.getThanPrice(dto); + } else if ("11".equals(kind)) {// 100克双胶牛皮 + dto.setKindValue("1"); + priceList = productMapper.getThanPrice(dto); + } else if ("3".equals(kind)) {// 200克珠光冰白彩色信封 + // 200克珠光冰白彩色信封报价:140克的基础上每个+*元 + dto.setKindValue("2");// 140克的value值 + priceList = productMapper.getThanPrice(dto); + for (Product product : priceList) { + if ("2".equals(kind2)) { + product.setPrice(product.getPrice() + product.getCount() * 0.12); + } else if ("3".equals(kind2)) { + product.setPrice(product.getPrice() + product.getCount() * 0.15); + } else if ("4".equals(kind2)) { + product.setPrice(product.getPrice() + product.getCount() * 0.16); + } else if ("5".equals(kind2)) { + product.setPrice(product.getPrice() + product.getCount() * 0.32); + } else { + product.setPrice(product.getPrice() + product.getCount() * 0.11); + } + } + } else {// 120/100克牛皮纸/ 140克珠光冰白彩色信封/高端珠光冰白烫金信封 + kindValue9 = dto.getKindValue(); + if ("12".equals(dto.getKindValue())) { + dto.setKindValue("4"); + } + priceList = productMapper.getThanPrice(dto); + } + // 保留4个价格 + if (priceList.size() >= 4) { + priceList = priceList.subList(0, 4); + } + List carft_list = dto.getCraft() != null ? Arrays.asList(dto.getCraft()) : new ArrayList<>(); + // 产品价格倍数 + for (Product product : priceList) { + product.setPrice(Math.ceil(product.getPrice() * product.getPriceMultiple())); + if ("4".equals(kindValue9)) { + if (carft_list.contains("烫金")) { + if (carft_list.contains("2处")) { + product.setPrice(product.getPrice() + 100); + } + if (carft_list.contains("3处")) { + product.setPrice(product.getPrice() + 200); + } + } + } + if ("12".equals(kindValue9)) { + if (carft_list.contains("烫金")) { + if (carft_list.contains("1处")) { + product.setPrice(product.getPrice() + 150); + } + if (carft_list.contains("2处")) { + product.setPrice(product.getPrice() + 300); + } + if (carft_list.contains("3处")) { + product.setPrice(product.getPrice() + 450); + } + } + } + + } + // 根据款数重新算重量(重量在数据库中) + /* + * if (!StringUtils.isEmpty(priceList.get(0).getWeight())) { for (Product product : priceList) { product.setWeight(df.format(Double.valueOf(product.getWeight()) * number)); } } + */ + // 根据款数重新算价格 + double wei = 0.0; + if (kind.equals("0") || kind.equals("10")) { + wei = 0.12; + } else if (kind.equals("1") || kind.equals("11")) { + wei = 0.1; + } else if (kind.equals("2")) { + wei = 0.14; + } else if (kind.equals("3")) { + wei = 0.2; + } else if (kind.equals("4")) { + wei = 0.3; + } else { + wei = 0.15; + } + double area = 0; + if (kind.equals("0") || kind.equals("10") || kind.equals("1") || kind.equals("11")) { + if (dto.getKind2Value().equals("0")) { + area = 0.176 * 0.125; + } else if (dto.getKind2Value().equals("1")) { + area = 0.22 * 0.11; + } else if (dto.getKind2Value().equals("2")) { + area = 0.23 * 0.12; + } else if (dto.getKind2Value().equals("3")) { + area = 0.229 * 0.162; + } else if (dto.getKind2Value().equals("4")) { + area = 0.25 * 0.162; + } else { + area = 0.324 * 0.229; + } + } else if (kind.equals("2") || kind.equals("3")) { + if (dto.getKind2Value().equals("0")) { + area = 0.165 * 0.1; + } else if (dto.getKind2Value().equals("1")) { + area = 0.175 * 0.11; + } else if (dto.getKind2Value().equals("2")) { + area = 0.176 * 0.125; + } else if (dto.getKind2Value().equals("3")) { + area = 0.22 * 0.11; + } else if (dto.getKind2Value().equals("4")) { + area = 0.23 * 0.12; + } else if (dto.getKind2Value().equals("5")) { + area = 0.229 * 0.162; + } else if (dto.getKind2Value().equals("6")) { + area = 0.25 * 0.162; + } else { + area = 0.324 * 0.229; + } + } else if (kind.equals("4")) { + if (dto.getKind2Value().equals("0")) { + area = 0.09 * 0.06; + } else if (dto.getKind2Value().equals("1")) { + area = 0.1 * 0.07; + } else if (dto.getKind2Value().equals("2")) { + area = 0.12 * 0.08; + } else if (dto.getKind2Value().equals("3")) { + area = 0.15 * 0.08; + } else if (dto.getKind2Value().equals("4")) { + area = 0.17 * 0.09; + } else if (dto.getKind2Value().equals("5")) { + area = 0.19 * 0.09; + } else if (dto.getKind2Value().equals("6")) { + area = 0.21 * 0.11; + } else { + area = 0.22 * 0.12; + } + } else { + if (dto.getKind2Value().equals("0")) { + area = 0.22 * 0.11; + } else { + area = 0.094 * 0.064; + } + } + for (Product product : priceList) { + product.setWeight(df.format(area * product.getCount() * number * wei)); + product.setPrice(Math.floor(product.getPrice() * number)); + } + + return priceList; + } + + private List getBeiDianPrice(Product dto, Double width, Double length, String role, String kind2, String kind) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + // 单个产品的面积 + double area = length * width / 10000; + double rate = 1; + if ("烫黄金".equals(kind2)) { + if (craft_list.contains("单面烫黄金")) { + kind2 = "单面烫黄金"; + } + if (craft_list.contains("双面烫黄金")) { + kind2 = "双面烫黄金"; + } + } + if ("烫镭射银".equals(kind2)) { + if (craft_list.contains("单面烫镭射银")) { + kind2 = "单面烫镭射银"; + } + if (craft_list.contains("双面烫镭射银")) { + kind2 = "双面烫镭射银"; + } + rate = 1.2; + } + // 300克 + if ("3".equals(kind)) { + // 异形模切价格 + priceList = new PriceUtils().tagClothes300PriceCraftMo(dto, number, width, length, area, count, priceList); + if ("单面烫金".equals(dto.getCraftTang())) { + // 有2个尺寸带烫金 + if (!StringUtils.isEmpty(dto.getSize1())) { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 * 2 > 85 * 2 ? product.getPrice() * 0.09 * 2 : 85 * 2))); + } + } else { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 > 85 ? product.getPrice() * 0.09 : 85))); + } + } + } else if ("双面烫金".equals(dto.getCraftTang())) { + // 有2个尺寸带烫金 + if (!StringUtils.isEmpty(dto.getSize1())) { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 * 2 * 2 > 170 * 2 ? product.getPrice() * 0.09 * 2 * 2 : 170 * 2))); + } + } else { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() + (product.getPrice() * 0.09 * 2 > 170 ? product.getPrice() * 0.09 * 2 : 170))); + } + } + } + } else if ("6".equals(kind)) { + + priceList = new PriceUtils().tags600Price(dto, kind, kind2, area, count); + for (Product product : priceList) { + product.setPrice(Math.ceil(product.getPrice() * rate)); + } + } else if ("10".equals(kind) || "11".equals(kind)) { + int[] count_list = {50, 100, 200, 500, 1000}; + double[] jitu = {}; + double[] jitu_add = {}; + double[] tang = {}; + double[] yaao = {}; + double[] tanglei = {}; + if ("10".equals(kind)) { + jitu = new double[]{267, 317, 450, 733, 1200}; + jitu_add = new double[]{190, 210, 250, 320, 440}; + tang = new double[]{250, 283, 383, 650, 980}; + tanglei = new double[]{300, 340, 460, 780, 1176}; + yaao = new double[]{250, 267, 383, 617, 950}; + } else if ("11".equals(kind)) { + jitu = new double[]{267, 317, 417, 667, 1080}; + jitu_add = new double[]{95, 105, 125, 160, 220}; + tang = new double[]{250, 300, 350, 583, 930}; + tanglei = new double[]{300, 360, 420, 700, 1116}; + yaao = new double[]{250, 283, 317, 533, 900}; + } + craft_list = Arrays.asList(dto.getCraft()); + for (int i = 0; i < count_list.length; i++) { + if (priceList.size() > 2) { + break; + } + int count_item = count_list[i]; + if (count > count_item) { + continue; + } + Product product = new Product(); + product.setCount(count_item); + if (craft_list.contains("击凸")) { + product.setPrice(jitu[i]); + if (dto.getJtcolor() != null && dto.getJtcolor().length > 1) { + product.setPrice(jitu[i] + jitu_add[i]); + } + } + if (craft_list.contains("烫金")) { + product.setPrice(tang[i]); + } + if (craft_list.contains("烫镭射银")) { + product.setPrice(tanglei[i]); + if (dto.getTcolor().contains("双面烫镭射银")) { + product.setPrice(Math.ceil(tanglei[i] * 1.5)); + } + } + if (craft_list.contains("无色压凹")) { + product.setPrice(yaao[i]); + } + + priceList.add(product); + } + + } else if ("12".equals(kind)) { + double basePrice = 0; + if ("2mm".equals(dto.getSize1())) { + basePrice = 5; + } + if ("3mm".equals(dto.getSize1())) { + basePrice = 7; + } + if ("5mm".equals(dto.getSize1())) { + basePrice = 9; + } + Product pro = new Product(); + pro.setCount(count); + pro.setPrice(Math.max(Math.ceil(basePrice * count * number), 30) + 8 * (number - 1)); + priceList.add(pro); + return priceList; + + } else { + priceList = new PriceUtils().tags600Price(dto, kind, kind2, area, count); + // 服装吊牌里面的900克吊牌把价格*1.3倍 + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * 1.3)); + if (product.getCount() <= 2000) { + product.setPrice(Math.floor(product.getPrice() * 1.1)); + } + if (product.getCount() > 2000 && product.getCount() <= 5000) { + product.setPrice(Math.floor(product.getPrice() * 1.08)); + } + if (product.getCount() > 5000) { + product.setPrice(Math.floor(product.getPrice() * 1.06)); + } + } + for (int i = 0; i < priceList.size(); i++) { + if (priceList.get(i).getCount() == 500) { + priceList.get(i).setPrice(Math.floor(priceList.get(i + 1).getPrice() - 5)); + } + } + } + double wei = 0; + // 根据款数重新算价格 + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + if ("3".equals(kind)) { + wei = 0.3; + } else { + wei = 0.6; + } + product.setWeight(df.format(wei * area * product.getCount() * number)); + } + return priceList; + } + + private List getLiuSuanzhiPrice(Product dto, Double width, Double length, String role, String proType) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + // 单价*产品数量*款数 + if (dto.getStickerKind().equals("常用")) { + if (dto.getKindValue().equals("2")) { +// if ((length <= 9 && width <= 5.4) || (length <= 5.4 && width <= 9)) { +// if ("直角".equals(dto.getCraft()[0])) { +// if ("彩色".equals(dto.getKind())) { +// dto.setKind1Value("2"); +// } else { +// dto.setKind1Value("1"); +// } +// } else { +// if ("彩色".equals(dto.getKind())) { +// dto.setKind1Value("4"); +// } else { +// dto.setKind1Value("3"); +// } +// } +// if ((length <= 5 && width <= 3) || (length <= 3 && width <= 5)) { +// dto.setKindValue("1"); +// } else if ((length <= 6.8 && width <= 3) || (length <= 3 && width <= 6.8)) { +// dto.setKindValue("2"); +// } else if ((length <= 8 && width <= 3) || (length <= 3 && width <= 8)) { +// dto.setKindValue("3"); +// } else if ((length <= 7 && width <= 3.5) || (length <= 3.5 && width <= 7)) { +// dto.setKindValue("4"); +// } else { +// dto.setKindValue("5"); +// } +// priceList = productMapper.getThanPrice(dto); +// } else { + priceList = new PriceUtils().get80LszPrice(dto, width, length, count, priceList); +// } + } else { + priceList = new PriceUtils().get80LszPrice(dto, width, length, count, priceList); + } + // 款数计算 + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + } + } else {// 打印的价格和pvc不干胶打印价格一样--23.8.17更新后取消这个 + priceList = lessSticker(dto, proType, number, width, length, count, priceList, role); + return priceList; + } + double wei = 0; + // 重量 + for (Product product : priceList) { + if (dto.getKindValue().equals("1")) { + wei = 0.08; + } else { + wei = 0.135; + } + product.setWeight(df.format(number * length * width * product.getCount() / 10000 * wei)); + } + return priceList; + } + + private List getShouLaQiPrice(Product dto, Double width, Double length) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + + if ("常规".equals(dto.getStickerKind())) { + priceList = new FgqPrice().getSlqPrice(count, priceList); + } + if ("伸缩手拉旗".equals(dto.getStickerKind())) { + double base_price = 0; + if ((length == 24 && width == 70) || (length == 70 && width == 24)) { + base_price = 30; + } + if ((length == 24 && width == 50) || (length == 50 && width == 24)) { + base_price = 30; + } + if ((length == 24 && width == 100) || (length == 100 && width == 24)) { + base_price = 35; + } + if ((length == 17 && width == 70) || (length == 70 && width == 17)) { + base_price = 30; + } + if ((length == 17 && width == 50) || (length == 50 && width == 17)) { + base_price = 30; + } + if ((length == 17 && width == 100) || (length == 100 && width == 17)) { + base_price = 35; + } + Product product = new Product(); + product.setCount(dto.getCount()); + product.setNumber(number); + product.setPrice(Math.ceil(base_price * dto.getCount())); + priceList.add(product); + + } + /* } */ + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + product.setWeight(df.format(length * width * product.getCount() / 10000 * number * 0.075)); + } + return priceList; + } + + private List getkaTiePrice(Product dto, Double width, Double length) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + + int min = getNum(length, width); + dto.setProTypeValue("4"); + priceList = getHekaPrice(min, dto, priceList, count); + for (Product product : priceList) { + double dNum = 1; + if (product.getCount() / 1000 > 1) { + dNum = Math.floor(product.getCount() / 1000); + } + product.setPrice(Math.ceil(product.getPrice() + dNum * 3)); + } + //工艺计算 + if (!StringUtils.isEmpty(dto.getCraft())) { + List craList = Arrays.asList(dto.getCraft()); + + if (craList.contains("模切")) { + if (min < 3) { + for (Product product : priceList) { + product.setPrice(Math.ceil(product.getPrice() + 25 + 0.04 * product.getCount())); + } + } else if (min < 16) { + for (Product product : priceList) { + product.setPrice(Math.ceil(product.getPrice() + 50 + 0.04 * product.getCount())); + } + } else { + for (Product product : priceList) { + product.setPrice(Math.ceil(product.getPrice() + 30 + 50 + 0.04 * product.getCount())); + } + } + } + } + + // 根据款数重新算价格/计算重量 + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + product.setWeight(df.format(number * length / 100 * width / 100 * product.getCount() * 0.3 * 0.86)); + } + return priceList; + } + + private List getTuoBeiPrice(Product dto, Double width, Double length) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + String size = dto.getSize(); + double area = length * width / 10000; + if ("250克白卡纸".equals(dto.getKind())) { + priceList = CupHolderUtil.getPrice(area, count, priceList); + for (Product product : priceList) { + product.setWeight(df.format(number * length / 100 * width / 100 * product.getCount() * 0.25)); + } + + } else { + priceList = CupHolderUtil.getPvcPrice(size, dto.getKind(), count, priceList); + for (Product product : priceList) { + product.setWeight(df.format(0.38 * 0.0855 * 1.3 * 0.054 * product.getCount() * number)); + } + } + if (number > 1) { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + } + } + + return priceList; + } + + private List getTianMuPrice(Product dto, Double width, Double length) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + double area = length * width / 10000; + if (dto.getCraftShua().contains("空白") && dto.getCraftQie() != null && dto.getCraftQie().contains("模切")) { + dto.setCraftShua("定制"); + } + priceList = CanopyUtil.getPrice(area, count, priceList, dto.getKindValue(), dto.getCraftShua()); + if (number > 1) { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + } + } + if (dto.getShuliang() != null) { + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() + dto.getShuliang() * 50)); + product.setWeight(String.valueOf(Double.parseDouble(product.getWeight()) + dto.getShuliang() * 3.3)); + } + } + + return priceList; + } + + private List getGuaBuPrice(Product dto, Double width, Double length) { + List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); + List priceList = new ArrayList<>(); + int count = dto.getCount(); + int number = dto.getNumber(); + double area = length * width / 10000; + + priceList = AngClothUtil.getPrice(area, count, priceList, dto.getCraft()); + for (Product product : priceList) { + product.setPrice(Math.floor(product.getPrice() * number)); + double other_price = 0; + if (area <= 0.25) { + other_price = (count) * 5 * number; + product.setPrice(Math.floor(45 + other_price)); + } + product.setWeight(df.format(area * product.getCount() * number * 0.06)); + } + + return priceList; + } + private List getClotherPrice(Product dto, Double width, Double length) { List craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft()); List priceList = new ArrayList<>(); @@ -5553,7 +5755,7 @@ public class ProductService { baseWeight = 11; } double[][] prices = { - {118, 236, 350, 450, 480, 576, 672, 768, 864, 900}, + {118, 233, 346, 450, 480, 576, 672, 768, 864, 900}, {0, 0, 340, 450, 570, 684, 798, 912, 1026, 1040}, {0, 0, 350, 460, 810, 972, 1134, 1296, 1458, 1780}, }; @@ -7820,7 +8022,7 @@ public class ProductService { for (Product product : priceList) { for (int i = 0; i < counts.length; i++) { if (counts[i] == product.getCount()) { - product.setPrice(prices[i]); + product.setPrice(prices[i] * dto.getNumber()); } } diff --git a/src/main/java/lingtao/net/util/HuaFangPriceUtil.java b/src/main/java/lingtao/net/util/HuaFangPriceUtil.java new file mode 100644 index 0000000..9e4a2af --- /dev/null +++ b/src/main/java/lingtao/net/util/HuaFangPriceUtil.java @@ -0,0 +1,198 @@ +package lingtao.net.util; + + +import com.alibaba.fastjson.JSONObject; +import lingtao.net.vo.HuaFangPriceRequstVo; +import lingtao.net.vo.HuaFangPriceResultVo; +import lingtao.net.vo.HuaFangTokenVo; +import okhttp3.*; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +public class HuaFangPriceUtil { + + private static final OkHttpClient HTTP_CLIENT = new OkHttpClient(); + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static final MediaType FORM = MediaType.parse("application/x-www-form-urlencoded; charset=utf-8"); + + private static final String userName = "001008"; + + private static final String password = "lt666888"; + + /** + * 通用HTTP GET请求方法 + * + * @param url 请求地址 + * @param headers 请求头映射 + * @return 响应结果字符串 + */ + public static String sendGetRequest(String url, Map headers) { + Request.Builder builder = new Request.Builder() + .header("Content-Type", "application/json") + .url(url); + // 添加请求头 + if (headers != null && !headers.isEmpty()) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + + Request request = builder.build(); + + try (Response response = HTTP_CLIENT.newCall(request).execute()) { + if (!response.isSuccessful()) { + throw new IOException("请求异常: " + response.code()); + } + return response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + /** + * 通用HTTP GET请求方法(无请求头) + * + * @param url 请求地址 + * @return 响应结果字符串 + */ + public static String sendGetRequest(String url) { + return sendGetRequest(url, null); + } + + /** + * 通用HTTP POST请求方法(JSON参数) + * + * @param url 请求地址 + * @param jsonParam JSON参数 + * @param headers 请求头映射 + * @return 响应结果字符串 + */ + public static String sendPostRequest(String url, String jsonParam, Map headers) { + RequestBody body = RequestBody.create(JSON, jsonParam); + Request.Builder builder = new Request.Builder() + .header("Content-Type", "application/json") + .url(url) + .post(body); + + // 添加请求头 + if (headers != null && !headers.isEmpty()) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + + Request request = builder.build(); + + try (Response response = HTTP_CLIENT.newCall(request).execute()) { + if (!response.isSuccessful()) { + throw new IOException("请求异常: " + response.code()); + } + return response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + /** + * 通用HTTP POST请求方法(JSON参数,无请求头) + * + * @param url 请求地址 + * @param jsonParam JSON参数 + * @return 响应结果字符串 + */ + public static String sendPostRequest(String url, String jsonParam) { + return sendPostRequest(url, jsonParam, null); + } + + /** + * 通用HTTP POST请求方法(表单参数) + * + * @param url 请求地址 + * @param formParams 表单参数映射 + * @param headers 请求头映射 + * @return 响应结果字符串 + */ + public static String sendPostFormRequest(String url, Map formParams, Map headers) { + StringBuilder formBody = new StringBuilder(); + if (formParams != null && !formParams.isEmpty()) { + for (Map.Entry entry : formParams.entrySet()) { + if (formBody.length() > 0) { + formBody.append("&"); + } + formBody.append(entry.getKey()).append("=").append(entry.getValue()); + } + } + + RequestBody body = RequestBody.create(FORM, formBody.toString()); + Request.Builder builder = new Request.Builder() + .header("Content-Type", "application/json") + .url(url) + .post(body); + + // 添加请求头 + if (headers != null && !headers.isEmpty()) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + + Request request = builder.build(); + + try (Response response = HTTP_CLIENT.newCall(request).execute()) { + if (!response.isSuccessful()) { + throw new IOException("请求异常: " + response.code()); + } + return response.body().string(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + /** + * 通用HTTP POST请求方法(表单参数,无请求头) + * + * @param url 请求地址 + * @param formParams 表单参数映射 + * @return 响应结果字符串 + */ + public static String sendPostFormRequest(String url, Map formParams) { + return sendPostFormRequest(url, formParams, null); + } + + public static String getToken() { + String token = ""; + LocalDateTime currentTime = LocalDateTime.now(); + String templateName = "HUAFANG_TOKEN"; + + if (!RedisUtil.exists(templateName)) { + Map params = new HashMap<>(); + params.put("userName", userName); + params.put("password", password); + + String tokenString = sendPostRequest("http://ds.gw.chenghuiyin.com/ordering/api/User/GetToken", JSONObject.toJSONString(params)); + System.out.println("获取token返回:" + tokenString); + HuaFangTokenVo huaFangTokenVo = JSONObject.parseObject(tokenString, HuaFangTokenVo.class); + RedisUtil.set(templateName, huaFangTokenVo.getAccessToken(), huaFangTokenVo.getExpiresIn() - 50); + } + Object tokenObj = RedisUtil.get(templateName); + if (tokenObj != null) { + token = tokenObj.toString(); + } + System.out.println("获取token:" + token); + return token; + } + + public static HuaFangPriceResultVo getPrice(HuaFangPriceRequstVo params) { + Map heards = new HashMap<>(); + heards.put("Authorization", "Bearer " + getToken()); + String resultText = sendPostRequest("http://ds.quote.chenghuiyin.com/api/app/price/calc-price", JSONObject.toJSONString(params), heards); + HuaFangPriceResultVo result = JSONObject.parseObject(resultText, HuaFangPriceResultVo.class); + return result; + } +} diff --git a/src/main/java/lingtao/net/util/RedisUtil.java b/src/main/java/lingtao/net/util/RedisUtil.java new file mode 100644 index 0000000..406cc3d --- /dev/null +++ b/src/main/java/lingtao/net/util/RedisUtil.java @@ -0,0 +1,112 @@ +package lingtao.net.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +@Component +public class RedisUtil implements ApplicationContextAware { + + private static RedisTemplate redisTemplate; + private static ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext context) throws BeansException { + applicationContext = context; + redisTemplate = (RedisTemplate) applicationContext.getBean("redisTemplate"); + } + + /** + * 设置缓存 + * + * @param key 键 + * @param value 值 + */ + public static void set(String key, Object value) { + if (redisTemplate != null) { + redisTemplate.opsForValue().set(key, value); + } + } + + /** + * 设置缓存(带过期时间) + * + * @param key 键 + * @param value 值 + * @param expireTime 过期时间(秒) + */ + public static void set(String key, Object value, long expireTime) { + if (redisTemplate != null) { + redisTemplate.opsForValue().set(key, value, expireTime, TimeUnit.SECONDS); + } + } + + /** + * 获取缓存 + * + * @param key 键 + * @return 值 + */ + public static Object get(String key) { + if (redisTemplate != null) { + return redisTemplate.opsForValue().get(key); + } + return null; + } + + /** + * 删除缓存 + * + * @param key 键 + */ + public static void delete(String key) { + if (redisTemplate != null) { + redisTemplate.delete(key); + } + } + + /** + * 检查键是否存在 + * + * @param key 键 + * @return 是否存在 + */ + public static boolean exists(String key) { + if (redisTemplate != null) { + return redisTemplate.hasKey(key); + } + return false; + } + + /** + * 设置过期时间 + * + * @param key 键 + * @param expireTime 过期时间(秒) + * @return 是否成功 + */ + public static boolean expire(String key, long expireTime) { + if (redisTemplate != null) { + return redisTemplate.expire(key, expireTime, TimeUnit.SECONDS); + } + return false; + } + + /** + * 获取剩余过期时间 + * + * @param key 键 + * @return 剩余过期时间(秒) + */ + public static long getExpire(String key) { + if (redisTemplate != null) { + return redisTemplate.getExpire(key, TimeUnit.SECONDS); + } + return -1; + } + +} diff --git a/src/main/java/lingtao/net/vo/HuaFangPriceProcessItemsVo.java b/src/main/java/lingtao/net/vo/HuaFangPriceProcessItemsVo.java new file mode 100644 index 0000000..28bcd87 --- /dev/null +++ b/src/main/java/lingtao/net/vo/HuaFangPriceProcessItemsVo.java @@ -0,0 +1,13 @@ +package lingtao.net.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class HuaFangPriceProcessItemsVo { + + private String processName; + private String processValue; + private List sizes; +} diff --git a/src/main/java/lingtao/net/vo/HuaFangPriceRequstVo.java b/src/main/java/lingtao/net/vo/HuaFangPriceRequstVo.java new file mode 100644 index 0000000..14b9122 --- /dev/null +++ b/src/main/java/lingtao/net/vo/HuaFangPriceRequstVo.java @@ -0,0 +1,23 @@ +package lingtao.net.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class HuaFangPriceRequstVo { + + private Integer styleNum; + + private List sizes; + + private String productPrintFace; + private String productPrintColor; + private String productPaperCode; + private String productPaperName; + private String productName; + private Integer num; + + private List calcProcess; + +} diff --git a/src/main/java/lingtao/net/vo/HuaFangPriceResultVo.java b/src/main/java/lingtao/net/vo/HuaFangPriceResultVo.java new file mode 100644 index 0000000..3594547 --- /dev/null +++ b/src/main/java/lingtao/net/vo/HuaFangPriceResultVo.java @@ -0,0 +1,21 @@ +package lingtao.net.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class HuaFangPriceResultVo { + private String id; + + private Double amount; + @JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXXX") + private LocalDateTime deliveryTime; + + private Double totalWeight; + + private Double deliveryAmount; + + private Double productAmount; +} diff --git a/src/main/java/lingtao/net/vo/HuaFangTokenVo.java b/src/main/java/lingtao/net/vo/HuaFangTokenVo.java new file mode 100644 index 0000000..f7dec66 --- /dev/null +++ b/src/main/java/lingtao/net/vo/HuaFangTokenVo.java @@ -0,0 +1,11 @@ +package lingtao.net.vo; + +import lombok.Data; + +@Data +public class HuaFangTokenVo { + + private String accessToken; + private Integer expiresIn; + +} diff --git a/src/main/resources/applicationContext.xml b/src/main/resources/applicationContext.xml index 08f4b4c..ba577cd 100644 --- a/src/main/resources/applicationContext.xml +++ b/src/main/resources/applicationContext.xml @@ -123,4 +123,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/views/product/coupon.jsp b/src/main/webapp/views/product/coupon.jsp index 3881c83..9c6a293 100644 --- a/src/main/webapp/views/product/coupon.jsp +++ b/src/main/webapp/views/product/coupon.jsp @@ -47,6 +47,10 @@ right: 40px; } + .huafangCraft .layui-form-select .layui-edge { + right: 40px; + } + .value7 .layui-form-select .layui-edge { right: 20px; } @@ -470,8 +474,13 @@
覆膜工艺: - + + + + + + +
@@ -531,6 +540,21 @@ id="widthTang" class="layui-input" style="width:50px;height:35px;">
+ + + + +
+ +
x +
+ +
+
+
+
特殊工艺: @@ -1319,19 +1343,37 @@ form.render(); }) form.on("checkbox(z4PeiJian)", function (data) { - let peijiansize = []; + let craft_pei = []; $(".peijian:checked").each(function (i) { // 没有被禁用的工艺加到arr中 if (!$(this).is(':disabled') && $(this).val() != "opp袋") { - peijiansize.push($(this).val()); + craft_pei.push($(this).val()); } }); - if (peijiansize.length > 1) { + let craft_list = []; + $("input:checkbox[name='craft']:checked").each(function (i) { + if (!$(this).is(':disabled')) { + craft_list.push($(this).val()); + } + }); + if (craft_pei.length > 1) { $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox"); $(data.elem).prop("checked", false); layer.msg('配件只能选择一种!', {offset: ['300px', '300px']}, {icon: 5}); return false; } + const carft_pei = ["配葫芦针", "流苏", "尼龙绳", "配弹力绳", "配弹力绳捆", "opp袋", "配棉绳", "内部模切"]; + const carft_nopei = ["单面局部UV", "双面局部UV", "双面星光膜", "双面镭射膜", "双面触感膜", "双面雪花膜"]; + const carftpei = carft_pei.filter(craft => craft_list.includes(craft)); + const carftnopei = carft_nopei.filter(craft => craft_list.includes(craft)); + + if (carftpei.length > 0 && carftnopei.length > 0) { + $(data.elem).prop("checked", false); + layer.msg(carft_nopei.join(",") + "与配件、内部模切不能同时选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } if (data.value == "流苏") { if ($(data.elem).is(":checked")) { $("#peijian_ui .select_liusu").show(); @@ -1408,6 +1450,7 @@ return false; } + if (data.value == "配尼龙绳") { if ($(data.elem).is(":checked")) { $("#lesspeijian .scolor").show(); @@ -1438,6 +1481,7 @@ }); form.on("radio(kindValue2)", function (data) { peijianuiHide(); + if (data.value == 10) { $("#craftForm").hide(); $("#craftForm").find(":input").attr("disabled", true); @@ -1448,7 +1492,8 @@ $("#z4_craft").find(":input").attr("disabled", false); $("#peijian_ui").find(":input").attr("disabled", false); $("#z4_craft .ui_double_fm").prop("checked", true); - $('.ui_fm_l').find(":input").prop('checked', true); + $('.ui_fm_l').find(":input").prop('checked', false); + $('.ui_fm_l input[value="双面覆哑膜"]').prop('checked', true); $("#z4_craft .scolor").hide(); $("#peijian_ui .scolor").hide(); $("#z4_craft .dadianxianhide").hide(); @@ -1612,6 +1657,15 @@ $(".guaguaSize1").find("select").attr("disabled", true); var kind; var kindValue; + form.on('checkbox(switchMQ)', function (switchData) { + if ($(".normalCountHideCraft .mq:checked").length > 1) { + $(switchData.elem).next().attr("class", "layui-unselect layui-form-checkbox"); + $(switchData.elem).prop("checked", false); + layer.msg('[裁切- 模切]不能同时选择!', {offset: ['300px', '300px']}, {icon: 5}); + form.render('checkbox'); + return false; + } + }) form.on('radio(kind)', function (data) { kind = data.value; if (data.value == 1) { @@ -1631,8 +1685,11 @@ $(".lesspeijian").prop("checked", false); $("#lesspeijian").hide(); $("#lesspeijian").find(":input").attr("disabled", true); + $(".huafangCraft").hide(); + $(".huafangCraft").find(":input").attr("disabled", true); $(".ui_fm_l").show(); $('.ui_fm_l').find(":input").attr("disabled", false); + $('.ui_fm_l').find(":input").prop('checked', false); $("#peijian_ui form")[0].reset(); peijianuiHide() if (data.value == '直角卡片' || data.value == '异形卡片' || data.value == '贺卡' || data.value == '特种纸名片') { @@ -1737,7 +1794,7 @@ form.render('checkbox'); if (kindValueData.value == 2) { $("#craftHu").show(); - $('.ui_fm_l').find(":input").prop('checked', true); + $('.ui_fm_l input[value="双面覆哑膜"]').prop('checked', true); $(".ui_fm").prop('disabled', false); $(".yhydx").show(); $('.yhydx').find(":input").attr("disabled", false); @@ -1772,6 +1829,13 @@ } else { kindValueData.value = 1; } + if ($(".normalCountHideCraft .mq:checked").length > 1) { + $(switchData.elem).next().attr("class", "layui-unselect layui-form-checkbox"); + $(switchData.elem).prop("checked", false); + layer.msg('[裁切- 模切]不能同时选择!', {offset: ['300px', '300px']}, {icon: 5}); + form.render('checkbox'); + return false; + } if (switchData.elem.checked) { $(".disab").attr("disabled", true); @@ -1985,13 +2049,13 @@ //卡片默认覆膜 if (couponKind != "少数量" && data.value != 1 && data.value != 8 && data.value != 9 && data.value != 10 && data.value != 11) { $('.ui_double_fm').prop('checked', true); - $('.ui_fm_l').find(":input").prop('checked', true); + $('.ui_fm_l input[value="双面覆哑膜"]').prop('checked', true); form.on('checkbox(ui_fm)', function (switchData) { if (!switchData.elem.checked) { layer.msg('卡片不能取消 [覆膜] 工艺!', {offset: ['300px', '300px']}, function () { }); $('.ui_double_fm').prop('checked', true); - $('.ui_fm_l').find(":input").prop('checked', true); + $('.ui_fm_l input[value="双面覆哑膜"]').prop('checked', true); form.render('checkbox'); } getProductImage(switchData.elem.checked ? switchData.value : '') @@ -2085,14 +2149,12 @@ $(".tj").hide(); $(".tj").find(":input").attr("disabled", true); } - form.on('checkbox(switchMQ)', function (switchData) { - if ($(".normalCountHideCraft .mq:checked").length > 1) { - $(switchData.elem).next().attr("class", "layui-unselect layui-form-checkbox"); - $(switchData.elem).prop("checked", false); - layer.msg('[裁切- 模切]不能同时选择!', {offset: ['300px', '300px']}, {icon: 5}); - return false; - } - }) + + + if (data.value == 3) { + $(".huafangCraft").show(); + $(".huafangCraft").find(":input").attr("disabled", false); + } form.render('checkbox'); @@ -2620,13 +2682,13 @@ layer.msg('单面覆膜和双面覆膜只能选一种!', {offset: ['300px', '300px']}, {icon: 5}); return false; } - if (!data.elem.checked && data.value == "双面覆哑膜") { - layer.msg('不能取消 [覆膜] 工艺!', {offset: ['300px', '300px']}, function () { - }); - $(data.elem).prop("checked", true); - form.render(); - return; - } + // if (!data.elem.checked && data.value == "双面覆哑膜") { + // layer.msg('不能取消 [覆膜] 工艺!', {offset: ['300px', '300px']}, function () { + // }); + // $(data.elem).prop("checked", true); + // form.render(); + // return; + // } let craft_list = []; $("input:checkbox[name='craft']:checked").each(function (i) { if (!$(this).is(':disabled')) { @@ -2642,6 +2704,26 @@ form.render(); return false; } + const carft_list2 = ["双面覆哑膜", "双面星光膜", "双面镭射膜", "双面触感膜", "双面雪花膜"]; + const carft_pei = ["配葫芦针", "流苏", "尼龙绳", "配弹力绳", "配弹力绳捆", "opp袋", "配棉绳"]; + const carft_nopei = ["单面局部UV", "双面局部UV", "双面星光膜", "双面镭射膜", "双面触感膜", "双面雪花膜"]; + const carft2 = carft_list2.filter(craft => craft_list.includes(craft)); + const carftpei = carft_pei.filter(craft => craft_list.includes(craft)); + const carftnopei = carft_nopei.filter(craft => craft_list.includes(craft)); + if (carft2.length > 1) { + $(data.elem).prop("checked", false); + layer.msg("覆膜不能同时选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } + if (carftpei.length > 0 && carftnopei.length > 0) { + $(data.elem).prop("checked", false); + layer.msg(carft_nopei.join(",") + "与配件不能同时选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } if (data.value == "压痕") { if (data.elem.checked) { $(".yhselect").show(); @@ -2679,6 +2761,13 @@ // 监听工艺多选框 form.on('checkbox(switchMQ)', function (data) { var kind = $('input[name="kind"]:checked').val(); + if ($(".normalCountHideCraft .mq:checked").length > 1) { + $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox"); + $(data.elem).prop("checked", false); + layer.msg('[裁切- 模切]不能同时选择!', {offset: ['300px', '300px']}, {icon: 5}); + form.render('checkbox'); + return false; + } //判断当前多选框是选中还是取消选中 if (kind != 7) { // 除存酒卡 @@ -2748,7 +2837,7 @@ if (tangjin > 1) { $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox"); $(data.elem).prop("checked", false); - layer.msg('[单面烫金 - 双面烫金]不能同时选择!', {offset: ['300px', '300px']}, {icon: 5}); + layer.msg('烫金工艺不能同时选择!', {offset: ['300px', '300px']}, {icon: 5}); return false; } var hu = $(".ui_hu:checked").length; @@ -3079,20 +3168,29 @@ }); form.on('checkbox(nmq)', (data) => { - let craft = []; + let craft_list = []; $("input:checkbox[name='craft']:checked").each(function (i) { // 没有被禁用的工艺加到arr中 if (!$(this).is(':disabled')) { - craft.push($(this).val()); + craft_list.push($(this).val()); } }); - if (!craft.includes("模切")) { + if (!craft_list.includes("模切")) { $(data.elem).prop("checked", false); layer.msg("异形模切才能选择内部模切", {offset: ['300px', '300px']}, function () { }); form.render(); return false; } + const carft_nopei = ["单面局部UV", "双面局部UV", "双面星光膜", "双面镭射膜", "双面触感膜", "双面雪花膜"]; + const carftnopei = carft_nopei.filter(craft => craft_list.includes(craft)); + if (data.elem.checked && carftnopei.length > 0) { + $(data.elem).prop("checked", false); + layer.msg(carft_nopei.join(",") + "与配件、内部模切不能同时选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } if (data.elem.checked) { $(".n_mq_input").css("display", "flex") $(".n_mq_input input").prop("disabled", false); @@ -3250,6 +3348,22 @@ } } + if (kindValue2 == 2 && kind == 3) { + if ($(this).val() === '单面局部UV' || $(this).val() === '双面局部UV') { + if ($("#lengthVU").val() == '' || $("#widthUV").val() == '') { + layer.msg('请填写UV版尺寸!', {offset: ['300px', '300px']}, function () { + }); + return false; + } + if (Number(size.split("*")[0]) < Number($("#widthUV").val()) || Number(size.split("*")[1]) < Number($("#lengthVU").val())) { + layer.msg('UV版尺寸不能大于输入尺寸!', {offset: ['300px', '300px']}, function () { + }); + return false; + } + arr.push($(this).val() + $("#widthUV").val() + "*" + $("#lengthVU").val()); + return + } + } if ($(this).val() === '打孔' && kind != "种子纸") { arr.push("打孔" + $(".wkong:enabled option:selected").val()) return; @@ -3659,21 +3773,20 @@ } else { } } - // 没选中[覆膜]工艺,设置工艺为“不覆膜” - var fmFlag = false; - if (arr.length > 0) { - for (let i = 0; i < arr.length; i++) { - if (arr[i].indexOf('覆') != -1) { - fmFlag = true - } - } - if (!fmFlag) { - arr.push("双面不覆膜") - } - } else { - arr.push("双面不覆膜") - } + // var fmFlag = false; + // if (arr.length > 0) { + // for (let i = 0; i < arr.length; i++) { + // if (arr[i].indexOf('覆') != -1) { + // fmFlag = true + // } + // } + // if (!fmFlag) { + // arr.push("双面不覆膜") + // } + // } else { + // arr.push("双面不覆膜") + // } } else { if (kind != "种子纸") { arr.push($('input[name="craftShua"]:checked').val()) diff --git a/src/main/webapp/views/product/yafen.jsp b/src/main/webapp/views/product/yafen.jsp new file mode 100644 index 0000000..0495c47 --- /dev/null +++ b/src/main/webapp/views/product/yafen.jsp @@ -0,0 +1,416 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + Insert title here + <%@include file="/views/common.jsp" %> + + + +
+
+

哑粉纸

+
+
+ +

+ 材质 +

+
+ +
+

+ 尺寸(CM/厘米) +

+
+ +
+

+ 数量(个) +

+
+ +
+ +

+ 款数 +

+
+ +
+

+ 客户旺旺 +

+
+ +
+

+ 工艺 +

+
+ +
+ 裁切工艺: + + +
+ +
+ 常见工艺: + + + + + + +
+
+
+
+ + +
+

计算结果- + +

+
+ + <%@include file="../acountExpressFee.jsp" %> +
+
+
+
+
+
+
+ +
+
+ +<%@include file="/views/copyResult.jsp" %> + + \ No newline at end of file