提交代码

master
胡锐 6 months ago
parent 078c248854
commit 9db7e27bad
  1. 7
      order/src/main/java/com/order/controller/OrderAfterSalesApplyController.java
  2. 4
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java

@ -64,6 +64,9 @@ public class OrderAfterSalesApplyController {
if (orderChild == null) { if (orderChild == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品订单"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品订单");
} }
if (productCount > orderChild.getSurplusRefundCount()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "数量超过子订单可退数量");
}
Map<String,Object> param = new HashMap<>(); Map<String,Object> param = new HashMap<>();
if (orderChild.getSurplusRefundCount().equals(productCount)) { if (orderChild.getSurplusRefundCount().equals(productCount)) {
// 全部退款 // 全部退款
@ -72,9 +75,9 @@ public class OrderAfterSalesApplyController {
} else { } else {
// 部分退款 // 部分退款
// 计算单价 // 计算单价
BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(productCount.toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100")) BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
.divide(new BigDecimal(productCount.toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); .divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
param.put("refundPrice", unitPrice.multiply(new BigDecimal(productCount.toString()))); param.put("refundPrice", unitPrice.multiply(new BigDecimal(productCount.toString())));
param.put("refundIntegral", unitPriceIntegral.multiply(new BigDecimal("100")).longValue()); param.put("refundIntegral", unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
} }

@ -161,9 +161,9 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
} else { } else {
// 部分退款 // 部分退款
// 计算单价 // 计算单价
BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(productCount.toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100")) BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
.divide(new BigDecimal(productCount.toString()), 2, BigDecimal.ROUND_DOWN).setScale(2); .divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString()))); orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue()); orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());

Loading…
Cancel
Save