wuwenxiong 2022-02-15 22:44:38 +08:00
parent 01a62b214c
commit 9a37d32b88
2 changed files with 4 additions and 4 deletions

View File

@ -254,7 +254,7 @@ public class PresellOrderService extends BaseService {
BigDecimal out = Db.queryBigDecimal(sql, params.toArray());
return out == null ? new BigDecimal(0) : out;
return out == null ? new BigDecimal(0) : out.setScale(2, BigDecimal.ROUND_HALF_UP);
}
/**
@ -307,6 +307,6 @@ public class PresellOrderService extends BaseService {
BigDecimal out = Db.queryBigDecimal(sql, params.toArray());
return out == null ? new BigDecimal(0) : out;
return out == null ? new BigDecimal(0) : out.setScale(2, BigDecimal.ROUND_HALF_UP);
}
}

View File

@ -587,13 +587,13 @@ public class OrderclusterSyncService extends BaseSyncService {
// 余额
BigDecimal surplus = PresellOrderService.me.getPresellCustomerSurplusById(model.getCustomerId());
if (unitprice.multiply(model.getTotalWeight()).compareTo(surplus) > 0) {
if (unitprice.multiply(model.getTotalWeight()).setScale(2, BigDecimal.ROUND_HALF_UP).compareTo(surplus) > 0) {
return Result.failedstr("余额 %.2f 不足以购买 %.2f 吨 %s", surplus, model.getTotalWeight(), product.getName());
}
// 客户在所有砂站的未完成的配额中,未执行完成的总金额
BigDecimal undo_price = OrderclusterService.me.undoPrice(model.getCustomerId(), 1);
BigDecimal plan_total_price = model.getTotalWeight().multiply(unitprice).add(undo_price); // 本次配额总价格
BigDecimal plan_total_price = model.getTotalWeight().multiply(unitprice).add(undo_price).setScale(2, BigDecimal.ROUND_HALF_UP); // 本次配额总价格
// 本次计划总额加上未完成的量,不能超过余额
if (plan_total_price.compareTo(surplus) > 0) {