新增弹弹乐

This commit is contained in:
2026-08-01 16:59:22 +08:00
parent 0442428487
commit c95d699292
2 changed files with 402 additions and 0 deletions
@@ -4454,12 +4454,112 @@ public class ProductService {
case "吧唧徽章": case "吧唧徽章":
priceList = getBiteBadgePrice(dto, width, length, height); priceList = getBiteBadgePrice(dto, width, length, height);
return chucklePrice(role, priceList, dto); return chucklePrice(role, priceList, dto);
case "弹弹乐":
priceList = getPianoMusicPrice(dto, width, length, height);
return chucklePrice(role, priceList, dto);
default: default:
break; break;
} }
return null; return null;
} }
private List<Product> getPianoMusicPrice(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 area = width * length;
int[] counts = {1, 5, 10, 20, 30, 50, 100, 200, 500, 1000, 3000, 5000, 10000, 30000, 50000, 100000};
double[] areas = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600};
double[][] prices_area = {
{30.00, 5.65, 3.00, 1.70, 1.60, 1.50, 1.40, 1.35, 1.30, 1.30, 1.25, 1.25, 1.20, 1.20, 1.20, 1.15},
{30.00, 5.65, 3.00, 1.90, 1.80, 1.70, 1.60, 1.50, 1.45, 1.45, 1.40, 1.40, 1.35, 1.35, 1.30, 1.25},
{30.00, 5.65, 3.00, 2.20, 2.10, 1.95, 1.85, 1.75, 1.70, 1.65, 1.65, 1.60, 1.55, 1.55, 1.50, 1.45},
{30.00, 5.65, 3.00, 2.60, 2.50, 2.35, 2.20, 2.10, 2.00, 2.00, 1.95, 1.90, 1.90, 1.85, 1.80, 1.75},
{30.00, 5.65, 3.60, 3.15, 3.00, 2.80, 2.65, 2.55, 2.45, 2.40, 2.35, 2.30, 2.25, 2.25, 2.20, 2.10},
{30.00, 5.65, 4.35, 3.85, 3.65, 3.40, 3.20, 3.05, 2.95, 2.90, 2.85, 2.80, 2.75, 2.70, 2.65, 2.55},
{30.00, 5.75, 5.30, 4.60, 4.40, 4.10, 3.85, 3.70, 3.55, 3.50, 3.45, 3.35, 3.30, 3.25, 3.20, 3.10},
{30.00, 6.90, 6.30, 5.55, 5.25, 4.90, 4.60, 4.45, 4.25, 4.20, 4.10, 4.05, 3.95, 3.90, 3.80, 3.70},
{30.00, 8.20, 7.50, 6.55, 6.25, 5.85, 5.50, 5.25, 5.05, 4.95, 4.85, 4.80, 4.70, 4.60, 4.55, 4.40},
{30.00, 9.65, 8.80, 7.70, 7.35, 6.85, 6.45, 6.20, 5.95, 5.85, 5.70, 5.60, 5.50, 5.40, 5.35, 5.15},
{30.00, 11.25, 10.30, 9.00, 8.55, 8.00, 7.50, 7.20, 6.95, 6.80, 6.65, 6.55, 6.45, 6.30, 6.20, 6.00},
{30.00, 13.00, 11.90, 10.40, 9.90, 9.25, 8.65, 8.30, 8.00, 7.85, 7.70, 7.55, 7.45, 7.30, 7.20, 6.95},
{30.00, 14.90, 13.60, 11.90, 11.35, 10.60, 9.95, 9.55, 9.15, 9.00, 8.85, 8.65, 8.50, 8.35, 8.20, 7.95},
{30.00, 16.95, 15.50, 13.55, 12.90, 12.05, 11.30, 10.85, 10.45, 10.25, 10.05, 9.85, 9.70, 9.50, 9.35, 9.05},
{30.00, 19.15, 17.50, 15.30, 14.60, 13.60, 12.75, 12.25, 11.80, 11.55, 11.35, 11.15, 10.95, 10.75, 10.55, 10.20},
{30.00, 21.50, 19.65, 17.20, 16.40, 15.30, 14.35, 13.75, 13.25, 13.00, 12.75, 12.50, 12.30, 12.10, 11.85, 11.50},
{30.00, 24.00, 21.95, 19.20, 18.30, 17.05, 16.00, 15.35, 14.80, 14.50, 14.25, 13.95, 13.75, 13.50, 13.25, 12.80},
{30.00, 26.65, 24.40, 21.35, 20.30, 18.95, 17.80, 17.05, 16.40, 16.10, 15.80, 15.50, 15.25, 15.00, 14.70, 14.25},
{31.45, 29.45, 26.95, 23.60, 22.45, 20.95, 19.65, 18.85, 18.15, 17.80, 17.45, 17.15, 16.85, 16.55, 16.25, 15.75},
{34.60, 32.45, 29.65, 25.95, 24.70, 23.05, 21.65, 20.75, 19.95, 19.60, 19.25, 18.90, 18.55, 18.20, 17.90, 17.30},
{37.90, 35.55, 32.50, 28.45, 27.10, 25.30, 23.70, 22.75, 21.90, 21.45, 21.10, 20.70, 20.30, 19.95, 19.60, 18.95},
{41.40, 38.80, 35.50, 31.05, 29.60, 27.60, 25.90, 24.85, 23.90, 23.45, 23.00, 22.60, 22.20, 21.80, 21.45, 20.70},
{45.05, 42.25, 38.60, 33.80, 32.20, 30.05, 28.15, 27.05, 26.00, 25.50, 25.05, 24.60, 24.15, 23.70, 23.30, 22.55},
{48.85, 45.80, 41.90, 36.65, 34.90, 32.60, 30.55, 29.30, 28.20, 27.65, 27.15, 26.65, 26.20, 25.70, 25.30, 24.45},
{52.85, 49.55, 45.30, 39.65, 37.75, 35.25, 33.05, 31.70, 30.50, 29.90, 29.35, 28.85, 28.30, 27.80, 27.35, 26.45},
{56.95, 53.40, 48.80, 42.70, 40.70, 38.00, 35.60, 34.20, 32.85, 32.25, 31.65, 31.10, 30.50, 30.00, 29.45, 28.50},
{61.25, 57.45, 52.50, 45.95, 43.75, 40.85, 38.30, 36.75, 35.35, 34.70, 34.05, 33.40, 32.85, 32.25, 31.70, 30.65},
{65.70, 61.60, 56.35, 49.30, 46.95, 43.80, 41.10, 39.45, 37.90, 37.20, 36.50, 35.85, 35.20, 34.60, 34.00, 32.85},
{70.35, 65.95, 60.30, 52.75, 50.25, 46.90, 43.95, 42.20, 40.60, 39.80, 39.10, 38.35, 37.70, 37.05, 36.40, 35.20},
{75.10, 70.40, 64.40, 56.35, 53.65, 50.10, 46.95, 45.05, 43.35, 42.50, 41.75, 41.00, 40.25, 39.55, 38.85, 37.55},
{80.05, 75.05, 68.60, 60.05, 57.20, 53.40, 50.05, 48.05, 46.20, 45.30, 44.50, 43.70, 42.90, 42.15, 41.40, 40.05},
{85.15, 79.85, 73.00, 63.85, 60.85, 56.80, 53.25, 51.10, 49.15, 48.20, 47.30, 46.45, 45.65, 44.85, 44.05, 42.60},
{90.40, 84.75, 77.50, 67.80, 64.60, 60.30, 56.50, 54.25, 52.20, 51.20, 50.25, 49.35, 48.45, 47.60, 46.80, 45.20},
{95.85, 89.85, 82.15, 71.90, 68.45, 63.90, 59.90, 57.50, 55.30, 54.25, 53.25, 52.30, 51.35, 50.45, 49.60, 47.95},
{101.45, 95.10, 86.95, 76.10, 72.45, 67.65, 63.40, 60.90, 58.55, 57.45, 56.35, 55.35, 54.35, 53.40, 52.50, 50.75},
{107.20, 100.50, 91.90, 80.40, 76.60, 71.45, 67.00, 64.35, 61.85, 60.70, 59.55, 58.50, 57.45, 56.45, 55.45, 53.60},
{113.10, 106.05, 96.95, 84.85, 80.80, 75.40, 70.70, 67.90, 65.25, 64.05, 62.85, 61.70, 60.60, 59.55, 58.50, 56.55},
{119.20, 111.75, 102.15, 89.40, 85.15, 79.45, 74.50, 71.50, 68.75, 67.50, 66.25, 65.00, 63.85, 62.75, 61.65, 59.60},
{125.45, 117.60, 107.50, 94.10, 89.60, 83.65, 78.40, 75.25, 72.35, 71.00, 69.70, 68.45, 67.20, 66.05, 64.90, 62.75},
{131.85, 123.60, 113.00, 98.90, 94.15, 87.90, 82.40, 79.10, 76.05, 74.65, 73.25, 71.90, 70.65, 69.40, 68.20, 65.95},
};
int area_index = 0;
for (int i = 0; i < areas.length; i++) {
if (area <= areas[i]) {
area_index = i;
break;
}
}
double base_price = 0;
for (int i = 0; i < counts.length; i++) {
if (priceList.size() > 2) {
break;
}
int item_count = counts[i];
if (item_count < count) {
continue;
}
double price = 0;
if (priceList.size() == 0) {
if (count != item_count) {
price = new PriceUtils().TableCountCenterPrice(count, prices_area[area_index], counts);
Product pro = new Product();
pro.setCount(count);
pro.setPrice(Math.max(Math.ceil(price * count), 30));
priceList.add(pro);
}
}
price = new PriceUtils().TableCountCenterPrice(item_count, prices_area[area_index], counts);
Product pro = new Product();
pro.setCount(item_count);
pro.setPrice(Math.max(Math.ceil(price * item_count), 30));
priceList.add(pro);
}
if (priceList.size() == 0) {
Product pro = new Product();
pro.setCount(count);
pro.setPrice(Math.ceil(prices_area[area_index][prices_area[area_index].length - 1] / counts[counts.length - 1] * count));
priceList.add(pro);
}
for (Product product : priceList) {
product.setPrice(Math.ceil(product.getPrice() * number));
}
return priceList;
}
private List<Product> getBiteBadgePrice(Product dto, Double width, Double length, Double height) { 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<String> craft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>(); List<Product> priceList = new ArrayList<>();
@@ -0,0 +1,302 @@
<%@ 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>
尺寸(CM/厘米)
</p>
<div class="layui-form-item" id="ui_size">
<input type="text" name="size" id="size" placeholder="请输入格式:长*宽" class="layui-input" autocomplete="off">
</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="带透明边">
</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;
}
form.render();
})
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var size = $("#size").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;
}
if ((size.split("*")[0] < 1 || size.split("*")[1] < 1)) {
layer.msg("尺寸不能小于1*1 cm", {offset: ['300px', '300px']}, function () {
});
return false;
}
if ((size.split("*")[0] > 40 || size.split("*")[1] > 40)) {
layer.msg("尺寸不能超过40*40 cm", {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());
}
}
});
$.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>