This commit is contained in:
2025-04-13 01:36:45 +08:00
parent ea0c99e4d0
commit ca9eda8c57
25 changed files with 11087 additions and 336 deletions
@@ -0,0 +1,49 @@
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
/**
* 提供画布产品的定价策略。
* 该类主要用于计算画布类产品的价格列表,根据产品信息和用户角色进行价格计算。
*/
public class CanvasPricingStrategy implements PricingStrategy {
/**
* 根据产品信息和用户角色计算画布产品的价格。
*
* @param dto 产品信息对象,包含产品详细信息。
* @param role 用户角色,用于确定价格策略。
* @return 返回计算后的价格列表对象,如果未实现或无法计算则返回null。
*/
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
double price = 0.0;
double basePrice = 0.0;
List<ProductVo> resultList = new ArrayList<>();
if ("领鸿".equals(plantName)) {
double area = Math.max(count * number * width * length / 10000, 0.2);
price = new BigDecimal(basePrice * area).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
ProductVo pro = new ProductVo();
pro.setCount(count);
pro.setPrice(price);
pro.setNumber(number);
pro.setWeight(BigDecimal.valueOf(width / 100 * length / 100 * count * 0.07).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
resultList.add(pro);
return new PricingListVo(resultList);
}
}
@@ -1,2 +1,398 @@
package lingtao.net.Factory;public class CardPricingStrategy {
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
public class CardPricingStrategy implements PricingStrategy {
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
String kindValue = dto.getProTypeLabel();
if ("菜单".equals(kindValue)) {
//return new PricingListVo(100, "暂无报价"); // 返回空列表表示不适用
// String size = dto.getUi_menu_size();
// dto.setLength(Double.valueOf(size.substring(0, size.indexOf("*"))));
// if (size.contains(",")) {
// size = size.split(",")[0];
// }
// if (size.indexOf(("*"), size.indexOf("*") + 1) == -1) {
// dto.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1)));
// } else {
// dto.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1, size.indexOf(("*"), size.indexOf("*") + 1))));
// dto.setLength(Math.abs(Double.parseDouble(size.substring(size.indexOf(("*"), size.indexOf("*") + 1) + 1))));
// }
}
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
// 定义纸张尺寸(单位:毫米)
double paperLength = 280; // 纸张长度
double paperWidth = 420; // 纸张宽度
String basePrice = "0"; // 基础价格
BigDecimal price = new BigDecimal(0); // 最终价格
BigDecimal weight = BigDecimal.ZERO;
length = convertToMillimetersWithMargin(length);
width = convertToMillimetersWithMargin(width);
String material = "1";
if ("婚礼报纸".equals(kindValue)) {
material = "2";//157g铜版纸
} else if ("特种纸名片".equals(kindValue)) {
material = dto.getKindValue6();
} else if ("菜单".equals(kindValue) && "2".equals(dto.getKindValue5())) {
material = "pvc";
}
String ggSize = dto.getSize1();//刮刮膜
List<ProductVo> resultList = new ArrayList<>();
List<String> craft_list = dto.getCraft() != null ? Arrays.asList(dto.getCraft()) : new ArrayList<>();
if ("艾印".equals(plantName) && !"种子纸".equals(kindValue) && !"菜单".equals(kindValue)) {
if (craft_list.contains("烫金") || craft_list.contains("彩色印刷+烫金")) {
return new PricingListVo(100, "车间无烫金工艺"); // 返回空列表表示不适用
}
Map<String, Map<String, String>> kindValuePrice = new HashMap<>();
// 统一键的类型为字符串
kindValuePrice.put("1", createPriceMap("1", "3", "2", "3.3"));//300g铜版纸
kindValuePrice.put("2", createPriceMap("1", "1.8", "2", "2.4"));//157g铜版纸
kindValuePrice.put("皙贝", createPriceMap("1", "2.1", "2", "3.1"));//白卡
kindValuePrice.put("琮纹", createPriceMap("1", "2.5", "2", "3.7"));//刚古
kindValuePrice.put("玉蕊", createPriceMap("1", "2.7", "2", "3.8"));//蛋壳
kindValuePrice.put("睿狐", createPriceMap("1", "2.7", "2", "3.8"));//莱尼
kindValuePrice.put("溪雪", createPriceMap("1", "3.2", "2", "3.2"));//珠光
if (!kindValuePrice.containsKey(material)) {
return new PricingListVo(100, "暂无报价"); // 返回空列表表示不适用
}
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
int requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
//单双面单价不一致
Map<String, String> prices = kindValuePrice.get(material);
if ("双面印刷".equals(dto.getCraftShua())) {
basePrice = prices.get("2");
} else {
basePrice = prices.get("1");
}
price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
if ("刮刮卡".equals(kindValue)) {
Map<String, Map<String, String>> ggmPrices = new HashMap<String, Map<String, String>>();
ggmPrices.put("60*25", createPriceMap("50", "3", "100", "5"));
ggmPrices.put("48*15", createPriceMap("50", "2", "100", "3"));
ggmPrices.put("8*30", createPriceMap("50", "1", "100", "2"));
ggmPrices.put("6*22", createPriceMap("50", "0.8", "100", "1.6"));
if (!ggmPrices.containsKey(ggSize)) {
return new PricingListVo(100, "无该尺寸刮刮膜"); // 返回空列表表示不适用
}
Map<String, String> ggmPrice = ggmPrices.get(ggSize);
if (count <= 50) {
price = price.add(new BigDecimal(ggmPrice.get("50"))).setScale(2, RoundingMode.HALF_UP);
} else {
price = price.add(new BigDecimal(ggmPrice.get("100"))).setScale(2, RoundingMode.HALF_UP);
}
}
}
if ("即客".equals(plantName) && !"种子纸".equals(kindValue) && !"菜单".equals(kindValue)) {
if (craft_list.contains("烫金") || craft_list.contains("彩色印刷+烫金")) {
return new PricingListVo(100, "车间无烫金工艺"); // 返回空列表表示不适用
}
Map<String, Map<String, String>> kindValuePrice = new HashMap<>();
// 统一键的类型为字符串
kindValuePrice.put("1", createPriceMap("1", "3", "2", "3.3"));//300g铜版纸
kindValuePrice.put("2", createPriceMap("1", "1.8", "2", "2.4"));//157g铜版纸
kindValuePrice.put("萱姿", createPriceMap("1", "3", "2", "3"));//雅柔
kindValuePrice.put("芳怡", createPriceMap("1", "3", "2", "3"));//草香
if (!kindValuePrice.containsKey(material)) {
return new PricingListVo(100, "暂无报价"); // 返回空列表表示不适用
}
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
int requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
//单双面单价不一致
Map<String, String> prices = kindValuePrice.get(material);
if ("双面印刷".equals(dto.getCraftShua())) {
basePrice = prices.get("2");
} else {
basePrice = prices.get("1");
}
price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
if ("刮刮卡".equals(kindValue)) {
Map<String, Map<String, String>> ggmPrices = new HashMap<String, Map<String, String>>();
ggmPrices.put("60*25", createPriceMap("50", "3", "100", "6"));
ggmPrices.put("48*15", createPriceMap("50", "2", "100", "4"));
ggmPrices.put("8*30", createPriceMap("50", "1", "100", "2"));
ggmPrices.put("6*22", createPriceMap("50", "0.8", "100", "1.6"));
if (!ggmPrices.containsKey(ggSize)) {
return new PricingListVo(100, "无该尺寸刮刮膜"); // 返回空列表表示不适用
}
Map<String, String> ggmPrice = ggmPrices.get(ggSize);
if (count <= 50) {
price = price.add(new BigDecimal(ggmPrice.get("50"))).setScale(2, RoundingMode.HALF_UP);
} else {
price = price.add(new BigDecimal(ggmPrice.get("100"))).setScale(2, RoundingMode.HALF_UP);
}
}
}
if ("欣海信".equals(plantName) && !"种子纸".equals(kindValue)) {
paperLength = 272; // 纸张长度
paperWidth = 390; // 纸张宽度
Map<String, Map<String, String>> kindValuePrice = new HashMap<>();
// 统一键的类型为字符串
kindValuePrice.put("1", createPriceMap("1", "3", "2", "3.3"));//300g铜版纸
kindValuePrice.put("pvc", createPriceMap("1", "3", "2", "3.3"));//300g铜版纸
kindValuePrice.put("2", createPriceMap("1", "1.8", "2", "2.4"));//157g铜版纸
kindValuePrice.put("溪雪", createPriceMap("1", "4", "2", "6"));//珠光
kindValuePrice.put("琮纹", createPriceMap("1", "4", "2", "6"));//刚古
kindValuePrice.put("睿狐", createPriceMap("1", "4", "2", "6"));//莱尼
kindValuePrice.put("玉蕊", createPriceMap("1", "4", "2", "6"));//蛋壳
if (!kindValuePrice.containsKey(material)) {
return new PricingListVo(100, "暂无报价"); // 返回空列表表示不适用
}
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
int requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
//单双面单价不一致
Map<String, String> prices = kindValuePrice.get(material);
if ("双面印刷".equals(dto.getCraftShua())) {
basePrice = prices.get("2");
if (craft_list.contains("烫金") || craft_list.contains("彩色印刷+烫金")) {
basePrice = new BigDecimal(basePrice).add(new BigDecimal(prices.get("18"))).setScale(2, RoundingMode.HALF_UP).toString();
}
} else {
basePrice = prices.get("1");
if (craft_list.contains("烫金") || craft_list.contains("彩色印刷+烫金")) {
basePrice = new BigDecimal(basePrice).add(new BigDecimal(prices.get("9"))).setScale(2, RoundingMode.HALF_UP).toString();
}
}
price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
if ("刮刮卡".equals(kindValue)) {
price = price.add(new BigDecimal(0.3).multiply(new BigDecimal(count))).setScale(2, RoundingMode.HALF_UP);
}
}
if ("彩印通".equals(plantName) && !"种子纸".equals(kindValue) && !"菜单".equals(kindValue)) {
paperLength = 297;
paperWidth = 420;
if (craft_list.contains("烫金") || craft_list.contains("彩色印刷+烫金")) {
return new PricingListVo(100, "车间无烫金工艺"); // 返回空列表表示不适用
}
Map<String, Map<String, String>> kindValuePrice = new HashMap<>();
// 统一键的类型为字符串
kindValuePrice.put("1", createPriceMap("1", "2.5", "2", "3"));//300g铜版纸
kindValuePrice.put("芳怡", createPriceMap("1", "5.5", "2", "5.5"));//草香
kindValuePrice.put("溪雪", createPriceMap("1", "3.5", "2", "3.5"));//珠光
kindValuePrice.put("萱姿", createPriceMap("1", "5", "2", "5"));//雅柔
if (!kindValuePrice.containsKey(material)) {
return new PricingListVo(100, "暂无报价"); // 返回空列表表示不适用
}
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
int requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
//单双面单价不一致
Map<String, String> prices = kindValuePrice.get(material);
if ("双面印刷".equals(dto.getCraftShua())) {
basePrice = prices.get("2");
} else {
basePrice = prices.get("1");
}
if (craft_list.contains("异形")) {
basePrice = new BigDecimal(basePrice).add(new BigDecimal("0.5")).setScale(2, RoundingMode.HALF_UP).toString();
}
price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
if ("刮刮卡".equals(kindValue)) {
BigDecimal ggPrice = new BigDecimal("0.02").multiply(new BigDecimal(count));
price = price.add(ggPrice.compareTo(new BigDecimal("30")) > 0 ? ggPrice : new BigDecimal("30")).setScale(2, RoundingMode.HALF_UP);
}
}
if ("种子纸".equals(kindValue) && "鸿晟".equals(plantName)) {
if (!StringUtils.isEmpty(dto.getSwitchz3Size()) || "2".equals(dto.getZ3type())) {
count = Math.max(count, 300);
}
price = BigDecimal.valueOf((length * width * count * 70) / 1000000).setScale(2, RoundingMode.HALF_UP);//价格计算尺寸*数量*200/10000
if (craft_list.contains("编码")) {//起步价10
price = price.add(max(new BigDecimal(count * 0.4), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.contains("打孔")) {
price = price.add(max(new BigDecimal(count * 0.1), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.contains("手撕线")) {
price = price.add(max(new BigDecimal(count * 0.2), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.contains("压痕")) {
price = price.add(max(new BigDecimal(count * 0.2), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
price = price.multiply(new BigDecimal(number));//款数翻倍
price = max(price, new BigDecimal(80)).setScale(2, RoundingMode.HALF_UP);
if (!StringUtils.isEmpty(dto.getSwitchz3Size())) {
price = price.add(new BigDecimal(100)).add(new BigDecimal(count * 0.1)).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.size() > 0 && craft_list.contains("绳子")) {
price = price.add(max(new BigDecimal(0.1 * number * count), new BigDecimal(5))).setScale(2, RoundingMode.HALF_UP);
}
}
if ("种子纸".equals(kindValue) && "驰远".equals(plantName)) {
if (!StringUtils.isEmpty(dto.getSwitchz3Size()) || "2".equals(dto.getZ3type())) {
count = Math.max(count, 300);
}
basePrice = "45";
if (!StringUtils.isEmpty(dto.getSwitchz3Size())) {
basePrice = "65";
if (length > 12 || width > 12) {
return new PricingListVo(100, "纸张尺寸超出");
}
}
price = BigDecimal.valueOf((length * width * count) / 1000000).multiply(new BigDecimal(basePrice)).setScale(2, RoundingMode.HALF_UP);//价格计算尺寸*数量*200/10000
if (craft_list.contains("编码")) {//起步价10
price = price.add(max(new BigDecimal(count * 0.4), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.contains("打孔")) {
price = price.add(max(new BigDecimal(count * 0.1), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.contains("手撕线")) {
price = price.add(max(new BigDecimal(count * 0.2), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
if (craft_list.contains("压痕")) {
price = price.add(max(new BigDecimal(count * 0.2), new BigDecimal(10))).setScale(2, RoundingMode.HALF_UP);
}
price = price.multiply(new BigDecimal(number));//款数翻倍
price = max(price, new BigDecimal(80)).setScale(2, RoundingMode.HALF_UP);
if (craft_list.size() > 0 && craft_list.contains("绳子")) {
price = price.add(max(new BigDecimal(0.1 * number * count), new BigDecimal(5))).setScale(2, RoundingMode.HALF_UP);
}
}
weight = BigDecimal.valueOf(number * (length) / 1000 * (width) / 1000 * count * 0.25 * 1.15);
// 创建产品对象并添加到结果列表
ProductVo pro = new ProductVo();
pro.setPrice(price.doubleValue());
pro.setCount(count);
pro.setWeight(weight.toString());
resultList.add(pro);
return new PricingListVo(resultList);
}
public static BigDecimal max(BigDecimal a, BigDecimal b) {
if (a == null) {
return b;
}
if (b == null) {
return a;
}
return a.compareTo(b) >= 0 ? a : b;
}
/**
* 创建价格映射
*
* @param keysAndValues 键值对数组
* @return 初始化后的价格映射
*/
private Map<String, String> createPriceMap(String... keysAndValues) {
if (keysAndValues.length % 2 != 0) {
throw new IllegalArgumentException("键值对数量必须为偶数");
}
Map<String, String> priceMap = new HashMap<>();
for (int i = 0; i < keysAndValues.length; i += 2) {
priceMap.put(keysAndValues[i], keysAndValues[i + 1]);
}
return priceMap;
}
/**
* 将给定的尺寸转换为毫米,并在每边增加3毫米的边距
*
* @param size 需要转换的原始尺寸
* @return 转换后的尺寸,单位为毫米,包括边距
*/
private double convertToMillimetersWithMargin(double size) {
return size * 10 + 2 * 2; // 换成毫米,每边+2
}
/**
* 检查给定的长度和宽度是否在纸张尺寸范围内
*
* @param length 需要检查的长度
* @param width 需要检查的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 如果给定尺寸在纸张尺寸范围内,则返回true;否则返回false
*/
private boolean isWithinPaperSize(double length, double width, double paperLength, double paperWidth) {
return (length <= paperLength && width <= paperWidth) || (length <= paperWidth && width <= paperLength);
}
/**
* 计算每张纸最多可以容纳的物品数量
*
* @param length 物品的长度
* @param width 物品的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 每张纸最多可以容纳的物品数量
*/
private double calculateMaxItemsPerSheet(double length, double width, double paperLength, double paperWidth) {
return Math.max(
Math.floor(paperLength / length) * Math.floor(paperWidth / width),
Math.floor(paperLength / width) * Math.floor(paperWidth / length)
);
}
/**
* 计算完成指定数量的物品所需的纸张数量
*
* @param count 物品的总数量
* @param number 每个物品需要的数量
* @param maxItemsPerSheet 每张纸最多可以容纳的物品数量
* @return 完成指定数量的物品所需的纸张数量
*/
private int calculateRequiredSheets(int count, int number, double maxItemsPerSheet) {
return (int) Math.ceil((count * number) / maxItemsPerSheet);
}
}
@@ -0,0 +1,63 @@
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* 班级标志定价策略类
* 实现了PricingStrategy接口,用于根据用户角色计算产品价格
* 此策略专注于处理与班级标志相关的产品价格计算
*/
public class ClassFlagPricingStrategy implements PricingStrategy {
/**
* 根据用户角色计算产品价格
* 此方法旨在根据不同用户角色计算产品的价格,但具体实现尚未完成
*
* @param dto 产品信息对象,包含产品详细信息
* @param role 用户角色,用于确定价格策略
* @return 返回计算后的价格信息对象,当前实现返回null
*/
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
double price = 0.0;
double basePrice = 0.0;
List<ProductVo> resultList = new ArrayList<>();
List<String> craft_list = Optional.ofNullable(dto)
.map(Product::getCraft) // 假设 dto 是 Dto 类型
.map(Arrays::asList)
.orElseGet(ArrayList::new);
// 确保 craftList 是可变的
craft_list = new ArrayList<>(craft_list);
if ("领鸿".equals(plantName)) {
//旗帜布
basePrice = 6.5;
double area = Math.max(count * number * width * length / 10000, 0.3);
price = new BigDecimal(basePrice * area).setScale(2, RoundingMode.HALF_UP).doubleValue();
if (craft_list.contains("旗杆")) {
price = BigDecimal.valueOf(price).add(BigDecimal.valueOf(count * number * 15.0)).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
}
ProductVo pro = new ProductVo();
pro.setCount(count);
pro.setPrice(price);
pro.setNumber(number);
pro.setWeight(BigDecimal.valueOf(width / 100 * length / 100 * count * 0.07).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
resultList.add(pro);
return new PricingListVo(resultList);
}
}
@@ -0,0 +1,60 @@
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* 提供了一种特定的定价策略。
* 该策略专门用于处理挂布产品的定价计算,根据产品信息和用户角色来确定最终价格。
*/
public class DossalPricingStrategy implements PricingStrategy {
/**
* 根据产品信息和用户角色计算价格。
* 此方法旨在根据不同类型的用户(如普通用户、会员等)对Dossal产品提供定制化的定价。
*
* @param dto 产品信息对象,包含了需要计算价格的产品的所有必要信息。
* @param role 用户角色,用于确定用户类型,进而影响最终的定价结果。
* @return 返回计算后的价格列表视图对象,若不适用或未实现则返回null。
*/
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
double price = 0.0;
double basePrice = 0.0;
List<ProductVo> resultList = new ArrayList<>();
List<String> craft_list = Optional.ofNullable(dto)
.map(Product::getCraft) // 假设 dto 是 Dto 类型
.map(Arrays::asList)
.orElseGet(ArrayList::new);
// 确保 craftList 是可变的
craft_list = new ArrayList<>(craft_list);
if ("领鸿".equals(plantName)) {
if ("半透纱幔".equals(dto.getKindValue())) {
basePrice = 15.0;
double area = Math.max(count * number * width * length / 10000, 0.3);
price = new BigDecimal(basePrice * area).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
}
ProductVo pro = new ProductVo();
pro.setCount(count);
pro.setPrice(price);
pro.setNumber(number);
pro.setWeight(BigDecimal.valueOf(width / 100 * length / 100 * count * 0.07).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
resultList.add(pro);
return new PricingListVo(resultList);
}
}
@@ -0,0 +1,61 @@
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
public class HandFlagPricingStrategy implements PricingStrategy {
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
double price = 0.0;
double basePrice = 0.0;
List<ProductVo> resultList = new ArrayList<>();
if ("领鸿".equals(plantName)) {
//春亚布
if ("1".equals(dto.getKindValue())) {
// 合并逻辑,减少嵌套层级
if (width == 17 && length <= 20) {
basePrice = 2.5;
} else if (width == 24 && length <= 70) {
basePrice = 3;
} else if (length > 70) {
basePrice = 4;
}
}
//贡缎布
if ("2".equals(dto.getKindValue())) {
if (width == 17 && length <= 20) {
basePrice = 4;
} else if (width == 24 && length <= 70) {
basePrice = 5;
} else if (length > 70) {
basePrice = 6;
}
}
if (basePrice == 0) {
return new PricingListVo(100, "暂无报价。");
}
price = new BigDecimal(basePrice * count * number / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
ProductVo pro = new ProductVo();
pro.setCount(count);
pro.setPrice(price);
pro.setNumber(number);
pro.setWeight(BigDecimal.valueOf(width / 100 * length / 100 * count * 0.07).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
resultList.add(pro);
return new PricingListVo(resultList);
}
}
@@ -1,2 +1,231 @@
package lingtao.net.Factory;public class MetalTargetStrategy {
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.util.PriceUtils;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public class MetalTargetStrategy implements PricingStrategy {
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
List<ProductVo> resultList = new ArrayList<>();
// 定义纸张尺寸(单位:毫米)
double paperLength = 295; // 纸张长度
double paperWidth = 195; // 纸张宽度
double basePrice = 0; // 基础价格
double minPrice = 0; // 起步价
double price = 0; // 最终价格
double colorPrice = 0; // 颜色附加费
double moreColorPrice = 0; // 多颜色附加费
int requiredSheets = 0;
BigDecimal weight = BigDecimal.ZERO;
// 转换尺寸为毫米并增加边距
length = convertToMillimetersWithMargin(length);
width = convertToMillimetersWithMargin(width);
if ("金大".equals(plantName) || "鑫灿".equals(plantName)) {
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
// 计算颜色附加费
if (!"金色".equals(dto.getTcolor()) && !"银色".equals(dto.getTcolor()) && !"玫瑰金色".equals(dto.getTcolor())) {
colorPrice = 1;
}
if ("金大".equals(plantName)) {
// 设置起步价
minPrice = 45;
if ("双色".equals(dto.getCraftMo())) {
minPrice = 70;
moreColorPrice = 10;
}
if ("彩色(三色)".equals(dto.getCraftMo())) {
minPrice = 105;
moreColorPrice = 20;
}
colorPrice += moreColorPrice;
// 根据数量计算基础价格
if (requiredSheets <= 2) {
price = minPrice + colorPrice;
} else if (requiredSheets <= 9) {
price = minPrice + (requiredSheets - 2) * (12 + colorPrice);
} else if (requiredSheets <= 19) {
price = Math.ceil((13 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 29) {
price = Math.ceil((12 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 39) {
price = Math.ceil((11 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 49) {
price = Math.ceil((10 + colorPrice) * requiredSheets);
} else {
price = Math.ceil((9 + colorPrice) * requiredSheets);
}
}
if ("鑫灿".equals(plantName)) {
// 设置起步价
minPrice = 45;
if ("双色".equals(dto.getCraftMo())) {
minPrice = 55;
moreColorPrice = 10;
}
if ("彩色(三色)".equals(dto.getCraftMo())) {
minPrice = 105;
moreColorPrice = 20;
}
colorPrice += moreColorPrice;
// 根据数量计算基础价格
if (requiredSheets <= 2) {
price = minPrice + colorPrice;
} else if (requiredSheets <= 9) {
price = minPrice + (requiredSheets - 2) * (10 + colorPrice);
} else if (requiredSheets <= 19) {
price = Math.ceil((13 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 29) {
price = Math.ceil((12 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 39) {
price = Math.ceil((11 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 49) {
price = Math.ceil((10 + colorPrice) * requiredSheets);
} else if (requiredSheets <= 100) {
price = Math.ceil((9 + colorPrice) * requiredSheets);
} else {
price = Math.ceil((8 + colorPrice) * requiredSheets);
}
}
}
if ("紫瑶".equals(plantName)) {
paperLength = 170;
paperWidth = 300;
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
// 计算颜色附加费
if (!"银色".equals(dto.getTcolor())) {
colorPrice = 1;
}
// 设置起步价
minPrice = 40;
if ("单色".equals(dto.getCraftMo())) {
if (requiredSheets == 1) {
price = colorPrice == 1 ? 45 : 40;
} else if (requiredSheets == 2) {
price = colorPrice == 1 ? 55 : 50;
} else if (requiredSheets == 3) {
price = colorPrice == 1 ? 65 : 55;
} else if (requiredSheets == 4) {
price = colorPrice == 1 ? 70 : 60;
} else if (requiredSheets == 5) {
price = colorPrice == 1 ? 75 : 65;
} else if (requiredSheets == 6) {
price = colorPrice == 1 ? 80 : 70;
} else {
price = colorPrice == 1 ? 80 + (requiredSheets - 6) * 9 : 70 + (requiredSheets - 6) * 8;
}
}
if ("双色".equals(dto.getCraftMo())) {
minPrice = 60;
moreColorPrice = 30;
}
if ("彩色(三色)".equals(dto.getCraftMo())) {
minPrice = 70;
moreColorPrice = 40;
}
if (price == 0) {
price = Math.ceil(minPrice + moreColorPrice * (requiredSheets - 1));
}
}
// 创建产品对象并添加到结果列表
ProductVo pro = new ProductVo();
pro.setPrice(price);
pro.setCount(count);
pro.setWeight(BigDecimal.valueOf(requiredSheets / 30).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
resultList.add(pro);
return new PricingListVo(resultList);
}
/**
* 将给定的尺寸转换为毫米,并在每边增加3毫米的边距
*
* @param size 需要转换的原始尺寸
* @return 转换后的尺寸,单位为毫米,包括边距
*/
private double convertToMillimetersWithMargin(double size) {
return size * 10 + 2 * 1.5; // 换成毫米,每边+3
}
/**
* 检查给定的长度和宽度是否在纸张尺寸范围内
*
* @param length 需要检查的长度
* @param width 需要检查的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 如果给定尺寸在纸张尺寸范围内,则返回true;否则返回false
*/
private boolean isWithinPaperSize(double length, double width, double paperLength, double paperWidth) {
return (length <= paperLength && width <= paperWidth) || (length <= paperWidth && width <= paperLength);
}
/**
* 计算每张纸最多可以容纳的物品数量
*
* @param length 物品的长度
* @param width 物品的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 每张纸最多可以容纳的物品数量
*/
private double calculateMaxItemsPerSheet(double length, double width, double paperLength, double paperWidth) {
return Math.max(
Math.floor(paperLength / length) * Math.floor(paperWidth / width),
Math.floor(paperLength / width) * Math.floor(paperWidth / length)
);
}
/**
* 计算完成指定数量的物品所需的纸张数量
*
* @param count 物品的总数量
* @param number 每个物品需要的数量
* @param maxItemsPerSheet 每张纸最多可以容纳的物品数量
* @return 完成指定数量的物品所需的纸张数量
*/
private int calculateRequiredSheets(int count, int number, double maxItemsPerSheet) {
return (int) Math.ceil((count * number) / maxItemsPerSheet);
}
}
@@ -0,0 +1,200 @@
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
public class PosterPricingStrategy implements PricingStrategy {
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
String kindValue = dto.getKindValue();
String kinde2Value = dto.getKind2Value();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
List<ProductVo> resultList = new ArrayList<>();
double price = 0;
double basePrice = 0;
if ("佳达".equals(plantName)) {
//制度牌
if ("0".equals(kindValue)) {
//室内写真裱冷板
if ("0".equals(kinde2Value)) {
basePrice = 20;
}
//室内写真裱冷板装小C边(小金边/银边)
if ("3".equals(kinde2Value)) {
basePrice = 11;
}
//户外写真裱冷板装小C边(小金边/银边)
if ("8".equals(kinde2Value)) {
basePrice = 11;
}
}
//室内写真
if ("1".equals(kindValue)) {
//pp纸(室内)
if ("3".equals(kinde2Value)) {
basePrice = 12;
}
//直喷PVC
if ("5".equals(kinde2Value)) {
basePrice = 11;
}
//软膜
if ("14".equals(kinde2Value)) {
basePrice = 15;
}
//地贴(复防滑膜)
if ("15".equals(kinde2Value)) {
basePrice = 25;
}
}
//户外写真
if ("2".equals(kindValue)) {
//户外写真白胶(国产)
if ("0".equals(kinde2Value)) {
basePrice = 11;
}
//户外写真黑胶(国产)
if ("1".equals(kinde2Value)) {
basePrice = 11;
}
//户外写真可移白胶、黑胶
if ("2".equals(kinde2Value)) {
basePrice = 12;
}
//车贴(白胶)
if ("6".equals(kinde2Value)) {
basePrice = 22;
}
//摆摊软膜灯箱
if ("24".equals(kinde2Value)) {
basePrice = 190;
}
}
//布
if ("3".equals(kindValue)) {
//黑底布
if ("2".equals(kinde2Value)) {
basePrice = 8;
}
//写真布
if ("6".equals(kinde2Value)) {
basePrice = 0;
}
//油画布
if ("8".equals(kinde2Value)) {
basePrice = 22;
}
//550灯布
if ("11".equals(kinde2Value)) {
basePrice = 6.5;
}
//550黑底灯布
if ("13".equals(kinde2Value)) {
basePrice = 8;
}
}
//展架
if ("4".equals(kindValue)) {
//直喷PVC装美式展架180*80cm
if ("0".equals(kinde2Value)) {
basePrice = 28;
}
//直喷PVC装美式展架160*60cm
if ("1".equals(kinde2Value)) {
basePrice = 21;
}
//PP纸装美式展架180*80cm
if ("2".equals(kinde2Value)) {
basePrice = 28;
}
//PP纸装美式展架160*60cm
if ("3".equals(kinde2Value)) {
basePrice = 21;
}
//直喷PVC装门型展架180*80cm
if ("4".equals(kinde2Value)) {
basePrice = 40.5;
}
//PP纸装门型展架180*80cm
if ("6".equals(kinde2Value)) {
basePrice = 40.5;
}
//PP纸装门型展架160*60cm
if ("7".equals(kinde2Value)) {
basePrice = 37;
}
//X展架180*80cm(不含画面)
if ("8".equals(kinde2Value)) {
basePrice = 12;
}
//X展架160*60cm(不含画面)
if ("9".equals(kinde2Value)) {
basePrice = 10;
}
//门型展架180*80cm(不含画面)
if ("10".equals(kinde2Value)) {
basePrice = 30;
}
//门型展架160*60cm(不含画面)
if ("11".equals(kinde2Value)) {
basePrice = 27;
}
//直喷pvc铝合金易拉宝202*78cm
if ("12".equals(kinde2Value)) {
basePrice = 40;
}
//直喷pvc塑钢易拉宝200*80cm
if ("13".equals(kinde2Value)) {
basePrice = 47;
}
}
if (basePrice == 0) {
return new PricingListVo(100, "暂无报价。");
}
if (!"4".equals(kindValue)) {
price = new BigDecimal(basePrice * count * number * width * length / 10000).setScale(2, RoundingMode.HALF_UP).doubleValue();
} else {
price = new BigDecimal(basePrice * count * number).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
}
if ("领鸿".equals(plantName)) {
//旗帜布
if ("6".equals(dto.getKindValue())) {
basePrice = 6.5;
}
//贡缎布
if ("7".equals(dto.getKindValue())) {
basePrice = 15;
}
if (basePrice == 0) {
return new PricingListVo(100, "暂无报价。");
}
double area = Math.max(count * number * width * length / 10000, 0.3);
price = new BigDecimal(basePrice * area).setScale(2, RoundingMode.HALF_UP).doubleValue();
//旗杆
if (dto.getYaheng() != null && dto.getYaheng() > 0) {
price = BigDecimal.valueOf(price).add(BigDecimal.valueOf(dto.getYaheng() * 15.0)).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
}
ProductVo pro = new ProductVo();
pro.setCount(count);
pro.setPrice(price);
pro.setNumber(number);
resultList.add(pro);
return new PricingListVo(resultList);
}
}
@@ -1,2 +1,10 @@
package lingtao.net.Factory;public interface PricingStrategy {
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import java.util.List;
public interface PricingStrategy {
PricingListVo calculatePrice(Product dto, String role);
}
@@ -1,2 +1,31 @@
package lingtao.net.Factory;public class PricingStrategyFactory {
package lingtao.net.Factory;
public class PricingStrategyFactory {
public static PricingStrategy getStrategy(String proType) {
switch (proType) {
case "0":
return new StickerPricingStrategy();
// 其他产品类型对应的策略
case "金属标":
return new MetalTargetStrategy();
// 其他产品类型对应的策略
case "卡片少数量":
return new CardPricingStrategy();
case "17":
return new PosterPricingStrategy();
case "帆布":
return new CanvasPricingStrategy();
case "班旗":
return new ClassFlagPricingStrategy();
case "挂布":
return new DossalPricingStrategy();
case "手拉旗":
return new HandFlagPricingStrategy();
// 其他产品类型对应的策略
default:
return null;
}
}
}
@@ -0,0 +1,246 @@
package lingtao.net.Factory;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 提供不干胶产品的定价策略。
* 该类主要用于处理贴纸产品价格的计算,根据不同的用户角色提供相应的价格策略。
*/
public class StickerPricingStrategy implements PricingStrategy {
/**
* 根据用户角色计算产品价格。
* 此方法旨在根据不同用户的角色对产品进行定价,但当前实现尚未完成。
*
* @param dto 产品信息的传输对象,包含需要计算价格的产品数据。
* @param role 用户角色,用于确定适用的定价策略。
* @return 返回经过计算价格更新后的产品列表,当前实现返回null。
*/
@Override
public PricingListVo calculatePrice(Product dto, String role) {
String plantName = dto.getPlantName();
double width = dto.getWidth();
double length = dto.getLength();
int count = dto.getCount();
int number = dto.getNumber();
// 定义纸张尺寸(单位:毫米)
double paperLength = 280; // 纸张长度
double paperWidth = 420; // 纸张宽度
String basePrice = "0"; // 基础价格
BigDecimal price = new BigDecimal(0); // 最终价格
length = convertToMillimetersWithMargin(length);
width = convertToMillimetersWithMargin(width);
int requiredSheets = 0;
List<ProductVo> resultList = new ArrayList<>();
if ("艾印".equals(plantName) || "即客".equals(plantName)) {
Map<String, String> kindValuePrice = new HashMap<String, String>() {{
put("0", "2.3"); //铜版纸不干胶
put("1", "2.9"); //pvc不干胶
put("2", "2.9"); //透明不干胶
put("3", "2.3"); //牛皮纸
put("5", "3.2"); //哑金不干胶
put("6", "3.2"); //哑银不干胶
put("7", "2.7"); //书写纸不干胶
put("亮金", "3.2"); //
put("亮银", "3.2"); //
put("珠光冰白纸", "3.2"); //
put("美纹纸", "2.8"); //
put("拉丝金", "3.3"); //
put("拉丝银", "3.3"); //
put("易碎纸不干胶", "3.7"); //
put("PP合成纸", "2.9"); //
put("刚古水纹超白", "2.8"); //
}};
if ("即客".equals(plantName)) {
kindValuePrice.put("树纹纸", "3.3");
kindValuePrice.put("银平光", "3.6");
kindValuePrice.put("白散金", "2.8");
kindValuePrice.put("红洒金", "2.8");
kindValuePrice.put("布纹纸超白", "5");
kindValuePrice.put("草香纸", "3");
}
if (!kindValuePrice.containsKey(dto.getKindValue())) {
return new PricingListVo(100, "暂不支持该产品");
}
basePrice = kindValuePrice.get(dto.getKindValue());
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "超出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
}
if ("欣海信".equals(dto.getPlantName())) {
paperLength = 390; // 纸张长度
paperWidth = 272; // 纸张宽度
// 检查是否超出纸张尺寸限制
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "超出纸张尺寸限制"); // 返回空列表表示不适用
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
BigDecimal paperCount = new BigDecimal(requiredSheets);
BigDecimal yinbai = new BigDecimal("0");
//铜版纸
if ("0".equals(dto.getKindValue())) {
basePrice = "2.5";
} else {
basePrice = "4";
}
if ("印白墨".equals(dto.getYinbai())) {
yinbai = "0".equals(dto.getKindValue()) ? new BigDecimal("20") : new BigDecimal("22");
}
price = new BigDecimal(basePrice).multiply(paperCount).setScale(2, RoundingMode.HALF_UP);
price = price.add(yinbai.multiply(paperCount)).setScale(2, RoundingMode.HALF_UP);
if (dto.getN_mq_num() > 0) {
price = price.add(paperCount).setScale(2, RoundingMode.HALF_UP);
}
}
if ("彩印通".equals(dto.getPlantName())) {
Map<String, String> kindValuePrice = new HashMap<String, String>() {{
put("0", "2"); //铜版纸不干胶
put("1", "3.2"); //pvc不干胶
put("2", "3.2"); //透明不干胶
put("3", "2.5"); //牛皮纸
put("5", "3.5"); //哑金不干胶
put("6", "3.5"); //哑银不干胶
put("7", "3"); //书写纸不干胶
put("亮金", "3.5"); //
put("亮银", "4"); //
put("珠光冰白纸", "3.5"); //
put("美纹纸", "2.5"); //
put("红洒金", "3.5"); //
put("布纹纸超白", "3.5"); //
put("刚古水纹超白", "3.5"); //
put("银平光", "4"); //
put("拉丝金", "3.5"); //
put("拉丝银", "3.5"); //
put("易碎纸不干胶", "4"); //
put("PP合成纸", "3.2"); //
put("草香纸", "3.5"); //
put("树纹纸", "3.5"); //
put("白散金", "3.5"); //
put("飘金超白不干胶", "3.5"); //
put("美纹纸散金", "3.5"); //
}};
if ("0".equals(dto.getKindValue())) {
paperLength = 450; // 纸张长度
paperWidth = 320; // 纸张宽度
} else {
paperLength = 420; // 纸张长度
paperWidth = 297; // 纸张宽度
}
if (!kindValuePrice.containsKey(dto.getKindValue())) {
return new PricingListVo(100, "暂无报价"); // 返回空列表表示不适用
}
if (!isWithinPaperSize(length, width, paperLength, paperWidth)) {
return new PricingListVo(100, "出纸张尺寸限制"); // 返回空列表表示不适用
}
basePrice = kindValuePrice.get(dto.getKindValue());
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
BigDecimal yinbai = new BigDecimal("0");
if ("印白墨".equals(dto.getYinbai())) {
yinbai = "2".equals(dto.getKindValue()) ? new BigDecimal("6.2") : new BigDecimal("3");
}
BigDecimal paperCount = new BigDecimal(requiredSheets);
price = new BigDecimal(basePrice).multiply(paperCount).setScale(2, RoundingMode.HALF_UP);
price = price.add(yinbai.multiply(paperCount)).setScale(2, RoundingMode.HALF_UP);
}
ProductVo pro = new ProductVo();
pro.setPrice(price.doubleValue());
pro.setCount(count);
// if ("1".equals(dto.getKindValue())) {
// pro.setWeight(BigDecimal.valueOf(number * length / 100 * width / 100 * requiredSheets * 0.3).setScale(2, RoundingMode.HALF_UP).toString());
// } else {
// pro.setWeight(BigDecimal.valueOf(number * length / 100 * width / 100 * requiredSheets * 0.24).setScale(2, RoundingMode.HALF_UP).toString());
// }
pro.setWeight(BigDecimal.valueOf(number * length / 1000 * width / 1000 * count * 0.21 * 1.16).setScale(2, RoundingMode.HALF_UP).toString());
// 创建产品对象并添加到结果列表
resultList.add(pro);
return new PricingListVo(resultList);
}
/**
* 将给定的尺寸转换为毫米,并在每边增加3毫米的边距
*
* @param size 需要转换的原始尺寸
* @return 转换后的尺寸,单位为毫米,包括边距
*/
private double convertToMillimetersWithMargin(double size) {
return size * 10 + 2 * 2; // 换成毫米,每边+2
}
/**
* 检查给定的长度和宽度是否在纸张尺寸范围内
*
* @param length 需要检查的长度
* @param width 需要检查的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 如果给定尺寸在纸张尺寸范围内,则返回true;否则返回false
*/
private boolean isWithinPaperSize(double length, double width, double paperLength, double paperWidth) {
return (length <= paperLength && width <= paperWidth) || (length <= paperWidth && width <= paperLength);
}
/**
* 计算每张纸最多可以容纳的物品数量
*
* @param length 物品的长度
* @param width 物品的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 每张纸最多可以容纳的物品数量
*/
private double calculateMaxItemsPerSheet(double length, double width, double paperLength, double paperWidth) {
return Math.max(
Math.floor(paperLength / length) * Math.floor(paperWidth / width),
Math.floor(paperLength / width) * Math.floor(paperWidth / length)
);
}
/**
* 计算完成指定数量的物品所需的纸张数量
*
* @param count 物品的总数量
* @param number 每个物品需要的数量
* @param maxItemsPerSheet 每张纸最多可以容纳的物品数量
* @return 完成指定数量的物品所需的纸张数量
*/
private int calculateRequiredSheets(int count, int number, double maxItemsPerSheet) {
return (int) Math.ceil((count * number) / maxItemsPerSheet);
}
}
@@ -54,6 +54,8 @@ public class Product {
private String kind2Value;
private String kindValue2;
private String kindValue6;
private String kindValue5;
private String kind2Label;
@@ -170,4 +172,8 @@ public class Product {
private String shen_color;
private String[] jtcolor;//击凸颜色
private String tcolor;//烫金颜色
private String plantName;
private String ui_menu_size;
private String address;
}
@@ -2,12 +2,17 @@ package lingtao.net.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lingtao.net.Factory.PricingStrategy;
import lingtao.net.Factory.PricingStrategyFactory;
import lingtao.net.bean.Msg;
import lingtao.net.bean.Product;
import lingtao.net.bean.SysDictSearchPro;
import lingtao.net.bean.SysUser;
import lingtao.net.service.PriceService;
import lingtao.net.service.ProductService;
import lingtao.net.service.QuoteLogService;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -18,9 +23,12 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@RestController
public class ProductController {
@@ -31,6 +39,9 @@ public class ProductController {
@Autowired
private QuoteLogService quoteLogService;
@Autowired
private PriceService priceService;
// 价格跳转页面
@RequestMapping("/product/index")
public void index(HttpServletRequest request, HttpServletResponse response) throws Exception {
@@ -52,8 +63,6 @@ public class ProductController {
/**
* 修改价格
*
* @param customerData
*/
@RequestMapping("/updatePriceById")
public Msg updatePriceById(@RequestParam(value = "proId") int proId, @RequestParam(value = "field") String field,
@@ -70,10 +79,10 @@ public class ProductController {
@RequestMapping("/getThanSum")
public Msg thanPrice(Product product, HttpServletRequest request) {
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
/*if (StringUtils.isEmpty(product.getWangwang().trim()) && user.getRole().contains("999")
&& !user.getRole().contains("1049")) {
return Msg.fail("请填写客户旺旺!");
}*/
/*if (StringUtils.isEmpty(product.getWangwang().trim()) && user.getRole().contains("999")
&& !user.getRole().contains("1049")) {
return Msg.fail("请填写客户旺旺!");
}*/
if ("帆布".equals(product.getProTypeValue())) {
if ("套餐".equals(product.getStickerKind())) {
product.setCount(1);
@@ -113,9 +122,9 @@ public class ProductController {
} else {
if (product.getNumber() != null && product.getNumber() > 1) {
// if ("专版打印".equals(product.getStickerKind()) || "少数量".equals(product.getCouponKind())) {
if (request.getParameter("desType") != null && !"".equals(request.getParameter("desType"))) {
product.setP(Integer.valueOf(request.getParameter("desType")));
}
if (request.getParameter("desType") != null && !"".equals(request.getParameter("desType"))) {
product.setP(Integer.valueOf(request.getParameter("desType")));
}
// }
}
}
@@ -127,19 +136,19 @@ public class ProductController {
//银瑾单独报价
if (user.getRole().indexOf("1010") > -1) {
double otherPrice = 0;
/*if("5".equals(product.getKind())) {
for (Product list : proList) {
list.setPrice(list.getPrice() + 30);
}
}else if("帆布".equals(product.getProTypeValue())) {
for (Product list : proList) {
otherPrice = Math.floor(list.getPrice() + 5);
list.setPrice(otherPrice > 40 ? otherPrice : 40);
if(product.getNumber() > 1) {
list.setPrice(Math.floor(list.getPrice() + 2 * (product.getNumber()-1)));
}
}
}else */
/*if("5".equals(product.getKind())) {
for (Product list : proList) {
list.setPrice(list.getPrice() + 30);
}
}else if("帆布".equals(product.getProTypeValue())) {
for (Product list : proList) {
otherPrice = Math.floor(list.getPrice() + 5);
list.setPrice(otherPrice > 40 ? otherPrice : 40);
if(product.getNumber() > 1) {
list.setPrice(Math.floor(list.getPrice() + 2 * (product.getNumber()-1)));
}
}
}else */
if ("22".equals(product.getProTypeValue())) {
for (Product list : proList) {
list.setPrice(list.getPrice() + 50);
@@ -208,8 +217,8 @@ public class ProductController {
if (StringUtils.isEmpty(product.getAotu())) {
return Msg.fail("哑金不干胶该尺寸无法制作,最大做到 39*27 cm");
} /*else {
return Msg.fail("哑金不干胶带凹凸工艺该尺寸无法制作 (1*1CM至11*11CM;10*6至12*8CM;20*4以内)");
}*/
return Msg.fail("哑金不干胶带凹凸工艺该尺寸无法制作 (1*1CM至11*11CM;10*6至12*8CM;20*4以内)");
}*/
} else if ("易碎纸不干胶".equals(product.getKindValue()) && proList == null) {
return Msg.fail("易碎纸不干胶该尺寸无法制作,最大做到 42*38 cm");
} else if (("拉丝金".equals(product.getKindValue()) || "拉丝银".equals(product.getKindValue()))
@@ -248,115 +257,175 @@ public class ProductController {
}
if (product.getKindValue() != null) {//判断是否大店报不干胶价格
/*if(product.getKindValue().equals("0")) {
double width = 0, length = 0;
if(product.getWidth() != null) {
width = product.getWidth();
}
if(product.getLength() != null) {
length = product.getLength();
}
String role = user.getRole();
if(length < width) {
length = product.getWidth();
width = product.getLength();
}
if(width == 0 && length == 0) {
}else if((length <= 5 && width <= 4)) {
String tang = product.getCraftTang();
if(AStickersPrice.f_getRole(role) == 1 && tang == null) {
List<Product> price = new ArrayList<Product>();
if(length == 1 && width == 1) {
int priceArr[] = {30, 35, 50, 55, 65, 90, 135, 185, 235, 285};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 2 && width == 1) {
int priceArr[] = {35, 40, 55, 60, 70, 95, 140, 190, 240, 290};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 3 && width == 1) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 1) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 1) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 2 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 3 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 3 && width == 3) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 3) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 3) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 4) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 4) {
int priceArr[] = {35, 40, 55, 70, 150, 240, 420, 600, 790, 980};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}
if (proList.size() >= 4) {
proList = proList.subList(0, 4);
}
for(int i = 0; i < price.size(); i ++){
if(product.getNumber() > 1) {
proList.get(i).setPrice(price.get(i).getPrice() * product.getNumber());
}else {
proList.get(i).setPrice(price.get(i).getPrice());
}
}
}
}
}elseif(user.getRole().indexOf("1033") > 0 && product.getProTypeValue().equals("17")) {
if(product.getKindValue().equals("6")) {
for (Product products : proList) {
products.setPrice(Math.floor(products.getPrice() * 0.88));
}
}
} */
/*if(product.getKindValue().equals("0")) {
double width = 0, length = 0;
if(product.getWidth() != null) {
width = product.getWidth();
}
if(product.getLength() != null) {
length = product.getLength();
}
String role = user.getRole();
if(length < width) {
length = product.getWidth();
width = product.getLength();
}
if(width == 0 && length == 0) {
}else if((length <= 5 && width <= 4)) {
String tang = product.getCraftTang();
if(AStickersPrice.f_getRole(role) == 1 && tang == null) {
List<Product> price = new ArrayList<Product>();
if(length == 1 && width == 1) {
int priceArr[] = {30, 35, 50, 55, 65, 90, 135, 185, 235, 285};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 2 && width == 1) {
int priceArr[] = {35, 40, 55, 60, 70, 95, 140, 190, 240, 290};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 3 && width == 1) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 1) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 1) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 2 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 3 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 80, 125, 205, 290, 370, 455};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 2) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 3 && width == 3) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 3) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 3) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 4 && width == 4) {
int priceArr[] = {35, 40, 55, 70, 110, 170, 290, 410, 535, 665};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}else if(length == 5 && width == 4) {
int priceArr[] = {35, 40, 55, 70, 150, 240, 420, 600, 790, 980};
price = f_getPrice( priceArr, product.getCount(), product.getCraftMo());
}
if (proList.size() >= 4) {
proList = proList.subList(0, 4);
}
for(int i = 0; i < price.size(); i ++){
if(product.getNumber() > 1) {
proList.get(i).setPrice(price.get(i).getPrice() * product.getNumber());
}else {
proList.get(i).setPrice(price.get(i).getPrice());
}
}
}
}
}elseif(user.getRole().indexOf("1033") > 0 && product.getProTypeValue().equals("17")) {
if(product.getKindValue().equals("6")) {
for (Product products : proList) {
products.setPrice(Math.floor(products.getPrice() * 0.88));
}
}
} */
}
return Msg.success().add("proList", proList);
}
/*public List<Product> f_getPrice( int priceArr[], int count, String craftMo) {
List<Product> list = new ArrayList<Product>();
Product p = new Product();
int countArr[] = { 500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000 };
for(int i = 0; i < countArr.length; i++) {
if(countArr[i] < count || list.size() > 3) {
continue;
}
p = new Product();
p.setCount(countArr[i]);
if(craftMo.equals("覆哑膜")) {
p.setPrice(Math.ceil(Double.valueOf(priceArr[i]) * 1.2));
}else {
p.setPrice(Double.valueOf(priceArr[i]));
}
list.add(p);
}
return list;
}*/
@RequestMapping("/getProductPrice")
public Msg getProductPrice(Product product, HttpServletRequest request) {
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
if (StringUtils.isEmpty(product.getCount()) || product.getCount() <= 0) {
return Msg.fail("数量必须大于0");
}
String size = product.getSize();
if (("17".equals(product.getProTypeValue()) && "6".equals(product.getKindValue())) || "手拉旗".equals(product.getProTypeValue())) {
if (!StringUtils.isEmpty(size)) {
String sizeList[] = size.split(",");
size = sizeList[0];
}
product.setLength(Double.valueOf(size));
} else if (!StringUtils.isEmpty(size)) {
product.setLength(Double.valueOf(size.substring(0, size.indexOf("*"))));
String other_size = size;
if (size.contains(",")) {
size = size.split(",")[0];
}
if (size.indexOf(("*"), size.indexOf("*") + 1) == -1) {
product.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1)));
} else {
product.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1, size.indexOf(("*"), size.indexOf("*") + 1))));
product.setLength(Math.abs(Double.parseDouble(size.substring(size.indexOf(("*"), size.indexOf("*") + 1) + 1))));
}
}
product.setRole(user.getRole());
PricingStrategy pricingStrategy = PricingStrategyFactory.getStrategy(product.getProTypeValue());
PricingListVo listvo = pricingStrategy.calculatePrice(product, user.getRole());
if (listvo.getCode() != 0) {
return Msg.fail(listvo.getMsg());
}
List<ProductVo> proList = listvo.getProList();
if (proList == null || proList.size() == 0 || proList.get(0).getPrice() == 0) {
return Msg.fail("暂无报价");
}
PricingListVo result = priceService.getAddressPrice(product, proList);
if (result.getCode() != 0) {
return Msg.fail(result.getMsg());
}
proList = result.getProList();
String log = quoteLogService.log(product, request, new ArrayList<>());
if ("登陆失效".equals(log)) {
return Msg.fail("登录信息失效~请刷新页面!");
}
// 把角色存入,前台判断,区分不同价格
for (ProductVo p : proList) {
p.setRole(user.getRole());
}
return Msg.success().add("proList", proList);
}
/*public List<Product> f_getPrice( int priceArr[], int count, String craftMo) {
List<Product> list = new ArrayList<Product>();
Product p = new Product();
int countArr[] = { 500, 1000, 2000, 3000, 5000, 10000, 20000, 30000, 40000, 50000 };
for(int i = 0; i < countArr.length; i++) {
if(countArr[i] < count || list.size() > 3) {
continue;
}
p = new Product();
p.setCount(countArr[i]);
if(craftMo.equals("覆哑膜")) {
p.setPrice(Math.ceil(Double.valueOf(priceArr[i]) * 1.2));
}else {
p.setPrice(Double.valueOf(priceArr[i]));
}
list.add(p);
}
return list;
}*/
/**
* 根据产品种类获取材质
@@ -0,0 +1,575 @@
package lingtao.net.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lingtao.net.bean.Product;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import lingtao.net.vo.ProvidePrice;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Service
public class PriceService {
public PricingListVo getAddressPrice(Product product, List<ProductVo> proList) {
Province province = parseAddress(product.getAddress());
if (province == null) {
return new PricingListVo(100, "无效地址。");
}
String plantName = product.getPlantName();
if ("领鸿".equals(plantName) || "欣海信".equals(plantName)) {
List<ProvincePriceVo> lyst = JSONObject.parseArray(ly_st, ProvincePriceVo.class);
List<ProvincePriceVo> lyyt = JSONObject.parseArray(ly_yt, ProvincePriceVo.class);
List<BigDecimal> prices = getProvincePrice(lyst, province.province);
if (prices != null && prices.size() > 0) {
double firstPrice = StringtoDouble(prices.get(4).toString());
double secPrice = StringtoDouble(prices.get(5).toString());
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
if (weight <= 0.5) {
finalePrice = StringtoDouble(prices.get(0).toString());
} else if (weight <= 1) {
finalePrice = StringtoDouble(prices.get(1).toString());
} else if (weight <= 2) {
finalePrice = StringtoDouble(prices.get(2).toString());
} else if (weight <= 3) {
finalePrice = StringtoDouble(prices.get(3).toString());
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
productVo.getProvidePrices().add(new ProvidePrice("申通快递", finalePrice));
}
}
prices = getProvincePrice(lyyt, province.province);
if (prices != null && prices.size() > 0) {
double firstPrice = StringtoDouble(prices.get(5).toString());
double secPrice = StringtoDouble(prices.get(6).toString());
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
if (weight <= 0.3 && StringtoDouble(prices.get(0).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(0).toString());
} else if (weight <= 0.5 && StringtoDouble(prices.get(1).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(1).toString());
} else if (weight <= 1 && StringtoDouble(prices.get(2).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(2).toString());
} else if (weight <= 2 && StringtoDouble(prices.get(3).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(3).toString());
} else if (weight <= 3 && StringtoDouble(prices.get(4).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(4).toString());
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
productVo.getProvidePrices().add(new ProvidePrice("圆通快递", finalePrice));
}
}
}
if ("艾印".equals(plantName) || "即客".equals(plantName)) {
List<String> list17 = Arrays.asList("新疆", "西藏", "甘肃", "宁夏", "青海");
List<String> list8 = Arrays.asList("内蒙古");
double price = 0;
if (isInAddress(list17, province.getProvince())) {
price = 17;
} else if (isInAddress(list8, province.getProvince())) {
price = 8;
} else {
price = 3.5;
if ("即客".equals(plantName)) {
price = 4;
}
}
for (ProductVo productVo : proList) {
productVo.getProvidePrices().add(new ProvidePrice("EMS", price));
}
}
if ("彩印通".equals(plantName)) {
List<ProvincePriceVo> cytzt = JSONObject.parseArray(cyt_zt, ProvincePriceVo.class);
List<ProvincePriceVo> cytyt = JSONObject.parseArray(cyt_yt, ProvincePriceVo.class);
List<ProvincePriceVo2> sfsome = JSONObject.parseArray(cyt_sf_some, ProvincePriceVo2.class);
List<ProvincePriceVo2> sfmorning = JSONObject.parseArray(cyt_sf_morning, ProvincePriceVo2.class);
List<ProvincePriceVo2> sfnextDay = JSONObject.parseArray(cyt_sf_nextDay, ProvincePriceVo2.class);
List<ProvincePriceVo2> sftowDay = JSONObject.parseArray(cyt_sf_towDay, ProvincePriceVo2.class);
calculateAndAddPrices(cytzt, "中通速递", province, proList, false);
calculateAndAddPrices(cytyt, "圆通速递", province, proList, false);
calculateAndAddPrices2(sfsome, "顺丰今日达", province, proList, false);
calculateAndAddPrices2(sfmorning, "顺丰次晨达", province, proList, false);
calculateAndAddPrices2(sfnextDay, "顺丰次日达", province, proList, false);
calculateAndAddPrices2(sftowDay, "顺丰隔日达", province, proList, true);
}
if ("鸿晟".equals(plantName)) {
for (ProductVo productVo : proList) {
productVo.getProvidePrices().add(new ProvidePrice("Other", 3.5));
}
double price = 0;
List<String> list12 = Arrays.asList("浙江", "江苏", "上海", "安徽");
List<String> list16 = Arrays.asList("福建");
if (isInAddress(list12, province.getProvince())) {
price = 12;
} else if (isInAddress(list16, province.getProvince())) {
price = 16;
} else {
price = 23;
}
for (ProductVo productVo : proList) {
productVo.getProvidePrices().add(new ProvidePrice("SF", price));
}
}
if ("驰远".equals(plantName)) {
Map<String, Map<String, List<String>>> sf_bk = (Map<String, Map<String, List<String>>>) JSON.parse(cy_sf_bk);
Map<String, Map<String, List<String>>> sf_tk = (Map<String, Map<String, List<String>>>) JSON.parse(cy_sf_tk);
List<ProvincePriceVo> yt_xiao = JSONObject.parseArray(cy_yt_xiao, ProvincePriceVo.class);
List<ProvincePriceVo> yt_sd = JSONObject.parseArray(cy_yt_sd, ProvincePriceVo.class);
List<ProvincePriceVo> ems = JSONObject.parseArray(cy_ems, ProvincePriceVo.class);
String priceString = priceKey(sf_bk, province);
if (!StringUtils.isEmpty(priceString)) {
double firstPrice = StringtoDouble(priceString.split("_")[1]);
double secPrice = StringtoDouble(priceString.split("_")[2]);
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double secWeightPrice = 0.0;
if (weight > 1) {
secWeightPrice = Math.ceil(weight - 1.0) * secPrice;
}
productVo.getProvidePrices().add(new ProvidePrice("顺丰标快", firstPrice + secWeightPrice));
}
}
priceString = priceKey(sf_tk, province);
if (!StringUtils.isEmpty(priceString)) {
double firstPrice = StringtoDouble(priceString.split("_")[1]);
double secPrice = StringtoDouble(priceString.split("_")[2]);
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double secWeightPrice = 0.0;
if (weight > 1) {
secWeightPrice = Math.ceil(weight - 1.0) * secPrice;
}
productVo.getProvidePrices().add(new ProvidePrice("顺丰特快", firstPrice + secWeightPrice));
}
}
List<BigDecimal> prices = getProvincePrice(yt_xiao, province.province);
if (prices != null && prices.size() > 0) {
double firstPrice = StringtoDouble(prices.get(4).toString());
double secPrice = StringtoDouble(prices.get(5).toString());
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
if (weight <= 0.5) {
finalePrice = StringtoDouble(prices.get(0).toString());
} else if (weight <= 1) {
finalePrice = StringtoDouble(prices.get(1).toString());
} else if (weight <= 2) {
finalePrice = StringtoDouble(prices.get(2).toString());
} else if (weight <= 3) {
finalePrice = StringtoDouble(prices.get(3).toString());
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
productVo.getProvidePrices().add(new ProvidePrice("圆通快递", finalePrice));
}
}
prices = getProvincePrice(yt_sd, province.province);
if (prices != null && prices.size() > 0) {
double firstPrice = StringtoDouble(prices.get(0).toString());
double secPrice = StringtoDouble(prices.get(1).toString());
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
productVo.getProvidePrices().add(new ProvidePrice("圆通速递", finalePrice));
}
}
prices = getProvincePrice(ems, province.province);
if (prices != null && prices.size() > 0) {
double firstPrice = StringtoDouble(prices.get(4).toString());
double secPrice = StringtoDouble(prices.get(5).toString());
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
if (weight <= 0.5 && StringtoDouble(prices.get(0).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(0).toString());
} else if (weight <= 1 && StringtoDouble(prices.get(1).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(1).toString());
} else if (weight <= 2 && StringtoDouble(prices.get(2).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(2).toString());
} else if (weight <= 3 && StringtoDouble(prices.get(3).toString()) != 0) {
finalePrice = StringtoDouble(prices.get(3).toString());
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
productVo.getProvidePrices().add(new ProvidePrice("邮政快递", finalePrice));
}
}
}
return new PricingListVo(proList);
}
private static Double StringtoDouble(String str) {
try {
return new BigDecimal(str).doubleValue();
} catch (Exception e) {
return 0.0;
}
}
// 定义一个通用方法来处理价格计算逻辑
private void calculateAndAddPrices(List<ProvincePriceVo> priceData, String courierName, Province province, List<ProductVo> proList, boolean hasThirdPrice) {
List<BigDecimal> prices = getProvincePrice(priceData, province.province);
List<String> nofirst = Arrays.asList("内蒙古", "西藏", "新疆", "香港", "澳门", "台湾");
if (prices == null || prices.size() < (hasThirdPrice ? 3 : 2)) {
return; // 如果价格数据不足,则直接返回
}
try {
double firstPrice = StringtoDouble(prices.get(0).toString());
double secPrice = StringtoDouble(prices.get(1).toString());
double thrPrice = hasThirdPrice && prices.size() > 2 ? StringtoDouble(prices.get(2).toString()) : 0;
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
if (courierName.equals("中通速递") || courierName.equals("圆通速递")) {
if (weight <= 3 && !isInAddress(nofirst, province.getProvince())) {
finalePrice = firstPrice;
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
} else {
if (hasThirdPrice && weight > 30) {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * thrPrice;
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
}
productVo.getProvidePrices().add(new ProvidePrice(courierName, finalePrice));
}
} catch (Exception e) {
// 记录日志或采取其他措施处理异常
System.err.println("Error parsing price data: " + e.getMessage());
}
}
private void calculateAndAddPrices2(List<ProvincePriceVo2> priceData, String courierName, Province province, List<ProductVo> proList, boolean hasThirdPrice) {
List<BigDecimal> prices = getProvincePrice2(priceData, province);
List<String> nofirst = Arrays.asList("内蒙古", "西藏", "新疆", "香港", "澳门", "台湾");
if (prices == null || prices.size() < (hasThirdPrice ? 3 : 2)) {
return; // 如果价格数据不足,则直接返回
}
try {
double firstPrice = StringtoDouble(prices.get(0).toString());
double secPrice = StringtoDouble(prices.get(1).toString());
double thrPrice = hasThirdPrice && prices.size() > 2 ? StringtoDouble(prices.get(2).toString()) : 0;
for (ProductVo productVo : proList) {
double weight = StringtoDouble(productVo.getWeight());
double finalePrice = 0;
if (courierName.equals("中通速递") || courierName.equals("圆通速递")) {
if (weight <= 3 && !isInAddress(nofirst, province.getProvince())) {
finalePrice = firstPrice;
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
} else {
if (hasThirdPrice && weight > 30) {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * thrPrice;
} else {
finalePrice = firstPrice + Math.ceil(weight - 1.0) * secPrice;
}
}
productVo.getProvidePrices().add(new ProvidePrice(courierName, finalePrice));
}
} catch (Exception e) {
// 记录日志或采取其他措施处理异常
System.err.println("Error parsing price data: " + e.getMessage());
}
}
private static List<BigDecimal> getProvincePrice2(List<ProvincePriceVo2> list, Province province) {
List<BigDecimal> prices = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
if (isInAddress(Arrays.asList(list.get(i).getProvince()), province.getProvince())) {
List<String> cities = list.get(i).getCities();
if (cities.size() == 0 || isInAddress(cities, province.getCity())) {
prices = list.get(i).getPrices();
} else if (list.get(i).getOtherPrices().size() > 0) {
prices = list.get(i).getOtherPrices();
}
}
}
return prices;
}
private static List<BigDecimal> getProvincePrice(List<ProvincePriceVo> list, String provinceName) {
List<BigDecimal> prices = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
if (isInAddress(list.get(i).getRegions(), provinceName)) {
prices = list.get(i).getPrice();
}
}
return prices;
}
/**
* 根据省份信息查找价格键
* 该方法通过遍历一个复杂的映射结构来查找与给定省份信息相对应的价格键
* 它首先遍历外层映射,然后遍历内层映射中的每个省份列表,检查是否有匹配的省份和城市
*
* @param map 一个映射,其键是价格键,值是另一个映射;内层映射的键是省份名称,值是城市列表
* @param province 省份对象,包含需要查找的省份和城市信息
* @return 如果找到匹配的省份和城市,则返回对应的价格键;否则返回空字符串
*/
private static String priceKey(Map<String, Map<String, List<String>>> map, Province province) {
// 初始化结果字符串
String result = "";
// 获取外层映射的条目迭代器
Iterator<Map.Entry<String, Map<String, List<String>>>> iterator = map.entrySet().iterator();
// 遍历外层映射
while (iterator.hasNext()) {
// 获取当前外层映射条目
Map.Entry<String, Map<String, List<String>>> entry = iterator.next();
// 获取内层映射
Map<String, List<String>> value = entry.getValue();
// 获取内层映射的条目迭代器
Iterator<Map.Entry<String, List<String>>> iteratorValue = value.entrySet().iterator();
// 遍历内层映射
while (iteratorValue.hasNext()) {
// 获取当前内层映射条目
Map.Entry<String, List<String>> provinces = iteratorValue.next();
// 获取省份名称
String provincesName = provinces.getKey();
// 检查省份名称是否与给定的省份信息匹配
if (isInAddress(Arrays.asList(provincesName), province.getProvince())) {
// 获取城市列表
List<String> citys = provinces.getValue();
// 如果城市列表为空,则直接返回当前的价格键
if (citys.size() == 0) {
result = entry.getKey();
return result;
} else {
// 如果城市列表不为空,进一步检查城市是否匹配
if (isInAddress(citys, province.getCity())) {
result = entry.getKey();
return result;
}
}
}
}
}
// 如果没有找到匹配的省份和城市,返回空字符串
return result;
}
//驰远顺丰标快
private static String cy_sf_bk = "{\"price_12_1\":{\"福建省\":[\"龙岩\"]},\"price_13_2\":{\"福建省\":[\"南平\",\"莆田\",\"福州\",\"泉州\",\"漳州\",\"厦门\",\"三明\",\"宁德\"]},\"price_16_6\":{\"广东省\":[\"河源\",\"韶关\",\"汕头\",\"清远\",\"深圳\",\"广州\",\"中山\",\"惠州\",\"揭阳\",\"东莞\",\"佛山\",\"汕尾\",\"潮州\",\"梅州\"],\"浙江省\":[\"台州\",\"温州\"]},\"price_18_5\":{\"北京市\":[],\"上海市\":[],\"天津市\":[],\"河北省\":[],\"河南省\":[],\"山东省\":[],\"浙江省\":[\"湖州\",\"宁波\",\"舟山\",\"丽水\",\"金华\",\"嘉兴\",\"衢州\",\"绍兴\",\"杭州\"],\"江西省\":[]},\"price_18_6\":{\"广西壮族自治区\":[\"河池\",\"防城港\",\"百色\",\"梧州/贺州\",\"钦州\",\"北海\",\"柳州\",\"来宾\",\"桂林\",\"玉林\",\"崇左\",\"贵港\",\"南宁\"],\"海南省\":[],\"重庆市\":[],\"辽宁省\":[],\"江苏省\":[],\"湖北省\":[],\"四川省\":[],\"陕西省\":[],\"贵州省\":[],\"云南省\":[],\"山西省\":[],\"内蒙古自治区\":[\"包头\",\"通辽\",\"呼和浩特\",\"乌海\",\"锡林郭勒盟\",\"赤峰\",\"鄂尔多斯\",\"乌兰察布\",\"阿拉善盟\",\"巴彦淖尔\"],\"安徽省\":[],\"广东省\":[\"江门\",\"茂名\",\"云浮\",\"湛江\",\"阳江\",\"珠海\",\"肇庆\"],\"湖南省\":[],\"甘肃省\":[],\"宁夏回族自治区\":[],\"青海省\":[\"海南藏族自治州\",\"果洛藏族自治州\",\"海东\",\"黄南藏族自治州\",\"海西蒙古族藏族自治州\",\"格尔木\",\"海北藏族自治州\",\"西宁\"]},\"price_18_9\":{\"吉林省\":[],\"黑龙江省\":[],\"内蒙古自治区\":[\"呼伦贝尔\",\"兴安盟\"]},\"price_20_10\":{\"新疆维吾尔自治区\":[]},\"price_21_12\":{\"青海省\":[\"玉树藏族自治州\"]},\"price_25_19\":{\"西藏自治区\":[\"拉萨\",\"日喀则\",\"那曲\",\"山南\",\"林芝\"]},\"price_26_21\":{\"西藏自治区\":[\"昌都\"]}}";
//驰远顺丰特快
private static String cy_sf_tk = "{\"price_18_8\":{\"广东省\":[\"汕头\",\"揭阳\",\"汕尾\",\"潮州\"]},\"price_20_8\":{\"广东省\":[\"河源\",\"茂名\",\"韶关\",\"清远\",\"深圳\",\"珠海\",\"广州\",\"肇庆\",\"中山\",\"江门\",\"云浮\",\"惠州\",\"湛江\",\"东莞\",\"阳江\",\"佛山\"],\"浙江省\":[\"宁波\",\"舟山\"]},\"price_22_10\":{\"上海市\":[],\"江苏省\":[],\"浙江省\":[\"湖州\",\"丽水\",\"金华\",\"嘉兴\",\"衢州\",\"绍兴\",\"杭州\"]},\"price_22_8\":{\"江西省\":[]},\"price_23_10\":{\"北京市\":[],\"天津市\":[],\"湖北省\":[],\"河北省\":[],\"河南省\":[],\"山东省\":[],\"安徽省\":[],\"湖南省\":[],\"广西壮族自治区\":[],\"海南省\":[]},\"price_23_13\":{\"重庆市\":[],\"辽宁省\":[],\"四川省\":[],\"陕西省\":[],\"贵州省\":[],\"云南省\":[],\"山西省\":[],\"甘肃省\":[],\"宁夏回族自治区\":[]},\"price_23_14\":{\"内蒙古自治区\":[\"包头\",\"通辽\",\"呼和浩特\",\"乌海\",\"锡林郭勒盟\",\"赤峰\",\"鄂尔多斯\",\"乌兰察布\",\"阿拉善盟\",\"巴彦淖尔\"],\"青海省\":[\"海南藏族自治州\",\"果洛藏族自治州\",\"海东\",\"黄南藏族自治州\",\"海西蒙古族藏族自治州\",\"格尔木\",\"玉树藏族自治州\",\"海北藏族自治州\",\"西宁\"]},\"price_23_18\":{\"吉林省\":[],\"黑龙江省\":[],\"内蒙古自治区\":[\"呼伦贝尔\",\"兴安盟\"]},\"price_26_21\":{\"西藏自治区\":[\"拉萨\",\"日喀则\",\"那曲\",\"山南\",\"林芝\",\"昌都\"],\"新疆维吾尔自治区\":[\"阿勒泰地区\",\"克孜勒苏柯尔克孜自治州\",\"哈密地区\",\"铁门关\",\"双河\",\"巴音郭楞蒙古自治州\",\"博尔塔拉蒙古自治州\",\"阿克苏地区\",\"昌吉回族自治州\",\"克拉玛依\",\"乌鲁木齐\",\"石河子\",\"喀什地区\",\"奎屯\",\"吐鲁番地区\",\"伊犁哈萨克自治州\",\"塔城地区\",\"和田地区\"]},\"price_20_10\":{\"新疆维吾尔自治区\":[\"乌鲁木齐\",\"石河子\",\"喀什地区\",\"奎屯\",\"吐鲁番地区\",\"伊犁哈萨克自治州\",\"塔城地区\",\"和田地区\"]},\"price_21_12\":{\"青海省\":[\"玉树藏族自治州\"]},\"price_25_19\":{\"西藏自治区\":[\"拉萨\",\"日喀则\",\"那曲\",\"山南\",\"林芝\"]}}";
//驰远圆通快递
private static String cy_yt_xiao = "[{\"price\":[2.7,3.2,3.7,4.7,4.5,0.8],\"regions\":[\"省内\"]},{\"price\":[2.7,3.2,3.7,4.7,5.0,1.2],\"regions\":[\"江苏\",\"浙江\",\"安徽\",\"广东\",\"江西\",\"湖南\"]},{\"price\":[3.7,4.2,4.7,5.7,7.0,1.4],\"regions\":[\"上海\"]},{\"price\":[2.7,3.2,3.7,4.7,5.5,1.8],\"regions\":[\"广西\",\"湖北\",\"河南省\",\"河北省\",\"天津市\",\"山西\"]},{\"price\":[2.7,3.2,3.7,4.7,6.0,2.3],\"regions\":[\"四川省\",\"重庆市\",\"云南\",\"贵州\"]},{\"price\":[2.7,3.2,3.7,4.7,6.0,1.8],\"regions\":[\"山东\"]},{\"price\":[2.7,3.2,3.7,4.7,6.0,2.1],\"regions\":[\"陕西省\"]},{\"price\":[4.2,4.7,5.2,6.2,8.0,2.0],\"regions\":[\"北京\"]},{\"price\":[8.3,8.3,14.3,20.3,8.0,6.0],\"regions\":[\"甘肃省\",\"宁夏\"]},{\"price\":[8.3,8.3,16.3,24.3,8.0,8.0],\"regions\":[\"青海省\"]},{\"price\":[10.3,10.3,18.3,26.3,10.0,8.0],\"regions\":[\"内蒙古\"]},{\"price\":[18.3,18.3,33.3,48.3,18.0,15.0],\"regions\":[\"新疆\"]},{\"price\":[22.3,22.3,40.3,58.3,22.0,18.0],\"regions\":[\"西藏\"]},{\"price\":[2.7,3.2,3.7,4.7,7.0,3.2],\"regions\":[\"黑龙江\",\"吉林\",\"辽宁\"]}]";
//驰远邮政快递
private static String cy_ems = "[{\"price\":[2.8,3.4,4.0,6.0,6.0,2.0],\"regions\":[\"福建\"]},{\"price\":[2.8,3.4,4.0,6.0,8.0,2.0],\"regions\":[\"江西省\",\"浙江省\",\"湖北省\",\"湖南省\",\"上海市\",\"广东省\",\"江苏省\",\"安徽省\"]},{\"price\":[2.8,3.4,6.0,8.0,10.0,3.0],\"regions\":[\"河南省\",\"贵州省\",\"山东省\",\"广西\",\"河北省\",\"陕西省\",\"海南省\",\"山西省\",\"天津市\",\"重庆市\",\"四川省\"]},{\"price\":[3.5,5.0,7.0,20.0,14.0,4.0],\"regions\":[\"云南省\",\"甘肃省\",\"内蒙\",\"辽宁省\",\"吉林省\",\"宁夏\",\"黑龙江省\"]},{\"price\":[8.0,0,0,0,10.0,3.0],\"regions\":[\"北京\"]},{\"price\":[12.0,0,0,0,16.0,12.0],\"regions\":[\"青海省\",\"新疆\",\"西藏\"]}]";
//驰远圆通速递(重货)
private static String cy_yt_sd = "[{\"price\":[4.0,0.8],\"regions\":[\"福建\"]},{\"price\":[4.0,1.0],\"regions\":[\"广东\"]},{\"price\":[5.0,1.3],\"regions\":[\"上海\"]},{\"price\":[4.5,1.1],\"regions\":[\"浙江\",\"江西\",\"江苏\",\"安徽\",\"湖南\"]},{\"price\":[4.5,1.4],\"regions\":[\"湖北\",\"山东\",\"河南\",\"河北\",\"天津\"]},{\"price\":[5.5,1.7],\"regions\":[\"北京\"]},{\"price\":[5.5,1.6],\"regions\":[\"陕西\"]},{\"price\":[5.5,1.4],\"regions\":[\"广西\",\"山西\"]},{\"price\":[5.5,1.9],\"regions\":[\"贵州\",\"重庆\",\"云南\",\"四川\",\"海南\"]},{\"price\":[5.5,2.5],\"regions\":[\"辽宁\",\"黑龙江\",\"吉林\"]},{\"price\":[12.0,6.6],\"regions\":[\"甘肃\",\"宁夏\",\"青海\"]},{\"price\":[13.0,7.6],\"regions\":[\"内蒙古\"]},{\"price\":[20.0,15.6],\"regions\":[\"西藏\",\"新疆\"]}]";
//彩印通中通
private static String cyt_zt = "[{\"price\":[3.5,1],\"regions\":[\"广东\"]},{\"price\":[3.5,2],\"regions\":[\"浙江\",\"湖南\",\"福建\",\"江苏\",\"湖北\",\"广西\",\"江西\",\"安徽\"]},{\"price\":[3.5,3],\"regions\":[\"天津\",\"河南\",\"河北\",\"山东\",\"四川\",\"重庆\",\"贵州\",\"海南\",\"云南\"]},{\"price\":[3.5,4],\"regions\":[\"山西\",\"陕西\",\"黑龙江\",\"吉林\",\"辽宁\"]},{\"price\":[6,2],\"regions\":[\"上海\"]},{\"price\":[4.5,3],\"regions\":[\"北京\"]},{\"price\":[6,6],\"regions\":[\"甘肃\",\"宁夏\",\"青海\",\"内蒙古\"]},{\"price\":[20,20],\"regions\":[\"澳门\",\"香港\",\"台湾\"]},{\"price\":[10,8],\"regions\":[\"新疆\",\"西藏\"]}]";
//彩印通圆通
private static String cyt_yt = "[{\"price\":[2.6,1],\"regions\":[\"广东\"]},{\"price\":[2.6,2],\"regions\":[\"江苏省\",\"浙江省\",\"安徽省\",\"上海\",\"广西壮族自治区\",\"福建省\",\"江西省\",\"湖南省\",\"湖北省\"]},{\"price\":[2.6,3],\"regions\":[\"贵州省\",\"云南省\",\"海南省\",\"河南省\",\"山东省\",\"四川省\",\"重庆市\",\"北京市\",\"河北省\",\"天津市\"]},{\"price\":[2.6,4],\"regions\":[\"黑龙江省\",\"辽宁省\",\"吉林省\",\"山西省\",\"陕西省\"]},{\"price\":[2.6,5],\"regions\":[\"宁夏回族自治区\",\"青海省\",\"甘肃省\"]},{\"price\":[6,6],\"regions\":[\"内蒙古自治区\"]},{\"price\":[10,8],\"regions\":[\"新疆维吾尔自治区\",\"西藏自治区\"]},{\"price\":[30,15],\"regions\":[\"台湾\",\"香港\",\"澳门\"]}]\n";
//彩印通顺丰今日达
private static String cyt_sf_some = "[{\"province\":\"广东\",\"cities\":[\"佛山\"],\"price\":[11,1]},{\"province\":\"广东\",\"cities\":[\"广州\",\"深圳\"],\"price\":[16,2]},{\"province\":\"广东\",\"cities\":[\"江门\",\"中山\",\"东莞\"],\"price\":[15,2]}]";
//彩印通顺丰次晨达
private static String cyt_sf_morning = "[{\"province\":\"广东\",\"cities\":[\"佛山\",\"肇庆\",\"云浮\"],\"price\":[11,1]},{\"province\":\"广东\",\"cities\":[\"广州\",\"深圳\"],\"price\":[13,2]},{\"province\":\"广东\",\"cities\":[\"江门\",\"中山\",\"东莞\",\"惠州\",\"珠海\",\"肇庆\",\"清远\",\"云浮\",\"阳江\",\"揭阳\",\"茂名\",\"韶关\",\"梅州\",\"汕头\",\"湛江\",\"河源\",\"潮州\",\"汕尾\"],\"price\":[12,2]},{\"province\":\"广西\",\"cities\":[\"贺州\",\"梧州\"],\"price\":[16,6]},{\"province\":\"福建\",\"cities\":[\"泉州\"],\"price\":[20,8]},{\"province\":\"江苏\",\"cities\":[\"南京\",\"无锡\",\"镇江\",\"苏州\",\"常州\"],\"price\":[25,13]},{\"province\":\"上海\",\"cities\":[\"上海\"],\"price\":[25,13]},{\"province\":\"浙江\",\"cities\":[\"杭州\",\"湖州\",\"嘉兴\",\"宁波\",\"绍兴\",\"台州\",\"温州\"],\"price\":[25,13]},{\"province\":\"北京\",\"cities\":[\"北京\"],\"price\":[25,14]}]";
//彩印通次日达
private static String cyt_sf_nextDay = "[{\"province\":\"广东\",\"cities\":[\"阳江\",\"揭阳\",\"茂名\",\"韶关\",\"梅州\",\"汕头\",\"湛江\",\"河源\",\"潮州\",\"汕尾\"],\"prices\":[22,8],\"otherPrices\":[0,0]},{\"province\":\"福建\",\"cities\":[],\"prices\":[20,8],\"otherPrices\":[0,0]},{\"province\":\"广西\",\"cities\":[\"贺州\",\"梧州\"],\"prices\":[16,6],\"otherPrices\":[22,8]},{\"province\":\"江西\",\"cities\":[],\"prices\":[22,8],\"otherPrices\":[0,0]},{\"province\":\"湖南\",\"cities\":[],\"prices\":[22,8],\"otherPrices\":[0,0]},{\"province\":\"海南\",\"cities\":[],\"prices\":[22,8],\"otherPrices\":[0,0]},{\"province\":\"贵州\",\"cities\":[],\"prices\":[23,12],\"otherPrices\":[0,0]},{\"province\":\"安徽\",\"cities\":[],\"prices\":[23,12],\"otherPrices\":[0,0]},{\"province\":\"湖北\",\"cities\":[],\"prices\":[23,12],\"otherPrices\":[0,0]},{\"province\":\"江苏\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"上海\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"浙江\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"重庆\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"四川\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"云南\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"河南\",\"cities\":[],\"prices\":[23,13],\"otherPrices\":[0,0]},{\"province\":\"北京\",\"cities\":[],\"prices\":[23,14],\"otherPrices\":[0,0]},{\"province\":\"天津\",\"cities\":[],\"prices\":[23,14],\"otherPrices\":[0,0]},{\"province\":\"辽宁\",\"cities\":[],\"prices\":[23,14],\"otherPrices\":[0,0]},{\"province\":\"陕西\",\"cities\":[],\"prices\":[23,14],\"otherPrices\":[0,0]},{\"province\":\"河北\",\"cities\":[],\"prices\":[23,14],\"otherPrices\":[0,0]},{\"province\":\"山东\",\"cities\":[],\"prices\":[23,14],\"otherPrices\":[0,0]},{\"province\":\"甘肃\",\"cities\":[],\"prices\":[23,18],\"otherPrices\":[0,0]},{\"province\":\"宁夏\",\"cities\":[],\"prices\":[23,18],\"otherPrices\":[0,0]},{\"province\":\"青海\",\"cities\":[],\"prices\":[23,18],\"otherPrices\":[0,0]},{\"province\":\"内蒙古\",\"cities\":[\"呼伦贝尔\",\"兴安盟\"],\"prices\":[25,20],\"otherPrices\":[23,18]},{\"province\":\"吉林\",\"cities\":[],\"prices\":[25,20],\"otherPrices\":[0,0]},{\"province\":\"黑龙江\",\"cities\":[],\"prices\":[25,20],\"otherPrices\":[0,0]},{\"province\":\"新疆\",\"cities\":[],\"prices\":[28,25],\"otherPrices\":[0,0]},{\"province\":\"西藏\",\"cities\":[],\"prices\":[28,25],\"otherPrices\":[0,0]}]";
//彩印通隔日达
private static String cyt_sf_towDay = "[{\"province\":\"江西\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"湖南\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"海南\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"贵州\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"安徽\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"湖北\",\"cities\":[],\"prices\":[18,8,8],\"otherPrices\":[0,0,0]},{\"province\":\"江苏\",\"cities\":[],\"prices\":[18,9,9],\"otherPrices\":[0,0,0]},{\"province\":\"上海\",\"cities\":[],\"prices\":[18,9,9],\"otherPrices\":[0,0,0]},{\"province\":\"浙江\",\"cities\":[],\"prices\":[18,9,9],\"otherPrices\":[0,0,0]},{\"province\":\"重庆\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"四川\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"云南\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"河南\",\"cities\":[],\"prices\":[18,6,6],\"otherPrices\":[0,0,0]},{\"province\":\"北京\",\"cities\":[],\"prices\":[18,7,7],\"otherPrices\":[0,0,0]},{\"province\":\"天津\",\"cities\":[],\"prices\":[18,7,7],\"otherPrices\":[0,0,0]},{\"province\":\"辽宁\",\"cities\":[],\"prices\":[18,7,7],\"otherPrices\":[0,0,0]},{\"province\":\"陕西\",\"cities\":[],\"prices\":[18,7,7],\"otherPrices\":[0,0,0]},{\"province\":\"河北\",\"cities\":[],\"prices\":[18,7,7],\"otherPrices\":[0,0,0]},{\"province\":\"山东\",\"cities\":[],\"prices\":[18,7,7],\"otherPrices\":[0,0,0]},{\"province\":\"甘肃\",\"cities\":[],\"prices\":[18,9,9],\"otherPrices\":[0,0,0]},{\"province\":\"宁夏\",\"cities\":[],\"prices\":[18,9,9],\"otherPrices\":[0,0,0]},{\"province\":\"青海\",\"cities\":[],\"prices\":[18,9,9],\"otherPrices\":[0,0,0]},{\"province\":\"内蒙古\",\"cities\":[\"呼伦贝尔\",\"兴安盟\"],\"prices\":[20,10,10],\"otherPrices\":[18,9,9]},{\"province\":\"吉林\",\"cities\":[],\"prices\":[20,10,10],\"otherPrices\":[0,0,0]},{\"province\":\"黑龙江\",\"cities\":[],\"prices\":[20,10,10],\"otherPrices\":[0,0,0]},{\"province\":\"新疆\",\"cities\":[],\"prices\":[22,12,12],\"otherPrices\":[0,0,0]},{\"province\":\"西藏\",\"cities\":[],\"prices\":[0,0,0],\"otherPrices\":[0,0,0]}]";
//龙岩圆通
private static String ly_yt = "[{\"price\":[1.9,2.2,2.9,3.5,4.5,4.9,0.6],\"regions\":[\"福建\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,4.9,1.2],\"regions\":[\"广东\",\"安徽\",\"浙江\",\"江苏\",\"江西\",\"湖北\",\"湖南\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,4.9,1.4],\"regions\":[\"上海\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,4.9,1.9],\"regions\":[\"北京\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,4.9,1.6],\"regions\":[\"河南\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,5.9,1.6],\"regions\":[\"山东\",\"天津\",\"河北\",\"陕西\",\"广西\",\"山西\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,5.9,2.1],\"regions\":[\"海南\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,5.9,2.0],\"regions\":[\"四川\",\"贵州\",\"云南\",\"重庆\"]},{\"price\":[1.9,2.2,2.9,3.5,4.5,6.9,2.5],\"regions\":[\"黑龙江\",\"吉林\",\"辽宁\"]},{\"price\":[0,0,0,0,0,8.4,6.0],\"regions\":[\"甘肃\",\"宁夏\",\"青海\"]},{\"price\":[0,0,0,0,0,9.4,7.0],\"regions\":[\"内蒙古\"]},{\"price\":[0,0,0,0,0,15.4,12.0],\"regions\":[\"新疆\"]},{\"price\":[0,0,0,0,0,19.4,17.0],\"regions\":[\"西藏\"]}]";
//龙岩申通
private static String ly_st = "[{\"price\":[2.4,3.2,3.5,4.5,4.5,0.8],\"regions\":[\"福建\"]},{\"price\":[2.4,3.2,3.5,4.5,4.5,1.2],\"regions\":[\"广东\",\"安徽\",\"浙江\",\"江苏\",\"上海\",\"江西\",\"湖北\",\"湖南\"]},{\"price\":[2.4,3.2,3.5,4.5,5.0,2.0],\"regions\":[\"北京\"]},{\"price\":[2.4,3.2,3.5,4.5,5.0,2.5],\"regions\":[\"河南\",\"山东\",\"陕西\",\"四川\",\"广西\",\"山西\",\"贵州\",\"云南\",\"重庆\"]},{\"price\":[2.4,3.2,3.5,4.5,5.0,2.0],\"regions\":[\"天津\",\"河北\",\"海南\"]},{\"price\":[2.4,3.2,3.5,4.5,5.5,4.0],\"regions\":[\"黑龙江\",\"吉林\",\"辽宁\"]},{\"price\":[10.0,10.0,20.0,30.0,10.0,10.0],\"regions\":[\"甘肃\",\"宁夏\",\"青海\",\"内蒙古\"]},{\"price\":[15.0,16.0,30.0,45.0,18.0,16.0],\"regions\":[\"新疆\",\"西藏\"]}]";
private static Boolean isInAddress(List<String> list, String address) {
Boolean result = false;
for (int i = 0; i < list.size(); i++) {
if (address.contains(list.get(i))) {
result = true;
break;
}
}
return result;
}
private static class ProvincePriceVo2 {
private List<BigDecimal> prices = new ArrayList<>();
private List<String> cities = new ArrayList<>();
private List<BigDecimal> otherPrices = new ArrayList<>();
private String province = "";
public List<BigDecimal> getPrices() {
return prices;
}
public List<String> getCities() {
return cities;
}
public List<BigDecimal> getOtherPrices() {
return otherPrices;
}
public String getProvince() {
return province;
}
public void setPrices(List<BigDecimal> prices) {
this.prices = prices;
}
public void setCities(List<String> cities) {
this.cities = cities;
}
public void setOtherPrices(List<BigDecimal> otherPrices) {
this.otherPrices = otherPrices;
}
public void setProvince(String province) {
this.province = province;
}
}
private static class ProvincePriceVo {
private List<BigDecimal> price = new ArrayList<>();
private List<String> regions = new ArrayList<>();
private List<BigDecimal> otherPrices = new ArrayList<>();
public List<BigDecimal> getPrice() {
return price;
}
public List<String> getRegions() {
return regions;
}
public List<BigDecimal> getOtherPrices() {
return otherPrices;
}
public void setPrice(List<BigDecimal> price) {
this.price = price;
}
public void setRegions(List<String> regions) {
this.regions = regions;
}
public void setOtherPrices(List<BigDecimal> otherPrices) {
this.otherPrices = otherPrices;
}
}
private static class Province {
private String province;
private String city;
private String district;
private String detailAddress;
public Province(String province, String city, String district, String detailAddress) {
this.province = province;
this.city = city;
this.district = district;
this.detailAddress = detailAddress;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getDetailAddress() {
return detailAddress;
}
public void setDetailAddress(String detailAddress) {
this.detailAddress = detailAddress;
}
}
private static Province parseAddress(String address) {
if (StringUtils.isEmpty(address)) {
return null;
}
String province = "";
String city = "";
String district = "";
String detailAddress = "";
// 匹配省级(省、自治区、直辖市)
String provinceRegex = "(?<province>[^省]+省|.+自治区|北京市|上海市|天津市|重庆市)";
Matcher provinceMatcher = Pattern.compile(provinceRegex).matcher(address);
if (provinceMatcher.find()) {
province = provinceMatcher.group("province");
String remaining = address.substring(province.length());
// 匹配市级(市、自治州、地区、盟)
String cityRegex = "(?<city>[^市]+市|.+自治州|.+地区|.+盟|市辖区)";
Matcher cityMatcher = Pattern.compile(cityRegex).matcher(remaining);
if (cityMatcher.find()) {
city = cityMatcher.group("city");
String districtPart = remaining.substring(city.length());
// 匹配区级(区、县、市、旗)
String districtRegex = "(?<district>[^区]+区|.+县|.+市|.+旗)";
Matcher districtMatcher = Pattern.compile(districtRegex).matcher(districtPart);
if (districtMatcher.find()) {
district = districtMatcher.group("district");
detailAddress = districtPart.substring(district.length());
}
}
}
return new Province(province, city, district, detailAddress);
}
}
@@ -25,223 +25,226 @@ import lingtao.net.util.IPUtils;
@Service
public class QuoteLogService {
@Autowired
private QuoteLogMapper quoteLogMapper;
@Autowired
private QuoteLogMapper quoteLogMapper;
@Autowired
private QuoteDataMapper quoteDataMapper;
@Autowired
private QuoteDataMapper quoteDataMapper;
@Autowired
ProductImgMapper productImgMapper;
@Autowired
ProductImgMapper productImgMapper;
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysRoleService sysRoleService;
// 列表
public List<QuoteLog> quoteLogs(QuoteLog quoteLog) {
quoteLog.setQuoteTimeEnd(new DateFormatUtils().formatEndTime(quoteLog.getQuoteTimeBegin()));
quoteLog.setQuoteTimeBegin(new DateFormatUtils().formatBeginTime(quoteLog.getQuoteTimeBegin()));
return quoteLogMapper.quoteLogs(quoteLog);
}
// 列表
public List<QuoteLog> quoteLogs(QuoteLog quoteLog) {
quoteLog.setQuoteTimeEnd(new DateFormatUtils().formatEndTime(quoteLog.getQuoteTimeBegin()));
quoteLog.setQuoteTimeBegin(new DateFormatUtils().formatBeginTime(quoteLog.getQuoteTimeBegin()));
return quoteLogMapper.quoteLogs(quoteLog);
}
// 操作日志
public String log(Product product, HttpServletRequest request, List<Product> proList) {
long startTime, endTime = 0;
startTime = System.currentTimeMillis();
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
if (user == null) {
return "登陆失效";
}
QuoteLog log = new QuoteLog();
ProductImg productImg = new ProductImg();
// 操作日志
public String log(Product product, HttpServletRequest request, List<Product> proList) {
long startTime, endTime = 0;
startTime = System.currentTimeMillis();
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
if (user == null) {
return "登陆失效";
}
QuoteLog log = new QuoteLog();
ProductImg productImg = new ProductImg();
// product转productImg
BeanUtils.copyProperties(product, productImg);
// 根据value查询label
if ("13".equals(productImg.getProTypeValue()) || "15".equals(productImg.getProTypeValue())
|| "4".equals(productImg.getProTypeValue())) {
productImg.setKind2Value(null);
}
// 优惠券
if ("4".equals(productImg.getProTypeValue())) {
productImg.setKindValue("0");
productImg.setKind2Value(product.getKind());
}
// 合版封套
if ("6".equals(productImg.getProTypeValue())) {
if (product.getLengthSize() > 0) {
productImg.setKind2Value("0");
}
}
// 根据value获取label
SysDictProduct label = productImgMapper.getLabel(productImg);
// product转productImg
BeanUtils.copyProperties(product, productImg);
// 根据value查询label
if ("13".equals(productImg.getProTypeValue()) || "15".equals(productImg.getProTypeValue())
|| "4".equals(productImg.getProTypeValue())) {
productImg.setKind2Value(null);
}
// 优惠券
if ("4".equals(productImg.getProTypeValue())) {
productImg.setKindValue("0");
productImg.setKind2Value(product.getKind());
}
// 合版封套
if ("6".equals(productImg.getProTypeValue())) {
if (product.getLengthSize() > 0) {
productImg.setKind2Value("0");
}
}
// 根据value获取label
SysDictProduct label = productImgMapper.getLabel(productImg);
if (StringUtils.isEmpty(label)) {
return null;
}
String s = "";
String remark_judge = "";
String proTypeLabel = "";
if ("常用种类".equals(product.getStickerKind())) {
s += "常用种类- ";
}
if ("少数量".equals(product.getStickerKind())) {
s += "少数量- ";
}
if ("专版打印".equals(product.getStickerKind())) {
s += "专版打印- ";
}
if (!StringUtils.isEmpty(label.getProTypeLabel())) {
if ("金属标".equals(label.getProTypeLabel()) && StringUtils.isEmpty(product.getCraftMo())) {
s += "UV转印贴 - ";
proTypeLabel = "UV转印贴";
} else {
s += label.getProTypeLabel() + " - ";
proTypeLabel = label.getProTypeLabel();
}
}
if ("少数量".equals(product.getCouponKind())) {
s += product.getProTypeLabel() + " - ";
}
if (!StringUtils.isEmpty(label.getKindLabel())) {
s += label.getKindLabel() + " - ";
}
if (!StringUtils.isEmpty(label.getKind2Label())) {
s += label.getKind2Label() + " - ";
}
if (!StringUtils.isEmpty(product.getKind3Value())) {
if ("0".equals(product.getKind3Value())) {
s += "骑马钉 - ";
}
}
String new_s = s;
new_s += "客户旺旺:" + product.getWangwang() + " - ";
// 产品 - 种类
remark_judge = new_s;
// 不区分专版打印或者常用,3分钟内都不要
if (remark_judge.contains("常用种类- ") || remark_judge.contains("专版打印- ")) {
remark_judge = remark_judge.substring(6);
}
// 画册P数
if (!StringUtils.isEmpty(product.getPcount())) {
s += product.getPcount() + "P - ";
}
if (!StringUtils.isEmpty(product.getSize())) {
s += product.getSize() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftMo())) {
s += product.getCraftMo() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftTang())) {
s += product.getCraftTang() + " - ";
}
if (!StringUtils.isEmpty(product.getAotu())) {
s += product.getAotu() + " - ";
}
if (!StringUtils.isEmpty(product.getYinbai())) {
s += product.getYinbai() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftSheng())) {
s += product.getCraftSheng() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftShua())) {
s += product.getCraftShua() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftBu())) {
s += product.getCraftBu() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftJiao())) {
s += product.getCraftJiao() + " - ";
}
if (StringUtils.isEmpty(label)) {
return null;
}
if (proList.size() == 0) {
return null;
}
String s = "";
String remark_judge = "";
String proTypeLabel = "";
if ("常用种类".equals(product.getStickerKind())) {
s += "常用种类- ";
}
if ("少数量".equals(product.getStickerKind())) {
s += "少数量- ";
}
if ("专版打印".equals(product.getStickerKind())) {
s += "专版打印- ";
}
if (!StringUtils.isEmpty(label.getProTypeLabel())) {
if ("金属标".equals(label.getProTypeLabel()) && StringUtils.isEmpty(product.getCraftMo())) {
s += "UV转印贴 - ";
proTypeLabel = "UV转印贴";
} else {
s += label.getProTypeLabel() + " - ";
proTypeLabel = label.getProTypeLabel();
}
}
if ("少数量".equals(product.getCouponKind())) {
s += product.getProTypeLabel() + " - ";
}
if (!StringUtils.isEmpty(label.getKindLabel())) {
s += label.getKindLabel() + " - ";
}
if (!StringUtils.isEmpty(label.getKind2Label())) {
s += label.getKind2Label() + " - ";
}
if (!StringUtils.isEmpty(product.getKind3Value())) {
if ("0".equals(product.getKind3Value())) {
s += "骑马钉 - ";
}
}
String new_s = s;
new_s += "客户旺旺:" + product.getWangwang() + " - ";
// 产品 - 种类
remark_judge = new_s;
// 不区分专版打印或者常用,3分钟内都不要
if (remark_judge.contains("常用种类- ") || remark_judge.contains("专版打印- ")) {
remark_judge = remark_judge.substring(6);
}
// 画册P数
if (!StringUtils.isEmpty(product.getPcount())) {
s += product.getPcount() + "P - ";
}
if (!StringUtils.isEmpty(product.getSize())) {
s += product.getSize() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftMo())) {
s += product.getCraftMo() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftTang())) {
s += product.getCraftTang() + " - ";
}
if (!StringUtils.isEmpty(product.getAotu())) {
s += product.getAotu() + " - ";
}
if (!StringUtils.isEmpty(product.getYinbai())) {
s += product.getYinbai() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftSheng())) {
s += product.getCraftSheng() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftShua())) {
s += product.getCraftShua() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftBu())) {
s += product.getCraftBu() + " - ";
}
if (!StringUtils.isEmpty(product.getCraftJiao())) {
s += product.getCraftJiao() + " - ";
}
if (!StringUtils.isEmpty(product.getCraft())) {
String[] craft = product.getCraft();
for (int i = 0; i < craft.length; i++) {
if (StringUtils.isEmpty(craft[i]))
continue;
s += craft[i] + " - ";
}
}
if (!StringUtils.isEmpty(product.getNumber())) {
s += product.getNumber() + "款 - ";
}
if (!StringUtils.isEmpty(product.getCraft())) {
String[] craft = product.getCraft();
for (int i = 0; i < craft.length; i++) {
if (StringUtils.isEmpty(craft[i]))
continue;
s += craft[i] + " - ";
}
}
if (!StringUtils.isEmpty(product.getNumber())) {
s += product.getNumber() + "款 - ";
}
if ("16".equals(product.getProTypeValue())) {
s += product.getCount() + "" + proList.get(0).getPrice() + "";
} else {
s += product.getCount() + "" + proList.get(0).getPrice() + "";
}
if ("16".equals(product.getProTypeValue())) {
s += product.getCount() + "" + proList.get(0).getPrice() + "";
} else {
s += product.getCount() + "" + proList.get(0).getPrice() + "";
}
log.setRemark(s);
log.setRealname(user.getRealname());
log.setUsername(user.getUsername());
log.setQuoteIp(IPUtils.getIpAddr(request));// 获取ip
log.setBrower(IPUtils.getBrowserName(request));// 获取浏览器名称
log.setOs(IPUtils.getOsName(request)); // 获取操作系统名称
log.setPrice(proList.get(0).getPrice());
List<SysRole> allRoleNames = sysRoleService.getAllRoleName(null);
String roleName = "";
String[] split = user.getRole().split(",");
for (SysRole sysRole : allRoleNames) {
for (int i = 0; i < split.length; i++) {
if (split[i].equals(String.valueOf(sysRole.getRoleId()))) {
roleName += sysRole.getRoleName() + "";
}
}
}
log.setShopname(roleName);
quoteLogMapper.insertSelective(log);
log.setRemark(s);
log.setRealname(user.getRealname());
log.setUsername(user.getUsername());
log.setQuoteIp(IPUtils.getIpAddr(request));// 获取ip
log.setBrower(IPUtils.getBrowserName(request));// 获取浏览器名称
log.setOs(IPUtils.getOsName(request)); // 获取操作系统名称
log.setPrice(proList.get(0).getPrice());
List<SysRole> allRoleNames = sysRoleService.getAllRoleName(null);
String roleName = "";
String[] split = user.getRole().split(",");
for (SysRole sysRole : allRoleNames) {
for (int i = 0; i < split.length; i++) {
if (split[i].equals(String.valueOf(sysRole.getRoleId()))) {
roleName += sysRole.getRoleName() + "";
}
}
}
log.setShopname(roleName);
quoteLogMapper.insertSelective(log);
endTime = System.currentTimeMillis();
System.out.println("【insertSelective】使用的时间:" + (endTime - startTime));
endTime = System.currentTimeMillis();
System.out.println("【insertSelective】使用的时间:" + (endTime - startTime));
long startTime2, endTime2 = 0;
startTime2 = System.currentTimeMillis();
boolean flag = false;
// 查询3分钟内自己报的数据
List<String> remarkJudgeData = quoteDataMapper.getQuoteDataByMinutes(user.getUsername());
endTime2 = System.currentTimeMillis();
System.out.println("【getQuoteDataByMinutes】使用的时间:" + (endTime2 - startTime2));
for (String remarkJudge : remarkJudgeData) {
if (remarkJudge.equals(remark_judge)) {
// 如果3分钟内报过相同数据
flag = true;
break;
}
}
// 插入数据(给客服数据新增用的)
String role = user.getRole();
// 客服报的且3分钟内没有同一个客户报的数据才插入
if (role.contains("999,") && !flag) {
QuoteData quoteData = new QuoteData();
quoteData.setUsername(user.getUsername());
quoteData.setRealname(user.getRealname());
quoteData.setPrice(proList.get(0).getPrice());
quoteData.setRole(user.getRole());
// 默认都是没选择店铺
quoteData.setIsSelect("0");
long startTime2, endTime2 = 0;
startTime2 = System.currentTimeMillis();
boolean flag = false;
// 查询3分钟内自己报的数据
List<String> remarkJudgeData = quoteDataMapper.getQuoteDataByMinutes(user.getUsername());
endTime2 = System.currentTimeMillis();
System.out.println("【getQuoteDataByMinutes】使用的时间:" + (endTime2 - startTime2));
for (String remarkJudge : remarkJudgeData) {
if (remarkJudge.equals(remark_judge)) {
// 如果3分钟内报过相同数据
flag = true;
break;
}
}
// 插入数据(给客服数据新增用的)
String role = user.getRole();
// 客服报的且3分钟内没有同一个客户报的数据才插入
if (role.contains("999,") && !flag) {
QuoteData quoteData = new QuoteData();
quoteData.setUsername(user.getUsername());
quoteData.setRealname(user.getRealname());
quoteData.setPrice(proList.get(0).getPrice());
quoteData.setRole(user.getRole());
// 默认都是没选择店铺
quoteData.setIsSelect("0");
// role = role.replace("999,", "").replace(",1049", "").replace(",1011", "");
// 规则:第一位客服,第二位主店铺
String shopname = role.substring(role.indexOf(",") + 1);
if (shopname.indexOf(",") != -1) {
shopname = shopname.substring(0, shopname.indexOf(","));
}
System.out.println(shopname);
quoteData.setShopname(shopname);
quoteData.setIsSelect("1");
// 除去【客服】只有一个店铺,所属店铺就是剩下这个店铺 切 选择状态改为已选择
// 规则:第一位客服,第二位主店铺
String shopname = role.substring(role.indexOf(",") + 1);
if (shopname.indexOf(",") != -1) {
shopname = shopname.substring(0, shopname.indexOf(","));
}
System.out.println(shopname);
quoteData.setShopname(shopname);
quoteData.setIsSelect("1");
// 除去【客服】只有一个店铺,所属店铺就是剩下这个店铺 切 选择状态改为已选择
// if (!role.contains(",")) {
// }
quoteData.setIsBuy("0");
quoteData.setIsBuyToDay("0");
quoteData.setRemark(s);
quoteData.setRemarkJudge(remark_judge);
// 默认都是填写旺旺号
quoteData.setIsFillIn("1");
quoteData.setWangwang(product.getWangwang().trim());
quoteData.setProTypeLabel(proTypeLabel);
quoteDataMapper.addQuoteData(quoteData);
}
return null;
}
quoteData.setIsBuy("0");
quoteData.setIsBuyToDay("0");
quoteData.setRemark(s);
quoteData.setRemarkJudge(remark_judge);
// 默认都是填写旺旺号
quoteData.setIsFillIn("1");
quoteData.setWangwang(product.getWangwang().trim());
quoteData.setProTypeLabel(proTypeLabel);
quoteDataMapper.addQuoteData(quoteData);
}
return null;
}
}
@@ -0,0 +1,27 @@
package lingtao.net.vo;
import lingtao.net.bean.Product;
import lombok.Data;
import java.util.List;
@Data
public class PricingListVo {
int code = 0;
List<ProductVo> proList = null;
String msg = "";
public PricingListVo() {
}
public PricingListVo(int code, String msg) {
this.code = code;
this.msg = msg;
}
public PricingListVo(List<ProductVo> proList) {
this.proList = proList;
}
}
@@ -0,0 +1,24 @@
package lingtao.net.vo;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class ProductVo {
// 价格
private Double price;
// 重量
private String weight;
// 款数
private Integer number;
// 数量
private Integer count;
private String role;
private List<ProvidePrice> providePrices = new ArrayList<>();
}
@@ -0,0 +1,27 @@
package lingtao.net.vo;
public class ProvidePrice {
private String name;
private double price;
public ProvidePrice(String name, double price) {
this.name = name;
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
@@ -0,0 +1,292 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@include file="/views/common.jsp" %>
</head>
<!-- 挂布 -->
<style>
</style>
<body>
<div class="big_box">
<div class="left_div">
<h1 class="h2">挂布</h1> <span style="color:red;font-weight:700;"></span>
<hr>
<form class="layui-form">
<p>
地址
</p>
<input type="text" name="address" class="layui-input"/>
<p>
车间
</p>
<div class="layui-form-item">
<div class="layui-form-item">
<select class="select" name="plantName">
<option value="领鸿">领鸿</option>
</select>
</div>
</div>
<p>
材质
</p>
<div class="layui-form-item">
<select name="kindValue" id="kindValue" lay-filter="kindValue" class="select">
<option value="半透纱幔">半透纱幔</option>
</select>
</div>
<input type="hidden" name="proTypeValue" class="layui-input" value="挂布">
<input type="hidden" id="proTypeValue" value="挂布">
<p>
尺寸(CM/厘米) <span style="font-size:14px;color:red">输入格式: 长 * 宽 </span>
</p>
<div class="layui-form-item">
<input type="text" placeholder="格式:长*宽" name="size" id="size" class="layui-input"
autocomplete="off">
</div>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="count" id="count" class="layui-input"
lay-verify="number">
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
class="layui-input" lay-verify="number">
</div>
<p>
配件:<span
style="font-size:14px;color:red"></span>
</p>
<div class="layui-input-block">
<input type="checkbox" name="craftys" lay-filter="switch" value="木棍(长度50厘米)" title="木棍(长度50厘米)">
</div>
<p>
工艺
</p>
<div class="layui-input-block">
<input type="checkbox" name="craft" lay-filter="switch" value="净裁" title="净裁">
<input type="checkbox" name="craft" lay-filter="switch" value="打孔" title="打孔">
<input type="checkbox" name="craft" lay-filter="switch" value="缝筒" title="缝筒">
</div>
<hr>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<script src="../../js/carousel.js" charset="utf-8"></script>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
//建造实例
ins = carousel.render({});
function getProductImage(craft) {
$("#carousel").empty();
$("#remark").empty();
let data = {proTypeValue: "挂布"}
let remark = "";
let html = "";
if (craft != '' && craft == '定制') {
data.craftValue = craft;
}
$.ajax({
url: "${pageContext.request.contextPath}/getImgs",
type: "GET",
data,
//dataType : "json",
success: function (result) {
for (let i = 0; i < result.length; i++) {
// 只留一个remark
remark = "";
html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
remark += '<div><span>' + result[0].remark + '<span/></div>';
}
$("#carousel").append(html);
// 如果没有说明,就不显示null
if (remark.indexOf("null") < 0) {
$("#remark").append(remark);
}
// 如果没有轮播图就隐藏
if (result.length == 0) {
document.getElementById("test1").style.display = "none"; //隐藏
} else {
document.getElementById("test1").style.display = "block"; //显示
ins.reload({
elem: '#test1',
width: result[0].imgWidth, //设置容器宽度
height: result[0].imgHeight
});
}
}
});
}
form.on("radio(switch)", (data) => {
getProductImage(data.elem.checked ? data.value : '');
})
form.on("checkbox(switch)", (data) => {
let arr = []
if ($("input[name='craft']:checked").length > 1) {
$(data.elem).next().attr("class", "layui-unselect layui-form-checkbox");
$(data.elem).prop("checked", false);
layer.msg('工艺不能同时选择!', {offset: ['300px', '300px']}, function () {
});
return false;
}
getProductImage(data.elem.checked ? data.value : '');
})
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
let size = $("#size").val();
let count = $("#count").val();
let craftys = $("input[name='craftys']:checked").val();
if (!size) {
layer.msg('请输入尺寸!', {offset: ['300px', '300px']}, function () {
});
return false;
}
if (!count) {
layer.msg('请输入数量!', {offset: ['300px', '300px']}, function () {
});
return false;
}
if (size.split("*")[0] < 20 || size.split("*")[1] < 20) {
layer.msg('挂布最小尺寸20*20cm', {offset: ['300px', '300px']}, function () {
});
return false;
}
if (size.split("*")[0] > 150 || size.split("*")[1] > 150) {
layer.msg('挂布宽度超过150cm需要拼接!', {offset: ['300px', '300px']}, function () {
});
}
$.ajax({
url: "${path}/getProductPrice",
type: "GET",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
let arr = [];
let data = result.data.proList;
let kind = $("select[name='kindValue'] option:selected").val();
let number = $("#number").val();
let craftys = $("input[name='craftys']:checked").val();
$("input[name='craft']:checked").each(function () {
if (!$(this).is("disabled")) {
arr.push($(this).val())
}
})
let span_result = kind + ' - ' + size + ' 厘米 -(同款内容)\n' + "工艺 :" + arr.join(",") + "\n";
if (craftys) {
span_result += "配件:" + craftys
span_result += "\n"
}
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
$("#span_result").val(span_result);
getRemark($("#proTypeValue").val(), size, count, kind, number, arr, "");
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>
+292
View File
@@ -0,0 +1,292 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@include file="/views/common.jsp" %>
</head>
<body>
<div class="big_box">
<div class="left_div">
<h1 class="h1">班旗</h1> <span style="color:red;font-weight:700;"></span>
<hr>
<form class="layui-form">
<input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="班旗"/>
<p>
地址
</p>
<input type="text" name="address" class="layui-input"/>
<p>
车间
</p>
<div class="layui-form-item">
<div class="layui-form-item">
<select class="select" name="plantName">
<option value="领鸿">领鸿</option>
</select>
</div>
</div>
<p>
材质
</p>
<div class="layui-form-item">
<select name="ui_bq_name" id="ui_bq_name" lay-filter="ui_fb_name" class="select" lay-search>
<option value="1">旗帜布</option>
</select>
</div>
<p>
尺寸(CM/厘米)
</p>
<div class="layui-form-item ui_size">
<select name="size" id="ui_size" class="select">
<option value="96*64">96*64</option>
<option value="192*128">192*128</option>
<option value="144*96">144*96</option>
<option value="240*160">240*160</option>
<option value="288*192">288*192</option>
<option value="120*80">120*80</option>
</select>
</div>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="count" class="layui-input" id="count">
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
class="layui-input" lay-verify="number">
</div>
<p>
客户旺旺
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
class="layui-input">
</div>
<p>
工艺 <span style="font-size:14px;color:red">旗杆长度是2.5米</span>
</p>
<div class="layui-form-item">
<input type="radio" name="craftShua" value="单面印刷" title="单面印刷" lay-filter="craftShua" checked="checked">
<input type="radio" name="craftShua" value="双喷" title="双喷" lay-filter="craftShua">
<br/>
<input type="checkbox" name="craft" value="旗杆" title="旗杆" lay-filter="craft" checked="checked">
<input type="checkbox" name="craft" value="缝筒" title="缝筒" lay-filter="craft" checked="checked">
<div class="layui-inline ui_feb" style="display:none">
<select name="fb" class="select fb" lay-filter="fb">
<option value="1" selected>左缝筒</option>
<option value="2">右缝筒</option>
</select>
</div>
<%-- <input type="checkbox" name="craft" value="手绘" title="手绘" lay-filter="craft">--%>
</div>
<hr>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
//建造实例
ins = carousel.render({});
var html = " ";
var remark = " ";
// 清空轮播图
$("#carousel").empty();
$("#remark").empty();
$(".ui_feb").show();
$(".ui_feb select").attr("disabled", false);
$.ajax({
url: "${pageContext.request.contextPath}/getImgs",
type: "GET",
data: {
proTypeValue: $("#proTypeValue").val(),
kindValue: $('input[name="kindValue"]').val()
},
success: function (result) {
for (let i = 0; i < result.length; i++) {
// 只留一个remark
remark = "";
html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
remark += '<div><span>' + result[i].remark + '<span/></div>';
}
$("#carousel").append(html);
// 如果没有说明,就不显示null
if (remark.indexOf("null") < 0) {
$("#remark").append(remark);
}
// 如果没有轮播图就隐藏
if (result.length == 0) {
document.getElementById("test1").style.display = "none"; //隐藏
} else {
document.getElementById("test1").style.display = "block"; //显示
ins.reload({
elem: '#test1',
width: result[0].imgWidth, //设置容器宽度
height: result[0].imgHeight
});
}
}
});
form.on('checkbox(craft)', function (data) {
var craft = [];
$("input:checkbox[name='craft']:checked").each(function (i) {
// 没有被禁用的工艺加到arr中
if (!$(this).is(':disabled')) {
craft.push($(this).val());
}
});
if (craft.indexOf("缝筒") > -1) {
$(".ui_feb").show();
$(".ui_feb select").attr("disabled", false);
} else {
$(".ui_feb").hide();
$(".ui_feb select").attr("disabled", true);
}
form.render();
});
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var size = $("#size").val();
var count = $("#count").val();
var kind = $("#kindValue option:selected").text();
var craftShua = $("input[name='craftShua']:checked").val();
var craft = [];
$("input:checkbox[name='craft']:checked").each(function (i) {
// 没有被禁用的工艺加到arr中
if (!$(this).is(':disabled')) {
craft.push($(this).val());
}
});
$.ajax({
url: "${path}/getProductPrice",
type: "GET",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
var data = result.data.proList;
if ($("input[name='switchSize']:checked").val() == "on") {
size = $("#ui_zdy_size").val();
} else {
size = $("#ui_size option:selected").val();
}
var bq_name = $("#ui_bq_name option:selected").text();
if (craft != "") {
craftShua += ',' + craft;
}
var span_result = '班旗 - ' + bq_name + '-' + craftShua + '-' + size + ' CM (同款内容)\n';
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "条,共" + data[i].price + "元" + '\n'
data[i].number = number;
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
$("#span_result").val(span_result);
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'wangwang',
align: "center",
width: '16%',
title: '折扣价'
}, {
field: 'wangwang',
align: "center",
width: '19%',
title: '跳楼价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>
+357
View File
@@ -0,0 +1,357 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@include file="/views/common.jsp" %>
</head>
<body>
<div class="big_box">
<div class="left_div">
<h1 class="h1">帆布</h1> <span style="color:red;font-weight:700;"></span>
<hr>
<form class="layui-form">
<p>
地址
</p>
<input type="text" name="address" class="layui-input"/>
<p>
车间
</p>
<div class="layui-form-item">
<div class="layui-form-item">
<select class="select" name="plantName">
<option value="领鸿">领鸿</option>
</select>
</div>
</div>
<input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="帆布"/>
<div class="layui-form-item">
<input type="radio" lay-filter="stickerKind" name="stickerKind" value="常规" title="常规" checked="checked">
<input type="radio" lay-filter="stickerKind" name="stickerKind" value="套餐" title="套餐">
</div>
<p>
材质
</p>
<div class="layui-form-item">
<select name="ui_fb_name" id="ui_fb_name" lay-filter="ui_fb_name" class="select" lay-search>
<option value="1">露营布</option>
<option value="2">摆摊布</option>
</select>
</div>
<div class="ui_normal">
<p>
尺寸(CM/厘米) <span style="font-size:14px;color:red">输入格式: 长 * 宽 </span>
<input type="checkbox" name="switchSize" class="switchSizeCoupon" lay-filter="switchSizeCoupon"
title="自定义尺寸" lay-skin="primary">
</p>
<div class="layui-form-item ui_size">
<select name="size" id="ui_size" class="select">
<option value="100*45">100*45</option>
<option value="45*45">45*45</option>
</select>
</div>
<span class="ui_zdy_size" style="display:none">
<input type="text" id="ui_zdy_size" placeholder="格式:长*宽" class="layui-input" autocomplete="off">
</span>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="count" class="layui-input"
id="count">
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
class="layui-input" lay-verify="number">
</div>
</div>
<p>
客户旺旺
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
class="layui-input">
</div>
<p>
工艺<span style="font-size:14px;color:red">木棍长度50cm</span>
</p>
<div class="layui-form-item">
<input type="checkbox" name="craft" value="封边" title="封边" lay-filter="craft">
<div class="layui-inline ui_feb" style="width:100px;display:none">
<select name="fb" class="select fb" lay-filter="fb">
<option value="1" selected>上封边</option>
<option value="2">下封边</option>
<option value="3">左封边</option>
<option value="4">右封边</option>
<option value="5">上下封边</option>
<option value="6">左右封边</option>
</select>
</div>
<input type="checkbox" name="craft" value="四角打孔" title="四角打孔" lay-filter="craft">
<input type="checkbox" name="craft" value="净裁" title="净裁" lay-filter="craft">
<input type="checkbox" name="craft" value="吊耳" title="吊耳" lay-filter="craft">
<span class="ui_normal">
<input type="checkbox" name="craft" value="缝兜" title="缝兜" lay-filter="craft">
</span>
<input type="checkbox" name="craft" value="木棍" title="木棍" lay-filter="craft">
</div>
<hr>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
//建造实例
ins = carousel.render({});
var html = " ";
var remark = " ";
// 清空轮播图
$("#carousel").empty();
$("#remark").empty();
$.ajax({
url: "${pageContext.request.contextPath}/getImgs",
type: "GET",
data: {
proTypeValue: $("#proTypeValue").val(),
kindValue: $('input[name="kindValue"]').val()
},
success: function (result) {
for (let i = 0; i < result.length; i++) {
// 只留一个remark
remark = "";
html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
remark += '<div><span>' + result[i].remark + '<span/></div>';
}
$("#carousel").append(html);
// 如果没有说明,就不显示null
if (remark.indexOf("null") < 0) {
$("#remark").append(remark);
}
// 如果没有轮播图就隐藏
if (result.length == 0) {
document.getElementById("test1").style.display = "none"; //隐藏
} else {
document.getElementById("test1").style.display = "block"; //显示
ins.reload({
elem: '#test1',
width: result[0].imgWidth, //设置容器宽度
height: result[0].imgHeight
});
}
}
});
// 自定义尺寸
form.on('checkbox(switchSizeCoupon)', function (data) {
if (data.elem.checked) {
$('.switchSizeCoupon').val("on")
$(".ui_zdy_size").show();
$("#ui_zdy_size").attr("name", "size");
$(".ui_size").hide();
$("#ui_size").attr("name", "");
$(".ui_zdy_size").find(":input").attr("disabled", false);
$(".ui_size").find(":input").attr("disabled", true);
} else {
$('.switchSizeCoupon').val("off")
$(".ui_size").show();
$("#ui_size").attr("name", "size");
$(".ui_zdy_size").hide();
$("#ui_zdy_size").attr("name", "");
$(".ui_size").find(":input").attr("disabled", false);
$(".ui_zdy_size").find(":input").attr("disabled", true);
// 恢复标准数量的时候会被禁用,加这个解决
form.render();
}
});
form.on('checkbox(craft)', function (data) {
if ($("input[name='craft']:checked").val() == "封边") {
$(".ui_feb").show();
$(".ui_feb select").attr("disabled", false);
} else {
$(".ui_feb").hide();
$(".ui_feb select").attr("disabled", true);
}
form.render();
});
form.on('radio(stickerKind)', function (data) {
if (data.value == "常规") {
$(".ui_normal").show();
$(".ui_normal").find(":input").attr("disabled", false);
} else {
$(".ui_normal").hide();
$(".ui_normal").find(":input").attr("disabled", true);
}
form.render('radio');
});
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var size = $("#size").val();
var count = $("#count").val();
var kind = $("#kindValue option:selected").text();
var craft = $("input[name='craft']:checked").val();
var stickerKind = $("input[name='stickerKind']:checked").val();
if ($("input[name='switchSize']:checked").val() == "on") {
if ($("#ui_zdy_size").val().split("*")[0] < 25 || $("#ui_zdy_size").val().split("*")[1] < 25) {
layer.msg('帆布最小尺寸25*25cm', {offset: ['300px', '300px']}, function () {
});
return false;
}
if ($("#ui_zdy_size").val().split("*")[0] > 140 && $("#ui_zdy_size").val().split("*")[1] > 140) {
layer.msg('帆布尺寸超过140cm需要拼接!', {offset: ['300px', '300px']}, function () {
});
}
}
var craft = [];
$("input:checkbox[name='craft']:checked").each(function (i) {
// 没有被禁用的工艺加到arr中
if (!$(this).is(':disabled')) {
craft.push($(this).val());
}
});
if (stickerKind == "常规") {
if (!count) {
layer.msg('请填写数量!', {offset: ['300px', '300px']}, function () {
});
return false;
}
}
$.ajax({
url: "${path}/getProductPrice",
type: "GET",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
var data = result.data.proList;
if ($("input[name='switchSize']:checked").val() == "on") {
size = $("#ui_zdy_size").val();
} else {
size = $("#ui_size option:selected").val();
}
var fb_name = $("#ui_fb_name option:selected").text();
if (craft == "封边" || craft == "打孔") {
craft = craft + "绳子";
}
var span_result = '帆布 - ' + fb_name + '-' + craft + '-';
if (stickerKind == "套餐") {
span_result += "套餐" + data[0].price + "元\n150*60cm 2条\n130*60cm 2条\n";
} else {
span_result += size + ' CM (同款内容)\n';
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "条,共" + data[i].price + "元" + '\n'
data[i].number = number;
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
$("#span_result").val(span_result);
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'wangwang',
align: "center",
width: '16%',
title: '折扣价'
}, {
field: 'wangwang',
align: "center",
width: '19%',
title: '跳楼价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>
File diff suppressed because it is too large Load Diff
+476
View File
@@ -0,0 +1,476 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%@include file="/views/common.jsp" %>
</head>
<!-- 金属标 -->
<style>
</style>
<body>
<div class="big_box">
<div class="left_div">
<h1 class="h1">金属标</h1> <span style="color:red;font-weight:700;"></span>
<hr>
<form class="layui-form">
<input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="金属标">
<p>
地址
</p>
<input type="text" name="address" class="layui-input"/>
<p>
车间
</p>
<div class="layui-form-item">
<div class="layui-form-item">
<select class="select" name="plantName">
<option value="金大">金大</option>
<option value="鑫灿">鑫灿</option>
<option value="紫瑶">紫瑶</option>
</select>
</div>
</div>
<p>
产品种类
</p>
<div class="layui-form-item">
<input type="radio" lay-filter="kind" name="kind" value="金属标" title="金属标">
<%-- <input type="radio" lay-filter="kind" name="kind" value="UV转印贴" title="UV转印贴">--%>
</div>
<div class="metal">
<p>
颜色
</p>
<div class="layui-form-item">
<select id="color" lay-filter="color" class="select" name="tcolor">
<option value="金色">金色</option>
<option value="银色">银色</option>
<option value="蓝色">蓝色</option>
<option value="绿色">绿色</option>
<option value="红色">红色</option>
<option value="黑色">黑色</option>
<option value="橙色">橙色</option>
<option value="紫色">紫色</option>
<option value="玫红色">玫红色</option>
<option value="玫瑰金色">玫瑰金色</option>
</select>
</div>
<p>
印色
</p>
<div class="layui-form-item">
<input type="radio" name="craftMo" lay-filter="craftMo" value="单色" title="单色" checked="checked">
<input type="radio" name="craftMo" lay-filter="craftMo" value="双色" title="双色">
<input type="radio" name="craftMo" lay-filter="craftMo" value="彩色(三色)" title="彩色(三色)">
<input type="radio" name="craftMo" lay-filter="craftMo" value="彩色(四色)" title="彩色(四色)">
</div>
<p>
尺寸(CM/厘米) <span style="font-size:14px;color:red">输入格式: 长 * 宽</span>
</p>
<div class="layui-form-item">
<input type="text" placeholder="格式:长*宽" name="size" id="size" class="layui-input"
autocomplete="off">
</div>
<span style="color:red;font-weight:700;">金属标尺寸不能超过29*19 cm</span>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="count" class="layui-input"
id="count1">
</div>
</div>
<div class="UVSticker" style="display:none" id="UVSticker">
<p>
尺寸(CM/厘米) <span style="font-size:14px;color:red">输入格式: 长 * 宽</span>
</p>
<div class="layui-form-item">
<input type="text" placeholder="格式:长*宽" name="size" id="UVSize" class="layui-input"
autocomplete="off">
</div>
<%-- <span style="color:red;font-weight:700;">UV转印贴尺寸不能超过500*58cm,加工艺不能超过42*28.5cm</span>--%>
<span style="color:red;font-weight:700;">UV转印贴尺寸不能超过500*58cm</span>
<p>
数量(个)
</p>
<!-- <div class="count">
<div class="layui-form-item">
<select name="count" class="select">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="2000">2000</option>
<option value="5000">5000</option>
<option value="10000">10000</option>
</select>
</div>
</div> -->
<div class="layui-form-item">
<input type="text" name="count" id="count" placeholder="请输入整数" class="layui-input"
autocomplete="off">
</div>
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
class="layui-input" lay-verify="number">
</div>
<p>
客户旺旺
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
class="layui-input">
</div>
<div class="UVSticker" style="display:none">
<p>
工艺
</p>
<div class="layui-form-item">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="专金" title="专金"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="专银" title="专银"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="烫金" title="烫金"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="烫银" title="烫银"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="烫蓝" title="烫蓝"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="烫红" title="烫红"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="烫黑" title="烫黑"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="镭射银" title="镭射银"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="镭射金" title="镭射金"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="玫瑰金" title="玫瑰金"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="印刷+烫金" title="印刷+烫金"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="印刷+烫银" title="印刷+烫银"
class="craftZhuan">
<input type="checkbox" name="craft" lay-filter="craftZhuan" value="双面贴" title="双面贴"
class="craftZhuan">
</div>
<div class="layui-form-item">
<input type="radio" name="craftQie" calss="moqie" value="模切" lay-skin="primary" title="模切"
checked="checked">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<!--<h2>下单备注-<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult" onclick="copyBz()">点击复制</button></h2>
<div>
<textarea rows="5" cols="75" id="bz_result" readonly="readonly"></textarea>
</div>-->
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
function getProductImage() {
var html = " ";
var remark = " ";
let craft = $("input[name='craft']:checked").val();
let craftMo = $("input[name='craftMo']:checked").val();
let data = {
proTypeValue: $('input[name="kind"]:checked').val()
}
if (data.proTypeValue == '金属标' && (craftMo == '双色' || craftMo == '彩色(三色)')) {
data.craftValue = craftMo;
}
if (data.proTypeValue == 'UV转印贴') {
data.craftValue = craft;
}
// 清空轮播图
$("#carousel").empty();
$("#remark").empty();
$.ajax({
url: "${pageContext.request.contextPath}/getImgs",
type: "GET",
data,
success: function (result) {
for (let i = 0; i < result.length; i++) {
// 只留一个remark
remark = "";
html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
remark += '<div><span>' + result[i].remark + '<span/></div>';
}
$("#carousel").append(html);
// 如果没有说明,就不显示null
if (remark.indexOf("null") < 0) {
$("#remark").append(remark);
}
// 如果没有轮播图就隐藏
if (result.length == 0) {
document.getElementById("test1").style.display = "none"; //隐藏
} else {
document.getElementById("test1").style.display = "block"; //显示
ins.reload({
elem: '#test1',
width: result[0].imgWidth, //设置容器宽度
height: result[0].imgHeight
});
}
}
});
}
//建造实例
ins = carousel.render({});
form.on("radio(craftMo)", function (data) {
getProductImage()
})
form.on('radio(kind)', function (kindData) {
getProductImage()
if (kindData.value == "金属标") {
// 切换为品种单选框
$(".metal").show();
$(".metal").find(":input").attr("disabled", false);
$(".UVSticker").hide();
$(".UVSticker").find(":input").attr("disabled", true);
$(".diyCount").hide();
$(".count").hide();
$(".diyCount").find(":input").attr("disabled", true);
$(".count").find(":input").attr("disabled", true);
} else {
// 少数量、专版打印的时候,切换为品种下拉框
$(".UVSticker").show();
$(".UVSticker").find(":input").attr("disabled", false);
$(".count").show();
$(".count").find(":input").attr("disabled", false);
$(".metal").hide();
$(".metal").find(":input").attr("disabled", true);
}
form.render();//必须写
})
// 自定义数量
/* form.on('checkbox(switchCount)', function(data) {
if(data.elem.checked){
$(".diyCount").show();
$(".count").hide();
$(".diyCount").find(":input").attr("disabled", false);
$(".count").find(":input").attr("disabled", true);
} else {
$(".count").show();
$(".diyCount").hide();
$(".count").find(":input").attr("disabled", false);
$(".diyCount").find(":input").attr("disabled", true);
// 恢复标准数量的时候会被禁用,加这个解决
form.render();
}
}) */
form.on('checkbox(craftZhuan)', function (data) {
// 专金专银只能选一个
var craftZhuan = $(".craftZhuan:checked").length;
if (craftZhuan > 1) {
$(data.elem).next().attr("class", "layui-unselect layui-form-checkbox");
$(data.elem).prop("checked", false);
layer.msg('[专金 - 专银]不能同时选择!', {offset: ['300px', '300px']}, {icon: 5});
return false;
}
getProductImage()
})
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var kind = $('input[name="kind"]:checked').val()
var number = $("#number").val();
var craftMo = $("input[name='craftMo']:checked").val();
if (kind == '金属标') {
var size = $("#size").val();
var color = $("#color").val();
} else {
var size = $("#UVSize").val();
var craftMo = $('input[name="craftMo"]:checked').val();
var craftShua = [$('input[name="craft"]:checked').val()];
}
if (!kind) {
layer.msg("请选择产品种类!", {offset: ['300px', '300px']}, function () {
});
return false;
}
if (!size) {
layer.msg("请填写尺寸!", {offset: ['300px', '300px']}, function () {
});
return false;
}
// 选中‘自定义数量’
/* if($('input[name="switchCount"]:checked').length != 0){
if ($("#count").val() > 10) {
layer.msg("自定义数量只能填写十以内的整数",{offset:['300px','300px']},function(){});
return false;
}
} */
if (kind == '金属标') {
if ((size.split("*")[0] > 29 || size.split("*")[1] > 19) && (size.split("*")[0] > 19 || size.split("*")[1] > 29)) {
layer.msg("【金属标】尺寸不能超过29*19 cm", {offset: ['300px', '300px']}, function () {
});
return false;
}
} else {
if ((size.split("*")[0] > 500 || size.split("*")[1] > 58) && (size.split("*")[0] > 58 || size.split("*")[1] > 500)) {
layer.msg("【UV转印贴】尺寸不能超过500*58 cm", {offset: ['300px', '300px']}, function () {
});
return false;
}
if (craftShua != "" && craftShua != "双面贴" && (size.split("*")[0] > 42 || size.split("*")[1] > 28.5) && (size.split("*")[0] > 28.5 || size.split("*")[1] > 42)) {
layer.msg("【UV转印贴】带工艺尺寸不能超过42*28.5 cm", {offset: ['300px', '300px']}, function () {
});
return false;
}
}
$.ajax({
url: "${path}/getProductPrice",
type: "GET",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
var data = result.data.proList;
if (kind == '金属标') {
var span_result = '金属标 - ' + color + ' - ' + size + '厘米 -' + craftMo + '-(同款内容)\n';
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
} else {
var span_result = 'UV转印贴 - ' + craftShua + ' - ' + size + '厘米 -(同款内容) - ' + [data[0].msg] + '\n';
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
data[i].kindLabel = 'UV转印贴'
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
$("#span_result").val(span_result);
var craft = "";
var count = "";
var kindValue = "";
if ($("#UVSticker").css("display") == "none") {
count = $("#count1").val();
kindValue = color;
} else {
count = $("#count").val();
craft = "模切";
craft += craftShua;
}
getRemark(kind, size, count + "张", kindValue, number, craft, "");
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'wangwang',
align: "center",
width: '16%',
title: '折扣价'
}, {
field: 'wangwang',
align: "center",
width: '19%',
title: '跳楼价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>
File diff suppressed because it is too large Load Diff
+259
View File
@@ -0,0 +1,259 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@include file="/views/common.jsp" %>
</head>
<body>
<div class="big_box">
<div class="left_div">
<h1 class="h1">手拉旗</h1> <span style="color:red;font-weight:700;"></span>
<hr>
<form class="layui-form">
<input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="手拉旗"/>
<p>
地址
</p>
<input type="text" name="address" class="layui-input"/>
<p>
车间
</p>
<div class="layui-form-item">
<div class="layui-form-item">
<select class="select" name="plantName">
<option value="领鸿">领鸿</option>
</select>
</div>
</div>
<p>
材质
</p>
<div class="layui-form-item">
<select name="kindValue" id="kindValue" lay-filter="kindValue" class="select" lay-search>
<option value=""></option>
<option value="1">春亚布</option>
<option value="2">贡缎布</option>
</select>
</div>
<p>
宽度
</p>
<div class="layui-form-item">
<select name="width" id="width" class="select">
<option value="17">17cm</option>
<option value="24">24cm</option>
</select>
</div>
<p>
长度(CM/厘米)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入长度" name="size" id="size" class="layui-input" autocomplete="off">
</div>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="count" class="layui-input" id="count">
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
class="layui-input" lay-verify="number">
</div>
<p>
客户旺旺
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
class="layui-input">
</div>
<hr>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
//建造实例
ins = carousel.render({});
var html = " ";
var remark = " ";
// 清空轮播图
$("#carousel").empty();
$("#remark").empty();
$.ajax({
url: "${pageContext.request.contextPath}/getImgs",
type: "GET",
data: {
proTypeValue: $("#proTypeValue").val(),
},
success: function (result) {
for (let i = 0; i < result.length; i++) {
// 只留一个remark
remark = "";
html += '<div><img style="width:' + result[0].imgWidth + 'px" src="' + result[i].imgUrl + '"></div>';
remark += '<div><span>' + result[i].remark + '<span/></div>';
}
$("#carousel").append(html);
// 如果没有说明,就不显示null
if (remark.indexOf("null") < 0) {
$("#remark").append(remark);
}
// 如果没有轮播图就隐藏
if (result.length == 0) {
document.getElementById("test1").style.display = "none"; //隐藏
} else {
document.getElementById("test1").style.display = "block"; //显示
ins.reload({
elem: '#test1',
width: result[0].imgWidth, //设置容器宽度
height: result[0].imgHeight
});
}
}
});
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var length = $("#size").val();
var width = $("#width option:selected").val();
var count = $("#count").val();
var kind = $("#kindValue option:selected").text();
var craft = $("input[name='craft']:checked").val();
if (!length) {
layer.msg('请填写长度!', {offset: ['300px', '300px']}, function () {
});
return false;
}
if (length > 100) {
layer.msg('最大长度100cm', {offset: ['300px', '300px']}, function () {
});
return false;
}
if (!count) {
layer.msg('请填写数量!', {offset: ['300px', '300px']}, function () {
});
return false;
}
$.ajax({
url: "${path}/getProductPrice",
type: "GET",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
var data = result.data.proList;
if ((length == 70 && width == 24) || (length == 50 && width == 17)) {
kind += "(特价)";
}
var span_result = '手拉旗 - ' + kind + '-' + length + '*' + width + ' CM (同款内容)\n';
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
$("#span_result").val(span_result);
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'wangwang',
align: "center",
width: '16%',
title: '折扣价'
}, {
field: 'wangwang',
align: "center",
width: '19%',
title: '跳楼价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>
File diff suppressed because it is too large Load Diff