|
@@ -5,6 +5,7 @@ import com.qmrb.system.pojo.entity.ContractPlaceNumberRel;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
@@ -74,6 +75,15 @@ public class ParkingFeeCalculator {
|
|
|
// 3. 计算计费时长
|
|
|
Duration billingDuration = Duration.between(billingStartTime, billingEndTime);
|
|
|
|
|
|
+ try{
|
|
|
+ //3.1 计算优惠券时长的情况 add by chenqiwang
|
|
|
+ if (StringUtils.equals(parkingRecord.couponRecord.couponType,"2")) {//时长券
|
|
|
+ //如果有优惠券并且是时长券
|
|
|
+ billingDuration = billingDuration.minusMinutes(new BigDecimal(parkingRecord.couponRecord.denomination).intValue());
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
|
|
|
// 4. 检查离场时长宽容度
|
|
|
/*if (feeRule.gracePeriodMinutes > 0) {
|
|
@@ -213,6 +223,9 @@ public class ParkingFeeCalculator {
|
|
|
PaymentRecord paymentRecord = new PaymentRecord();
|
|
|
paymentRecord.paymentTime = LocalDateTime.of(2025, 3, 14, 10, 0);
|
|
|
parkingRecord.paymentRecords.add(paymentRecord);
|
|
|
+
|
|
|
+ parkingRecord.couponRecord.denomination = 10.0;//优惠券面额
|
|
|
+ parkingRecord.couponRecord.couponType = "2";//优惠券类型(1-金额券, 2-时长券)
|
|
|
// 计算费用
|
|
|
double fee = calculateParkingFee(parkingRecord, feeRule, false);
|
|
|
System.out.println("停车费用: " + fee + " 元");
|
|
@@ -354,7 +367,7 @@ public class ParkingFeeCalculator {
|
|
|
*/
|
|
|
public static void main(String[] args) {
|
|
|
// e1();
|
|
|
-// e2();
|
|
|
- e3();
|
|
|
+ e2();
|
|
|
+// e3();
|
|
|
}
|
|
|
}
|