Ver código fonte

新增卡片工艺

zhuyiyi 2 semanas atrás
pai
commit
3da5fa97a8

+ 1 - 0
.gitignore

@@ -1,2 +1,3 @@
 .idea/*
 target/*
+.vscode/*

+ 34 - 19
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<String> craLists = !StringUtils.isEmpty(dto.getCraft()) ? Arrays.asList(dto.getCraft()) : new ArrayList<>();
@@ -4381,6 +4370,33 @@ public class ProductService {
         return null;
     }
 
+    private List<Product> getsmPVCPrice(Product dto, Double width, Double length, String role) {
+        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();
+        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<Product> getYaFenPrice(Product dto, Double width, Double length) {
         List<String> craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
         List<Product> 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();

+ 28 - 0
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;

+ 61 - 4
src/main/webapp/views/product/coupon.jsp

@@ -141,6 +141,8 @@
                     <input type="radio" name="kindValue6" lay-filter="kindValue6" value="萱姿" title="萱姿">
                     <input type="radio" name="kindValue6" lay-filter="kindValue6" value="草香" title="草香">
                     <input type="radio" name="kindValue6" lay-filter="kindValue6" value="芳怡" title="芳怡">
+                    <input type="radio" name="kindValue6" lay-filter="kindValue6" value="金绒" title="金绒">
+                    <input type="radio" name="kindValue6" lay-filter="kindValue6" value="超感" title="超感">
                 </div>
                 <div class="kindValue7" style="display:none">
                     <input type="radio" name="kindValue7" lay-filter="kindValue7" value="2" title="300克铜版纸"
@@ -936,8 +938,14 @@
                                 <option value="12*10">12*10CM</option>
                             </select>
                         </div>
-                        <input type="checkbox" class="peijian" name="craft" lay-filter="z4PeiJian" value="配棉绳"
-                               title="配棉绳">
+                        <input type="checkbox" class="peijian" name="craft" lay-filter="z4PeiJian" value="配棉绳" title="配棉绳">
+                        <div class="yzlayout layui-inline">
+                            <input type="checkbox" class="peijian" name="craft" lay-filter="z4PeiJian" value="配印章" title="配印章">
+                            <div class="layui-inline yzinput" style="width: 110px;display: none">
+                                <input type="text" placeholder="请输入整数" autocomplete="off" name="po_number" value="1" class="layui-input"
+                                       style="width: 70px"/>
+                            </div>
+                        </div>
                     </div>
                 </form>
             </div>
@@ -1097,7 +1105,7 @@
                         for (let i = 0; i < result.length; i++) {
                             // 只留一个remark
                             remark = "";
-                            html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
+                            html += '<div><img style="width:100%;height: 100%;object-fit: contain" src="' + result[i].imgUrl + '"></div>';
                             remark += '<div><span>' + result[i].remark + '<span/></div>';
                         }
                         $("#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();

+ 73 - 22
src/main/webapp/views/product/pvcfigure.jsp

@@ -97,6 +97,10 @@
                     <br/>
                     <input type="checkbox" name="ui_dk" lay-filter="switch" value="打孔" title="打孔">
                     <input type="checkbox" name="craft" value="背胶" title="背胶">
+                    <input type="checkbox" name="craft" lay-filter="switch" value="菜品夹" title="菜品夹">
+                    <span class="layui-inline cqjinput" style="display: none">
+                        <input type="text" placeholder="请输入整数" autocomplete="off" name="stickNum" value="1" class="layui-input" style="width: 70px">
+                    </span>
                 </div>
             </div>
             <hr>
@@ -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 = data.value;
-            if (val == 11) {
-                val = 1;
+            let val = "";
+            let params = {
+                proTypeValue: $('#proTypeValue').val()
             }
-            if (val == 12) {
-                val = 2;
+            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 == 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 != "") {