130 lines
4.1 KiB
Java
130 lines
4.1 KiB
Java
package lingtao.net.util;
|
|
|
|
import lingtao.net.bean.Product;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class ZsPrice {
|
|
public List<Product> getPrice(int count, double length, double width, List<Product> list, int number, String shenzi) {
|
|
double price = 50;
|
|
double l = 438.0;
|
|
double w = 304.0;
|
|
length += 3;
|
|
width += 3;
|
|
// 一张l/w 大的纸张能做多少个此类尺寸的产品
|
|
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
|
Math.floor(l / width) * Math.floor(w / length));
|
|
// 报的数量需要多少张大纸
|
|
// 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
|
|
int num = (int) Math.ceil(count * number / max);
|
|
price += (num - 1) * 15;
|
|
if ("绳子".equals(shenzi)) {
|
|
price += 1 * count * number;
|
|
}
|
|
|
|
if (number > 1) {//多款算设计费
|
|
price += 10 * number;
|
|
}
|
|
|
|
Product pro = new Product();
|
|
pro.setPrice(Math.ceil(price));
|
|
pro.setCount(count);
|
|
list.add(pro);
|
|
|
|
return list;
|
|
}
|
|
|
|
public static List<Product> getSmPrice(int count, Double length, Double width, List<Product> list, Integer number, String[] craft, Product dto, String role) {
|
|
double price = 60;
|
|
double l = 438.0;
|
|
double w = 304.0;
|
|
if ("10".equals(dto.getKindValue())) {
|
|
price = 90;
|
|
}
|
|
if ((length < 8.55 && width < 5.4) || (width < 8.55 && length < 5.4)) {
|
|
length = 8.55;
|
|
width = 5.4;
|
|
}
|
|
length = length * 10 + 3;
|
|
width = width * 10 + 3;
|
|
// 一张l/w 大的纸张能做多少个此类尺寸的产品
|
|
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
|
|
Math.floor(l / width) * Math.floor(w / length));
|
|
// 报的数量需要多少张大纸
|
|
// 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
|
|
int num = (int) Math.ceil(count * number / max);
|
|
if ("10".equals(dto.getKindValue())) {
|
|
price += (num - 1) * 30;
|
|
} else {
|
|
price += (num - 1) * 15;
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(craft) && craft[0].equals("背胶")) {
|
|
price += num * 10;
|
|
}
|
|
|
|
|
|
if (number > 1) {
|
|
double desFee = 0;
|
|
|
|
if (!role.contains("1045") && !role.contains("1054") && !role.contains("1029")) {
|
|
if (dto.getP() == 1) {
|
|
desFee = 0.6 * (number - 1);
|
|
} else {
|
|
desFee = 10* (number - 1);
|
|
// if (number == 2) {
|
|
// desFee = 5.75;
|
|
// }
|
|
// if (number == 3) {
|
|
// desFee = 5.75 + 3.75;
|
|
// }
|
|
// if (number > 3) {
|
|
// desFee = 5.75 + 3.75 + 2.75 * (number - 3);
|
|
// }
|
|
}
|
|
price += desFee;
|
|
} else {
|
|
if (dto.getP() == 1 || dto.getP() == 2 || dto.getP() == 3) {
|
|
desFee = 3;
|
|
} else if (dto.getP() == 4) {
|
|
desFee = 5;
|
|
} else if (dto.getP() == 5) {
|
|
desFee = 6;
|
|
} else {
|
|
desFee = 10;
|
|
}
|
|
price += desFee * (number - 1);
|
|
}
|
|
}
|
|
|
|
|
|
Product pro = new Product();
|
|
pro.setPrice(Math.ceil(price));
|
|
pro.setCount(count);
|
|
list.add(pro);
|
|
|
|
return list;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
|
|
}
|
|
|
|
public int[] twoSum(int[] nums, int target) {
|
|
|
|
List<Integer> list = new ArrayList<>();
|
|
|
|
for (int i = 0; i < nums.length; i++) {
|
|
if (list.get(target - nums[i]) != null) {
|
|
return new int[]{list.get(target - nums[i]), i};
|
|
}
|
|
|
|
list.add(target - nums[i], nums[i]);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|