refactor(adviceProcess): 调整大数除法判断的代码结构
将取余判断的逻辑嵌套到数量大于等于单位占比的分支内,优化代码可读性
This commit is contained in:
@@ -415,9 +415,11 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
&& advice.getMinUnitCode() != null
|
||||
&& !advice.getUnitCode().equals(advice.getMinUnitCode())) {
|
||||
BigDecimal partPercent = advice.getPartPercent();
|
||||
BigDecimal[] divideResult = quantity.divideAndRemainder(partPercent);
|
||||
if (quantity.compareTo(partPercent) >= 0 && BigDecimal.ZERO.compareTo(divideResult[1]) == 0) {
|
||||
quantity = divideResult[0];
|
||||
if (quantity.compareTo(partPercent) >= 0) {
|
||||
BigDecimal[] divideResult = quantity.divideAndRemainder(partPercent);
|
||||
if (BigDecimal.ZERO.compareTo(divideResult[1]) == 0) {
|
||||
quantity = divideResult[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user