From 3da5fa97a83600f6f249d7ca6bb18c16642166e1 Mon Sep 17 00:00:00 2001 From: zhuyiyi <649091362@qq.com> Date: Thu, 23 Apr 2026 15:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=A1=E7=89=87=E5=B7=A5?= =?UTF-8?q?=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../lingtao/net/service/ProductService.java | 53 +++++++---- .../java/lingtao/net/util/PriceUtils.java | 28 ++++++ src/main/webapp/views/product/coupon.jsp | 65 ++++++++++++- src/main/webapp/views/product/pvcfigure.jsp | 95 ++++++++++++++----- 5 files changed, 197 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index e87c343..5207aa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/* target/* +.vscode/* diff --git a/src/main/java/lingtao/net/service/ProductService.java b/src/main/java/lingtao/net/service/ProductService.java index 98a7310..e043247 100644 --- a/src/main/java/lingtao/net/service/ProductService.java +++ b/src/main/java/lingtao/net/service/ProductService.java @@ -1140,6 +1140,9 @@ public class ProductService { if (craft_list.contains("内部模切")) { carft_price += 15 * dto.getN_mq_num(); } + if (craft_list.contains("配印章")) { + carft_price += 10 * dto.getPo_number(); + } //腰封的模切费单独计算 product.setPrice(Math.ceil((product.getPrice() + carft_price) * number + Math.max(Math.ceil(moqiePrice * product.getCount() * number), moqiePrice > 0 ? 55 : 0))); product.setWeight(df.format(number * length / 100 * width / 100 * product.getCount() * 0.3 * 0.86)); @@ -4272,21 +4275,7 @@ public class ProductService { } return priceList; case "数码PVC": - // 价格按照大纸裁 - priceList = ZsPrice.getSmPrice(count, length, width, priceList, number, dto.getCraft(), dto, role); - for (Product product : priceList) { - if (dto.getKindValue().equals("1") || dto.getKindValue().equals("2") || dto.getKindValue().equals("3")) { - wei = 0.38; - } else if (dto.getKindValue().equals("4") || dto.getKindValue().equals("5") || dto.getKindValue().equals("6")) { - wei = 0.84; - } else if (dto.getKindValue().equals("11") || dto.getKindValue().equals("12") || dto.getKindValue().equals("13")) { - wei = 0.76; - } else { - wei = 1; - } - product.setWeight(df.format(wei * length * width * product.getCount() / 10000 * number * 1.3)); - } - return priceList; + return getsmPVCPrice(dto, width, length, role); case "班旗": priceList = new BqPrice().getPrice(count, length, priceList, number, dto.getCraftShua(), dto.getCraft()); List craLists = !StringUtils.isEmpty(dto.getCraft()) ? Arrays.asList(dto.getCraft()) : new ArrayList<>(); @@ -4381,6 +4370,33 @@ public class ProductService { return null; } + private List getsmPVCPrice(Product dto, Double width, Double length, String role) { + 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 wei = 0; + // 价格按照大纸裁 + priceList = ZsPrice.getSmPrice(count, length, width, priceList, number, dto.getCraft(), dto, role); + for (Product product : priceList) { + if (craft_list.contains("菜品夹")) { + product.setPrice(Math.ceil(product.getPrice() + dto.getStickNum() * 2)); + } + + if (dto.getKindValue().equals("1") || dto.getKindValue().equals("2") || dto.getKindValue().equals("3")) { + wei = 0.38; + } else if (dto.getKindValue().equals("4") || dto.getKindValue().equals("5") || dto.getKindValue().equals("6")) { + wei = 0.84; + } else if (dto.getKindValue().equals("11") || dto.getKindValue().equals("12") || dto.getKindValue().equals("13")) { + wei = 0.76; + } else { + wei = 1; + } + product.setWeight(df.format(wei * length * width * product.getCount() / 10000 * number * 1.3)); + } + return priceList; + } + 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<>(); @@ -5866,6 +5882,7 @@ public class ProductService { //布钱 +人工+印刷+手提 Product pro = null; double lastPrice = 0; + int lastCount = 0; for (int i = 0; i < counts.length; i++) { int itemCount = counts[i]; double basePrice = unit_prices[base][i]; @@ -5873,18 +5890,16 @@ public class ProductService { if (itemCount < count) { lastPrice = basePrice; + lastCount = itemCount; continue; } if (priceList.size() > 2) { break; } if (priceList.size() == 0 && itemCount != count) { - if (lastPrice > 0) { - basePrice = (lastPrice + basePrice) / 2; - } pro = new Product(); pro.setCount(count); - pro.setPrice(Math.ceil(basePrice * count * number)); + pro.setPrice(Math.ceil(new PriceUtils().calcByTargetN(lastCount, lastPrice, itemCount, basePrice, count) * number)); priceList.add(pro); } pro = new Product(); diff --git a/src/main/java/lingtao/net/util/PriceUtils.java b/src/main/java/lingtao/net/util/PriceUtils.java index 35f323a..91f8a8b 100644 --- a/src/main/java/lingtao/net/util/PriceUtils.java +++ b/src/main/java/lingtao/net/util/PriceUtils.java @@ -3613,6 +3613,34 @@ public class PriceUtils { return price == 0 ? last_price : price; } + public double calcByTargetN(int startN, double highPrice, int endN, double lowPrice, int targetN) { + // 高价商品个数线性插值 + double a = startN * (double) (endN - targetN) / (endN - startN); + double b = targetN - a; + double total = a * highPrice + b * lowPrice; + return total; + } + + public double TableCountCenterPrice(int area, double[] price_list, int[] areas) { + double price = 0; + int startIndex = 0; + int endIndex = 0; + for (int i = 0; i < areas.length; i++) { + if (area > areas[i]) { + startIndex = endIndex; + endIndex = Math.min(i + 1, areas.length - 1); + } + } + if (startIndex == endIndex && startIndex == 0) { + price = price_list[endIndex]; + } else if (startIndex == endIndex) { + price = (price_list[endIndex] / areas[endIndex]) * area; + } else { + price = ((areas[endIndex] - (double) area) / (areas[endIndex] - areas[startIndex])) * price_list[startIndex] + (((double) area - areas[startIndex]) / (areas[endIndex] - areas[startIndex])) * price_list[endIndex]; + } + return price; + } + public double TablePrice(double area, int[] price_list, double[] areas) { double price = 0; int startIndex = 0; diff --git a/src/main/webapp/views/product/coupon.jsp b/src/main/webapp/views/product/coupon.jsp index 9c6a293..c17a5d3 100644 --- a/src/main/webapp/views/product/coupon.jsp +++ b/src/main/webapp/views/product/coupon.jsp @@ -141,6 +141,8 @@ + + - + +
+ + +
@@ -1097,7 +1105,7 @@ for (let i = 0; i < result.length; i++) { // 只留一个remark remark = ""; - html += '
'; + html += '
'; remark += '
' + result[i].remark + '
'; } $("#carousel").append(html); @@ -1295,6 +1303,8 @@ $("#peijian_ui .opp select").prop("disabled", true); $("#peijian_ui .select_opp").hide(); $("#peijian_ui .select_opp select").prop("disabled", true); + $("#peijian_ui .yzinput").hide(); + $("#peijian_ui .yzinput input").prop("disabled", true); form.render(); } @@ -1426,6 +1436,19 @@ } } + if (data.value == "配印章") { + if ($(data.elem).is(":checked")) { + $("#peijian_ui .yzinput").show(); + $("#peijian_ui .yzinput input").prop("disabled", false); + getProductImage('印章'); + } else { + $("#peijian_ui .yzinput").hide(); + $("#peijian_ui .yzinput input").prop("disabled", true); + getProductImage(); + + } + } + form.render(); }); form.on("select(mashu)", function (data) { @@ -1481,7 +1504,8 @@ }); form.on("radio(kindValue2)", function (data) { peijianuiHide(); - + $("#peijian_ui .yzlayout").hide(); + $("#peijian_ui .yzlayout").find(":input").attr("disabled", true); if (data.value == 10) { $("#craftForm").hide(); $("#craftForm").find(":input").attr("disabled", true); @@ -1567,6 +1591,7 @@ $("#peijian_ui").show(); $("#peijian_ui input").attr("disabled", false); $("#peijian_ui .scolor").hide(); + $("#peijian_ui .yzlayout").show(); } } getProductImage(); @@ -2738,6 +2763,34 @@ $(".ydxselect").hide(); } } + if (data.value == "双面星光膜") { + if ($(data.elem).is(":checked")) { + getProductImage('星光膜'); + } else { + getProductImage(); + } + } + if (data.value == "双面镭射膜") { + if ($(data.elem).is(":checked")) { + getProductImage('镭射膜'); + } else { + getProductImage(); + } + } + if (data.value == "双面触感膜") { + if ($(data.elem).is(":checked")) { + getProductImage('触感膜'); + } else { + getProductImage(); + } + } + if (data.value == "双面雪花膜") { + if ($(data.elem).is(":checked")) { + getProductImage('雪花膜'); + } else { + getProductImage(); + } + } form.render(); }) @@ -3401,6 +3454,10 @@ arr.push(tscolor + "配弹力绳(15CM)"); return; } + if ($(this).val() == "配印章") { + arr.push($("input[name='po_number']").val() + "印章"); + return; + } if ($(this).val() == "opp袋") { let oppdai = $(".select_opp select[name='craft'] option:selected").val(); let oppSize = $("select[name='toothpick_size'] option:selected").text(); diff --git a/src/main/webapp/views/product/pvcfigure.jsp b/src/main/webapp/views/product/pvcfigure.jsp index 6d3e90e..bb7ee35 100644 --- a/src/main/webapp/views/product/pvcfigure.jsp +++ b/src/main/webapp/views/product/pvcfigure.jsp @@ -97,6 +97,10 @@
+ +
@@ -206,33 +210,48 @@ }) form.on('select(kindValue)', (data) => { + getImages(data) + }) + + function getImages(data, craft) { var html = " "; // 清空轮播图 $("#carousel").empty(); $("#shuangmian").show(); $("input[name='craftShua'][value='单面']").attr("checked", true); - if (data.value == 10) { - $("#shuangmian").hide(); + let val = ""; + let params = { + proTypeValue: $('#proTypeValue').val() } - let val = data.value; - if (val == 11) { - val = 1; + if (data) { + if (data.value == 10) { + $("#shuangmian").hide(); + } + val = data.value; + if (val == 11) { + val = 1; + } + if (val == 12) { + val = 2; + } + if (val == 13) { + val = 3; + } + params.kindValue = val; } - if (val == 12) { - val = 2; - } - if (val == 13) { - val = 3; + + + if (craft) { + params.craftValue = craft + } else { + params.kindValue = $("select[name='kindValue'] option:selected").val(); } form.render(); $.ajax({ url: "${pageContext.request.contextPath}/getImgs", type: "GET", - data: { - proTypeValue: $('#proTypeValue').val(), - kindValue: val - }, + data: params, //dataType : "json", success: function (result) { for (let i = 0; i < result.length; i++) { @@ -254,7 +273,8 @@ } } }) - }) + } + $("#number").on("input", function (e) { var number = e.delegateTarget.value; if (number > 1) { @@ -263,6 +283,25 @@ $("#ui_des").hide(); } }); + + form.on("checkbox(switch)", function (data) { + let craft_list = []; + $("input:checkbox[name='craft']:checked").each(function (i) { + if (!$(this).is(':disabled')) { + craft_list.push($(this).val()); + } + }); + $(".cqjinput").hide(); + $(".cqjinput").find(":input").attr("disabled", true); + if (craft_list.includes("菜品夹")) { + $(".cqjinput").show(); + $(".cqjinput").find(":input").attr("disabled", false); + getImages(null, "菜品夹") + } else { + getImages(null, "") + } + form.render(); + }) // 点击计算,计算价格 form.on('submit(acount_btn)', function (data) { var kindValue = $("#kindValue option:checked").text(); @@ -277,10 +316,19 @@ var size = $("#size").val(); var jx = $("input[name='ui_jx']:checked").val(); var shua = $("input[name='craftShua']:checked").val(); - var craft = $("input[name='craft']:checked").val(); var dk = $("input[name='ui_dk']:checked").val(); var length = size.split("*")[0]; var width = size.split("*")[1]; + let craft_list = []; + $("input:checkbox[name='craft']:checked").each(function (i) { + if (!$(this).is(':disabled')) { + if ($(this).val() == "菜品夹") { + craft_list.push($("input[name='stickNum']").val() + $(this).val()); + } else { + craft_list.push($(this).val()); + } + } + }); if (!size) { layer.msg('请填写尺寸!', {offset: ['300px', '300px']}, function () { }); @@ -321,15 +369,18 @@ return false; } var data = result.data.proList; - shua = jx + shua; - if (craft != null) { - shua += craft; + if (jx != null) { + craft_list.push(jx); + } + if (shua != null) { + craft_list.push(shua); } if (dk != null) { - shua += dk; + craft_list.push(dk); } let desType = $("#desType option:selected").text(); - var span_result = "数码PVC" + ' - ' + kindValue + '-' + size + 'cm' + '-' + shua + ' -(同款内容)\n'; + var span_result = "数码PVC" + ' - ' + kindValue + '-' + size + 'cm' + ' -(同款内容)\n'; + span_result += "工艺:" + craft_list.join(",") + "\n"; if (number > 1) { span_result += "款数:" + number + "-" + desType + "\n"; } @@ -347,7 +398,7 @@ span_result += '包邮,免费设计呢~(偏远地区需补邮费)' $("#span_result").val(span_result); - getRemark("PVC证件", size + "mm", count + "张", kindValue, number, craft, ""); + getRemark("PVC证件", size + "mm", count + "张", kindValue, number, craft_list.join(","), ""); //计算完自动复制文本 var e = document.getElementById("span_result");//对象是content if (e.value != "") {