新增刺绣贴

This commit is contained in:
2026-07-06 10:53:27 +08:00
parent f66834e631
commit 03e4bf9029
3 changed files with 373 additions and 1 deletions
@@ -4493,12 +4493,72 @@ public class ProductService {
case "钥匙扣":
priceList = getKeychain(dto, width, length);
return chucklePrice(role, priceList, dto);
case "刺绣贴":
priceList = embroideredPatch(dto, width, length);
return chucklePrice(role, priceList, dto);
default:
break;
}
return null;
}
private List<Product> embroideredPatch(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 area = width * length;
double price = 0;
int[] counts = {1, 5, 10, 20, 30, 50, 100, 200};
double[] areas = {16, 25, 36, 49, 64, 100, 225, 400, 625, 900};
double[][] prices = {
{100, 28.8, 16.8, 13.2, 9.6, 7.2, 6, 4.8},
{100, 28.8, 16.8, 13.2, 9.6, 7.2, 6, 4.8},
{100, 28.8, 16.8, 13.2, 10.8, 8.4, 6.6, 5.4},
{100, 28.8, 16.8, 13.2, 10.8, 8.4, 6.6, 5.4},
{100, 33.6, 19.2, 14.4, 12, 9.6, 7.2, 6},
{100, 40.8, 23.4, 17.4, 14.4, 11.52, 8.64, 7.2},
{100, 50.4, 28.8, 21.6, 18, 14.4, 10.8, 9},
{100, 50.4, 28.8, 21.6, 18, 14.4, 10.8, 9},
{100, 67.2, 38.4, 28.8, 24, 19.2, 14.4, 12},
{100, 67.2, 38.4, 28.8, 24, 19.2, 14.4, 12},
};
int area_index = 0;
for (int i = 0; i < areas.length; i++) {
if (area <= areas[i]) {
area_index = i;
break;
}
}
double base_price = 0;
for (int i = 0; i < counts.length; i++) {
if (count > counts[i]) {
continue;
}
if (priceList.size() > 2) {
break;
}
int itemCount = priceList.size() == 0 ? count : counts[i];
base_price = prices[area_index][Math.max(itemCount == count ? i - 1 : i, 0)];
Product pro = new Product();
pro.setCount(itemCount);
pro.setNumber(dto.getNumber());
pro.setPrice(Math.ceil(itemCount * base_price * number));
priceList.add(pro);
}
if (priceList.size() == 0) {
Product pro = new Product();
pro.setCount(count);
pro.setNumber(number);
pro.setPrice(Math.ceil(prices[area_index][prices[area_index].length - 1] * count * number));
priceList.add(pro);
}
return priceList;
}
private List<Product> getKeychain(Product dto, Double width, Double length) {
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();