diff --git a/src/main/java/lingtao/net/service/ProductService.java b/src/main/java/lingtao/net/service/ProductService.java index 2d15eda..c89d496 100644 --- a/src/main/java/lingtao/net/service/ProductService.java +++ b/src/main/java/lingtao/net/service/ProductService.java @@ -4545,7 +4545,7 @@ public class ProductService { basePrice = 22; basePrice = new PriceUtils().calcByTargetN(5000, 24, 10000, 22, num); } else { - basePrice = 20*num; + basePrice = 20 * num; //basePrice = new PriceUtils().calcByTargetN(10000, 20, 10000, 20, num); } double craftPrice = 0; @@ -5119,6 +5119,7 @@ public class ProductService { } rate = 1.2; } + List sdList = Arrays.asList("14", "15", "16", "17", "18", "19", "20"); // 300克 if ("3".equals(kind)) { // 异形模切价格 @@ -5222,6 +5223,123 @@ public class ProductService { priceList.add(pro); return priceList; + } else if (sdList.contains(dto.getKindValue())) { + ShengDaPriceNoPartsRequstVo requstVo = new ShengDaPriceNoPartsRequstVo(); + requstVo.setProductCategory("BEIDIAN"); + requstVo.setWidth(width * 10); + requstVo.setHeight(length * 10); + requstVo.setSizeUnit("MM"); + requstVo.setNum(count); + requstVo.setStyleNum(number); + requstVo.setSize(dto.getNotePaperKind()); + requstVo.setPrintSide(1); + List craft = new ArrayList<>(); + boolean isMO = true; + double base_rate = 0; + double min_pirce = 80; + double[] rate_list = {0.75, 0.72, 0.70, 0.68, 0.65, 0.60, 0.58, 0.55, 0.50}; + int[] counts = {200, 400, 600, 800, 1000, 2000, 3000, 5000, 10000}; + double maxRate = 0.48; + if ("14".equals(dto.getKindValue())) { + requstVo.setPaper("250克吸水棉纸"); + if ("90*90圆形".equals(requstVo.getSize())) { + isMO = false; + } + if ("90*90方形".equals(requstVo.getSize())) { + isMO = false; + } + if ("90*90花边".equals(requstVo.getSize())) { + isMO = false; + } + if ("100*100圆形".equals(requstVo.getSize())) { + isMO = false; + } + } + if ("15".equals(dto.getKindValue())) { + requstVo.setPaper("450克瑞典棉卡"); + } + if ("16".equals(dto.getKindValue())) { + requstVo.setPaper("500克吸水棉纸"); + } + if ("17".equals(dto.getKindValue())) { + requstVo.setPaper("980克吸水杯垫"); + } + if ("18".equals(dto.getKindValue())) { + requstVo.setPaper("PU皮革杯垫"); + isMO = false; + + } + if ("19".equals(dto.getKindValue())) { + requstVo.setProductCategory("MAOZHANDIAN"); + requstVo.setPaper("3MM毛毡"); + isMO = false; + } + if ("20".equals(dto.getKindValue())) { + requstVo.setProductCategory("MAOZHANDIAN"); + requstVo.setPaper("彩色毛毡"); + isMO = false; + ShengDaPriceRequstItemVo item = new ShengDaPriceRequstItemVo(); + item.setName("彩色毛毡"); + item.setParameters(Collections.singletonMap("颜色", dto.getTcolor())); + craft.add(item); + } + if ("18".equals(dto.getKindValue()) || "19".equals(dto.getKindValue()) || "20".equals(dto.getKindValue())) { + rate_list = new double[]{0.70, 0.65, 0.60, 0.55, 0.50}; + counts = new int[]{50, 100, 200, 500, 1000}; + maxRate = 0.45; + } + if (craft_list.contains("双面")) { + requstVo.setPrintSide(2); + requstVo.setDoubleSideType("不同"); + } + if (craft_list.contains("装OPP袋")) { + ShengDaPriceRequstItemVo item = new ShengDaPriceRequstItemVo(); + item.setName("装OPP袋"); + item.setParameters(Collections.singletonMap("类型", "平口袋")); + craft.add(item); + } + if (craft_list.contains("模切")) { + ShengDaPriceRequstItemVo item = new ShengDaPriceRequstItemVo(); + item.setName("模切"); + item.setParameters(Collections.singletonMap("类型", "圆形(仅模切外轮廓 )")); + craft.add(item); + } + if (craft_list.contains("激光")) { + ShengDaPriceRequstItemVo item = new ShengDaPriceRequstItemVo(); + item.setName("激光"); + craft.add(item); + } + if (craft_list.contains("雕刻")) { + ShengDaPriceRequstItemVo item = new ShengDaPriceRequstItemVo(); + item.setName("雕刻"); + craft.add(item); + } + if (isMO) { + ShengDaPriceRequstItemVo item = new ShengDaPriceRequstItemVo(); + item.setName("光油"); + craft.add(item); + } + requstVo.setCrafts(craft); + ShengDaPriceResultVo result = ShengDaPriceUtils.getPrice(requstVo); + + for (int i = 0; i < counts.length; i++) { + if (counts[i] < count) { + continue; + } + base_rate = rate_list[i]; + break; + } + if (base_rate == 0) { + base_rate = maxRate; + } + double price = Math.ceil(result.getData().getPrice() / (1 - base_rate)); + double designPrice = 0; + + Product product = new Product(); + product.setPrice(Math.ceil(Math.max(price, min_pirce) + designPrice)); + product.setCount(dto.getCount()); + product.setNumber(dto.getNumber()); + priceList.add(product); } else { priceList = new PriceUtils().tags600Price(dto, kind, kind2, area, count); // 服装吊牌里面的900克吊牌把价格*1.3倍 diff --git a/src/main/java/lingtao/net/util/ShengDaPriceUtils.java b/src/main/java/lingtao/net/util/ShengDaPriceUtils.java index 983ada2..f47c112 100644 --- a/src/main/java/lingtao/net/util/ShengDaPriceUtils.java +++ b/src/main/java/lingtao/net/util/ShengDaPriceUtils.java @@ -30,4 +30,12 @@ public class ShengDaPriceUtils { return result; } + public static ShengDaPriceResultVo getPrice(ShengDaPriceNoPartsRequstVo params) { + Map heards = new HashMap<>(); + heards.put("Authorization", "Bearer " + getToken()); + String resultText = HttpUtils.sendPostRequest("https://open.sd2000.com/api/app/calculate", JSONObject.toJSONString(params), heards); + ShengDaPriceResultVo result = JSONObject.parseObject(resultText, ShengDaPriceResultVo.class); + return result; + } + } diff --git a/src/main/java/lingtao/net/vo/ShengDaPriceNoPartsRequstVo.java b/src/main/java/lingtao/net/vo/ShengDaPriceNoPartsRequstVo.java new file mode 100644 index 0000000..bf0693e --- /dev/null +++ b/src/main/java/lingtao/net/vo/ShengDaPriceNoPartsRequstVo.java @@ -0,0 +1,24 @@ +package lingtao.net.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class ShengDaPriceNoPartsRequstVo { + + private String productCategory; + + private String paper; + + private List crafts; + private String name; + private String size; + private Integer num; + private String sizeUnit; + private String doubleSideType; + private Double height; + private Double width; + private Integer printSide; + private Integer styleNum; +} diff --git a/src/main/webapp/views/product/coaster.jsp b/src/main/webapp/views/product/coaster.jsp index e2c2dce..adee79a 100644 --- a/src/main/webapp/views/product/coaster.jsp +++ b/src/main/webapp/views/product/coaster.jsp @@ -44,15 +44,25 @@
+

材质

- - - - - - - +
+
@@ -369,8 +426,9 @@ layui.use(['table', 'form'], function () { var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功 var table = layui.table; + let sdList = [14, 15, 16, 17, 18, 19, 20] - form.on('radio(kindValue)', function (kindValueData) { + form.on('select(kindValue)', function (kindValueData) { $(".diycount").hide(); $(".diycount").find(":input").attr("disabled", true); $(".diycount").find("select").attr("disabled", true); @@ -380,6 +438,9 @@ $(".pvcCraft").hide(); $(".pvcCraft").find(":input").attr("disabled", true); $(".pvcCraft").find("select").attr("disabled", true); + $(".sdCraft").hide(); + $(".sdCraft").find(":input").attr("disabled", true); + $(".sdCraft").find("select").attr("disabled", true); $(".aromatherCraft").hide(); $(".aromatherCraft").find(":input").attr("disabled", true); $(".aromatherCraft").find("select").attr("disabled", true); @@ -398,6 +459,12 @@ $("#color_type").hide(); $("#color_type").find("select").attr("disabled", true); $("input[name='kind2Value'][value='无']").prop("checked", true); + $("#diySize").show(); + $("#diySize").find(":input").attr("disabled", false); + $("#sdSize").hide(); + $("#sdSize").find("select").attr("disabled", true); + + if (kindValueData.value == 10 || kindValueData.value == 11) { $(".fixcount").show(); $(".fixcount").find(":input").attr("disabled", false); @@ -407,7 +474,7 @@ $(".pvcCraft").show(); $(".pvcCraft").find(":input").attr("disabled", false); $(".pvcCraft").find("select").attr("disabled", false); - } else if (kindValueData.value != 13) { + } else if (kindValueData.value == 4 || kindValueData.value == 6) { $(".diycount").show(); $(".diycount").find(":input").attr("disabled", false); $(".diycount").find("select").attr("disabled", false); @@ -442,6 +509,72 @@ $(".aromatherCraft").find(":input").attr("disabled", false); $(".aromatherCraft").find("select").attr("disabled", false); $(".pvcCraft") + } else if (sdList.includes(Number(kindValueData.value))) { + $("#diySize").hide(); + $("#diySize").find("input").attr("disabled", true); + $("#sdSize").show(); + $("#sdSize").find("select").attr("disabled", false); + $(".sdCraft").show(); + $(".sdCraft").find("input").attr("disabled", false); + $(".sdCraft").find("select").attr("disabled", false); + $(".colorCraft").hide(); + $(".colorCraft").find("select").attr("disabled", true); + $(".colorCraft").find("input").attr("disabled", true); + $(".qieCraft").hide(); + $(".qieCraft").find("input").attr("disabled", true); + let html = ` + + + + + + + + + + + + + + `; + if (kindValueData.value == 15 || kindValueData.value == 16 || kindValueData.value == 17) { + html = ` + + + + + + + + + + + + `; + } + if (kindValueData.value == 18) { + html = ` + `; + } + if (kindValueData.value == 19 || kindValueData.value == 20) { + html = ` + + `; + $(".qieCraft").show(); + $(".qieCraft").find("input").attr("disabled", false); + } + $("#sdCraft input[name='craft'][value='双面']").attr("disabled", false); + if (kindValueData.value == 17 || kindValueData.value == 19 || kindValueData.value == 20) { + $("#sdCraft input[name='craft'][value='单面']").prop("checked", true); + $("#sdCraft input[name='craft'][value='双面']").prop("checked", false); + $("#sdCraft input[name='craft'][value='双面']").attr("disabled", true); + } + if (kindValueData.value == 20) { + $(".colorCraft").show(); + $(".colorCraft").find("select").attr("disabled", false); + $(".colorCraft").find("input").attr("disabled", false); + } + $("#sdSize select").empty().append(html); } form.render(); @@ -523,7 +656,7 @@ let data = {proTypeValue: "杯垫"} let remark = ""; let html = ""; - let kindValue = $("input[name='kindValue']:checked").val(); + let kindValue = $("select[name='kindValue'] option:selected").val(); if (!!kindValue) { if (kindValue == 4 || kindValue == 6) { kindValue = "铜版纸"; @@ -577,6 +710,43 @@ const carft_list4 = ["穿涤纶丝带", "穿吊牌绳", "穿弹力绳"]; const carft_list5 = ["配涤纶丝带", "配吊牌绳", "配弹力绳"]; + const carft_list6 = ["激光", "雕刻"]; + + form.on('checkbox(sd_craft)', function (data) { + let craft_list = []; + let kindValue = $("select[name='kindValue'] option:selected").val(); + craft_list.push($("select[name='craft'] option:selected").val()); + $("input[name='craft']:checked").each(function () { + if (!$(this).is(':disabled')) { + craft_list.push($(this).val()); + } + } + ); + + const carft1 = carft_list1.filter(craft => craft_list.includes(craft)); + if (carft1.length > 1) { + $(data.elem).prop("checked", false); + layer.msg("印面工艺不能同时选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } + if (!craft_list.includes("模切") && (kindValue == 19 || kindValue == 20)) { + $(data.elem).prop("checked", true); + layer.msg("裁切工艺不能取消选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } + const carft6 = carft_list6.filter(craft => craft_list.includes(craft)); + if (carft6.length > 1 && (kindValue == 19 || kindValue == 20)) { + $(data.elem).prop("checked", false); + layer.msg("常见工艺不能同时选择", {offset: ['300px', '300px']}, function () { + }); + form.render(); + return false; + } + }) form.on('checkbox(ui_craft)', function (data) { let craft_list = []; craft_list.push($("select[name='craft'] option:selected").val()); @@ -654,260 +824,320 @@ } form.render(); }) + + function scaleSize(str, factor = 10) { + // 匹配所有数字(整数或小数,这里只考虑整数),将匹配到的数字乘以因子 + return str.replace(/\d+(\.\d+)?/g, (match) => { + const num = parseFloat(match) * factor; + // 如果结果不是整数,保留原小数位数(或者直接返回 num 本身) + return Number.isInteger(num) ? num.toString() : num.toFixed(2); + }); + } + // 点击计算,计算价格 form.on('submit(acount_btn)', function (data) { - // 选中‘自定义数量’ - var kindValue = $('input[name="kindValue"]:checked').val(); - var kind2Value = $('input[name="kind2Value"]:checked').val(); - var craftQie = $('input[name="craftQie"]:checked').val(); - var craftMo = $('input[name="craftMo"]:checked').val(); - var size = $("#size").val(); - var count = $("select[name='count'] option:selected").text(); - var craftTang = $('input[name="craftTang"]:checked').val(); - var arr = []; - arr.push(craftMo); - if (!kindValue) { - layer.msg("请选择材质", {offset: ['300px', '300px']}, function () { - }); - return false; - } - if (kindValue == 4) { - if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) { - layer.msg("【杯垫900克】尺寸不能低于3*3 cm!", {offset: ['300px', '300px']}, function () { + // 选中‘自定义数量’ + var kindValue = $("select[name='kindValue'] option:selected").val(); + var kind2Value = $('input[name="kind2Value"]:checked').val(); + var craftQie = $('input[name="craftQie"]:checked').val(); + var craftMo = $('input[name="craftMo"]:checked').val(); + var size = $("#size").val(); + var count = $("select[name='count'] option:selected").text(); + var craftTang = $('input[name="craftTang"]:checked').val(); + var arr = []; + arr.push(craftMo); + if (!kindValue) { + layer.msg("请选择材质", {offset: ['300px', '300px']}, function () { }); return false; } - } - $("#proTypeValue").val("杯垫"); - if ((kindValue == 3)) { - if (craftQie == "异形模切") { - if ((size.split("*")[0] > 21 || size.split("*")[1] > 21)) { - layer.msg("【900克双胶纸】尺寸不能小于21*21 cm!", {offset: ['300px', '300px']}, function () { + if (kindValue == 4) { + if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) { + layer.msg("【杯垫900克】尺寸不能低于3*3 cm!", {offset: ['300px', '300px']}, function () { }); return false; } - if ((size.split("*")[0] <= 9 && size.split("*")[1] <= 5.4) || (size.split("*")[0] <= 5.4 && size.split("*")[1] <= 9)) { - if (craftTang) { - if (craftTang == "单面烫金") { - $("#proTypeValue").val(3); - } - } else { - if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) { - $("#proTypeValue").val(3); - $("input[name='kindValue']:checked").val(0); + } + $("#proTypeValue").val("杯垫"); + if ((kindValue == 3)) { + if (craftQie == "异形模切") { + if ((size.split("*")[0] > 21 || size.split("*")[1] > 21)) { + layer.msg("【900克双胶纸】尺寸不能小于21*21 cm!", {offset: ['300px', '300px']}, function () { + }); + return false; + } + if ((size.split("*")[0] <= 9 && size.split("*")[1] <= 5.4) || (size.split("*")[0] <= 5.4 && size.split("*")[1] <= 9)) { + if (craftTang) { + if (craftTang == "单面烫金") { + $("#proTypeValue").val(3); + } } else { - $("#proTypeValue").val("杯垫"); + if ((size.split("*")[0] < 3 || size.split("*")[1] < 3)) { + $("#proTypeValue").val(3); + } else { + $("#proTypeValue").val("杯垫"); + } } - } - form.render(); - } - } - } - let craft = $("input[name='craft']:checked").val(); - if (craft == "击凸" && $("input[name='jtcolor']:checked").length == 0) { - layer.msg("【击凸】颜色必须选一个!", {offset: ['300px', '300px']}, function () { - }); - return false; - } - var number = $("#number").val(); - - if (kindValue == "12") { - - if ((size.split("*")[0] < 5 || size.split("*")[1] < 5)) { - layer.msg("【PVC】最小尺寸5*5!", {offset: ['300px', '300px']}, function () { - }); - return false; - } - if ((size.split("*")[0] > 10 || size.split("*")[1] > 10)) { - layer.msg("【PVC】最大尺寸10*10!", {offset: ['300px', '300px']}, function () { - }); - return false; - } - - } - if (kindValue == "13") { - arr = []; - if ((size.split("*")[0] > 42 || size.split("*")[1] > 28.5) && (size.split("*")[1] > 42 || size.split("*")[0] > 28.5)) { - layer.msg('最大尺寸42*28.5cm!', {offset: ['300px', '300px']}, function () { - }); - return false; - } - if ((size.split("*")[0] < 1 || size.split("*")[1] < 1)) { - layer.msg('最小尺寸1*1cm!', {offset: ['300px', '300px']}, function () { - }); - return false; - } - arr.push($("#xiangwei select[name='craft'] option:selected").val()); - arr.push($(".aromatherCraft select[name='kind'] option:selected").text()); - $("input:checkbox[name='craft']:checked").each(function (i) { - // 没有被禁用的工艺加到arr中 - if (!$(this).is(':disabled')) { - if (carft_list4.indexOf($(this).val()) > -1) { - arr.push($(this).val() + $("#peijian_ui select[name='shen_color'] option:selected").val()); - } else if ($(this).val() == "抠图") { - arr.push($(this).val() + $("input[name='cropNumber']").val()); - return; - } else { - arr.push($(this).val()); + form.render(); } } - }); + } + let craft = $("input[name='craft']:checked").val(); + if (craft == "击凸" && $("input[name='jtcolor']:checked").length == 0) { + layer.msg("【击凸】颜色必须选一个!", {offset: ['300px', '300px']}, function () { + }); + return false; + } + var number = $("#number").val(); - const carft1 = carft_list1.filter(item => arr.includes(item)); - if (carft1.length == 0) { - layer.msg("请选择印面工艺", {offset: ['300px', '300px']}, function () { - }); - return false; - } - const carft2 = carft_list2.filter(item => arr.includes(item)); - if (carft2.length == 0) { - layer.msg("请选择裁切工艺", {offset: ['300px', '300px']}, function () { - }); - return false; - } - const carft3 = carft_list3.filter(item => arr.includes(item)); - if (carft3.length == 0) { - layer.msg("请选择包装工艺", {offset: ['300px', '300px']}, function () { - }); - return false; - } - } - kindValueData = { - 3: "350克铜版纸", - 6: "600克铜版纸", - 4: "900克双胶纸", - 10: "轻羽", - 11: "简单", - 12: "透明PVC", - 13: "香薰卡" - }; - $.ajax({ - url: "${path}/getThanSum", - type: "GET", - data: $(".big_box form").serialize(), - success: function (result) { - if (result.code == 100) { - layer.msg(result.msg, {offset: ['300px', '300px']}, function () { + if (kindValue == "12") { + + if ((size.split("*")[0] < 5 || size.split("*")[1] < 5)) { + layer.msg("【PVC】最小尺寸5*5!", {offset: ['300px', '300px']}, function () { }); return false; } - var data = result.data.proList; - if ("无" != kind2Value) { - - if (kind2Value == "击凸" || kind2Value == "压凹" || kind2Value == "单面烫金+压凹" || kind2Value == "单面烫金+击凸") { - arr.push(kind2Value + $("#color_type select[name='craft'] option:selected").val()) - } else if (kind2Value == '烫镭射银') { - arr.push($("#leishe_type select[name='craft'] option:selected").val()) - } else if (kind2Value == '烫黄金') { - arr.push($("#huangjin_type select[name='craft'] option:selected").val()) - } else { - arr.push(kind2Value) - } - } - var span_result = '杯垫 - ' + kindValueData[kindValue] + ' - ' + size + '厘米\n' - if (kindValue == "3" || kindValue == "4" || kindValue == "6") { - span_result += "工艺: " + craftQie + ', ' + arr + "\n"; - } else if (kindValue == "12") { - let craftQie = $("input[name='craftQie']:checked").val(); - let craftQieType = $("input[name='craftQieType']:checked").val(); - let size1 = $("select[name='size1'] option:selected").val(); - let craft_list = ['规格' + size1, craftQie, craftQieType]; - span_result += "工艺: " + craft_list.join(",") + "\n"; - } else if (kindValue == "13") { - span_result += `工艺:` + arr.join(",") + '\n'; - } else { - let aotu = $("input[name='aotu']:checked").val(); - let craft = $("input[name='craft']:checked").val(); - let craft_list = [aotu]; - - if (craft == "击凸") { - let ys = $("input[name='jtcolor']:checked"); - ys.each(item => { - craft_list.push($(ys[item]).val()); - }) - } else if (craft == "烫金") { - let ys = $("input[name='tcolor']:checked").val(); - craft_list.push(ys); - } else if (craft == "烫镭射银") { - let ys = $("input[name='tcolor']:checked").val(); - craft_list.push(ys); - } else { - craft_list.push(craft); - } - span_result += "工艺: " + craft_list.join(",") + "\n"; - } - if (number > 1) { - for (let i = 0; i < data.length; i++) { - span_result += number + '款 各' + data[i].count + "张,共" + data[i].price + "元" + '\n' - data[i].number = number; - } - } else { - for (let i = 0; i < data.length; i++) { - span_result += number + '款 ' + data[i].count + "张,共" + data[i].price + "元" + '\n' - data[i].number = number; - } - } - span_result += '包邮,免费设计呢~(偏远地区需补邮费)' - if (window.parent.system_isGai) { - span_result += "\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!" + if ((size.split("*")[0] > 10 || size.split("*")[1] > 10)) { + layer.msg("【PVC】最大尺寸10*10!", {offset: ['300px', '300px']}, function () { + }); + return false; } - addLog(span_result); - $("#span_result").val(span_result); - var craft = craftQie + arr; - getRemark("杯垫", size, count + "张", kindValueData[kindValue], number, craft, ""); - //计算完自动复制文本 - var e = document.getElementById("span_result");//对象是content - if (e.value != "") { - e.select();//选择对象 - document.execCommand("Copy");//执行浏览器复制命令 + } + if (kindValue == "13") { + arr = []; + if ((size.split("*")[0] > 42 || size.split("*")[1] > 28.5) && (size.split("*")[1] > 42 || size.split("*")[0] > 28.5)) { + layer.msg('最大尺寸42*28.5cm!', {offset: ['300px', '300px']}, function () { + }); + return false; } - - //生成表格 - table.render({ - elem: '#priceTable', - even: true, //隔行变色 - data: data, // 赋值已知数据 - width: 500, - cols: [[{ - field: 'number', - width: '12%', - align: "center", - title: '款数' - }, { - field: 'count', - width: '16%', - align: "center", - title: '数量' - }, { - field: 'price', - width: '16%', - align: "center", - title: '报价' - }, { - field: 'wangwang', - align: "center", - width: '16%', - title: '折扣价' - }, { - field: 'wangwang', - align: "center", - width: '19%', - title: '跳楼价' - }, { - field: 'weight', - width: '21%', - align: "center", - title: '重量(kg)' - }]], - done: function () { + if ((size.split("*")[0] < 1 || size.split("*")[1] < 1)) { + layer.msg('最小尺寸1*1cm!', {offset: ['300px', '300px']}, function () { + }); + return false; + } + arr.push($("#xiangwei select[name='craft'] option:selected").val()); + arr.push($(".aromatherCraft select[name='kind'] option:selected").text()); + $("input:checkbox[name='craft']:checked").each(function (i) { + // 没有被禁用的工艺加到arr中 + if (!$(this).is(':disabled')) { + if (carft_list4.indexOf($(this).val()) > -1) { + arr.push($(this).val() + $("#peijian_ui select[name='shen_color'] option:selected").val()); + } else if ($(this).val() == "抠图") { + arr.push($(this).val() + $("input[name='cropNumber']").val()); + return; + } else { + arr.push($(this).val()); + } } }); + + const carft1 = carft_list1.filter(item => arr.includes(item)); + if (carft1.length == 0) { + layer.msg("请选择印面工艺", {offset: ['300px', '300px']}, function () { + }); + return false; + } + const carft2 = carft_list2.filter(item => arr.includes(item)); + if (carft2.length == 0) { + layer.msg("请选择裁切工艺", {offset: ['300px', '300px']}, function () { + }); + return false; + } + const carft3 = carft_list3.filter(item => arr.includes(item)); + if (carft3.length == 0) { + layer.msg("请选择包装工艺", {offset: ['300px', '300px']}, function () { + }); + return false; + } } - }); - return false; - }); + if (sdList.includes(Number(kindValue))) { + count = $("input[name='count']:not(:disabled)").val(); + size = $("select[name='size']:not(:disabled) option:selected").val(); + $("input[name='notePaperKind']").val(scaleSize($("#sdSize select option:selected").text())) + arr = []; + if (kindValue == "20") { + arr.push($("select[name='tcolor'] option:selected").val()) + } + $("input:checkbox[name='craft']:checked").each(function (i) { + // 没有被禁用的工艺加到arr中 + if (!$(this).is(':disabled')) { + if (carft_list4.indexOf($(this).val()) > -1) { + arr.push($(this).val() + $("#peijian_ui select[name='shen_color'] option:selected").val()); + } else if ($(this).val() == "抠图") { + arr.push($(this).val() + $("input[name='cropNumber']").val()); + return; + } else { + arr.push($(this).val()); + } + } + }); + if (arr.includes("装OPP袋")) { + if (size.split("*")[0] != 9 || size.split("*")[1] != 9) { + layer.msg("当工艺包含装OPP袋时,尺寸限于90*90圆形、90*90方形、90*90花边", {offset: ['300px', '300px']}, function () { + }); + return false; + } + } + if (kindValue != "18" && kindValue != "19" && kindValue != "20") { + if (count % 200 != 0) { + layer.msg("数量大于等于200的且是200的倍数", {offset: ['300px', '300px']}, function () { + }); + return false; + } + } + const carft6 = carft_list6.filter(craft => arr.includes(craft)); + if (carft6.length == 0 && (kindValue == 20)) { + layer.msg("常见工艺必须选择", {offset: ['300px', '300px']}, function () { + }); + return false; + } + } + kindValueData = { + 3: "350克铜版纸", + 6: "600克铜版纸", + 4: "900克双胶纸", + 10: "轻羽", + 11: "简单", + 12: "透明PVC", + 13: "香薰卡", + 14: "250克吸水棉纸", + 15: "450克瑞典棉卡", + 16: "500克吸水棉纸", + 17: "980克吸水棉纸", + 18: "PU皮革", + 19: "3MM毛毡", + 20: "彩色毛毡", + }; + $.ajax({ + url: "${path}/getThanSum", + type: "GET", + data: $(".big_box form").serialize(), + success: function (result) { + if (result.code == 100) { + layer.msg(result.msg, {offset: ['300px', '300px']}, function () { + }); + return false; + } + var data = result.data.proList; + if ("无" != kind2Value && !$('input[name="kind2Value"]:checked').is(":disabled")) { + + if (kind2Value == "击凸" || kind2Value == "压凹" || kind2Value == "单面烫金+压凹" || kind2Value == "单面烫金+击凸") { + arr.push(kind2Value + $("#color_type select[name='craft'] option:selected").val()) + } else if (kind2Value == '烫镭射银') { + arr.push($("#leishe_type select[name='craft'] option:selected").val()) + } else if (kind2Value == '烫黄金') { + arr.push($("#huangjin_type select[name='craft'] option:selected").val()) + } else { + arr.push(kind2Value) + } + } + var span_result = '杯垫 - ' + kindValueData[kindValue] + ' - ' + size + '厘米\n' + if (kindValue == "3" || kindValue == "4" || kindValue == "6") { + span_result += "工艺: " + craftQie + ', ' + arr + "\n"; + } else if (kindValue == "12") { + let craftQie = $("input[name='craftQie']:checked").val(); + let craftQieType = $("input[name='craftQieType']:checked").val(); + let size1 = $("select[name='size1'] option:selected").val(); + let craft_list = ['规格' + size1, craftQie, craftQieType]; + span_result += "工艺: " + craft_list.join(",") + "\n"; + } else if (kindValue == "13" || sdList.includes(Number(kindValue))) { + span_result += `工艺:` + arr.join(",") + '\n'; + } else { + let aotu = $("input[name='aotu']:checked").val(); + let craft = $("input[name='craft']:checked").val(); + let craft_list = [aotu]; + + if (craft == "击凸") { + let ys = $("input[name='jtcolor']:checked"); + ys.each(item => { + craft_list.push($(ys[item]).val()); + }) + } else if (craft == "烫金") { + let ys = $("input[name='tcolor']:checked").val(); + craft_list.push(ys); + } else if (craft == "烫镭射银") { + let ys = $("input[name='tcolor']:checked").val(); + craft_list.push(ys); + } else { + craft_list.push(craft); + } + span_result += "工艺: " + craft_list.join(",") + "\n"; + } + if (number > 1) { + for (let i = 0; i < data.length; i++) { + span_result += number + '款 各' + data[i].count + "张,共" + data[i].price + "元" + '\n' + data[i].number = number; + } + } else { + for (let i = 0; i < data.length; i++) { + span_result += number + '款 ' + data[i].count + "张,共" + data[i].price + "元" + '\n' + data[i].number = number; + } + } + span_result += '包邮,免费设计呢~(偏远地区需补邮费)' + if (window.parent.system_isGai) { + span_result += "\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!" + } + + addLog(span_result); + $("#span_result").val(span_result); + var craft = craftQie + arr; + getRemark("杯垫", size, count + "张", kindValueData[kindValue], number, craft, ""); + //计算完自动复制文本 + var e = document.getElementById("span_result");//对象是content + if (e.value != "") { + e.select();//选择对象 + document.execCommand("Copy");//执行浏览器复制命令 + } + + //生成表格 + table.render({ + elem: '#priceTable', + even: true, //隔行变色 + data: data, // 赋值已知数据 + width: 500, + cols: [[{ + field: 'number', + width: '12%', + align: "center", + title: '款数' + }, { + field: 'count', + width: '16%', + align: "center", + title: '数量' + }, { + field: 'price', + width: '16%', + align: "center", + title: '报价' + }, { + field: 'wangwang', + align: "center", + width: '16%', + title: '折扣价' + }, { + field: 'wangwang', + align: "center", + width: '19%', + title: '跳楼价' + }, { + field: 'weight', + width: '21%', + align: "center", + title: '重量(kg)' + }]], + done: function () { + } + }); + } + }); + return false; + } + ) + ; }); \ No newline at end of file