232 lines
9.8 KiB
Java
232 lines
9.8 KiB
Java
package lingtao.net.util;
|
|
|
|
import lingtao.net.bean.Product;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 优惠券/贺卡价格
|
|
*/
|
|
public class CouponPrice {
|
|
|
|
int countArr[] = {200, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000};
|
|
|
|
int countArr2[] = {200, 500, 1000, 2000, 3000, 5000, 10000};
|
|
|
|
|
|
/**
|
|
* 遍历添加价格
|
|
*/
|
|
private List<Product> setPrice(int count, int min, List<Product> list, Double[] priceArr) {
|
|
Product pro = new Product();
|
|
if (min <= 4) {
|
|
for (int i = 0; i < countArr.length; i++) {
|
|
if (countArr[i] < count) {
|
|
continue;
|
|
}
|
|
pro = new Product();
|
|
pro.setCount(countArr[i]);
|
|
pro.setPrice(Math.ceil(priceArr[i]));
|
|
list.add(pro);
|
|
}
|
|
} else if (min > 4) {
|
|
for (int i = 0; i < countArr.length; i++) {
|
|
if (countArr[i] < count) {
|
|
continue;
|
|
}
|
|
pro = new Product();
|
|
pro.setCount(countArr[i]);
|
|
pro.setPrice(priceArr[i] * min);
|
|
list.add(pro);
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public List<Product> getPrice(int count, int min) {
|
|
List<Product> list = new ArrayList<Product>();
|
|
if (min == 1) {
|
|
Double priceArrA[] = {35.0, 40.0, 60.0, 100.0, 150.0, 180.0, 200.0, 240.0, 280.0, 320.0, 360.0, 380.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 2) {
|
|
Double priceArrA[] = {65.0, 70.0, 80.0, 130.0, 180.0, 240.0, 320.0, 380.0, 440.0, 500.0, 520.0, 540.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 3) {
|
|
Double priceArrA[] = {90.0, 100.0, 120.0, 180.0, 280.0, 380.0, 480.0, 570.0, 670.0, 780.0, 840.0, 880.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 4) {
|
|
Double priceArrA[] = {120.0, 120.0, 150.0, 240.0, 320.0, 400.0, 480.0, 600.0, 680.0, 800.0, 1040.0, 1080.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 5) {
|
|
Double priceArrA[] = {26.0, 32.0, 36.0, 52.0, 76.0, 90.0, 116.0, 136.0, 150.0, 180.0, 220.0, 225.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min > 5 && min <= 9) {
|
|
Double priceArrA[] = {24.0, 25.0, 30.0, 50.0, 70.0, 85.0, 105.0, 135.0, 150.0, 180.0, 200.0, 210.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 10) {
|
|
Double priceArrA[] = {22.0, 23.0, 30.0, 50.0, 70.0, 85.0, 105.0, 135.0, 150.0, 180.0, 200.0, 210.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min > 10 && min <= 20) {
|
|
Double priceArrA[] = {20.0, 20.0, 28.0, 48.0, 70.0, 85.0, 100.0, 135.0, 150.0, 180.0, 200.0, 200.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min > 20 && min < 30) {
|
|
Double priceArrA[] = {15.0, 18.0, 24.0, 45.0, 70.0, 85.0, 95.0, 135.0, 150.0, 180.0, 190.0, 190.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 30) {
|
|
Double priceArrA[] = {14.0, 17.0, 23.0, 44.0, 69.0, 84.0, 92.0, 132.0, 147.0, 176.0, 185.0, 185.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 40) {
|
|
Double priceArrA[] = {13.0, 16.0, 22.0, 43.0, 68.0, 83.0, 90.0, 130.0, 145.0, 174.0, 180.0, 180.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
} else if (min == 50) {
|
|
Double priceArrA[] = {12.0, 15.0, 21.0, 42.0, 66.0, 83.0, 88.0, 128.0, 143.0, 170.0, 175.0, 175.0};
|
|
list = setPrice(count, min, list, priceArrA);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
private static final String compate = "basePrice + area*price";
|
|
private static final String moCompate = "chu*number";
|
|
|
|
public List<Product> getCouponPrice(int min, Product dto, List<Product> priceList, int count, List<String> craftList) {
|
|
Product product = null;
|
|
List<Product> products = new ArrayList<>();
|
|
int[] priceArr = {20, 28, 52, 100, 155, 165, 250};
|
|
|
|
double minPrice = 0.00;
|
|
if ("0".equals(dto.getFmType())) {
|
|
minPrice = 60.00;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
minPrice = 55.00;
|
|
}
|
|
dto.setNumber(dto.getNumber() == null || dto.getNumber() == 0 ? 1 : dto.getNumber());
|
|
for (int i = 0; i < countArr2.length; i++) {
|
|
product = new Product();
|
|
if (count > countArr2[i] || products.size() >= 3) {
|
|
continue;
|
|
}
|
|
Double price = this.price(min, dto, countArr2[i], Double.valueOf(priceArr[i]), minPrice, craftList);
|
|
|
|
product.setPrice(price);
|
|
product.setCount(countArr2[i]);
|
|
products.add(product);
|
|
}
|
|
return products;
|
|
}
|
|
|
|
private Double price(int min, Product dto, int count, double basePrice, double minPrice, List<String> craftList) {
|
|
//200张以内16元/款/单,200张以上24元/款/单
|
|
int price = count <= 200 ? 16 * dto.getNumber() : 20 * dto.getNumber();
|
|
if (min == 1) {
|
|
price = count <= 200 ? 19 * dto.getNumber() : 25 * dto.getNumber();
|
|
}
|
|
double minW = min;
|
|
if (minW > 1) {
|
|
minW = minW - 0.5;
|
|
}
|
|
double v = 0;
|
|
if (craftList.contains("模切")) {
|
|
int[][] prices = {
|
|
{73, 78, 83, 88, 90, 100, 110, 115, 120, 125, 130, 135, 142, 145, 160, 230, 420},
|
|
{78, 83, 88, 93, 95, 105, 115, 120, 132, 142, 152, 162, 172, 185, 198, 243, 435},
|
|
{125, 128, 130, 132, 135, 140, 145, 150, 159, 169, 189, 210, 220, 298, 358, 412, 525},
|
|
{220, 225, 228, 230, 236, 240, 245, 250, 280, 305, 325, 350, 370, 530, 610, 745, 950},
|
|
{320, 325, 330, 335, 340, 345, 350, 355, 396, 455, 480, 495, 528, 790, 880, 1120, 1390},
|
|
{415, 420, 425, 430, 440, 450, 460, 465, 520, 555, 600, 620, 670, 910, 990, 1265, 2100},
|
|
{700, 705, 710, 715, 725, 735, 745, 750, 800, 820, 870, 950, 1150, 1450, 1680, 2390, 3790}
|
|
};
|
|
double[] areas = {16, 25, 30, 35, 36, 40, 45, 48.60, 49, 54, 64, 81, 97.20, 100, 145.80, 255, 289};
|
|
int[] count_list = {200, 500, 1000, 2000, 3000, 5000, 10000};
|
|
int count_index = Arrays.binarySearch(count_list, count);
|
|
double area = dto.getWidth() * dto.getLength();
|
|
v = new PriceUtils().TablePrice(area, prices[count_index], areas);
|
|
} else {
|
|
v = basePrice * min * dto.getNumber() + ((dto.getAwards() - 1) * minW * price);
|
|
}
|
|
String[] size_list = dto.getSize1().split(",");
|
|
double chu = 0.00;
|
|
double total_chu = 0.00;
|
|
List<Double> chu_list = new ArrayList<>();
|
|
|
|
//0贴膜1配膜
|
|
for (int i = 0; i < size_list.length; i++) {
|
|
if ("60*25".equals(size_list[i])) {
|
|
if ("0".equals(dto.getFmType())) {
|
|
chu = 0.12 * count;
|
|
chu = chu < 30 ? 30 : chu;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
chu = 0.08 * count;
|
|
chu = chu < 20 ? 20 : chu;
|
|
}
|
|
} else if ("8*36".equals(size_list[i]) || "18*32".equals(size_list[i]) || "15*48".equals(size_list[i])) {
|
|
if ("0".equals(dto.getFmType())) {
|
|
chu = 0.1 * count;
|
|
chu = chu < 30 ? 30 : chu;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
chu = 0.07 * count;
|
|
chu = chu < 20 ? 20 : chu;
|
|
}
|
|
} else if ("35*58".equals(size_list[i])) {
|
|
if ("0".equals(dto.getFmType())) {
|
|
chu = 0.22 * count;
|
|
chu = chu < 100 ? 100 : chu;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
chu = 0.14 * count;
|
|
chu = chu < 50 ? 50 : chu;
|
|
}
|
|
} else if ("41*72".equals(size_list[i])) {
|
|
if ("0".equals(dto.getFmType())) {
|
|
chu = 0.24 * count;
|
|
chu = chu < 100 ? 100 : chu;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
chu = 0.16 * count;
|
|
chu = chu < 50 ? 50 : chu;
|
|
}
|
|
} else if ("70*50".equals(size_list[i])) {
|
|
if ("0".equals(dto.getFmType())) {
|
|
chu = 0.26 * count;
|
|
chu = chu < 100 ? 100 : chu;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
chu = 0.18 * count;
|
|
chu = chu < 50 ? 50 : chu;
|
|
}
|
|
} else {
|
|
//正常规格
|
|
if ("0".equals(dto.getFmType())) {
|
|
chu = count <= 10000 ? 0.05 * count : 0.03 * count;
|
|
chu = chu < 30 ? 30 : chu;
|
|
}
|
|
if ("1".equals(dto.getFmType())) {
|
|
chu = 0.04 * count;
|
|
chu = chu < 20 ? 20 : chu;
|
|
}
|
|
}
|
|
chu_list.add(chu);
|
|
}
|
|
if (dto.getAwards() == 1 && count == 500) {//只有一个奖项时500和200价格相同 500+5
|
|
minPrice = minPrice + 5;
|
|
}
|
|
Collections.sort(chu_list);
|
|
for (Double aDouble : chu_list) {
|
|
if (total_chu > 0.00) {
|
|
total_chu = total_chu + aDouble * dto.getNumber();
|
|
} else {
|
|
total_chu = Math.max(v + aDouble * dto.getNumber(), minPrice);
|
|
}
|
|
}
|
|
total_chu = Math.round(total_chu);
|
|
|
|
return total_chu;
|
|
}
|
|
|
|
}
|