Pārlūkot izejas kodu

新增包装纸

zhuyiyi 1 nedēļu atpakaļ
vecāks
revīzija
cdb2c65ce5

+ 48 - 3
src/main/java/lingtao/net/service/ProductService.java

@@ -4882,12 +4882,57 @@ public class ProductService {
                 return getWallPaintingPrice(dto, width, length);
             case "电线胶":
                 return getWireTapePrice(dto, width, length);
+            case "包装纸":
+                return getWrappingPaper(dto, width, length);
             default:
                 break;
         }
         return null;
     }
 
+    private List<Product> getWrappingPaper(Product dto, Double width, Double length) {
+        List<String> craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
+        List<Product> priceList = new ArrayList<>();
+        int count = dto.getCount();
+        int number = dto.getNumber();
+        int min_count = 5;
+        int[] prices = {60, 100, 190, 500, 800};
+        int[] counts = {5, 10, 20, 50, 100};
+        if ("1".equals(dto.getKind()) && (width == 490 || length == 490)) {
+            prices = new int[]{50, 80, 140, 300, 450};
+        }
+        if ("2".equals(dto.getKind())) {
+            prices = new int[]{50, 80, 140, 300, 450};
+        }
+        if ("3".equals(dto.getKind())) {
+            prices = new int[]{50, 80, 140, 300, 450};
+        }
+        double craft_price = 0;
+        if (craft_list.contains("双面胶")) {
+            craft_price += Math.max(dto.getMaxian(), 1) * 1.5;
+        }
+        if (craft_list.contains("丝带")) {
+            craft_price += Math.max(dto.getPcount(), 1) * 1.5;
+        }
+        for (int i = 0; i < counts.length; i++) {
+            int countItem = counts[i];
+            if (count >= countItem) {
+                continue;
+            }
+            if (priceList.size() > 2) {
+                break;
+            }
+            Boolean isFirst = priceList.size() == 0;
+            int base_price = prices[isFirst ? Math.max(i - 1, 0) : i];
+            Product pro = new Product();
+            pro.setCount(isFirst ? count : countItem);
+            pro.setNumber(number);
+            pro.setPrice(Math.ceil((double) base_price / counts[isFirst ? Math.max(i - 1, 0) : i] * Math.max(min_count, isFirst ? count : countItem) + craft_price));
+            priceList.add(pro);
+        }
+        return priceList;
+    }
+
     private List<Product> getWireTapePrice(Product dto, Double width, Double length) {
         List<String> craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
         List<Product> priceList = new ArrayList<>();
@@ -5734,13 +5779,13 @@ public class ProductService {
         if ("2".equals(dto.getKind())) {
             max_width = 420;
             max_length = 310;
-            base_price = 35;
+            base_price = 45;
             min_price = 60;
         }
         if ("3".equals(dto.getKind())) {
             max_width = 420;
             max_length = 310;
-            base_price = 40;
+            base_price = 48;
             min_price = 60;
         }
         width = width * 10 + 4;
@@ -5953,7 +5998,7 @@ public class ProductService {
         double[] lengths = {1.2, 1.5, 1.8, 2, 2.4};
         if ("2".equals(dto.getKind())) {
             prices = new double[][]{
-                    {110, 236, 290, 587},
+                    {110, 210, 290, 587},
                     {119, 240, 298, 587},
                     {125, 240, 308, 587},
                     {137, 240, 316, 630},

+ 71 - 113
src/main/webapp/views/product/wrappingPaper.jsp

@@ -16,16 +16,18 @@
 </style>
 <div class="big_box">
     <div class="left_div">
-        <h1 class="h1">方巾</h1> <span style="color:red;font-weight:700;"></span>
+        <h1 class="h1">包装纸</h1> <span style="color:red;font-weight:700;"></span>
         <hr>
         <form class="layui-form">
-            <input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="方巾纸"/>
+            <input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="包装纸"/>
             <p>
                 材质
             </p>
             <div class="layui-form-item">
-                <select name="kind" class="select" lay-search>
-                    <option value="1">15克木浆纸</option>
+                <select name="kind" class="select" lay-search lay-filter="kind_filter">
+                    <option value="1">157克铜版纸</option>
+                    <option value="2">100克白牛皮</option>
+                    <option value="3">100克黄牛皮</option>
                 </select>
             </div>
             <p>
@@ -33,48 +35,12 @@
             </p>
             <div class="layui-form-item">
                 <select name="size" class="layui-form-select" lay-filter="pcount_filter">
-                    <option value="22*22">22*22cm</option>
-                    <option value="23*23">23*23cm</option>
-                    <option value="27*27">27*27cm</option>
-                </select>
-            </div>
-            <div class="layui-form-item">
-                <input type="radio" name="shen_color" lay-filter="colorType" title="单色" value="单色" checked>
-                <span>
-                <input type="radio" name="shen_color" lay-filter="colorType" title="双色" value="双色">
-                </span>
-            </div>
-            <p>
-                印刷颜色
-            </p>
-            <div class="layui-form-item">
-                <select name="craft" class="layui-form-select">
-                    <option value="黑色">黑色</option>
-                    <option value="咖啡色">咖啡色</option>
-                    <option value="浅绿色">浅绿色</option>
-                    <option value="深绿色">深绿色</option>
-                    <option value="蓝色">蓝色</option>
-                    <option value="橘色">橘色</option>
-                    <option value="黄色">黄色</option>
-                    <option value="红色">红色</option>
-                </select>
-
-
-            </div>
-            <div class="layui-form-item" style="display: none">
-                <select id="colorT" name="craft" class="layui-form-select" disabled>
-                    <option value="黑色">黑色</option>
-                    <option value="咖啡色">咖啡色</option>
-                    <option value="浅绿色">浅绿色</option>
-                    <option value="深绿色">深绿色</option>
-                    <option value="蓝色">蓝色</option>
-                    <option value="橘色">橘色</option>
-                    <option value="黄色">黄色</option>
-                    <option value="红色">红色</option>
+                    <option value="98*70">98*70cm</option>
+                    <option value="70*49">70*49cm</option>
                 </select>
             </div>
             <p>
-                数量(箱)
+                数量
             </p>
             <div class="layui-form-item">
                 <input type="text" name="count" id="count" class="layui-input">
@@ -103,7 +69,23 @@
                 </div>
                 <div class="layui-input-block">
                     裁切工艺:
-                    <input type="checkbox" name="craft" lay-filter="ui_craft" value="方形" title="方形" checked readonly>
+                    <input type="checkbox" name="craft" lay-filter="ui_craft" value="直角裁切" title="直角裁切" checked readonly>
+                </div>
+                <div class="layui-input-block fumo">
+                    覆膜工艺:
+                    <input type="checkbox" name="craft" lay-filter="ui_craft" value="哑膜" title="哑膜">
+                    <input type="checkbox" name="craft" lay-filter="ui_craft" value="亮膜" title="亮膜">
+                </div>
+                <div class="layui-input-block">
+                    配件:
+                    <input type="checkbox" name="craft" lay-filter="ui_craft" value="双面胶" title="双面胶">
+                    <div class="layui-inline shuang" style="width: 100px;display: none">
+                        <input class="layui-input" name="maxian"/>
+                    </div>
+                    <input type="checkbox" name="craft" lay-filter="ui_craft" value="丝带" title="丝带">
+                    <div class="layui-inline sidai" style="width: 100px;display: none">
+                        <input class="layui-input" name="pcount"/>
+                    </div>
                 </div>
             </div>
             <hr>
@@ -146,7 +128,7 @@
         ins = carousel.render({});
         var html = " ";
         var remark = " ";
-        const carft_list1 = ["单面", "双面"];
+        const carft_list1 = ["哑膜", "亮膜"];
 
         // 清空轮播图
         $("#carousel").empty();
@@ -185,41 +167,51 @@
                 }
             }
         });
-        form.on('select(pcount_filter)', function (data) {
-            $("input[name='shen_color'][value='单色']").click();
-            $("input[name='shen_color'][value='双色']").parent().show();
-            $("input[name='shen_color'][value='双色']").attr("disabled", false);
-            $("#colorT").parent().hide();
-            $("#colorT").attr("disabled", true)
-            if (data.value == '23*23') {
-                $("input[name='shen_color'][value='双色']").parent().hide();
-                $("input[name='shen_color'][value='双色']").attr("disabled", true);
-            }
-            form.render();
-        })
-        form.on("radio(colorType)", function (data) {
-            $("#colorT").parent().hide();
-            $("#colorT").attr("disabled", true)
-            if (data.value == '双色') {
-                $("#colorT").parent().show();
-                $("#colorT").attr("disabled", false)
+
+        form.on("select(kind_filter)", function (data) {
+            let html = ` <option value="98*70">98*70cm</option>
+                    <option value="70*49">70*49cm</option>`;
+            $(".fumo").show();
+            $(".fumo").find(":input").attr("disabled", false);
+
+            if (data.value != '1') {
+                html = ` <option value="72*50">72*50cm</option>`;
+                $(".fumo").hide();
+                $(".fumo").find(":input").attr("disabled", true);
             }
+            $("select[name='size']").empty();
+            $("select[name='size']").append(html);
             form.render();
         })
+
         form.on('checkbox(ui_craft)', function (data) {
             let craft_list = [];
-            $(data.elem).prop("checked", true);
-            layer.msg("工艺不能取消", {offset: ['300px', '300px']}, function () {
-            });
-            form.render();
-            return false;
-            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("双面胶")) {
+                $(".shuang").show();
+            } else {
+                $(".shuang").hide();
+            }
+            if (craft_list.includes("丝带")) {
+                $(".sidai").show();
+            } else {
+                $(".sidai").hide();
+            }
+            form.render();
         })
 
         // 点击计算,计算价格
@@ -229,54 +221,20 @@
             var count = $("#count").val();
             var kind = $("select[name='kind'] option:selected").text();
             var craft = [];
-            if (size == "") {
-                layer.msg('请填写尺寸!', {offset: ['300px', '300px']}, function () {
-                });
-                return false;
-            }
-            $("select[name='craft']").each(function (i) {
-                // 没有被禁用的工艺加到arr中
-                if (!$(this).is(':disabled')) {
-                    craft.push($(this).find("option:selected").val());
 
-                }
-            });
             $("input:checkbox[name='craft']:checked").each(function (i) {
                 // 没有被禁用的工艺加到arr中
                 if (!$(this).is(':disabled')) {
-
-                    craft.push($(this).val());
+                    if ($(this).val() == "双面胶") {
+                        craft.push($("input[name='maxian']").val() + "个" + $(this).val());
+                    } else if ($(this).val() == "丝带") {
+                        craft.push($("input[name='pcount']").val() + "个" + $(this).val());
+                    } else {
+                        craft.push($(this).val());
+                    }
                 }
             });
 
-            const carft1 = carft_list1.filter(item => craft.includes(item));
-            if (carft1.length == 0) {
-                layer.msg("请选择印面工艺", {offset: ['300px', '300px']}, function () {
-                });
-                return false;
-            }
-            if (size == "23*23") {
-                if (count < 3) {
-                    layer.msg("23*23尺寸3箱起做", {offset: ['300px', '300px']}, function () {
-                    });
-                    return false;
-                }
-            }
-            if (size == "27*27") {
-                if (count < 5) {
-                    layer.msg("23*23尺寸5箱起做", {offset: ['300px', '300px']}, function () {
-                    });
-                    return false;
-                }
-            }
-            let colorType = $("input[name='shen_color']:checked").val();
-
-            if (colorType == "双色" && count < 5) {
-                layer.msg("双色5箱起做", {offset: ['300px', '300px']}, function () {
-                });
-                return false;
-            }
-
             $.ajax({
                 url: "${path}/getThanSum",
                 type: "GET",
@@ -289,18 +247,18 @@
                     }
                     var data = result.data.proList;
 
-                    var span_result = '方巾 - ' + kind + ' - ' + size + ' CM (同款内容)\n';
+                    var span_result = '包装纸 - ' + kind + ' - ' + size + ' CM (同款内容)\n';
 
                     span_result += `工艺:` + craft.join(",") + '\n';
 
                     if (number > 1) {
                         for (let i = 0; i < data.length; i++) {
-                            span_result += number + '款 各' + data[i].count + ",共" + data[i].price + "元" + '\n'
+                            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'
+                            span_result += number + '款 ' + data[i].count + ",共" + data[i].price + "元" + '\n'
                             data[i].number = number;
                         }
                     }