Ver Fonte

增加销售收入

周箭河 há 5 anos atrás
pai
commit
833f4c763e

+ 19 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -370,7 +370,6 @@ public class PayServiceImpl implements PayService {
     }
 
     /**
-     *
      * @param organId
      * @param orderNo
      * @param amount
@@ -388,14 +387,30 @@ public class PayServiceImpl implements PayService {
         List<SysPaymentConfig> paymentConfigByOrganIds = sysPaymentConfigService.findPaymentConfigByOrganIds(organIds);
 
         BigDecimal sellActualAmount = sellOrderService.getSellActualAmount(orderNo);
+        if (sellActualAmount == null) {
+            return null;
+        }
 
-        for (RouteScaleDto routeScaleDto : routeScaleDtos) {
+        Iterator<RouteScaleDto> iterator = routeScaleDtos.iterator();
+        boolean hasFeeFlag = false;
+        while (iterator.hasNext()) {
+            RouteScaleDto routeScaleDto = iterator.next();
             routeScaleDto.setPayType(paymentConfig.getPayType());
-            if(routeScaleDto.getFeeType().equals(FeeTypeEnum.SELL)){
+            if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SELL)) {
                 routeScaleDto.setAmount(sellActualAmount);
-            }else {
+            } else {
                 routeScaleDto.setAmount(amount.subtract(sellActualAmount));
             }
+
+            if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
+                iterator.remove();
+                continue;
+            }
+            if (!hasFeeFlag && routeScaleDto.getAmount().compareTo(amount.divide(new BigDecimal(2), 2, BigDecimal.ROUND_DOWN)) >= 0) {
+                routeScaleDto.setFeeFlag("Y");
+                hasFeeFlag = true;
+            }
+
             for (SysPaymentConfig paymentConfigByOrganId : paymentConfigByOrganIds) {
                 if (!paymentConfigByOrganId.getOrganId().equals(routeScaleDto.getOrganId())) continue;
                 if (paymentConfig.getPayType().equals(PaymentChannelEnum.YQPAY)) {
@@ -405,7 +420,6 @@ public class PayServiceImpl implements PayService {
                 }
             }
         }
-
         return routeScaleDtos;
     }
 

+ 39 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -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;
     }
 
 }