|
@@ -49,6 +49,7 @@ import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static java.math.BigDecimal.ROUND_DOWN;
|
|
|
+import static java.math.BigDecimal.ROUND_UP;
|
|
|
|
|
|
/**
|
|
|
* 达达配送商-计价serviceImpl
|
|
@@ -319,33 +320,30 @@ public class ApiDadaValuationServiceImpl implements ApiDadaValuationService {
|
|
|
orderFreight.setDistance(Integer.valueOf(bicyclingInfo.getDistance() + ""));
|
|
|
// 获取距离加价配置
|
|
|
List<PackageFreightDistance> distanceList = iPackageFreightDistanceService.getPackageById(packageId);
|
|
|
- if (distanceList != null && distanceList.size() > 0) {
|
|
|
+ if (CollectionUtils.isNotEmpty(distanceList)) {
|
|
|
BigDecimal orderKm = new BigDecimal(String.valueOf(bicyclingInfo.getDistance())).divide(new BigDecimal(String.valueOf(1000)), 2, BigDecimal.ROUND_UP);
|
|
|
BigDecimal distanceAdd = new BigDecimal(BigInteger.ZERO);
|
|
|
for (PackageFreightDistance distance : distanceList) {
|
|
|
// 起始 < orderKm <= 无穷大
|
|
|
- if (distance.getEndDistance() == null && orderKm.compareTo(distance.getStartDistance()) == 1) {
|
|
|
+ if (distance.getEndDistance() == null && orderKm.compareTo(distance.getStartDistance()) > 0) {
|
|
|
// 计算加价次数
|
|
|
- BigDecimal addNum = orderKm.subtract(distance.getStartDistance()).divide(distance.getDistance())
|
|
|
- .setScale(0, ROUND_DOWN);
|
|
|
+ BigDecimal addNum = orderKm.subtract(distance.getStartDistance()).divide(distance.getDistance(), 0, ROUND_UP);
|
|
|
valuationPrice = valuationPrice.add(distance.getPrice().multiply(addNum));
|
|
|
distanceAdd = distanceAdd.add(distance.getPrice().multiply(addNum));
|
|
|
}
|
|
|
|
|
|
// 起始 < orderKm <= 结束值
|
|
|
- if (distance.getEndDistance() != null && orderKm.compareTo(distance.getEndDistance()) == 1) {
|
|
|
+ if (distance.getEndDistance() != null && orderKm.compareTo(distance.getEndDistance()) > 0) {
|
|
|
// 计算加价次数
|
|
|
- BigDecimal addNum = distance.getEndDistance().subtract(distance.getStartDistance()).divide(distance.getDistance())
|
|
|
- .setScale(0, ROUND_DOWN);
|
|
|
+ BigDecimal addNum = distance.getEndDistance().subtract(distance.getStartDistance()).divide(distance.getDistance(), 0, ROUND_UP);
|
|
|
valuationPrice = valuationPrice.add(distance.getPrice().multiply(addNum));
|
|
|
distanceAdd = distanceAdd.add(distance.getPrice().multiply(addNum));
|
|
|
}
|
|
|
|
|
|
if (distance.getEndDistance() != null &&
|
|
|
- (orderKm.compareTo(distance.getStartDistance()) == 1 && orderKm.compareTo(distance.getEndDistance()) < 1)) {
|
|
|
+ (orderKm.compareTo(distance.getStartDistance()) > 0 && orderKm.compareTo(distance.getEndDistance()) < 1)) {
|
|
|
// 计算加价次数
|
|
|
- BigDecimal addNum = orderKm.subtract(distance.getStartDistance()).divide(distance.getDistance())
|
|
|
- .setScale(0, ROUND_DOWN);
|
|
|
+ BigDecimal addNum = orderKm.subtract(distance.getStartDistance()).divide(distance.getDistance(), 0, ROUND_UP);
|
|
|
valuationPrice = valuationPrice.add(distance.getPrice().multiply(addNum));
|
|
|
distanceAdd = distanceAdd.add(distance.getPrice().multiply(addNum));
|
|
|
}
|
|
@@ -355,33 +353,30 @@ public class ApiDadaValuationServiceImpl implements ApiDadaValuationService {
|
|
|
|
|
|
// 获取重量加价配置
|
|
|
List<PackageFreightWeight> weightList = iPackageFreightWeightService.getPackageById(packageId);
|
|
|
- if(weightList != null && weightList.size() > 0) {
|
|
|
+ if(CollectionUtils.isNotEmpty(weightList)) {
|
|
|
BigDecimal orderWeight = new BigDecimal(Integer.toString(orderReq.getWeight()));
|
|
|
BigDecimal weightAdd = new BigDecimal(BigInteger.ZERO);
|
|
|
for (PackageFreightWeight weight : weightList) {
|
|
|
// 起始 < orderWeight <= 无穷大
|
|
|
- if (weight.getEndWeight() == null && orderWeight.compareTo(weight.getStartWeight()) == 1) {
|
|
|
+ if (weight.getEndWeight() == null && orderWeight.compareTo(weight.getStartWeight()) > 0) {
|
|
|
// 计算加价次数
|
|
|
- BigDecimal addNum = orderWeight.subtract(weight.getStartWeight()).divide(weight.getWeight())
|
|
|
- .setScale(0, ROUND_DOWN);
|
|
|
+ BigDecimal addNum = orderWeight.subtract(weight.getStartWeight()).divide(weight.getWeight(), 0, ROUND_UP);
|
|
|
valuationPrice = valuationPrice.add(weight.getPrice().multiply(addNum));
|
|
|
weightAdd = weightAdd.add(weight.getPrice().multiply(addNum));
|
|
|
}
|
|
|
|
|
|
// 起始 < orderWeight <= 结束值
|
|
|
- if (weight.getEndWeight() != null && orderWeight.compareTo(weight.getEndWeight()) == 1) {
|
|
|
+ if (weight.getEndWeight() != null && orderWeight.compareTo(weight.getEndWeight()) > 0) {
|
|
|
// 计算加价次数
|
|
|
- BigDecimal addNum = weight.getEndWeight().subtract(weight.getStartWeight()).divide(weight.getWeight())
|
|
|
- .setScale(0, ROUND_DOWN);
|
|
|
+ BigDecimal addNum = weight.getEndWeight().subtract(weight.getStartWeight()).divide(weight.getWeight(), 0, ROUND_UP);
|
|
|
valuationPrice = valuationPrice.add(weight.getPrice().multiply(addNum));
|
|
|
weightAdd = weightAdd.add(weight.getPrice().multiply(addNum));
|
|
|
}
|
|
|
|
|
|
if (weight.getEndWeight() != null &&
|
|
|
- (orderWeight.compareTo(weight.getStartWeight()) == 1 && orderWeight.compareTo(weight.getEndWeight()) < 1)) {
|
|
|
+ (orderWeight.compareTo(weight.getStartWeight()) > 0 && orderWeight.compareTo(weight.getEndWeight()) < 1)) {
|
|
|
// 计算加价次数
|
|
|
- BigDecimal addNum = orderWeight.subtract(weight.getStartWeight()).divide(weight.getWeight())
|
|
|
- .setScale(0, ROUND_DOWN);
|
|
|
+ BigDecimal addNum = orderWeight.subtract(weight.getStartWeight()).divide(weight.getWeight(), 0, ROUND_UP);
|
|
|
valuationPrice = valuationPrice.add(weight.getPrice().multiply(addNum));
|
|
|
weightAdd = weightAdd.add(weight.getPrice().multiply(addNum));
|
|
|
}
|
|
@@ -391,17 +386,17 @@ public class ApiDadaValuationServiceImpl implements ApiDadaValuationService {
|
|
|
|
|
|
// 获取商品金额加价配置
|
|
|
List<PackageFreightMoney> moneyList = iPackageFreightMoneyService.getPackageById(packageId);
|
|
|
- if (moneyList != null && moneyList.size() > 0) {
|
|
|
- BigDecimal orderAmount = orderReq.getProductAmount();
|
|
|
+ if (CollectionUtils.isNotEmpty(moneyList)) {
|
|
|
+ BigDecimal orderAmount = orderReq.getWaimaiOrderId() == null ? orderReq.getProductAmount() : orderReq.getMtMoney();
|
|
|
BigDecimal moneyAdd = new BigDecimal(BigInteger.ZERO);
|
|
|
for (PackageFreightMoney money : moneyList) {
|
|
|
// 起始 < orderAmount <= 结束值
|
|
|
- if (orderAmount.compareTo(money.getEndMoney()) == 1) {
|
|
|
+ if (orderAmount.compareTo(money.getEndMoney()) > 0) {
|
|
|
valuationPrice = valuationPrice.add(money.getPrice());
|
|
|
moneyAdd = moneyAdd.add(money.getPrice());
|
|
|
}
|
|
|
|
|
|
- if (orderAmount.compareTo(money.getStartMoney()) == 1 && orderAmount.compareTo(money.getEndMoney()) < 1) {
|
|
|
+ if (orderAmount.compareTo(money.getStartMoney()) > 0 && orderAmount.compareTo(money.getEndMoney()) < 1) {
|
|
|
valuationPrice = valuationPrice.add(money.getPrice());
|
|
|
moneyAdd = moneyAdd.add(money.getPrice());
|
|
|
}
|
|
@@ -411,7 +406,7 @@ public class ApiDadaValuationServiceImpl implements ApiDadaValuationService {
|
|
|
|
|
|
// 获取时间段加价配置
|
|
|
List<PackageFreightTime> timeList = iPackageFreightTimeService.getPackageById(packageId);
|
|
|
- if (timeList != null && timeList.size() > 0) {
|
|
|
+ if (CollectionUtils.isNotEmpty(timeList)) {
|
|
|
Date newDate = new Date();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
|
|
String now = sdf.format(newDate);
|
|
@@ -423,7 +418,7 @@ public class ApiDadaValuationServiceImpl implements ApiDadaValuationService {
|
|
|
timeAdd = timeAdd.add(time.getPrice());
|
|
|
}
|
|
|
|
|
|
- if (now.compareTo(time.getStartTime()) > 0 && (now.compareTo(time.getEndTime()) < 0 || now.compareTo(time.getEndTime()) == 0)) {
|
|
|
+ if (now.compareTo(time.getStartTime()) > 0 && now.compareTo(time.getEndTime()) < 1) {
|
|
|
valuationPrice = valuationPrice.add(time.getPrice());
|
|
|
timeAdd = timeAdd.add(time.getPrice());
|
|
|
}
|