| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import com.ruoyi.order.api.model.AccountingStrategyDetailOrder; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.vo.TransactionRecordMessageVO; |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | |
| | | class ChargingSimulationSupportTest { |
| | | |
| | | @Test |
| | | void supportsBalanceAndMixedPaymentAmounts() { |
| | | TChargingOrder balance = new TChargingOrder(); |
| | | balance.setPayMethod(1); |
| | | balance.setRechargeAmount(new BigDecimal("10.00")); |
| | | balance.setChargeAmount(new BigDecimal("10.00")); |
| | | balance.setBalancePayAmount(new BigDecimal("10.00")); |
| | | balance.setThirdPayAmount(BigDecimal.ZERO); |
| | | |
| | | assertEquals(new BigDecimal("10.00"), ChargingSimulationSupport.availableAmount(balance)); |
| | | assertEquals("余额支付", ChargingSimulationSupport.paymentMode(balance)); |
| | | |
| | | TChargingOrder mixed = new TChargingOrder(); |
| | | mixed.setPayMethod(2); |
| | | mixed.setRechargePaymentType(1); |
| | | mixed.setSourceName("ICBC"); |
| | | mixed.setRechargeAmount(new BigDecimal("10.00")); |
| | | mixed.setBalancePayAmount(new BigDecimal("4.00")); |
| | | mixed.setThirdPayAmount(new BigDecimal("6.00")); |
| | | |
| | | assertEquals(new BigDecimal("10.00"), ChargingSimulationSupport.availableAmount(mixed)); |
| | | assertEquals("余额+工行支付", ChargingSimulationSupport.paymentMode(mixed)); |
| | | |
| | | TChargingOrder alipay = new TChargingOrder(); |
| | | alipay.setPayMethod(3); |
| | | alipay.setRechargePaymentType(2); |
| | | alipay.setRechargeAmount(new BigDecimal("10.00")); |
| | | alipay.setBalancePayAmount(BigDecimal.ZERO); |
| | | alipay.setThirdPayAmount(new BigDecimal("10.00")); |
| | | |
| | | assertEquals("支付宝支付", ChargingSimulationSupport.paymentMode(alipay)); |
| | | |
| | | TChargingOrder legacyAlipay = new TChargingOrder(); |
| | | legacyAlipay.setPayMethod(3); |
| | | legacyAlipay.setRechargePaymentType(2); |
| | | legacyAlipay.setRechargeAmount(new BigDecimal("10.00")); |
| | | |
| | | assertEquals("支付宝支付", ChargingSimulationSupport.paymentMode(legacyAlipay)); |
| | | assertEquals(new BigDecimal("10.00"), ChargingSimulationSupport.thirdPayAmount(legacyAlipay)); |
| | | |
| | | TChargingOrder legacyMixed = new TChargingOrder(); |
| | | legacyMixed.setPayMethod(2); |
| | | legacyMixed.setRechargePaymentType(1); |
| | | legacyMixed.setSourceName("ICBC"); |
| | | legacyMixed.setRechargeAmount(new BigDecimal("10.00")); |
| | | legacyMixed.setBalancePayAmount(new BigDecimal("4.00")); |
| | | |
| | | assertEquals("余额+工行支付", ChargingSimulationSupport.paymentMode(legacyMixed)); |
| | | assertEquals(new BigDecimal("6.00"), ChargingSimulationSupport.thirdPayAmount(legacyMixed)); |
| | | } |
| | | |
| | | @Test |
| | | void buildsOneKwhRecordForSelectedTariffPeriod() { |
| | | AccountingStrategyDetailOrder first = detail(1, 1, "00:00", "12:00"); |
| | | AccountingStrategyDetailOrder second = detail(2, 3, "12:00", "23:59"); |