fix(order): 修复订单金额计算和显示问题
- 在 add.html 和 edit.html 中将订单金额输入框设置为只读,防止直接修改 - 添加 setOrderPriceData 函数用于计算和更新订单金额 - 在产品列表中添加计算订单总金额的逻辑 - 更新订单信息时自动计算和设置订单金额master
parent
c968dc1d9b
commit
e6bd2b80d1
|
@ -112,7 +112,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
function getAllPriceData(){
|
||||
function setOrderPriceData(){
|
||||
let allPrice=0.00;
|
||||
$('#productTable tbody').find('tr').find('.allPrice').each(function (index) {
|
||||
allPrice+=parseFloat($(this).val())
|
||||
|
@ -123,8 +123,11 @@
|
|||
$('#productTable3 tbody').find('tr').find('.allPrice').each(function (index) {
|
||||
allPrice+=parseFloat($(this).val())
|
||||
})
|
||||
console.log(`allPrice=${allPrice}`)
|
||||
console.log('allPrice='+allPrice)
|
||||
let shipmentAmount = $('#shipmentAmount');
|
||||
if (shipmentAmount){
|
||||
shipmentAmount.val(allPrice)
|
||||
$('#displayshipmentAmount').val(formatAmountNumber(allPrice))
|
||||
}
|
||||
}
|
||||
function addProduct(data) {
|
||||
let length = $('#productTable tbody').find('tr').length
|
||||
|
@ -223,10 +226,7 @@
|
|||
let flag=true
|
||||
console.log(data)
|
||||
if (data){
|
||||
console.log(data)
|
||||
|
||||
flag =! updatePriceProductList.filter(item=>item===data.productBomCode).length>0;
|
||||
console.log(flag)
|
||||
}
|
||||
|
||||
let tr = $(`
|
||||
|
@ -288,6 +288,7 @@
|
|||
$(this).parent().parent().find('.catalogueAllPrice').val((num * cateVal).toFixed(2))
|
||||
$(this).parent().parent().find('.catalogueAllPrice-formmat').val(formatAmountNumber((num * cateVal).toFixed(2)))
|
||||
}
|
||||
setOrderPriceData()
|
||||
})
|
||||
$('.productTable .catalogue-price-format').on('input', function () {
|
||||
let val = $(this).val()
|
||||
|
@ -308,7 +309,7 @@
|
|||
$(this).parent().parent().find('.catalogueAllPrice').val((val * quantity).toFixed(2))
|
||||
$(this).parent().parent().find('.catalogueAllPrice-formmat').val(formatAmountNumber((val * quantity).toFixed(2)))
|
||||
}
|
||||
|
||||
setOrderPriceData()
|
||||
})
|
||||
$('.productTable .guidance-discount-format').on('input', function () {
|
||||
let val = $(this).val()
|
||||
|
@ -323,6 +324,7 @@
|
|||
// $(this).parent().parent().find('.allPrice').val((price * quantity).toFixed(2))
|
||||
// $(this).parent().parent().find('.allPrice-formmat').val(Number((price * quantity).toFixed(2)).toLocaleString("en-US"))
|
||||
// }
|
||||
setOrderPriceData()
|
||||
})
|
||||
$('.productTable .discount-format').on('change', function () {
|
||||
let percentageDiscount = $(this).val()
|
||||
|
@ -336,6 +338,7 @@
|
|||
$(this).parent().parent().parent().find('.allPrice').val((price * num).toFixed(2))
|
||||
let allPrice = $(this).parent().parent().parent().find('.allPrice').val()
|
||||
$(this).parent().parent().parent().find('.allPrice-formmat').val(formatAmountNumber(allPrice))
|
||||
setOrderPriceData()
|
||||
})
|
||||
$('.productTable .price-formmat').change('input', function () {
|
||||
let val = $(this).val()
|
||||
|
@ -349,6 +352,7 @@
|
|||
let discount = (val*1.0000/cataloguePrice).toFixed(4);
|
||||
$(this).parent().parent().find('.discount').val(discount)
|
||||
$(this).parent().parent().find('.discount-format').val(discount * 100)
|
||||
setOrderPriceData()
|
||||
// $(this).val(formatAmountNumber(val))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
<td class="shortTd">订单金额<span class="is-required">*</span></td>
|
||||
<td>
|
||||
<input id="shipmentAmount" name="shipmentAmount" class="form-control" type="hidden" >
|
||||
<input type="text" required id="displayshipmentAmount" class="form-control" placeholder="输入金额"
|
||||
<input type="text" readonly required id="displayshipmentAmount" class="form-control" placeholder="输入金额"
|
||||
oninput="this.value = this.value.replace(/[^0-9.]/g,'').replace(/(\..*)\./g, '$1');"
|
||||
onfocus="this.value=document.getElementById('shipmentAmount').value"
|
||||
onblur="updateShipmentAmountValue('shipmentAmount')" >
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
<td class="shortTd">订单金额<span class="is-required">*</span></td>
|
||||
<td><input name="shipmentAmount" id="shipmentAmount" th:field="*{shipmentAmount}" class="form-control" type="hidden"
|
||||
>
|
||||
<input type="text" required id="displayshipmentAmount" class="form-control" placeholder="输入金额"
|
||||
<input type="text" readonly required id="displayshipmentAmount" class="form-control" placeholder="输入金额"
|
||||
oninput="this.value = this.value.replace(/[^0-9.]/g,'').replace(/(\..*)\./g, '$1');"
|
||||
onfocus="this.value=document.getElementById('shipmentAmount').value"
|
||||
onblur="updateShipmentAmountValue('shipmentAmount')" >
|
||||
|
@ -447,6 +447,7 @@
|
|||
|
||||
$(function () {
|
||||
let shipmentAmount = [[${projectOrderInfo.shipmentAmount}]] || ''
|
||||
|
||||
if (shipmentAmount) {
|
||||
document.getElementById('displayshipmentAmount').value=formatAmountNumber(shipmentAmount);
|
||||
}
|
||||
|
@ -815,7 +816,9 @@ ${
|
|||
addProduct3(ele)
|
||||
}) : '';
|
||||
window.localStorage.removeItem('getDetail')
|
||||
|
||||
if (!$('#shipmentAmount').val()) {
|
||||
setOrderPriceData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -228,9 +228,9 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
|
|||
projectInfo.setCompetitor(projectInfo.getCompetitorList().stream().filter(StringUtils::isNotEmpty).collect(Collectors.joining(",")));
|
||||
}
|
||||
//变更属地校验
|
||||
List<ProjectOrderInfo> projectOrderInfos = orderInfoService.selectProjectOrderInfoByProjectId(Collections.singletonList(projectInfo.getId()));
|
||||
if (!projectInfo.getAgentCode().equals(oldProjectInfo.getAgentCode())) {
|
||||
//查询订单信息 如果有抛出异常
|
||||
List<ProjectOrderInfo> projectOrderInfos = orderInfoService.selectProjectOrderInfoByProjectId(Collections.singletonList(projectInfo.getId()));
|
||||
if (CollUtil.isNotEmpty(projectOrderInfos)) {
|
||||
throw new ServiceException("该项目存在订单流转,无法更改代表处");
|
||||
}
|
||||
|
@ -245,6 +245,13 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
|
|||
saveOtherInfo(projectInfo);
|
||||
// 记录操作日志
|
||||
recordOperationLogs(projectInfo, oldProjectInfo);
|
||||
if (CollUtil.isNotEmpty(projectOrderInfos)){
|
||||
ProjectOrderInfo projectOrderInfo = projectOrderInfos.get(0);
|
||||
ProjectOrderInfo update = new ProjectOrderInfo();
|
||||
update.setId(projectOrderInfo.getId());
|
||||
update.setProjectId(projectOrderInfo.getProjectId());
|
||||
orderInfoService.updateProjectOrderInfo(update);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,9 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
projectOrderInfo.setCreateTime(DateUtils.getNowDate());
|
||||
projectOrderInfo.setCreateBy(ShiroUtils.getUserId().toString());
|
||||
saveProductInfo(projectOrderInfo, projectOrderInfo.getProjectId());
|
||||
List<ProjectProductInfo> projectProductInfos = productInfoService.selectProjectProductInfoListByProjectId(Collections.singletonList(projectOrderInfo.getProjectId()));
|
||||
BigDecimal bigDecimal = projectProductInfos.stream().map(ProjectProductInfo::getAllPrice).filter(Objects::nonNull).reduce(BigDecimal::add).get();
|
||||
projectOrderInfo.setShipmentAmount(bigDecimal);
|
||||
List<ProjectOrderFileLog> contractFileList = projectOrderInfo.getContractFileList();
|
||||
int i = projectOrderInfoMapper.insertProjectOrderInfo(projectOrderInfo);
|
||||
if (CollUtil.isNotEmpty(contractFileList)) {
|
||||
|
@ -135,6 +138,15 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为空为不修改数据 项目信息修改金额调用
|
||||
* @param projectOrderInfo
|
||||
* @param projectId
|
||||
* @author ch
|
||||
* @date 2025/06/26 11:10
|
||||
*/
|
||||
|
||||
|
||||
private void saveProductInfo(ProjectOrderInfo projectOrderInfo, Long projectId) {
|
||||
//插入产品信息
|
||||
List<ProjectProductInfo> projectProductInfoList = projectOrderInfo.getHardwareProjectProductInfoList();
|
||||
|
@ -193,7 +205,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
*/
|
||||
@Override
|
||||
public int updateProjectOrderInfo(ProjectOrderInfo projectOrderInfo) {
|
||||
ProjectOrderInfo existProjectOrderInfo = projectOrderInfoMapper.selectProjectOrderInfoById(projectOrderInfo.getId());
|
||||
// ProjectOrderInfo existProjectOrderInfo = projectOrderInfoMapper.selectProjectOrderInfoById(projectOrderInfo.getId());
|
||||
// if (!existProjectOrderInfo.getAgentName().equals(projectOrderInfo.getAgentName())) {
|
||||
// String orderNumber = generateOrderNumber(projectOrderInfo.getProjectId());
|
||||
// projectOrderInfo.setOrderCode(orderNumber);
|
||||
|
@ -203,6 +215,9 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
projectOrderInfo.setUpdateBy(ShiroUtils.getUserId().toString());
|
||||
projectOrderInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
saveProductInfo(projectOrderInfo, projectOrderInfo.getProjectId());
|
||||
List<ProjectProductInfo> projectProductInfos = productInfoService.selectProjectProductInfoListByProjectId(Collections.singletonList(projectOrderInfo.getProjectId()));
|
||||
BigDecimal bigDecimal = projectProductInfos.stream().map(ProjectProductInfo::getAllPrice).filter(Objects::nonNull).reduce(BigDecimal::add).get();
|
||||
projectOrderInfo.setShipmentAmount(bigDecimal);
|
||||
return projectOrderInfoMapper.updateProjectOrderInfo(projectOrderInfo);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue