ZsPrice.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package lingtao.net.util;
  2. import com.aspose.pdf.Document;
  3. import com.aspose.pdf.optimization.OptimizationOptions;
  4. import lingtao.net.bean.Product;
  5. import org.springframework.util.StringUtils;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. public class ZsPrice {
  9. public List<Product> getPrice(int count, double length, double width, List<Product> list, int number, String shenzi) {
  10. double price = 50;
  11. double l = 438.0;
  12. double w = 304.0;
  13. length += 3;
  14. width += 3;
  15. // 一张l/w 大的纸张能做多少个此类尺寸的产品
  16. double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
  17. Math.floor(l / width) * Math.floor(w / length));
  18. // 报的数量需要多少张大纸
  19. // 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
  20. int num = (int) Math.ceil(count * number / max);
  21. price += (num - 1) * 15;
  22. if ("绳子".equals(shenzi)) {
  23. price += 1 * count * number;
  24. }
  25. if (number > 1) {//多款算设计费
  26. price += 10 * number;
  27. }
  28. Product pro = new Product();
  29. pro.setPrice(Math.ceil(price));
  30. pro.setCount(count);
  31. list.add(pro);
  32. return list;
  33. }
  34. public static List<Product> getSmPrice(int count, Double length, Double width, List<Product> list, Integer number, String[] craft, Product dto, String role) {
  35. double price = 60;
  36. double l = 438.0;
  37. double w = 304.0;
  38. if ("10".equals(dto.getKindValue())) {
  39. price = 90;
  40. }
  41. if ((length < 8.55 && width < 5.4) || (width < 8.55 && length < 5.4)) {
  42. length = 8.55;
  43. width = 5.4;
  44. }
  45. length = length * 10 + 3;
  46. width = width * 10 + 3;
  47. // 一张l/w 大的纸张能做多少个此类尺寸的产品
  48. double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
  49. Math.floor(l / width) * Math.floor(w / length));
  50. // 报的数量需要多少张大纸
  51. // 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
  52. int num = (int) Math.ceil(count * number / max);
  53. if ("10".equals(dto.getKindValue())) {
  54. price += (num - 1) * 30;
  55. } else {
  56. price += (num - 1) * 15;
  57. }
  58. if (!StringUtils.isEmpty(craft) && craft[0].equals("背胶")) {
  59. price += num * 10;
  60. }
  61. if (number > 1) {
  62. double desFee = 0;
  63. if (!role.contains("1045") && !role.contains("1054") && !role.contains("1029")) {
  64. if (dto.getP() == 1) {
  65. desFee = 0.6 * (number - 1);
  66. } else {
  67. desFee = 10 * (number - 1);
  68. // if (number == 2) {
  69. // desFee = 5.75;
  70. // }
  71. // if (number == 3) {
  72. // desFee = 5.75 + 3.75;
  73. // }
  74. // if (number > 3) {
  75. // desFee = 5.75 + 3.75 + 2.75 * (number - 3);
  76. // }
  77. }
  78. price += desFee;
  79. } else {
  80. if (dto.getP() == 1 || dto.getP() == 2 || dto.getP() == 3) {
  81. desFee = 3;
  82. } else if (dto.getP() == 4) {
  83. desFee = 5;
  84. } else if (dto.getP() == 5) {
  85. desFee = 6;
  86. } else {
  87. desFee = 10;
  88. }
  89. price += desFee * (number - 1);
  90. }
  91. }
  92. Product pro = new Product();
  93. pro.setPrice(Math.ceil(price));
  94. pro.setCount(count);
  95. list.add(pro);
  96. return list;
  97. }
  98. public static void main(String[] args) {
  99. }
  100. public int[] twoSum(int[] nums, int target) {
  101. List<Integer> list = new ArrayList<>();
  102. for (int i = 0; i < nums.length; i++) {
  103. if (list.get(target - nums[i]) != null) {
  104. return new int[]{list.get(target - nums[i]), i};
  105. }
  106. list.add(target - nums[i], nums[i]);
  107. }
  108. return null;
  109. }
  110. }