| | |
| | | chargingOrderListInfoVO.setStatus(chargingOrder.getStatus()); |
| | | BigDecimal bigDecimal = new BigDecimal("0.006"); |
| | | if (chargingOrder.getOrderAmount()!=null){ |
| | | chargingOrderListInfoVO.setCommissionAmount(chargingOrder.getOrderAmount().multiply(bigDecimal)); |
| | | BigDecimal multiply = chargingOrder.getPaymentAmount().multiply(bigDecimal); |
| | | chargingOrderListInfoVO.setCommissionAmount(multiply.setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | chargingOrderListInfoVO.setElectrovalence(chargingOrder.getElectrovalence()); |
| | | chargingOrderListInfoVO.setServiceCharge(chargingOrder.getServiceCharge()); |
| | |
| | | } |
| | | } |
| | | } |
| | | chargingOrderListInfoVO.setChargingCapacity(chargingOrder.getChargingCapacity()); |
| | | |
| | | chargingOrderListInfoVO.setEndMode(chargingOrder.getEndMode()); |
| | | |
| | |
| | | } |
| | | } |
| | | if (!data6.isEmpty()){ |
| | | // 第一条数据soc为开始 最后一条数据soc为结束soc |
| | | chargingOrderListInfoVO.setStartSoc(data6.get(data6.size()-1).getSoc().toString()); |
| | | chargingOrderListInfoVO.setEndSoc(data6.get(0).getSoc().toString()); |
| | | chargingOrderListInfoVO.setChargingCapacity(data6.get(data6.size()-1).getCharging_degree()); |
| | | int min = 100; |
| | | int max = 0; |
| | | for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data6) { |
| | | if (uploadRealTimeMonitoringData.getSoc()>max){ |
| | | max = uploadRealTimeMonitoringData.getSoc(); |
| | | } |
| | | if (uploadRealTimeMonitoringData.getSoc()!=0 &&uploadRealTimeMonitoringData.getSoc()<min){ |
| | | min = uploadRealTimeMonitoringData.getSoc(); |
| | | } |
| | | } |
| | | chargingOrderListInfoVO.setEndSoc(max+""); |
| | | chargingOrderListInfoVO.setStartSoc(min+""); |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data6) { |
| | |
| | | } |
| | | } |
| | | } |
| | | //会员折扣金额 |
| | | discountAmount = discountAmount.setScale(2, RoundingMode.DOWN); |
| | | payAmount = payAmount.subtract(discountAmount); |
| | | |
| | | TChargingOrder order = new TChargingOrder(); |
| | |
| | | order.setEndTime(LocalDateTime.parse(vo.getEnd_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | order.setStatus(5); |
| | | order.setOrderAmount(orderAmount.setScale(2, RoundingMode.DOWN)); |
| | | order.setVipDiscountAmount(discountAmount.setScale(2, RoundingMode.DOWN)); |
| | | order.setVipDiscountAmount(discountAmount); |
| | | order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.DOWN)); |
| | | order.setChargingCapacity(vo.getTotal_electricity()); |
| | | order.setElectricity(vo.getTotal_electricity()); |
| | | |
| | | //计算优惠券 |
| | | BigDecimal couponDiscount = BigDecimal.ZERO; |
| | | if(null != chargingOrder.getAppCouponId()){ |
| | | //判断实际充电金额是否满足优惠券使用条件,如果不满足则不适用优惠券。 |
| | | TAppCoupon appCoupon = appCouponClient.getAppCouponById(chargingOrder.getAppCouponId()).getData(); |
| | |
| | | BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount(); |
| | | //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){ |
| | | refundAmount = refundAmount.add(periodServicePrice_total); |
| | | order.setCouponDiscountAmount(periodServicePrice_total); |
| | | payAmount = payAmount.subtract(periodServicePrice_total); |
| | | couponDiscount = periodServicePrice_total; |
| | | periodServicePrice_total = BigDecimal.ZERO; |
| | | }else{ |
| | | refundAmount = refundAmount.add(couponDiscountAmount); |
| | | order.setCouponDiscountAmount(couponDiscountAmount); |
| | | payAmount = payAmount.subtract(couponDiscountAmount); |
| | | couponDiscount = couponDiscountAmount; |
| | | periodServicePrice_total = periodServicePrice_total.subtract(couponDiscountAmount); |
| | | } |
| | | |
| | | appCoupon.setStatus(2); |
| | | appCouponClient.updateAppCoupon(appCoupon); |
| | | }else{ |
| | |
| | | divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; |
| | | //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | if(periodServicePrice_total.compareTo(divide) < 0){ |
| | | refundAmount = refundAmount.add(periodServicePrice_total); |
| | | order.setCouponDiscountAmount(periodServicePrice_total); |
| | | payAmount = payAmount.subtract(periodServicePrice_total); |
| | | couponDiscount = periodServicePrice_total; |
| | | periodServicePrice_total = BigDecimal.ZERO; |
| | | }else{ |
| | | refundAmount = refundAmount.add(divide); |
| | | order.setCouponDiscountAmount(divide); |
| | | payAmount = payAmount.subtract(divide); |
| | | couponDiscount = divide; |
| | | periodServicePrice_total = periodServicePrice_total.subtract(divide); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | //优惠券优惠金额 |
| | | couponDiscount = couponDiscount.setScale(2, RoundingMode.DOWN); |
| | | refundAmount = refundAmount.add(couponDiscount); |
| | | payAmount = payAmount.subtract(couponDiscount); |
| | | order.setCouponDiscountAmount(couponDiscount); |
| | | order.setServiceCharge(periodServicePrice_total.setScale(2, RoundingMode.DOWN)); |
| | | order.setPaymentAmount(payAmount.setScale(2, RoundingMode.DOWN)); |
| | | order.setRefundAmount(refundAmount.setScale(2, RoundingMode.DOWN)); |
| | |
| | | BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodServicePrice(); |
| | | BigDecimal multiply = couponDiscountAmount.multiply(periodServicePrice.divide(reduce, new MathContext(4, RoundingMode.HALF_EVEN))); |
| | | periodServicePrice = periodServicePrice.subtract(multiply); |
| | | chargingOrderAccountingStrategy.setPeriodServicePrice(periodServicePrice.setScale(2, RoundingMode.DOWN)); |
| | | chargingOrderAccountingStrategy.setCouponDiscountAmount(multiply.setScale(2, RoundingMode.DOWN)); |
| | | chargingOrderAccountingStrategy.setPeriodServicePrice(periodServicePrice.setScale(2, RoundingMode.HALF_EVEN)); |
| | | chargingOrderAccountingStrategy.setCouponDiscountAmount(multiply.setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | chargingOrderAccountingStrategyService.updateBatchById(list); |
| | | } |
| | |
| | | } |
| | | if (tChargingOrder.getPaymentAmount()!=null){ |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); |
| | | orderCommission = orderCommission.add(tChargingOrder.getPaymentAmount().multiply(new BigDecimal("0.006")) |
| | | .setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 三方交易手续费 三方收费*0.6% |
| | | commissionAmount = sharingAmount.multiply(new BigDecimal("0.006")); |
| | | // 订单手续费 订单支付金额 - 退款金额*0.6% |
| | | orderCommission = paymentAmount.multiply(new BigDecimal("0.006")); |
| | | tSettlementConfirm.setSharingAmount(sharingAmount.setScale(2, RoundingMode.HALF_DOWN)); |
| | | tSettlementConfirm.setCommissionAmount(commissionAmount.setScale(2, RoundingMode.HALF_DOWN)); |
| | | tSettlementConfirm.setElectrovalence(electrovalence.setScale(2, RoundingMode.HALF_DOWN)); |
| | | tSettlementConfirm.setServiceCharge(serviceCharge.subtract(orderCommission).setScale(2, RoundingMode.HALF_DOWN)); |
| | | tSettlementConfirm.setOrderCommission(orderCommission.setScale(2,BigDecimal.ROUND_DOWN)); |
| | | tSettlementConfirm.setOrderCommission(orderCommission); |
| | | tSettlementConfirm.setVipDiscount(vipDiscount); |
| | | tSettlementConfirm.setCouponDiscount(couponDiscount); |
| | | tSettlementConfirm.setSiteId(dto.getSiteId()); |