|
|
@@ -34,6 +34,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
private GoodsService goodsService;
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private SporadicChargeInfoDao sporadicChargeInfoDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, SellOrder> getDAO() {
|
|
|
@@ -336,17 +338,43 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
|
|
|
|
|
|
@Override
|
|
|
public BigDecimal getSellActualAmount(String orderNo) {
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findOrderByOrderNo(orderNo);
|
|
|
- List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetail(studentPaymentOrder.getId());
|
|
|
- //总余额支付
|
|
|
- BigDecimal totalBalance = studentPaymentOrder.getBalancePaymentAmount() != null ? studentPaymentOrder.getBalancePaymentAmount() : BigDecimal.ZERO;
|
|
|
- //总价格
|
|
|
- BigDecimal totalPrice = studentPaymentOrder.getExpectAmount();
|
|
|
- //商品总付款
|
|
|
- BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- //商品销售占的余额
|
|
|
- BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- return detailTotalPrice.subtract(detailTotalBalance);
|
|
|
+ StudentPaymentOrder order = studentPaymentOrderDao.findOrderByOrderNo(orderNo);
|
|
|
+ if (order == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //零星支付除了充值其他都是服务费用
|
|
|
+ if (order.getType().equals(OrderTypeEnum.SPORADIC)) {
|
|
|
+ SporadicChargeInfo info = sporadicChargeInfoDao.get(Integer.parseInt(order.getMusicGroupId()));
|
|
|
+ if (info.getChargeType().equals(SporadicChargeTypeEnum.RECHARGE)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //乐器销售
|
|
|
+ if (order.getType().equals(OrderTypeEnum.GOODS_SELL) || order.getType().equals(OrderTypeEnum.SUBJECT_CHANGE)) {
|
|
|
+ return order.getActualAmount();
|
|
|
+ }
|
|
|
+
|
|
|
+ //乐器维修
|
|
|
+ if(order.getType().equals(OrderTypeEnum.REPAIR)){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //乐团报名
|
|
|
+ if (order.getType().equals(OrderTypeEnum.APPLY)) {
|
|
|
+ List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetail(order.getId());
|
|
|
+ //总余额支付
|
|
|
+ BigDecimal totalBalance = order.getBalancePaymentAmount() != null ? order.getBalancePaymentAmount() : BigDecimal.ZERO;
|
|
|
+ //总价格
|
|
|
+ BigDecimal totalPrice = order.getExpectAmount();
|
|
|
+ //商品总付款
|
|
|
+ BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ //商品销售占的余额
|
|
|
+ BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ return detailTotalPrice.subtract(detailTotalBalance);
|
|
|
+ }
|
|
|
+
|
|
|
+ return BigDecimal.ZERO;
|
|
|
}
|
|
|
|
|
|
}
|