新增鼠标垫

This commit is contained in:
2025-12-05 09:51:29 +08:00
parent d7001df657
commit b5cb6cd1b0
5 changed files with 560 additions and 10 deletions
@@ -3009,6 +3009,11 @@ public class ProductService {
*/
}
}
if ("直角卡片".equals(dto.getKind()) && ((width > 42 && length > 28.5) || (width > 28.5 && length > 42))) {
for (Product product : priceList) {
product.setPrice(Math.max(Math.ceil(product.getPrice() * 0.85), fixPrice + designFee));
}
}
if ("1".equals(dto.getKindValue())) {
// 给产品加上重量 扣除出血的4毫米
for (Product product : priceList) {
@@ -4747,12 +4752,108 @@ public class ProductService {
return getTakeoutBoxPrice(dto, width, length);
case "方巾纸":
return getHandkerPrice(dto, width, length);
case "鼠标垫":
return getMousePadPrice(dto, width, length);
default:
break;
}
return null;
}
private List<Product> getMousePadPrice(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();
double miniPrice = 55;
double rate = 1;
String kind = dto.getKind();
int[] counts = {5, 10, 20, 30, 50, 100, 200};
double[] areas = {100, 400, 900, 1600, 2500, 3600, 4900, 6400, 8100, 10000, 20000, 30000, 45000};
double[][] prices = {
{10, 10, 10, 16, 24, 35, 47, 61, 70, 90, 180, 280, 400},
{4.7, 5, 8.75, 15, 23, 32, 44, 57.5, 71, 89, 175, 260, 350},
{2.35, 3.7, 7.8, 13, 21, 29, 40, 52, 65, 81, 160, 240, 340},
{1.5, 3.2, 6.8, 11, 18, 26, 35, 46, 55, 71, 142, 212, 317},
{0.8, 2.8, 6.06, 10.5, 16, 23, 31, 40, 50, 60, 126, 188, 280},
{0.7, 2.5, 5.44, 9.5, 14, 20, 28.3, 36.8, 46, 58, 113, 169, 254},
{0.63, 2.27, 4.9, 8.6, 13, 18, 25, 33, 40, 52, 100, 150, 230},
};
if ("3".equals(kind)) {
prices = new double[][]{
{11, 11, 11, 17.6, 26.4, 38.5, 51.7, 67.1, 77, 99, 198, 308, 440},
{5.17, 5.5, 9.625, 16.5, 25.3, 35.2, 48.4, 63.25, 78.1, 97.9, 192.5, 286, 385},
{2.585, 4.07, 8.58, 14.3, 23.1, 31.9, 44, 57.2, 71.5, 89.1, 176, 264, 374},
{1.65, 3.52, 7.48, 12.1, 19.8, 28.6, 38.5, 50.6, 60.5, 78.1, 156.2, 233.2, 348.7},
{0.88, 3.08, 6.666, 11.55, 17.6, 25.3, 34.1, 44, 55, 66, 138.6, 206.8, 308},
{0.77, 2.75, 5.984, 10.45, 15.4, 22, 31.13, 40.48, 50.6, 63.8, 124.3, 185.9, 279.4},
{0.693, 2.497, 5.39, 9.46, 14.3, 19.8, 27.5, 36.3, 44, 57.2, 110, 165, 253},
};
}
if ("4".equals(kind)) {
prices = new double[][]{
{12.1, 12.1, 12.1, 19.36, 29.04, 42.35, 56.87, 73.81, 84.7, 108.9, 217.8, 338.8, 484},
{5.687, 6.05, 10.5875, 18.15, 27.83, 38.72, 53.24, 69.575, 85.91, 107.69, 211.75, 314.6, 423.5},
{2.8435, 4.477, 9.438, 15.73, 25.41, 35.09, 48.4, 62.92, 78.65, 98.01, 193.6, 290.4, 411.4},
{1.815, 3.872, 8.228, 13.31, 21.78, 31.46, 42.35, 55.66, 66.55, 85.91, 171.82, 256.52, 383.57},
{0.968, 3.388, 7.3326, 12.705, 19.36, 27.83, 37.51, 48.4, 60.5, 72.6, 152.46, 227.48, 338.8},
{0.847, 3.025, 6.5824, 11.495, 16.94, 24.2, 34.243, 44.528, 55.66, 70.18, 136.73, 204.49, 307.34},
{0.7623, 2.7467, 5.929, 10.406, 15.73, 21.78, 30.25, 39.93, 48.4, 62.92, 121, 181.5, 278.3},
};
}
if ("5".equals(kind)) {
prices = new double[][]{
{13.2, 13.2, 13.2, 20.9, 31.9, 46.2, 62.7, 81.4, 93.5, 119.9, 239.8, 372.9, 532.4},
{6.05, 6.6, 12.1, 19.8, 30.8, 42.9, 58.3, 77, 94.6, 118.8, 233.2, 346.5, 466.4},
{3.08, 4.4, 9.9, 17.6, 27.5, 38.5, 52.8, 69.3, 86.9, 107.8, 213.4, 319, 452.1},
{1.98, 4.4, 8.8, 14.3, 24.2, 34.1, 46.2, 61.6, 73.7, 94.6, 189.2, 282.7, 422.4},
{0.99, 3.3, 7.7, 14.3, 20.9, 30.8, 41.8, 52.8, 67.1, 80.3, 167.2, 249.7, 372.9},
{0.88, 3.3, 7.7, 12.1, 18.7, 26.4, 37.4, 49.5, 61.6, 77, 150.7, 224.4, 337.7},
{0.88, 3.3, 6.6, 11, 17.6, 24.2, 33, 44, 52.8, 69.3, 133.1, 200.2, 305.8},
};
}
//不锁边97折
if (craft_list.contains("不锁边")) {
rate = 0.97;
}
if (craft_list.contains("异形模切")) {
rate = 1.35;
}
double unitPrice = 0;
Product pro = new Product();
for (int i = 0; i < counts.length; i++) {
int itemCount = counts[i];
unitPrice = PriceUtils.TableDoublePrice(width * length, prices[i], areas);
if (itemCount < count) {
continue;
}
if (priceList.size() > 2) {
break;
}
if (priceList.size() == 0 && itemCount != count) {
pro = new Product();
pro.setCount(count);
pro.setPrice(Math.max(Math.ceil(unitPrice * count * rate), miniPrice));
pro.setNumber(number);
priceList.add(pro);
}
pro = new Product();
pro.setCount(itemCount);
pro.setPrice(Math.max(Math.ceil(unitPrice * itemCount * rate), miniPrice));
pro.setNumber(number);
priceList.add(pro);
}
if (priceList.size() == 0) {
pro = new Product();
pro.setCount(count);
pro.setPrice(Math.max(Math.ceil(unitPrice * count * rate), miniPrice));
pro.setNumber(number);
priceList.add(pro);
}
return priceList;
}
private List<Product> getHandkerPrice(Product dto, Double width, Double length) {
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();
@@ -4772,6 +4873,13 @@ public class ProductService {
{0, 0, 340, 450, 570, 684, 798, 912, 1026, 1040},
{0, 0, 350, 460, 810, 972, 1134, 1296, 1458, 1780},
};
if ("双色".equals(dto.getShen_color())) {
prices = new double[][]{
{0, 0, 0, 0, 625, 720, 840, 960, 1080, 1200},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 875, 1020, 1190, 1280, 1350, 1450},
};
}
Product pro = new Product();
for (int i = 0; i < counts.length; i++) {
@@ -3631,6 +3631,26 @@ public class PriceUtils {
return price;
}
public static double TableDoublePrice(double area, double[] price_list, double[] 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] - area) / (areas[endIndex] - areas[startIndex])) * price_list[startIndex] + ((area - areas[startIndex]) / (areas[endIndex] - areas[startIndex])) * price_list[endIndex];
}
return price;
}
public static double TableUnitPrice(double area, int[] price_list, double[] areas, double last_price) {
double price = 0;
int startIndex = 0;