提交 c86ecbfe authored 作者: 胡宁宁's avatar 胡宁宁

平衡运费可以平衡为负数

上级 8812d158
...@@ -125,6 +125,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild, ...@@ -125,6 +125,7 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
.set(OrderChild::getUnloadTare, item.getUnloadTare()) .set(OrderChild::getUnloadTare, item.getUnloadTare())
.set(OrderChild::getWeight, item.getWeight()) .set(OrderChild::getWeight, item.getWeight())
.set(OrderChild::getFreight, item.getFreight()) .set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getPlatformServiceFee, item.getPlatformServiceFee())
); );
} }
......
package com.clx.performance.service.impl; package com.clx.performance.service.impl;
import com.clx.order.enums.QuotationEnum;
import com.clx.performance.dao.*; import com.clx.performance.dao.*;
import com.clx.performance.dto.payment.PaymentDTO;
import com.clx.performance.enums.*; import com.clx.performance.enums.*;
import com.clx.performance.enums.settle.SettlementWayEnum;
import com.clx.performance.model.*; import com.clx.performance.model.*;
import com.clx.performance.param.pc.PoundAuditParam; import com.clx.performance.param.pc.PoundAuditParam;
import com.clx.performance.service.OrderChildLogService; import com.clx.performance.param.pc.payment.PayPlatformFeeParam;
import com.clx.performance.service.OrderChildPoundAuditService; import com.clx.performance.service.*;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.service.OrderGoodsService;
import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO; import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO;
import com.msl.common.exception.ServiceSystemException; import com.msl.common.exception.ServiceSystemException;
import com.msl.user.data.UserSessionData; import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil; import com.msl.user.utils.TokenUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -48,7 +50,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -48,7 +50,7 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
private final OrderChildLogService orderChildLogService; private final OrderChildLogService orderChildLogService;
private final OrderChildService orderChildService; private final OrderChildService orderChildService;
private final PaymentService paymentService;
@Override @Override
public OrderChildPoundAuditDetailVO getPoundAuditDetail(String childNo) { public OrderChildPoundAuditDetailVO getPoundAuditDetail(String childNo) {
...@@ -128,6 +130,13 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -128,6 +130,13 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
orderChild.setWeight(orderChildWeightCalc(orderChild)); orderChild.setWeight(orderChildWeightCalc(orderChild));
orderChild.setFreight(orderChildFreightCalc(orderChild)); orderChild.setFreight(orderChildFreightCalc(orderChild));
//计算司机保证金
PaymentDTO paymentDTO = getPaymentDTO(orderChild);
if (Objects.nonNull(paymentDTO.getPlatformServiceFeeNew()) &&
paymentDTO.getPlatformServiceFeeNew().compareTo(BigDecimal.ZERO) != 0) {
orderChild.setPlatformServiceFee(paymentDTO.getPlatformServiceFeeNew());
}
// 更新装车净重 // 更新装车净重
updateOrderGoodsAmountLoad(orderGoods,orderChild.getChildNo(), dif); updateOrderGoodsAmountLoad(orderGoods,orderChild.getChildNo(), dif);
...@@ -144,13 +153,29 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -144,13 +153,29 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
//保存磅单审核日志数据 //保存磅单审核日志数据
orderChildPoundLogDao.saveEntity(poundLog); orderChildPoundLogDao.saveEntity(poundLog);
//判断是否平衡冻结金额
if(Objects.nonNull(paymentDTO.getChangeDeposit()) &&
paymentDTO.getChangeDeposit().compareTo(BigDecimal.ZERO) !=0){
paymentChangePlatformFee(orderChild.getChildNo(),paymentDTO.getChangeDeposit());
}
//保存运单日志数据 //保存运单日志数据
orderChildLogService.saveOrderChildLog(param.getChildNo(),type,OrderChildLogEnum.Type.getByCode(type).isPresent() ? OrderChildLogEnum.Type.getByCode(type).get().getMsg() :"", orderChildLogService.saveOrderChildLog(param.getChildNo(),type,OrderChildLogEnum.Type.getByCode(type).isPresent() ? OrderChildLogEnum.Type.getByCode(type).get().getMsg() :"",
OrderChildLogEnum.CreateType.PLATFORM.getCode(), loginUserInfo.getUserNo(),loginUserInfo.getUserName()); OrderChildLogEnum.CreateType.PLATFORM.getCode(), loginUserInfo.getUserNo(),loginUserInfo.getUserName());
} }
/***
* 平衡司机冻结保证金
*/
public void paymentChangePlatformFee(String childNo,BigDecimal changeDeposite){
if(changeDeposite.compareTo(BigDecimal.ZERO) !=0){
PayPlatformFeeParam payPlatformFeeParam = new PayPlatformFeeParam();
payPlatformFeeParam.setTradeNo(childNo);
payPlatformFeeParam.setFigure(changeDeposite.intValue());
//冻结司机押金
paymentService.paymentChangePlatformFee(payPlatformFeeParam);
}
}
/** /**
* 装车补偿 * 装车补偿
*/ */
...@@ -185,4 +210,43 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer ...@@ -185,4 +210,43 @@ public class OrderChildPoundAuditServiceImpl implements OrderChildPoundAuditSer
return totalFreight.setScale(0, RoundingMode.HALF_UP); return totalFreight.setScale(0, RoundingMode.HALF_UP);
} }
/***
* 获取最新的保证金金额和本次调增的金额
*/
public PaymentDTO getPaymentDTO(OrderChild orderChild){
//计算司机保证金
BigDecimal freightPrice = orderChild.getFreightPrice();
BigDecimal deposit = orderChild.getDeposit();
BigDecimal platformServiceFeeRate = orderChild.getPlatformServiceFeeRate();
BigDecimal platformServiceFee = orderChild.getPlatformServiceFee(); //平台服务费
BigDecimal freight = orderChild.getFreight();
//本次调整金额
BigDecimal changeDeposit = BigDecimal.ZERO;
//本次调整金额
BigDecimal platformServiceFeeNew = BigDecimal.ZERO;
log.info("运单号 {} ,原始冻结金额 {} ",orderChild.getChildNo(),platformServiceFee);
/**
* 如果之前未冻结保证金,本次不调整
* 如果 平台服务费率 为0 本次不处理
* 如果 本次吨数为 0 本次不处理
* 如果 本次调整金额为 0 本次不处理
* **/
if(Objects.nonNull(deposit) && deposit.compareTo(BigDecimal.ZERO) != 0 &&
Objects.nonNull(platformServiceFee) && platformServiceFee.compareTo(BigDecimal.ZERO) != 0 &&
Objects.nonNull(platformServiceFeeRate) && platformServiceFeeRate.compareTo(BigDecimal.ZERO) != 0 &&
Objects.nonNull(freight) && freight.compareTo(BigDecimal.ZERO) != 0
)
{
platformServiceFeeNew = freight
//平台服务费率 * 100
.multiply(platformServiceFeeRate).movePointLeft(2).setScale(2, RoundingMode.HALF_UP);
changeDeposit = platformServiceFeeNew.subtract(platformServiceFee);
log.info("运单号 {} ,原始冻结金额 {} ,最新冻结金额 {},运费差 {} 运费价格{},费率 {}",orderChild.getChildNo(),
platformServiceFee,platformServiceFeeNew,changeDeposit,freightPrice,platformServiceFeeRate
);
}
return PaymentDTO.builder().changeDeposit(changeDeposit).platformServiceFeeNew(platformServiceFeeNew).build();
}
} }
...@@ -1001,7 +1001,7 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -1001,7 +1001,7 @@ public class OrderChildServiceImpl implements OrderChildService {
if (orderChild.getUnloadTime() == null && if (orderChild.getUnloadTime() == null &&
Objects.equals(orderChild.getStatus(), OrderChildEnum.Status.ARRIVE_RECEIVE.getCode())) { Objects.equals(orderChild.getStatus(), OrderChildEnum.Status.ARRIVE_RECEIVE.getCode())) {
//计算司机保证金 //计算司机保证金
BigDecimal net = param.getUnloadRough().subtract(param.getUnloadTare()); BigDecimal net = orderChild.getLoadNet();
PaymentDTO paymentDTO = getPaymentDTO(net, orderChild); PaymentDTO paymentDTO = getPaymentDTO(net, orderChild);
if (Objects.nonNull(paymentDTO.getPlatformServiceFeeNew()) && if (Objects.nonNull(paymentDTO.getPlatformServiceFeeNew()) &&
paymentDTO.getPlatformServiceFeeNew().compareTo(BigDecimal.ZERO) != 0) { paymentDTO.getPlatformServiceFeeNew().compareTo(BigDecimal.ZERO) != 0) {
...@@ -1022,7 +1022,7 @@ public class OrderChildServiceImpl implements OrderChildService { ...@@ -1022,7 +1022,7 @@ public class OrderChildServiceImpl implements OrderChildService {
} }
} else { } else {
//计算司机保证金 //计算司机保证金
BigDecimal net = param.getUnloadRough().subtract(param.getUnloadTare()); BigDecimal net = orderChild.getLoadNet();
PaymentDTO paymentDTO = getPaymentDTO(net, orderChild); PaymentDTO paymentDTO = getPaymentDTO(net, orderChild);
if (Objects.nonNull(paymentDTO.getPlatformServiceFeeNew()) && if (Objects.nonNull(paymentDTO.getPlatformServiceFeeNew()) &&
paymentDTO.getPlatformServiceFeeNew().compareTo(BigDecimal.ZERO) != 0) { paymentDTO.getPlatformServiceFeeNew().compareTo(BigDecimal.ZERO) != 0) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论