first commit
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
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) {
|
||||
double price = 60;
|
||||
double l = 438.0;
|
||||
double w = 304.0;
|
||||
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) * 25;
|
||||
} else {
|
||||
price += (num - 1) * 15;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(craft) && craft[0].equals("背胶")) {
|
||||
price += num * 10;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user