diff --git a/quoted-admin/src/main/java/com/quoted/web/controller/product/ProductController.java b/quoted-admin/src/main/java/com/quoted/web/controller/product/ProductController.java new file mode 100644 index 0000000..7e06005 --- /dev/null +++ b/quoted-admin/src/main/java/com/quoted/web/controller/product/ProductController.java @@ -0,0 +1,28 @@ +package com.quoted.web.controller.product; + +import com.quoted.common.core.controller.BaseController; +import com.quoted.common.core.domain.AjaxResult; +import com.quoted.common.core.domain.entity.SysMenu; +import com.quoted.system.domain.vo.ProductPriceRequestVo; +import com.quoted.system.service.IProductPriceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +/** + * 缓存监控 + *

+ * quoted + */ +@RestController +@RequestMapping("/product") +public class ProductController extends BaseController { + + @Autowired + IProductPriceService productPriceService; + + @PostMapping("/getPrice") + public AjaxResult getPrice(@RequestBody ProductPriceRequestVo product) { + return success(productPriceService.getProductPrice(product)); + } +} diff --git a/quoted-common/pom.xml b/quoted-common/pom.xml index 9619694..31eeda4 100644 --- a/quoted-common/pom.xml +++ b/quoted-common/pom.xml @@ -52,13 +52,13 @@ org.apache.commons commons-lang3 - + com.fasterxml.jackson.core jackson-databind - + com.alibaba.fastjson2 @@ -113,6 +113,7 @@ javax.servlet-api + \ No newline at end of file diff --git a/quoted-system/pom.xml b/quoted-system/pom.xml index 573b756..b84eda7 100644 --- a/quoted-system/pom.xml +++ b/quoted-system/pom.xml @@ -22,7 +22,13 @@ com.quoted quoted-common - + + + org.projectlombok + lombok + 1.18.12 + provided + \ No newline at end of file diff --git a/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductCraftItemChildrenVo.java b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductCraftItemChildrenVo.java new file mode 100644 index 0000000..573c004 --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductCraftItemChildrenVo.java @@ -0,0 +1,22 @@ +package com.quoted.system.domain.vo; + +import lombok.Data; + +@Data +public class ProductCraftItemChildrenVo { + /** + * 类型 + */ + private String type; + /** + * 值 + */ + private String value; + /** + * 内置定义参数 + */ + private Integer count; + private Double width; + private Double length; + private String size; +} diff --git a/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductCraftItemVo.java b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductCraftItemVo.java new file mode 100644 index 0000000..7253974 --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductCraftItemVo.java @@ -0,0 +1,24 @@ +package com.quoted.system.domain.vo; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProductCraftItemVo { + /** + * 工艺 + */ + private String type; + /** + * 值 + */ + private String value; + + /** + * 工艺复项 + */ + private List children = new ArrayList<>(); + +} diff --git a/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductPriceDto.java b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductPriceDto.java new file mode 100644 index 0000000..8978398 --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductPriceDto.java @@ -0,0 +1,12 @@ +package com.quoted.system.domain.vo; + +import lombok.Data; + +@Data +public class ProductPriceDto { + + private double price; + private Integer count; + private Integer number; + private String message; +} diff --git a/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductPriceRequestVo.java b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductPriceRequestVo.java new file mode 100644 index 0000000..2880e6b --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/domain/vo/ProductPriceRequestVo.java @@ -0,0 +1,40 @@ +package com.quoted.system.domain.vo; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProductPriceRequestVo { + /** + * 类型 + */ + private String types; + /** + * 材质 + */ + private String material; + /** + * 长 + */ + private Double length; + /** + * 宽 + */ + private Double width; + /** + * 数量 + */ + private Integer count; + /** + * 款数 + */ + private Integer number; + /** + * 旺旺 + */ + private String customerWw; + + private List crafts = new ArrayList<>(); +} diff --git a/quoted-system/src/main/java/com/quoted/system/service/IProductPriceService.java b/quoted-system/src/main/java/com/quoted/system/service/IProductPriceService.java new file mode 100644 index 0000000..d3f6215 --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/service/IProductPriceService.java @@ -0,0 +1,11 @@ +package com.quoted.system.service; + +import com.quoted.system.domain.vo.ProductPriceDto; +import com.quoted.system.domain.vo.ProductPriceRequestVo; + +import java.util.List; + +public interface IProductPriceService { + + public List getProductPrice(ProductPriceRequestVo product); +} diff --git a/quoted-system/src/main/java/com/quoted/system/service/impl/ISysConfigServiceImpl.java b/quoted-system/src/main/java/com/quoted/system/service/impl/ISysConfigServiceImpl.java new file mode 100644 index 0000000..1444c38 --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/service/impl/ISysConfigServiceImpl.java @@ -0,0 +1,26 @@ +package com.quoted.system.service.impl; + +import com.quoted.system.domain.vo.ProductPriceDto; +import com.quoted.system.domain.vo.ProductPriceRequestVo; +import com.quoted.system.service.IProductPriceService; +import com.quoted.system.utils.StickerUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class ISysConfigServiceImpl implements IProductPriceService { + + + @Override + public List getProductPrice(ProductPriceRequestVo product) { + List list = new ArrayList<>(); + + if ("不干胶".equals(product.getTypes())) { + list = StickerUtils.getPrice(product); + } + + return list; + } +} diff --git a/quoted-system/src/main/java/com/quoted/system/utils/PriceCommonUtils.java b/quoted-system/src/main/java/com/quoted/system/utils/PriceCommonUtils.java new file mode 100644 index 0000000..e13a91a --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/utils/PriceCommonUtils.java @@ -0,0 +1,20 @@ +package com.quoted.system.utils; + +import com.quoted.system.domain.vo.ProductCraftItemVo; +import com.quoted.system.domain.vo.ProductPriceRequestVo; + +import java.util.ArrayList; +import java.util.List; + +public class PriceCommonUtils { + + static List getCraftList(ProductPriceRequestVo requestVo) { + List craft_list = new ArrayList<>(); + if (requestVo.getCrafts().size() > 0) { + for (ProductCraftItemVo craft : requestVo.getCrafts()) { + craft_list.add(craft.getValue()); + } + } + return craft_list; + } +} diff --git a/quoted-system/src/main/java/com/quoted/system/utils/StickerUtils.java b/quoted-system/src/main/java/com/quoted/system/utils/StickerUtils.java new file mode 100644 index 0000000..501a13e --- /dev/null +++ b/quoted-system/src/main/java/com/quoted/system/utils/StickerUtils.java @@ -0,0 +1,197 @@ +package com.quoted.system.utils; + +import com.quoted.system.domain.vo.ProductPriceDto; +import com.quoted.system.domain.vo.ProductPriceRequestVo; +import org.apache.commons.math3.stat.descriptive.summary.Product; + +import java.util.ArrayList; +import java.util.List; + +public class StickerUtils { + + public static List getPrice(ProductPriceRequestVo product) { + + List list = new ArrayList<>(); + Double length = product.getLength(); + Double width = product.getWidth(); + Integer count = product.getCount(); + Integer number = product.getNumber(); + List craft_list = PriceCommonUtils.getCraftList(product); + double area = length * width / 10000; + switch (product.getMaterial()) { + case "铜板纸不干胶": + // 带1厘米的尺寸,都变成2 + if (1 < length && length < 2) { + length = Math.ceil(length); + } + if (1 < width && width < 2) { + width = Math.ceil(width); + } + // 小数部分,四舍五入 + length = (double) Math.round(length); + width = (double) Math.round(width); + // 尺寸小数部分四舍五入后的面积 + double roundArea = length * width / 10000; + // 一个名片位内做特价:75折,价格在前端写死 + double[] priceArr = null; + int[] counts = {500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000}; + double areas[] = {0.004, 0.006, 0.008, 0.01, 0.012, 0.015, 0.017, 0.018, 0.02, 0.03, 0.04, 0.06, 0.1, 0.2, 0.3}; + //覆膜是否要加价 + boolean isMo = true; + int MaxCount = 0; + if (length == 1 && width == 1) { + priceArr = new double[]{30, 35, 50, 55, 100, 180, 270, 370, 470, 570}; + } else if ((length == 2 && width == 1) || (length == 1 && width == 2)) { + priceArr = new double[]{35, 40, 55, 60, 110, 190, 280, 380, 480, 580}; + } else if ((length > 2 && length <= 5 && width == 1) || (width > 2 && width <= 5 && length == 1)) { + priceArr = new double[]{35, 40, 55, 70, 120, 210, 308, 435, 555, 683}; + } else if ((length > 1 && length <= 3 && width == 2) || (width > 1 && width <= 3 && length == 2)) { + priceArr = new double[]{35, 40, 55, 70, 120, 210, 308, 435, 555, 683}; + } else if ((length > 3 && length <= 5 && width == 2) || (width > 3 && width <= 5 && length == 2)) { + priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798}; + } else if ((length >= 3 && length <= 5 && width == 3) || (length == 3 && width <= 5 && width >= 3)) { + priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798}; + } else if (length == 4 && width == 4) { + priceArr = new double[]{35, 40, 55, 70, 120, 220, 348, 492, 642, 798}; + } else if ((length == 5 && width == 4) || (length == 4 && width == 5)) { + priceArr = new double[]{35, 40, 55, 70, 150, 240, 420, 600, 790, 980}; + } else if (((length <= 9 && width <= 5.4) || (length <= 5.4 && width <= 9))) { + counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000}; + priceArr = new double[]{60, 70, 95, 125, 175, 270, 510, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200}; + isMo = false; + } else if (area <= 0.003) { + counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000}; + priceArr = new double[]{65, 75, 100, 130, 180, 275, 515, 805, 1005, 1205, 1405, 1605, 1805, 2005, 2205}; + isMo = false; + MaxCount = 40000; + } else { + counts = new int[]{500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000}; + double basePrice = 0; + if (area <= 0.004) { + basePrice = 7.5; + } else if (area <= 0.006) { + basePrice = 6.5; + } else if (area <= 0.2) { + basePrice = 5.5; + } else if (area <= 0.3) { + basePrice = 5; + } else if (area > 0.3) { + basePrice = 4.5; + } + + ProductPriceDto pro = new ProductPriceDto(); + if (count > counts[counts.length - 1]) { + pro.setCount(count); + pro.setPrice(Math.ceil(area * count * basePrice)); + list.add(pro); + } + for (int i = 0; i < counts.length; i++) { + if (counts[i] < count || list.size() > 3) { + continue; + } + + double[] arrPrice = new double[16]; + if (counts[i] == 500) { + arrPrice = new double[]{37, 33, 30, 26, 25, 21, 19, 18, 17, 19, 17, 12.8, 12.5, 12, 11.5, 11}; + } else if (counts[i] == 1000) { + arrPrice = new double[]{21, 19, 17, 17, 15, 14, 14, 12, 12, 12.5, 13, 9, 9, 8, 8, 7.8}; + } else if (counts[i] == 2000) { + arrPrice = new double[]{14, 13, 13, 12, 11, 11, 10, 10, 9, 10, 11, 7.8, 7.5, 7.5, 7.2, 7}; + } else if (counts[i] == 3000) { + arrPrice = new double[]{12, 11, 11, 10, 9, 9.5, 9, 8, 8, 9, 10, 6.8, 6.5, 6.5, 6, 6.5}; + } else if (counts[i] == 5000) { + arrPrice = new double[]{10, 9.5, 8, 7.8, 8.5, 9, 8.3, 7, 8, 6.5, 8, 6, 6, 6, 5.5, 5}; + } else if (counts[i] == 10000) { + arrPrice = new double[]{8, 7.5, 6.5, 6.5, 7.6, 8, 7.3, 6, 7.5, 6, 6, 6, 6, 6, 5, 5}; + } else if (counts[i] == 20000) { + arrPrice = new double[]{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 30000) { + arrPrice = new double[]{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 40000) { + arrPrice = new double[]{7.6, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 50000) { + arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 60000) { + arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 70000) { + arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 80000) { + arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 90000) { + arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } else if (counts[i] == 100000) { + arrPrice = new double[]{7.5, 6.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5, 4.5}; + } + + double pirce = getPriceInArea(counts[i], area, arrPrice, areas); + pro = new ProductPriceDto(); + pro.setCount(counts[i]); + pro.setPrice(Math.ceil(pirce)); + + list.add(pro); + break; + } + } + ProductPriceDto pro = null; + + if (MaxCount == 0) { + + for (int i = 0; i < counts.length; i++) { + if (counts[i] < count || list.size() > 3) { + continue; + } + pro = new ProductPriceDto(); + pro.setCount(counts[i]); + double price = priceArr[i]; + if (craft_list.contains("覆哑膜") && isMo) { + price = Math.ceil(price * 1.2); + } + pro.setPrice(price); + list.add(pro); + } + } else { + pro = new ProductPriceDto(); + pro.setCount(count); + double price = Math.ceil((Math.ceil(count / 10000.0) - 4) * 150 + 720); + + pro.setPrice(price); + list.add(pro); + } + break; + default: + break; + } + + + return list; + } + + // 判断小尺寸是否大于大尺寸价格 + private static double getPriceInArea(int count, Double area, double[] priceArr, double[] areas) { + double lastPrice = 0, price = 0; + if (area > areas[areas.length - 1]) { + price = area * count * priceArr[areas.length - 1]; + lastPrice = area * count * priceArr[areas.length - 2]; + if (lastPrice > price) { + price = lastPrice; + } + } + for (int i = 0; i < areas.length; i++) { + if (areas[i] < area) { + continue; + } + double lastArea = 0; + if (i > 0) { + lastArea = areas[i - 1]; + lastPrice = lastArea * count * priceArr[i - 1]; + } + price = area * count * priceArr[i]; + if (lastPrice > price) { + price = lastPrice; + } + break; + } + + return price; + } +} diff --git a/quoted-ui/src/api/product/index.js b/quoted-ui/src/api/product/index.js new file mode 100644 index 0000000..81e7f96 --- /dev/null +++ b/quoted-ui/src/api/product/index.js @@ -0,0 +1,8 @@ +import request from "@/utils/request"; +export function getProductPrice(data) { + return request({ + url: "/product/getPrice", + method: "post", + data: data, + }); +} diff --git a/quoted-ui/src/components/ImagePreview/index.vue b/quoted-ui/src/components/ImagePreview/index.vue index acd05c5..956a973 100644 --- a/quoted-ui/src/components/ImagePreview/index.vue +++ b/quoted-ui/src/components/ImagePreview/index.vue @@ -1,11 +1,5 @@ @@ -22,7 +22,9 @@