|
@@ -204,29 +204,8 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
|
|
|
|
|
|
//计算 总支出 毛利 毛利率
|
|
|
for (SettlementBo record : records) {
|
|
|
- //总支出
|
|
|
- BigDecimal totalExpenditure = BigDecimal.ZERO;
|
|
|
- totalExpenditure.add(record.getMaterialFee());//物料费
|
|
|
- totalExpenditure.add(record.getAfterSalesFee());//售后费用
|
|
|
- totalExpenditure.add(record.getTrailerFee());//拖车费
|
|
|
- totalExpenditure.add(record.getInspectionRedPackFee());//验货红包
|
|
|
- totalExpenditure.add(record.getCommissionFee());//佣金
|
|
|
- totalExpenditure.add(record.getOtherFee());//其他费用
|
|
|
- record.setTotalExpenditure(totalExpenditure);
|
|
|
-
|
|
|
- //毛利(总收入-总支出)
|
|
|
- record.setGrossProfit(record.getTotalIncome().subtract(record.getTotalExpenditure()));
|
|
|
-
|
|
|
- //毛利率(毛利/总收入*100%)
|
|
|
- BigDecimal grossProfitMargin = BigDecimal.ZERO;
|
|
|
- if (record.getGrossProfit().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- grossProfitMargin = record.getGrossProfit()
|
|
|
- .divide(record.getTotalIncome(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
|
|
|
- }
|
|
|
- record.setGrossProfitMargin(grossProfitMargin);
|
|
|
-
|
|
|
- //变成科学计数法问题处理
|
|
|
- record.setMaterialFee(record.getMaterialFee().setScale(4, RoundingMode.HALF_UP));
|
|
|
+ //调用公共代码计算
|
|
|
+ profitClearingConn(record);
|
|
|
}
|
|
|
|
|
|
return profitClearingPage;
|
|
@@ -240,15 +219,28 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
|
|
|
IWrapper<SalesContract> wrapper = getProfitClearingWrapper(dto);
|
|
|
SettlementBo record = baseMapper.getProfitSettlementHead(wrapper);
|
|
|
|
|
|
+ //调用公共代码计算
|
|
|
+ profitClearingConn(record);
|
|
|
+
|
|
|
+ return record;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公共的计算代码块
|
|
|
+ */
|
|
|
+ SettlementBo profitClearingConn(SettlementBo record){
|
|
|
+ //总收入
|
|
|
+ record.setTotalIncome(record.getContractClaimAmount().setScale(4, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
//总支出
|
|
|
BigDecimal totalExpenditure = BigDecimal.ZERO;
|
|
|
- totalExpenditure.add(record.getMaterialFee());//物料费
|
|
|
- totalExpenditure.add(record.getAfterSalesFee());//售后费用
|
|
|
- totalExpenditure.add(record.getTrailerFee());//拖车费
|
|
|
- totalExpenditure.add(record.getInspectionRedPackFee());//验货红包
|
|
|
- totalExpenditure.add(record.getCommissionFee());//佣金
|
|
|
- totalExpenditure.add(record.getOtherFee());//其他费用
|
|
|
- record.setTotalExpenditure(totalExpenditure);
|
|
|
+ totalExpenditure = totalExpenditure.add(record.getMaterialFee());//物料费
|
|
|
+ totalExpenditure = totalExpenditure.add(record.getAfterSalesFee());//售后费用
|
|
|
+ totalExpenditure = totalExpenditure.add(record.getTrailerFee());//拖车费
|
|
|
+ totalExpenditure = totalExpenditure.add(record.getInspectionRedPackFee());//验货红包
|
|
|
+ totalExpenditure = totalExpenditure.add(record.getCommissionFee());//佣金
|
|
|
+ totalExpenditure = totalExpenditure.add(record.getOtherFee());//其他费用
|
|
|
+ record.setTotalExpenditure(totalExpenditure.setScale(4, RoundingMode.HALF_UP));
|
|
|
|
|
|
//毛利(总收入-总支出)
|
|
|
record.setGrossProfit(record.getTotalIncome().subtract(record.getTotalExpenditure()));
|
|
@@ -257,13 +249,12 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
|
|
|
BigDecimal grossProfitMargin = BigDecimal.ZERO;
|
|
|
if (record.getGrossProfit().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
grossProfitMargin = record.getGrossProfit()
|
|
|
- .divide(record.getTotalIncome(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
|
|
|
+ .divide(record.getTotalIncome(), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
|
|
|
}
|
|
|
record.setGrossProfitMargin(grossProfitMargin);
|
|
|
|
|
|
//变成科学计数法问题处理
|
|
|
record.setMaterialFee(record.getMaterialFee().setScale(4, RoundingMode.HALF_UP));
|
|
|
-
|
|
|
return record;
|
|
|
}
|
|
|
|