新增木浆棉
This commit is contained in:
@@ -4494,7 +4494,10 @@ public class ProductService {
|
||||
priceList = getKeychain(dto, width, length);
|
||||
return chucklePrice(role, priceList, dto);
|
||||
case "刺绣贴":
|
||||
priceList = embroideredPatch(dto, width, length);
|
||||
priceList = getEmbroideredPatchPrice(dto, width, length);
|
||||
return chucklePrice(role, priceList, dto);
|
||||
case "木浆棉":
|
||||
priceList = getWoodPulpCottonPrice(dto, width, length);
|
||||
return chucklePrice(role, priceList, dto);
|
||||
default:
|
||||
break;
|
||||
@@ -4502,7 +4505,79 @@ public class ProductService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Product> embroideredPatch(Product dto, Double width, Double length) {
|
||||
private List<Product> getWoodPulpCottonPrice(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 paperLength = 420;
|
||||
double paperWith = 297;
|
||||
|
||||
width = width * 10 + 4;
|
||||
length = length * 10 + 4;
|
||||
// 一张l/w 大的纸张能做多少个此类尺寸的产品
|
||||
double max = Math.max(Math.floor(paperLength / length) * Math.floor(paperWith / width), Math.floor(paperLength / width) * Math.floor(paperWith / length));
|
||||
// 报的数量需要多少张大纸
|
||||
// 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
|
||||
int num = (int) Math.ceil(count * number / Math.max(max, 1));
|
||||
double basePrice = 0;
|
||||
if (num <= 100) {
|
||||
basePrice = 40;
|
||||
basePrice = new PriceUtils().calcByTargetN(100, 40, 100, 40, num);
|
||||
} else if (num <= 300) {
|
||||
basePrice = 35;
|
||||
basePrice = new PriceUtils().calcByTargetN(100, 40, 300, 35, num);
|
||||
} else if (num <= 500) {
|
||||
basePrice = 30;
|
||||
basePrice = new PriceUtils().calcByTargetN(300, 35, 500, 30, num);
|
||||
} else if (num <= 1000) {
|
||||
basePrice = 28;
|
||||
basePrice = new PriceUtils().calcByTargetN(500, 35, 1000, 28, num);
|
||||
} else if (num <= 2000) {
|
||||
basePrice = 26;
|
||||
basePrice = new PriceUtils().calcByTargetN(1000, 28, 2000, 26, num);
|
||||
} else if (num <= 5000) {
|
||||
basePrice = 24;
|
||||
basePrice = new PriceUtils().calcByTargetN(2000, 26, 5000, 24, num);
|
||||
} else if (num <= 10000) {
|
||||
basePrice = 22;
|
||||
basePrice = new PriceUtils().calcByTargetN(5000, 24, 10000, 22, num);
|
||||
} else {
|
||||
basePrice = 20*num;
|
||||
//basePrice = new PriceUtils().calcByTargetN(10000, 20, 10000, 20, num);
|
||||
}
|
||||
double craftPrice = 0;
|
||||
double craftBasePrice = 0;
|
||||
double craftMiniPrice = 0;
|
||||
if (craft_list.contains("装opp袋")) {
|
||||
craftBasePrice = 0.20;
|
||||
craftPrice += Math.max(craftBasePrice * count, 10);
|
||||
}
|
||||
if (craft_list.contains("穿绳子")) {
|
||||
craftBasePrice = 0.20;
|
||||
craftPrice += Math.max(craftBasePrice * count, 10);
|
||||
}
|
||||
|
||||
if (craft_list.contains("配opp袋")) {
|
||||
craftBasePrice = 0.15;
|
||||
craftPrice += Math.max(craftBasePrice * count, 5);
|
||||
}
|
||||
if (craft_list.contains("配绳子")) {
|
||||
craftBasePrice = 0.15;
|
||||
craftPrice += Math.max(craftBasePrice * count, 5);
|
||||
}
|
||||
Product pro = new Product();
|
||||
pro.setCount(count);
|
||||
pro.setNumber(number);
|
||||
pro.setPrice(Math.ceil((Math.max(basePrice, 80) + Math.max(craftPrice, craftMiniPrice)) * number));
|
||||
priceList.add(pro);
|
||||
|
||||
return priceList;
|
||||
}
|
||||
|
||||
private List<Product> getEmbroideredPatchPrice(Product dto, Double width, Double length) {
|
||||
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
|
||||
List<Product> priceList = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -3673,6 +3673,9 @@ public class PriceUtils {
|
||||
|
||||
public double calcByTargetN(int startN, double highPrice, int endN, double lowPrice, int targetN) {
|
||||
// 高价商品个数线性插值
|
||||
if (endN == startN) {
|
||||
return highPrice * targetN;
|
||||
}
|
||||
double a = startN * (double) (endN - targetN) / (endN - startN);
|
||||
double b = targetN - a;
|
||||
double total = a * highPrice + b * lowPrice;
|
||||
|
||||
Reference in New Issue
Block a user