新增呱唧徽章

This commit is contained in:
2026-08-01 15:12:06 +08:00
parent 454c0ec1d7
commit 0442428487
2 changed files with 457 additions and 38 deletions
@@ -4451,12 +4451,99 @@ public class ProductService {
case "无纺布手提袋":
priceList = getNonwovensPrice(dto, width, length, height);
return chucklePrice(role, priceList, dto);
case "吧唧徽章":
priceList = getBiteBadgePrice(dto, width, length, height);
return chucklePrice(role, priceList, dto);
default:
break;
}
return null;
}
private List<Product> getBiteBadgePrice(Product dto, Double width, Double length, Double height) {
List<String> craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();
int count = dto.getCount();
int number = dto.getNumber();
double[] prices = {};
List<String> list1 = Arrays.asList("白底", "拉丝银", "镭射素面银", "玻璃碎", "镭射乱线", "镭射小米点银", "镭射马赛克", "镭射银丝", "闪粉色");
List<String> list2 = Arrays.asList("白瓷", "白葱", "七彩白");
if (craft_list.contains("磁吸")) {
prices = new double[]{30.00, 5.65, 4.75, 4.15, 3.70, 3.45, 3.35, 3.20, 3.15, 3.10, 3.05, 3.00, 2.95, 2.90, 2.80};
if (list1.contains(dto.getKind2Value())) {
prices = new double[]{30.00, 5.65, 3.95, 3.50, 3.10, 2.90, 2.80, 2.70, 2.65, 2.60, 2.55, 2.50, 2.45, 2.40, 2.35};
}
if (list2.contains(dto.getKind2Value())) {
prices = new double[]{30.00, 6.00, 5.50, 4.85, 4.30, 4.05, 3.90, 3.75, 3.65, 3.60, 3.55, 3.45, 3.40, 3.35, 3.25};
}
} else {
double[][] prices_area = {
{30.00, 5.65, 3.75, 3.30, 2.90, 2.75, 2.65, 2.55, 2.50, 2.45, 2.40, 2.35, 2.30, 2.25, 2.20},
{30.00, 5.65, 4.25, 3.75, 3.30, 3.10, 3.00, 2.90, 2.85, 2.75, 2.70, 2.70, 2.65, 2.60, 2.50},
{30.00, 5.65, 4.45, 3.90, 3.50, 3.25, 3.15, 3.00, 2.95, 2.90, 2.85, 2.80, 2.75, 2.70, 2.60}
};
int currentIndex = 0;
if (width == 5.8 && length == 5.8) {
currentIndex = 0;
}
if (width == 7.5 && length == 7.5) {
currentIndex = 1;
}
if (width == 5 && length == 5) {
currentIndex = 2;
}
if (list1.contains(dto.getKind2Value())) {
prices_area = new double[][]{
{30.00, 5.65, 2.95, 2.60, 2.30, 2.20, 2.10, 2.00, 2.00, 1.95, 1.90, 1.85, 1.85, 1.80, 1.75},
{30.00, 5.65, 3.50, 3.05, 2.70, 2.55, 2.45, 2.35, 2.30, 2.25, 2.25, 2.20, 2.15, 2.10, 2.05},
{30.00, 5.65, 3.70, 3.25, 2.90, 2.70, 2.60, 2.50, 2.45, 2.40, 2.35, 2.30, 2.30, 2.25, 2.15}
};
}
if (list2.contains(dto.getKind2Value())) {
prices_area = new double[][]{
{30.00, 5.65, 4.50, 3.95, 3.50, 3.30, 3.15, 3.05, 3.00, 2.95, 2.90, 2.85, 2.80, 2.75, 2.65},
{30.00, 5.65, 5.00, 4.40, 3.90, 3.70, 3.55, 3.40, 3.35, 3.25, 3.20, 3.15, 3.10, 3.05, 2.95},
{30.00, 5.65, 5.20, 4.60, 4.10, 3.85, 3.70, 3.55, 3.45, 3.40, 3.35, 3.30, 3.25, 3.15, 3.05}
};
}
prices = prices_area[currentIndex];
}
int[] end_counts = {1, 5, 10, 20, 50, 100, 200, 500, 1000, 3000, 5000, 10000, 30000, 50000, 100000};
int[] start_counts = {1, 1, 5, 10, 20, 50, 100, 200, 500, 1000, 3000, 5000, 10000, 30000, 50000};
double[] low_price = prices;
double[] height_price = new double[prices.length];
height_price[0] = prices[0]; // 第一个
height_price[1] = prices[0]; // 再次添加到第一位
System.arraycopy(prices, 1, height_price, 2, prices.length - 2); // 复制原数组索引1~倒数第2个
double basePrice = 0;
if (count > end_counts[end_counts.length - 1]) {
basePrice = low_price[low_price.length - 1] * count;
} else {
// 查找匹配的区间
for (int i = 0; i < end_counts.length; i++) {
if (count <= end_counts[i]) {
int startN = start_counts[i];
int endN = end_counts[i];
double highPrice = height_price[i];
double lowPrice = low_price[i];
basePrice = new PriceUtils().calcByTargetN(startN, highPrice, endN, lowPrice, count);
break;
}
}
}
double designPrice = 0;
Product product = new Product();
product.setPrice(Math.ceil(Math.max(basePrice, 30) * number + designPrice));
product.setCount(dto.getCount());
product.setNumber(dto.getNumber());
priceList.add(product);
return priceList;
}
private List<Product> getNonwovensPrice(Product dto, Double width, Double length, Double height) {
List<String> craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();
@@ -6048,49 +6135,45 @@ public class ProductService {
requstVo.setCrafts(craft);
if ("18".equals(dto.getKindValue())) {
requstVo.setNum(base_count);
// rate_list = new double[]{0.70, 0.68, 0.65, 0.62, 0.58};
// counts = new int[]{50, 100, 200, 500, 1000};
// maxRate = 0.55;
rate_list = new double[]{0.7, 0.66, 0.62, 0.58, 0.54, 0.50, 0.45};
counts = new int[]{20, 50, 100, 200, 300, 500, 1000};
maxRate = 0.4;
if (count > 10) {
count = (int) (Math.ceil(count / 10.0) * 10);
}
}
if ("19".equals(dto.getKindValue()) || "20".equals(dto.getKindValue())) {
rate_list = new double[]{0.75, 0.7, 0.6986, 0.6497, 0.6198, 0.5899, 0.5499, 0.4799};
counts = new int[]{75, 200, 500, 1000, 2000, 3000, 5000, 10000};
maxRate = 0.4;
if (count > 10) {
count = (int) (Math.ceil(count / 100.0) * 100);
}
requstVo.setNum(count);
}
ShengDaPriceResultVo result = ShengDaPriceUtils.getPrice(requstVo);
double price = 0;
if ("18".equals(dto.getKindValue()) || "19".equals(dto.getKindValue()) || "20".equals(dto.getKindValue())) {
double rate_item = 1;
if (count <= 100) {
rate_item = 0.95;
} else if (count <= 200) {
rate_item = 0.93;
} else if (count <= 500) {
rate_item = 0.90;
} else if (count <= 1000) {
rate_item = 0.88;
} else if (count <= 2000) {
rate_item = 0.85;
} else if (count <= 5000) {
rate_item = 0.8;
} else {
rate_item = 0.75;
for (int i = 0; i < counts.length; i++) {
if (counts[i] < count) {
continue;
}
if ("18".equals(dto.getKindValue()) && count < 10) {
price = 150;
} else if ("19".equals(dto.getKindValue()) || "20".equals(dto.getKindValue())) {
price = Math.ceil(result.getData().getPrice() / (1 - 0.6));
} else {
price = Math.ceil(result.getData().getPrice() / (1 - 0.7) / base_count * count * rate_item);
}
} else {
for (int i = 0; i < counts.length; i++) {
if (counts[i] < count) {
continue;
}
base_rate = rate_list[i];
break;
}
if (base_rate == 0) {
base_rate = maxRate;
}
price = Math.ceil(result.getData().getPrice() / (1 - base_rate));
base_rate = rate_list[i];
break;
}
if (base_rate == 0) {
base_rate = maxRate;
}
if ("18".equals(dto.getKindValue()) && count < 10) {
price = 150;
} else if ("18".equals(dto.getKindValue())) {
price = Math.ceil(result.getData().getPrice() / base_count * count / (1 - base_rate));
} else {
price = Math.ceil(result.getData().getPrice() / (1 - base_rate));
}
// }
double designPrice = (number - 1) * 8;
Product product = new Product();
+336
View File
@@ -0,0 +1,336 @@
<%@ 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>
<style>
#z4_craft .layui-form-select .layui-edge {
right: 20px;
}
</style>
<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>
<div class="layui-form-item">
<select name="kind" class="select" lay-search lay-filter="kind">
<option value="吧唧徽章">吧唧徽章</option>
</select>
</div>
<p>
颜色
</p>
<div class="layui-form-item">
<select name="kind2Value" class="select" lay-search lay-filter="kind">
<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>
<option value="高闪白">高闪白</option>
<option value="白葱">白葱</option>
<option value="七彩白">七彩白</option>
</select>
</div>
<p>
尺寸(CM/厘米)
</p>
<div class="layui-form-item" id="ui_size">
<select name="size" class="layui-form-select">
<option value="5.8*5.8">5.8*5.8CM</option>
<option value="7.5*7.5">7.5*7.5CM</option>
<option value="5*5">5*5CM</option>
</select>
</div>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" name="count" id="diyCount" placeholder="请输入整数" class="layui-input" autocomplete="off">
</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>
工艺
</p>
<div class="layui-form-item" id='z4_craft'>
<div class="layui-input-block ">
印面:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="单面" title="单面" checked>
</div>
<div class="layui-input-block ">
常见工艺:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="别针" title="别针" checked>
<input type="checkbox" name="craft" lay-filter="ui_craft" value="磁吸" title="磁吸">
</div>
</div>
<div class="layui-input-block">
<input type="checkbox" name="craft" lay-filter="ui_craft" value="抠图" title="抠图">
<div class="layui-inline crop" style="display:none;width: 80px">
<input class="layui-input" type="text" name="cropNumber">
</div>
</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:100%;height: 100%;object-fit: contain" 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(ui_craft)', function (data) {
let craft_list = [];
$("input[name='craft']:checked").each(function () {
if (!$(this).is(':disabled')) {
craft_list.push($(this).val());
}
}
);
if (!craft_list.includes("单面")) {
$(data.elem).prop("checked", true);
layer.msg("印面工艺不能取消选择", {offset: ['300px', '300px']}, function () {
});
form.render();
return false;
}
let size = $("select[name='size'] option:selected").val();
if (size != '5.8*5.8' && craft_list.includes("磁吸")) {
$(data.elem).prop("checked", false);
layer.msg("5.8*5.8才能选择磁吸工艺不能同时选择", {offset: ['300px', '300px']}, function () {
});
form.render();
return false;
}
const carft_list1 = ["别针", "磁吸"];
const carft1 = carft_list1.filter(craft => craft_list.includes(craft));
if (carft1.length > 1) {
$(data.elem).prop("checked", false);
layer.msg("别针-磁吸不能同时选择", {offset: ['300px', '300px']}, function () {
});
form.render();
return false;
}
form.render();
})
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var size = $("select[name='size'] option:selected").val();
var count = $("#diyCount").val();
var kind = $("select[name='kind'] option:selected").text();
var kindValue = $("select[name='kindValue'] option:selected").text();
var craft = [];
if (size == "") {
layer.msg('请填写尺寸!', {offset: ['300px', '300px']}, function () {
});
return false;
}
$("input:checkbox[name='craft']:checked").each(function (i) {
// 没有被禁用的工艺加到arr中
if (!$(this).is(':disabled')) {
if ($(this).val() == "抠图") {
craft.push($(this).val() + $("input[name='cropNumber']").val());
return;
} else {
craft.push($(this).val());
}
}
});
let material = $("select[name='kind2Value'] option:selected").val();
craft.push(material);
$.ajax({
url: "${path}/getThanSum",
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;
var span_result = '吧唧徽章 - ' + size + ' cm (同款内容)\n';
span_result += `工艺:` + craft.join(",") + '\n';
if (number > 1) {
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
}
} else {
for (let i = 0; i < data.length; i++) {
span_result += number + '款 ' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
if (window.parent.system_isGai) {
span_result += "\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!"
}
addLog(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>