diff --git a/src/main/java/lingtao/net/service/ProductService.java b/src/main/java/lingtao/net/service/ProductService.java index a6ab239..bbee454 100644 --- a/src/main/java/lingtao/net/service/ProductService.java +++ b/src/main/java/lingtao/net/service/ProductService.java @@ -420,7 +420,7 @@ public class ProductService { if ("18".equals(kind)) { kind = "7"; } - priceList = new PriceUtils().rollLabelPrice(kind, area, count, dto.getCraft(), dto.getYinbai(), dto.getCraftTang(), getStickersTanBasePrice(area * 10000)); + priceList = new PriceUtils().rollLabelPrice(kind, area, count, dto.getCraft(), dto.getYinbai(), dto.getCraftTang(), getStickersTanBasePrice(area * 10000), dto); // 根据款数重新算价格/计算重量 for (Product product : priceList) { product.setPrice(Math.floor(product.getPrice() * number)); @@ -645,7 +645,7 @@ public class ProductService { case "2": // 单个产品的面积 area = (length + 0.3) * (width + 0.3) / 10000; - priceList = new PriceUtils().rollLabelPrice(kind, area, count, dto.getCraft(), dto.getYinbai(), dto.getCraftTang(), getStickersTanBasePrice(area * 10000)); + priceList = new PriceUtils().rollLabelPrice(kind, area, count, dto.getCraft(), dto.getYinbai(), dto.getCraftTang(), getStickersTanBasePrice(area * 10000), dto); // 根据款数重新算价格/计算重量 for (Product product : priceList) { product.setPrice(Math.floor(product.getPrice() * number)); diff --git a/src/main/java/lingtao/net/util/PriceUtils.java b/src/main/java/lingtao/net/util/PriceUtils.java index e85758c..6417bfe 100644 --- a/src/main/java/lingtao/net/util/PriceUtils.java +++ b/src/main/java/lingtao/net/util/PriceUtils.java @@ -27,9 +27,33 @@ public class PriceUtils { * @param yinbai * @return */ - public List rollLabelPrice(String kind, Double area, int count, String[] craft, String yinbai, String tang, double[] tangPrices) { + public List rollLabelPrice(String kind, Double area, int count, String[] craft, String yinbai, String tang, double[] tangPrices, Product dto) { List list = new ArrayList(); Product pro = new Product(); + + if ("封口贴".equals(dto.getKind())) { + int[] counts = {1000, 2000, 3000, 5000, 10000, 20000, 50000, 100000}; + double[] prices = {180, 260, 311, 400, 558, 650, 1100, 1800}; + if ("9*2".equals(dto.getSize())) { + prices = new double[]{180, 260, 311, 400, 558, 650, 1100, 1800}; + } + if ("10*2".equals(dto.getSize())) { + prices = new double[]{220, 300, 337, 412, 600, 680, 1200, 1980}; + } + for (int i = 0; i < counts.length; i++) { + if (counts[i] < dto.getCount()) { + continue; + } + if (list.size() > 2) { + break; + } + pro = new Product(); + pro.setCount(counts[i]); + pro.setPrice(prices[i] ); + list.add(pro); + } + return list; + } // 最低收费 double lowerPrice = 0.0; // 印工价格 @@ -281,8 +305,9 @@ public class PriceUtils { // 换成毫米每边+2 length = length * 10 + 4; width = width * 10 + 4; - if ((length > l || width > w) && (length > w || width > l)) + if ((length > l || width > w) && (length > w || width > l)) { return null; + } // 一张大纸能做多少个此类尺寸的不干胶 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); @@ -332,8 +357,9 @@ public class PriceUtils { // 换成毫米每边+2 length = length * 10 + 4; width = width * 10 + 4; - if ((length > l || width > w) && (length > w || width > l)) + if ((length > l || width > w) && (length > w || width > l)) { return null; + } // 一张大纸能做多少个此类尺寸的不干胶 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); @@ -1328,8 +1354,9 @@ public class PriceUtils { width = width * 10 + 2 * 1.5; // 数量*款数就是张数 // count = count * number; - if ((length > l || width > w) && (length > w || width > l)) + if ((length > l || width > w) && (length > w || width > l)) { return null; + } // 一张大纸29*19cm 能做多少个此类尺寸的金属标 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); @@ -1998,8 +2025,9 @@ public class PriceUtils { width = width * 10 + 2 * 1.5; // 数量*款数就是张数 count = count * number; - if ((length > l || width > w) && (length > w || width > l)) + if ((length > l || width > w) && (length > w || width > l)) { return null; + } // 一张大纸45*40cm 能做多少个此类尺寸的桌贴 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); @@ -2100,8 +2128,9 @@ public class PriceUtils { width = width * 10 + 2 * 3; // 数量 * 款数就是张数 count = count * number; - if ((length > l || width > w) && (length > w || width > l)) + if ((length > l || width > w) && (length > w || width > l)) { return null; + } // 一张大纸420*380mm 能做多少个此类尺寸的桌贴 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); @@ -3305,8 +3334,9 @@ public class PriceUtils { String kind = dto.getKind2Value(); length = length * 10; width = width * 10; - if ((length > l || width > w) && (length > w || width > l)) + if ((length > l || width > w) && (length > w || width > l)) { return null; + } // 一张大纸能做多少个此类尺寸的不干胶 double max = Math.max(Math.floor(l / length) * Math.floor(w / width), Math.floor(l / width) * Math.floor(w / length)); diff --git a/src/main/webapp/views/product/rollLabel.jsp b/src/main/webapp/views/product/rollLabel.jsp index 9c9d8e5..71a2155 100644 --- a/src/main/webapp/views/product/rollLabel.jsp +++ b/src/main/webapp/views/product/rollLabel.jsp @@ -23,12 +23,16 @@
+

+ 品类 +

+ +

材料

+
+ +
+
+

数量(个)

-
+
+
+ +

款数

@@ -75,25 +97,35 @@
覆膜 : - - - + + + + + + + +
-
+
白墨 :
-
+
烫金 :
卷芯 : - - - + + + + + + + +
出标方向 : @@ -102,7 +134,6 @@
-

@@ -141,7 +172,11 @@ layui.use(['table', 'form'], function () { var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功 var table = layui.table; - + $(".sealant").hide(); + $(".sealant").find("input").attr("disabled", true); + $(".sealant").find("select").attr("disabled", true); + $("input[name='yinbai']").attr("disabled", true); + form.render() form.on('select(kindValue)', function (data) { // 中间三个可以印白 if (data.value == 3 || data.value == 4 || data.value == 5) { @@ -182,9 +217,41 @@ }); }) + form.on("radio(kind)", function (data) { + let html = ` + + + + + + + ` + $(".sealant").hide(); + $(".sealant").find("input").attr("disabled", true); + $(".sealant").find("select").attr("disabled", true); + $(".roll").hide(); + $(".roll").find("input").attr("disabled", true); + if (data.value == "卷标") { + $(".roll").show(); + $(".roll").find("input").attr("disabled", false); + + $("input[name='jx'][value='7.5cm']").click() + } + if (data.value == "封口贴") { + html = ` ` + $(".sealant").show(); + $(".sealant").find("input").attr("disabled", false); + $(".sealant").find("select").attr("disabled", false); + $("input[name='jx'][value='2.5cm']").click() + } + $("input[name='yinbai']").attr("disabled", true); + $("#kindValue").empty().append(html); + form.render() + }) + form.on('checkbox(switch)', function (data) { // 亮膜哑膜只能选一个 - var moLen = $(".fm:checked").length; + var moLen = $(".fm:checked:not(:disabled)").length; if (moLen > 1) { $(data.elem).next().attr("class", "layui-unselect layui-form-checkbox"); $(data.elem).prop("checked", false); @@ -199,6 +266,7 @@ 3: "5丝格底透明", 4: "格底哑银 / 亮银", 5: "格底银平光", 6: "单防热敏纸(底纸白色)", 7: "三防热敏纸(底纸蓝色)" }; + var type = $("input[name='kind']:checked").val(); var kind = kindData[$("#kindValue").val()]; var size = $("#size").val(); var number = $("#number").val(); @@ -215,16 +283,22 @@ yinbai.push($(this).val()); } }); - if ((size.split("*")[0] > 42 || size.split("*")[1] > 38) && (size.split("*")[0] > 38 || size.split("*")[1] > 42)) { - layer.msg("卷装标签尺寸不能超过42*38 cm", {offset: ['300px', '300px']}, function () { - }); - return false; + if (type == "封口贴") { + size = $("select[name='size'] option:selected").val() } - if ((size.split("*")[0] < 2 || size.split("*")[1] < 2)) { - layer.msg("卷装标签尺寸小于2*2 cm 请单独报价!", {offset: ['300px', '300px']}, function () { - }); - return false; + if (type == "卷标") { + if ((size.split("*")[0] > 42 || size.split("*")[1] > 38) && (size.split("*")[0] > 38 || size.split("*")[1] > 42)) { + layer.msg("卷装标签尺寸不能超过42*38 cm", {offset: ['300px', '300px']}, function () { + }); + return false; + } + if ((size.split("*")[0] < 2 || size.split("*")[1] < 2)) { + layer.msg("卷装标签尺寸小于2*2 cm 请单独报价!", {offset: ['300px', '300px']}, function () { + }); + return false; + } } + $.ajax({ url: "${path}/getThanSum", type: "GET", @@ -240,23 +314,23 @@ let craft_list = []; if ($("#kindValue").val() == 0) { jx = $("input[name='jx']:checked").val(); - span_result = kind + ' - ' + size + ' 厘米 -卷芯直径' + $("input[name='jx']:checked").val() + '出标方向' + $("input[name='cb']:checked").val() + '(同款内容)\n' + '款数 : ' + number + '\n'; + span_result = kind + ' - ' + size + ' 厘米 -卷芯直径' + $("input[name='jx']:checked:not(:disabled)").val() + '出标方向' + $("input[name='cb']:checked:not(:disabled)").val() + '(同款内容)\n' + '款数 : ' + number + '\n'; } else { span_result = kind + ' - ' + size + ' 厘米 -(同款内容)\n' + '款数 : ' + number + '\n'; } - let fm = $("input[name='craft']:checked").val(); + let fm = $("input[name='craft']:checked:not(:disabled)").val(); if (!!fm) { craft_list.push(fm); } - let yb = $("input[name='yinbai']:checked").val(); + let yb = $("input[name='yinbai']:checked:not(:disabled)").val(); if (!!yb) { craft_list.push(yb); } - let craftTang = $("input[name='craftTang']:checked").val(); + let craftTang = $("input[name='craftTang']:checked:not(:disabled)").val(); if (!!craftTang) { craft_list.push(craftTang); } - if(craft_list.length > 0){ + if (craft_list.length > 0) { span_result += "工艺:" + craft_list.join(",") + '\n'; } if (number > 1) { @@ -271,9 +345,9 @@ } } span_result += '包邮,免费设计呢~(偏远地区需补邮费)' - if(window.parent.system_isGai){ - span_result +="\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!" - } + if (window.parent.system_isGai) { + span_result += "\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!" + } addLog(span_result); $("#span_result").val(span_result);