新增帆布袋,外卖盒,方巾

This commit is contained in:
2025-11-29 09:04:06 +08:00
parent 6ce28bae01
commit 1633d9b102
5 changed files with 1229 additions and 42 deletions
@@ -4741,12 +4741,148 @@ public class ProductService {
return getbadgePrice(dto, width, length);
case "冰箱贴":
return getfridgePrice(dto, width, length);
case "帆布袋":
return getCanvasBagPrice(dto, width, length);
case "外卖盒":
return getTakeoutBoxPrice(dto, width, length);
case "方巾纸":
return getHandkerPrice(dto, width, length);
default:
break;
}
return null;
}
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<>();
int maxCount = 10;
int count = dto.getCount();
int number = dto.getNumber();
int[] counts = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int base = 0;
if (width == 23) {
base = 1;
}
if (width == 27) {
base = 2;
}
double[][] prices = {
{118, 236, 350, 450, 480, 576, 672, 768, 864, 900},
{0, 0, 340, 450, 570, 684, 798, 912, 1026, 1040},
{0, 0, 350, 460, 810, 972, 1134, 1296, 1458, 1780},
};
Product pro = new Product();
for (int i = 0; i < counts.length; i++) {
int itemCount = counts[i];
if (itemCount < count) {
continue;
}
if (priceList.size() > 2) {
break;
}
pro = new Product();
pro.setCount(itemCount);
pro.setPrice(Math.ceil(prices[base][i] * number));
pro.setNumber(number);
priceList.add(pro);
}
if (priceList.size() == 0 && count > maxCount) {
double basePrice = prices[base][prices[base].length - 1];
pro = new Product();
pro.setCount(count);
pro.setPrice(Math.ceil(basePrice / maxCount * count * number));
pro.setNumber(number);
priceList.add(pro);
}
return priceList;
}
private List<Product> getTakeoutBoxPrice(Product dto, Double width, Double length) {
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();
int count = dto.getCount();
int number = dto.getNumber();
double[] prices = {2500, 4800, 7200, 12000};
if (dto.getPcount() == 3) {
prices = new double[]{6000, 12000, 18000, 27000};
}
if (dto.getPcount() == 4) {
prices = new double[]{3600, 7200, 10800, 17750};
}
int[] counts = {10000, 20000, 30000, 50000};
Product pro = new Product();
for (int i = 0; i < counts.length; i++) {
if (counts[i] < count) {
continue;
}
pro = new Product();
pro.setCount(counts[i]);
pro.setPrice(Math.ceil(prices[i] * number));
pro.setNumber(number);
priceList.add(pro);
}
return priceList;
}
private double getListNumber(int[] counts, int count, double[] numbers) {
for (int j = 0; j < counts.length; j++) {
if (counts[j] <= count) {
continue;
}
return numbers[j];
}
return 0.0;
}
private List<Product> getCanvasBagPrice(Product dto, Double width, Double length) {
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();
int count = dto.getCount();
//布钱
int[] counts = {5, 10, 20, 30, 50, 100, 200, 500, 1000, 5000, 10000};
double[][] unit_prices = {
{50, 34, 18, 12, 7.9, 4.5, 4, 3.6, 3.5, 3.3, 3},
{50, 35, 19, 13, 7.9, 4.4, 4.2, 3.6, 3.3, 3.1, 3},
{55, 38, 22, 15, 9.2, 4.8, 4.5, 4, 3.6, 3.4, 3.3}
};
int base = 2;
if (width <= 27 && length <= 33 || length <= 27 && width <= 33) {
base = 0;
}
if (width <= 30 && length <= 35 || length <= 30 && width <= 35) {
base = 1;
}
int number = dto.getNumber();
//布钱 +人工+印刷+手提
Product pro = null;
for (int i = 0; i < counts.length; i++) {
int itemCount = counts[i];
if (itemCount < count) {
continue;
}
if (priceList.size() > 2) {
break;
}
if (priceList.size() == 0 && itemCount != count) {
pro = new Product();
pro.setCount(count);
pro.setPrice(Math.ceil(unit_prices[base][i] * count * number));
priceList.add(pro);
}
pro = new Product();
pro.setCount(itemCount);
pro.setPrice(Math.ceil(unit_prices[base][i] * itemCount * number));
priceList.add(pro);
}
return priceList;
}
private List<Product> getfridgePrice(Product dto, Double width, Double length) {
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();