This commit is contained in:
2026-05-07 14:41:47 +08:00
parent 2b63fe4147
commit 4cac8394e6
8 changed files with 301 additions and 96 deletions
@@ -7,6 +7,8 @@ import java.util.List;
@Data @Data
public class ProductPriceRequestVo { public class ProductPriceRequestVo {
private String product;
/** /**
* 类型 * 类型
*/ */
@@ -12,12 +12,11 @@ import java.util.List;
@Service @Service
public class ISysConfigServiceImpl implements IProductPriceService { public class ISysConfigServiceImpl implements IProductPriceService {
@Override @Override
public List<ProductPriceDto> getProductPrice(ProductPriceRequestVo product) { public List<ProductPriceDto> getProductPrice(ProductPriceRequestVo product) {
List<ProductPriceDto> list = new ArrayList<>(); List<ProductPriceDto> list = new ArrayList<>();
if ("不干胶".equals(product.getTypes())) { if ("不干胶".equals(product.getProduct())) {
list = StickerUtils.getPrice(product); list = StickerUtils.getPrice(product);
} }
@@ -2,7 +2,6 @@ package com.quoted.system.utils;
import com.quoted.system.domain.vo.ProductPriceDto; import com.quoted.system.domain.vo.ProductPriceDto;
import com.quoted.system.domain.vo.ProductPriceRequestVo; import com.quoted.system.domain.vo.ProductPriceRequestVo;
import org.apache.commons.math3.stat.descriptive.summary.Product;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -35,103 +34,92 @@ public class StickerUtils {
// 一个名片位内做特价:75折,价格在前端写死 // 一个名片位内做特价:75折,价格在前端写死
double[] priceArr = null; double[] priceArr = null;
int[] counts = {500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000}; int[] counts = {500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000};
double areas[] = {0.004, 0.006, 0.008, 0.01, 0.012, 0.015, 0.017, 0.018, 0.02, 0.03, 0.04, 0.06, 0.1, 0.2, 0.3}; double[] areas = {0.004, 0.006, 0.008, 0.01, 0.012, 0.015, 0.017, 0.018, 0.02, 0.03, 0.04, 0.06, 0.1, 0.2, 0.3};
//覆膜是否要加价 //覆膜是否要加价
boolean isMo = true; boolean isMo = true;
int MaxCount = 0; int MaxCount = 0;
if (length == 1 && width == 1) { if (width < 21 && length < 21) {
priceArr = new double[]{30, 35, 50, 55, 100, 180, 270, 370, 470, 570};
} else if ((length == 2 && width == 1) || (length == 1 && width == 2)) { if (length == 1 && width == 1) {
priceArr = new double[]{35, 40, 55, 60, 110, 190, 280, 380, 480, 580}; priceArr = new double[]{30, 35, 50, 55, 100, 180, 270, 370, 470, 570};
} else if ((length > 2 && length <= 5 && width == 1) || (width > 2 && width <= 5 && length == 1)) { } else if ((length == 2 && width == 1) || (length == 1 && width == 2)) {
priceArr = new double[]{35, 40, 55, 70, 120, 210, 308, 435, 555, 683}; priceArr = new double[]{35, 40, 55, 60, 110, 190, 280, 380, 480, 580};
} else if ((length > 1 && length <= 3 && width == 2) || (width > 1 && width <= 3 && length == 2)) { } else if ((length > 2 && length <= 5 && width == 1) || (width > 2 && width <= 5 && length == 1)) {
priceArr = new double[]{35, 40, 55, 70, 120, 210, 308, 435, 555, 683}; priceArr = new double[]{35, 40, 55, 70, 120, 210, 308, 435, 555, 683};
} else if ((length > 3 && length <= 5 && width == 2) || (width > 3 && width <= 5 && length == 2)) { } else if ((length > 1 && length <= 3 && width == 2) || (width > 1 && width <= 3 && length == 2)) {
priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798}; priceArr = new double[]{35, 40, 55, 70, 120, 210, 308, 435, 555, 683};
} else if ((length >= 3 && length <= 5 && width == 3) || (length == 3 && width <= 5 && width >= 3)) { } else if ((length > 3 && length <= 5 && width == 2) || (width > 3 && width <= 5 && length == 2)) {
priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798}; priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798};
} else if (length == 4 && width == 4) { } else if ((length >= 3 && length <= 5 && width == 3) || (length == 3 && width <= 5 && width >= 3)) {
priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798}; priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798};
} else if ((length == 5 && width == 4) || (length == 4 && width == 5)) { } else if (length == 4 && width == 4) {
priceArr = new double[]{35, 40, 55, 70, 150, 240, 420, 600, 790, 980}; priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798};
} else if (((length <= 9 && width <= 5.4) || (length <= 5.4 && width <= 9))) { } else if ((length == 5 && width == 4) || (length == 4 && width == 5)) {
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000}; priceArr = new double[]{35, 40, 55, 70, 150, 240, 420, 600, 790, 980};
priceArr = new double[]{60, 70, 95, 125, 175, 270, 510, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200}; } else if (((length <= 9 && width <= 5.4) || (length <= 5.4 && width <= 9))) {
isMo = false; counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000};
} else if (area <= 0.003) { priceArr = new double[]{60, 70, 95, 125, 175, 270, 510, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200};
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000}; isMo = false;
priceArr = new double[]{65, 75, 100, 130, 180, 275, 515, 805, 1005, 1205, 1405, 1605, 1805, 2005, 2205}; } else if (area <= 0.003) {
isMo = false; counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000};
MaxCount = 40000; priceArr = new double[]{65, 75, 100, 130, 180, 275, 515, 805, 1005, 1205, 1405, 1605, 1805, 2005, 2205};
isMo = false;
if (count >= 40000) {
MaxCount = 40000;
}
} else {
list = getManyAreaPrice(count, area, areas);
break;
}
} else { } else {
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000}; if ((length == 1 && width <= 48) || (width == 1 && length <= 48)) {
double basePrice = 0; counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000};
if (area <= 0.004) { priceArr = new double[]{90, 100, 160, 190, 230, 420, 760, 1100, 1400};
basePrice = 7.5; isMo = false;
} else if (area <= 0.006) { if (count >= 40000) {
basePrice = 6.5; MaxCount = 40000;
} else if (area <= 0.2) {
basePrice = 5.5;
} else if (area <= 0.3) {
basePrice = 5;
} else if (area > 0.3) {
basePrice = 4.5;
}
ProductPriceDto pro = new ProductPriceDto();
if (count > counts[counts.length - 1]) {
pro.setCount(count);
pro.setPrice(Math.ceil(area * count * basePrice));
list.add(pro);
}
for (int i = 0; i < counts.length; i++) {
if (counts[i] < count || list.size() > 3) {
continue;
} }
} else if ((length == 1 && width <= 60) || (width == 1 && length <= 60)) {
double[] arrPrice = new double[16]; counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000};
if (counts[i] == 500) { priceArr = new double[]{100, 120, 180, 230, 300, 550, 960, 1300, 1600};
arrPrice = new double[]{37, 33, 30, 26, 25, 21, 19, 18, 17, 19, 17, 12.8, 12.5, 12, 11.5, 11}; isMo = false;
} else if (counts[i] == 1000) { if (count >= 40000) {
arrPrice = new double[]{21, 19, 17, 17, 15, 14, 14, 12, 12, 12.5, 13, 9, 9, 8, 8, 7.8}; MaxCount = 40000;
} else if (counts[i] == 2000) {
arrPrice = new double[]{14, 13, 13, 12, 11, 11, 10, 10, 9, 10, 11, 7.8, 7.5, 7.5, 7.2, 7};
} else if (counts[i] == 3000) {
arrPrice = new double[]{12, 11, 11, 10, 9, 9.5, 9, 8, 8, 9, 10, 6.8, 6.5, 6.5, 6, 6.5};
} else if (counts[i] == 5000) {
arrPrice = new double[]{10, 9.5, 8, 7.8, 8.5, 9, 8.3, 7, 8, 6.5, 8, 6, 6, 6, 5.5, 5};
} else if (counts[i] == 10000) {
arrPrice = new double[]{8, 7.5, 6.5, 6.5, 7.6, 8, 7.3, 6, 7.5, 6, 6, 6, 6, 6, 5, 5};
} else if (counts[i] == 20000) {
arrPrice = new double[]{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 30000) {
arrPrice = new double[]{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 40000) {
arrPrice = new double[]{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 50000) {
arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 60000) {
arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 70000) {
arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 80000) {
arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 90000) {
arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} else if (counts[i] == 100000) {
arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5};
} }
} else if ((length == 1 && width <= 70) || (width == 1 && length <= 70)) {
double pirce = getPriceInArea(counts[i], area, arrPrice, areas); counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000};
pro = new ProductPriceDto(); priceArr = new double[]{110, 130, 200, 270, 330, 580, 1100, 1500, 1900};
pro.setCount(counts[i]); isMo = false;
pro.setPrice(Math.ceil(pirce)); if (count >= 40000) {
MaxCount = 40000;
list.add(pro); }
} else if ((length == 1 && width <= 80) || (width == 1 && length <= 80)) {
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000};
priceArr = new double[]{130, 150, 240, 300, 380, 650, 1200, 1650, 2100};
isMo = false;
if (count >= 40000) {
MaxCount = 40000;
}
} else if ((length == 1 && width <= 90) || (width == 1 && length <= 90)) {
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000};
priceArr = new double[]{150, 170, 245, 320, 420, 750, 1300, 1750, 2200};
isMo = false;
if (count >= 40000) {
MaxCount = 40000;
}
} else if ((length == 1 && width <= 100) || (width == 1 && length <= 100)) {
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000};
priceArr = new double[]{170, 200, 260, 350, 480, 860, 1400, 2000, 2600};
isMo = false;
if (count >= 40000) {
MaxCount = 40000;
}
} else {
list = getManyAreaPrice(count, area, areas);
break; break;
} }
} }
ProductPriceDto pro = null; ProductPriceDto pro = null;
if (MaxCount == 0) { if (MaxCount == 0) {
@@ -158,6 +146,77 @@ public class StickerUtils {
list.add(pro); list.add(pro);
} }
break; break;
case "pvc不干胶":
case "透明不干胶":
if (width < 21 && length < 21) {
if ((length <= 9 && width > 5 && width <= 5.4) || (width <= 9 && length > 5 && length <= 5.4)) {
width = (Math.floor(width));
length = (Math.floor(length));
} else {
// 小数向上取整
width = (Math.ceil(width));
length = (Math.ceil(length));
}
if (count <= 10000) {
areas = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000};
double[][] areas_price = {
{90, 90, 90, 90, 90, 90, 90, 90, 90, 100, 120, 120, 130, 130, 140, 150, 150, 160, 160, 180},
{120, 120, 110, 120, 120, 110, 110, 110, 120, 120, 140, 140, 150, 150, 160, 180, 180, 200, 200, 200},
{190, 190, 190, 190, 190, 180, 180, 180, 200, 230, 260, 260, 260, 260, 280, 280, 280, 280, 300, 300},
{220, 220, 220, 220, 220, 220, 220, 240, 240, 270, 270, 270, 290, 290, 290, 290, 320, 320, 340, 340},
{350, 350, 350, 350, 350, 330, 360, 380, 400, 410, 420, 440, 460, 480, 500, 520, 540, 560, 600, 650},
{510, 510, 510, 510, 510, 580, 530, 600, 700, 780, 800, 840, 880, 920, 940, 960, 980, 1000, 1020, 1050},
};
list = getAreasPrice(count, area, areas_price, counts, areas);
break;
} else {
// 1*1,2*1 价格调整成和3*1一致
if (area < 0.0003) {
area = 0.0003;
}
}
}
counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000};
if (area <= 0.0004) {
priceArr = new double[]{450.0, 300.0, 238.0, 184.0, 175.0, 158.0, 87.0, 70.0, 65.0, 59.0, 52.0, 48.0, 45.0, 42.0, 39.0, 36.0};
} else if (area <= 0.0006) {
priceArr = new double[]{300.0, 200.0, 158.0, 122.0, 117.0, 85.0, 60.0, 50.0, 45.0, 40.0, 38.0, 37.0, 36.0, 35.0, 33.0, 32.0};
} else if (area <= 0.0008) {
priceArr = new double[]{260.0, 171.0, 135.0, 105.0, 100.0, 73.0, 51.0, 45.0, 39.0, 33.0, 32.0, 31.0, 30.0, 29.0, 28.0, 27.0};
} else if (area <= 0.001) {
priceArr = new double[]{200.0, 133.0, 105.0, 82.0, 78.0, 56.0, 42.0, 33.0, 28.0, 27.0, 26.0, 25.0, 24.0, 23.0, 22.0, 21.0};
} else if (area <= 0.0012) {
priceArr = new double[]{150.0, 92.0, 75.0, 62.0, 55.0, 48.0, 35.0, 29.0, 24.0, 23.0, 22.0, 21.0, 20.0, 19.0, 18.0, 17.0};
} else if (area <= 0.0014) {
priceArr = new double[]{138.0, 85.0, 70.0, 62.0, 54.0, 43.0, 31.0, 26.0, 22.0, 21.0, 20.0, 19.0, 18.0, 17.0, 16.0, 15.0};
} else if (area <= 0.0016) {
priceArr = new double[]{120.0, 80.0, 67.0, 54.0, 51.0, 43.0, 29.0, 23.0, 19.0, 19.0, 19.0, 18.0, 17.0, 16.0, 15.0, 15.0};
} else if (area <= 0.0025) {
priceArr = new double[]{118.0, 76.0, 68.0, 51.0, 48.0, 39.0, 20.0, 19.0, 18.0, 17.0, 16.0, 15.0, 14.0, 13.0, 13.0, 13.0};
} else if (area <= 0.0035) {
priceArr = new double[]{62.5, 60.0, 63.0, 47.0, 46.0, 38.0, 18.0, 18.0, 18.0, 16.0, 16.0, 15.0, 14.0, 13.0, 12.0, 12.0};
} else if (area <= 0.0045) {
priceArr = new double[]{84.0, 50.0, 44.0, 33.0, 25.0, 19.0, 15.0, 14.0, 14.0, 14.0, 13.0, 13.0, 12.0, 12.0, 12.0, 12.0};
} else if (area <= 0.0084) {
priceArr = new double[]{56.0, 35.0, 29.0, 26.0, 19.0, 16.0, 15.0, 14.0, 14.0, 13.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0};
} else if (area <= 0.012) {
priceArr = new double[]{42.0, 26.0, 23.0, 18.0, 14.0, 12.0, 14.0, 13.0, 13.0, 12.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0};
} else if (area <= 0.015) {
priceArr = new double[]{36.0, 25.0, 22.0, 17.0, 15.0, 13.0, 13.0, 12.0, 12.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0};
} else if (area <= 0.02) {
priceArr = new double[]{35.0, 24.0, 21.0, 17.0, 15.0, 13.0, 13.0, 12.0, 12.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0};
} else if (area <= 0.06) {
priceArr = new double[]{32.0, 23.0, 21.0, 17.0, 15.0, 13.0, 13.0, 12.0, 12.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0};
} else if (area <= 0.1) {
priceArr = new double[]{30.0, 20.0, 15.0, 13.0, 13.0, 13.0, 13.0, 12.0, 12.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0};
} else if (area <= 0.2) {
priceArr = new double[]{17.0, 14.0, 13.0, 12.0, 12.0, 12.0, 12.0, 11.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0};
} else {
priceArr = new double[]{15.0, 13.0, 12.0, 12.0, 11.0, 11.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0};
}
list = bigSizeAccountPrice(count, area, priceArr, counts);
break;
default: default:
break; break;
} }
@@ -166,6 +225,107 @@ public class StickerUtils {
return list; return list;
} }
private static List<ProductPriceDto> getManyAreaPrice(int count, double area, double[] areas) {
List<ProductPriceDto> list = new ArrayList<>();
int[] counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000};
double[][] areas_price = {
{37, 33, 30, 26, 25, 21, 19, 18, 17, 19, 17, 12.8, 12.5, 12, 11.5, 11},
{21, 19, 17, 17, 15, 14, 14, 12, 12, 12.5, 13, 9, 9, 8, 8, 7.8},
{14, 13, 13, 12, 11, 11, 10, 10, 9, 10, 11, 7.8, 7.5, 7.5, 7.2, 7},
{12, 11, 11, 10, 9, 9.5, 9, 8, 8, 9, 10, 6.8, 6.5, 6.5, 6, 6.5},
{10, 9.5, 8, 7.8, 8.5, 9, 8.3, 7, 8, 6.5, 8, 6, 6, 6, 5.5, 5},
{8, 7.5, 6.5, 6.5, 7.6, 8, 7.3, 6, 7.5, 6, 6, 6, 6, 6, 5, 5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5},
};
double basePrice = 0;
if (area <= 0.004) {
basePrice = 7.5;
} else if (area <= 0.006) {
basePrice = 6.5;
} else if (area <= 0.2) {
basePrice = 5.5;
} else if (area <= 0.3) {
basePrice = 5;
} else if (area > 0.3) {
basePrice = 4.5;
}
ProductPriceDto pro = new ProductPriceDto();
if (count > counts[counts.length - 1]) {
pro.setCount(count);
pro.setPrice(Math.ceil(area * count * basePrice));
list.add(pro);
} else {
for (int i = 0; i < counts.length; i++) {
if (counts[i] < count || list.size() > 3) {
continue;
}
double price = getPriceInArea(counts[i], area, areas, areas_price[i]);
pro = new ProductPriceDto();
pro.setCount(counts[i]);
pro.setPrice(Math.ceil(price));
list.add(pro);
}
}
return list;
}
private static List<ProductPriceDto> getAreasPrice(int count, double area, double[][] areas_price, int[] counts, double[] areas) {
List<ProductPriceDto> list = new ArrayList<>();
ProductPriceDto pro = new ProductPriceDto();
int areaIndex = 0;
for (int i = 0; i < areas.length; i++) {
if (area < areas[i]) {
break;
}
areaIndex = i;
}
for (int i = 0; i < counts.length; i++) {
if (counts[i] < count) {
continue;
}
double[] priceArr = areas_price[i];
pro = new ProductPriceDto();
pro.setCount(counts[i]);
pro.setPrice(priceArr[areaIndex]);
list.add(pro);
}
return list;
}
private static List<ProductPriceDto> bigSizeAccountPrice(int count, Double area, double[] priceArr, int[] bigCountArr) {
List<ProductPriceDto> list = new ArrayList<>();
ProductPriceDto pro = new ProductPriceDto();
if (count > bigCountArr[bigCountArr.length - 1]) {
pro.setCount(count);
pro.setPrice(Math.ceil(area * count * priceArr[bigCountArr.length - 1]));
list.add(pro);
}
for (int i = 0; i < bigCountArr.length; i++) {
if (bigCountArr[i] < count) {
continue;
}
pro = new ProductPriceDto();
pro.setCount(bigCountArr[i]);
pro.setPrice(Math.ceil(area * bigCountArr[i] * priceArr[i]));
list.add(pro);
}
return list;
}
// 判断小尺寸是否大于大尺寸价格 // 判断小尺寸是否大于大尺寸价格
private static double getPriceInArea(int count, Double area, double[] priceArr, double[] areas) { private static double getPriceInArea(int count, Double area, double[] priceArr, double[] areas) {
double lastPrice = 0, price = 0; double lastPrice = 0, price = 0;
+35 -2
View File
@@ -1,7 +1,7 @@
<template> <template>
<view class="result-container"> <view class="result-container">
<el-button type="primary" @click="handleGetPrice">获取价格</el-button> <el-button type="primary" @click="handleGetPrice">获取价格</el-button>
<el-input type="textarea" style="width: 400px; height: 400px" rows="10" resize="none" readonly></el-input> <el-input v-model="priceReulst" type="textarea" style="width: 400px; height: 400px" rows="10" resize="none" readonly></el-input>
</view> </view>
</template> </template>
@@ -15,11 +15,22 @@ const props = defineProps({
type: Object, type: Object,
required: true, required: true,
}, },
numberUnit: {
type: String,
default: "个",
},
sizeUnit: {
type: String,
default: "cm",
},
}); });
const priceReulst = ref("");
const emits = defineEmits(["verifyCraftData"]); const emits = defineEmits(["verifyCraftData"]);
const handleGetPrice = () => { const handleGetPrice = () => {
priceReulst.value = "";
emits("verifyCraftData", (result) => { emits("verifyCraftData", (result) => {
let { valid, message } = result; let { valid, message } = result;
if (!valid) { if (!valid) {
@@ -31,7 +42,29 @@ const handleGetPrice = () => {
return; return;
} }
getProductPrice(props.data).then((res) => { getProductPrice(props.data).then((res) => {
console.log(res); let { code, data, msg } = res;
if (code === 200) {
let result = "";
let resultList = [];
resultList.push(props.data.product);
resultList.push(props.data.material);
resultList.push(`${props.data.length}*${props.data.width}${props.sizeUnit}`);
result = resultList.join("-") + "\n";
if (props.data.crafts && props.data.crafts.length > 0) {
result += "工艺:";
resultList = [];
props.data.crafts.forEach((craft) => {
resultList.push(`${craft.text}`);
});
result += resultList.join(",") + "\n";
}
data.forEach((item) => {
result += `${props.data.number}${item.count}${props.numberUnit},共${item.price}\n`;
});
result += "包邮,免费设计呢~(偏远地区需补邮费)";
priceReulst.value = result;
}
}); });
}); });
}; };
@@ -217,6 +217,7 @@ const handleDataInfo = () => {
if (opt.checked) { if (opt.checked) {
item.type = opt.label; item.type = opt.label;
item.value = opt.value; item.value = opt.value;
let text = opt.value;
if (opt.children) { if (opt.children) {
let childItem = {}; let childItem = {};
item.children = []; item.children = [];
@@ -229,11 +230,19 @@ const handleDataInfo = () => {
}); });
item.children.push(childItem); item.children.push(childItem);
} }
if(text == "配刮刮膜" || text == "粘刮刮膜"){
text += `(${item.children[0].size})`
}
if(text == "内部模切"){
text += `(${item.children[0].count}${item.children[0].width}*${item.children[0].length}cm)`
}
item.text = text;
} }
datainfo.push(item); datainfo.push(item);
}); });
} }
}); });
console.log("🚀 ~ handleDataInfo ~ datainfo:", datainfo);
emits("update:modelValue", datainfo); emits("update:modelValue", datainfo);
}; };
@@ -241,7 +250,7 @@ const handleDataInfo = () => {
const verifyCraftData = () => { const verifyCraftData = () => {
// 验证工艺数据的完整性和正确性 // 验证工艺数据的完整性和正确性
return { valid: false, message: "工艺数据验证失败" }; return { valid: true, message: "工艺数据验证失败" };
}; };
handleDataInfo(); handleDataInfo();
@@ -3,7 +3,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, defineEmits, defineProps } from "vue"; import { ref } from "vue";
import ProductCraft from "@/components/ProductCraft"; import ProductCraft from "@/components/ProductCraft";
const defaultCraftData = ref([ const defaultCraftData = ref([
@@ -3,7 +3,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, defineEmits, defineProps } from "vue"; import { ref } from "vue";
import ProductCraft from "@/components/ProductCraft"; import ProductCraft from "@/components/ProductCraft";
const defaultCraftData = ref([ const defaultCraftData = ref([
@@ -159,6 +159,7 @@ const componentRef = ref(null);
const images = ref([]); const images = ref([]);
const remark = ref(""); const remark = ref("");
const data = ref({ const data = ref({
product: "不干胶",
types: "常用种类", types: "常用种类",
material: "", material: "",
length: null, length: null,
@@ -180,6 +181,7 @@ watch(
const handleChange = (val) => { const handleChange = (val) => {
const initData = { const initData = {
product: "不干胶",
types: val, types: val,
material: "", material: "",
length: null, length: null,