| | |
| | | package com.ruoyi.integration.barrierGate.server; |
| | | |
| | | import com.ruoyi.account.api.feignClient.AppUserCarClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.chargingPile.api.feignClient.ParkingLotClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ParkingRecordClient; |
| | | import com.ruoyi.chargingPile.api.model.TParkingLot; |
| | | import com.ruoyi.chargingPile.api.model.TParkingRecord; |
| | | import com.ruoyi.chargingPile.api.vo.GetParkingRecord; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.integration.barrierGate.model.CloudParkingOrder; |
| | | import com.ruoyi.integration.barrierGate.model.CloudParkingSpace; |
| | | import com.ruoyi.integration.barrierGate.model.OfflineParkingOrder; |
| | | import com.ruoyi.integration.barrierGate.model.OfflineParkingSpace; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | |
| | | @Resource |
| | | private ParkingLotClient parkingLotClient; |
| | | |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | |
| | |
| | | TParkingLot data = parkingLotClient.getParkingLotByAppKey(order.getAppkey()).getData(); |
| | | parkingRecord.setName(data.getName()); |
| | | parkingRecord.setParkingLotId(data.getId()); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getEnterDateTime(), DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSSZ")); |
| | | parse.plusDays(8); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getEnterDateTime(), DateTimeFormatter.ISO_DATE_TIME); |
| | | parse = parse.plusHours(8); |
| | | parkingRecord.setInParkingTime(parse); |
| | | parkingRecord.setStatus(1); |
| | | parkingRecord.setCreateTime(LocalDateTime.now()); |
| | |
| | | query.setLicensePlate(order.getPlate()); |
| | | query.setStatus(1); |
| | | TParkingRecord parkingRecord = parkingRecordClient.getParkingRecord(query).getData(); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getLeaveDateTime(), DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSSZ")); |
| | | parse.plusDays(8); |
| | | if(null == parkingRecord){ |
| | | return; |
| | | } |
| | | TParkingLot parkingLot = parkingLotClient.getParkingLotByAppKey(order.getAppkey()).getData(); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getLeaveDateTime(), DateTimeFormatter.ISO_DATE_TIME); |
| | | parse = parse.plusHours(8); |
| | | parkingRecord.setOutParkingTime(parse); |
| | | parkingRecord.setParkingDuration(Integer.valueOf(order.getLongTime())); |
| | | parkingRecord.setOrderAmount(new BigDecimal(order.getReceivable())); |
| | |
| | | parkingRecord.setPayType(order.getPayType()); |
| | | BigDecimal payment = new BigDecimal(order.getPayment()); |
| | | parkingRecord.setStatus(BigDecimal.ZERO.compareTo(payment) == 0 ? 2 : 3); |
| | | parkingRecord.setOutParkingType(BigDecimal.ZERO.compareTo(payment) == 0 ? 2 : 1); |
| | | parkingRecord.setTitle("【停车缴费】" + payment + "元"); |
| | | TAppUserCar appUserCar = appUserCarClient.getAppUserCarByLicensePlate(parkingRecord.getLicensePlate()).getData(); |
| | | TChargingOrder chargingOrder = null; |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | if(null != appUserCar){ |
| | | List<TChargingOrder> data = chargingOrderClient.getCarChargingOrder(appUserCar.getId(), parkingRecord.getInParkingTime().format(formatter), LocalDateTime.now().format(formatter)).getData(); |
| | | if(null != data && data.size() > 0){ |
| | | chargingOrder = data.get(0); |
| | | } |
| | | }else if(StringUtils.isNotEmpty(parkingRecord.getLicensePlate())){ |
| | | List<TChargingOrder> data = chargingOrderClient.getCarChargingOrderByPlateNum(parkingRecord.getLicensePlate(), parkingRecord.getInParkingTime().format(formatter), LocalDateTime.now().format(formatter)).getData(); |
| | | if(null != data && data.size() > 0){ |
| | | chargingOrder = data.get(0); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(null != chargingOrder){ |
| | | parkingRecord.setAppUserId(chargingOrder.getAppUserId()); |
| | | parkingRecord.setChargingOrderId(chargingOrder.getId()); |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | parkingRecord.setPhone(appUser.getPhone()); |
| | | parkingRecord.setFreeDuration(parkingLot.getChargeFreeDuration()); |
| | | long m = parkingRecord.getParkingDuration() - parkingRecord.getFreeDuration(); |
| | | parkingRecord.setTimeoutAmount(m > parkingLot.getChargeFreeDuration() ? new BigDecimal(m - parkingLot.getChargeFreeDuration()).multiply(parkingLot.getChargeRate()) : BigDecimal.ZERO); |
| | | }else{ |
| | | parkingRecord.setFreeDuration(parkingLot.getNonChargeFreeDuration()); |
| | | long m = parkingRecord.getParkingDuration() - parkingRecord.getFreeDuration(); |
| | | parkingRecord.setTimeoutAmount(m > parkingLot.getNonChargeFreeDuration() ? new BigDecimal(m - parkingLot.getNonChargeFreeDuration()).multiply(parkingLot.getChargeRate()) : BigDecimal.ZERO); |
| | | } |
| | | parkingRecord.setFreeAmount(parkingRecord.getOrderAmount().subtract(parkingRecord.getPayment())); |
| | | parkingRecordClient.updateParkingRecord(parkingRecord); |
| | | } |
| | | |
| | |
| | | TParkingLot data = parkingLotClient.getParkingLotByAppKey(order.getAppkey()).getData(); |
| | | parkingRecord.setName(data.getName()); |
| | | parkingRecord.setParkingLotId(data.getId()); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getEntertime(), DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSSZ")); |
| | | parse.plusDays(8); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getEntertime(), DateTimeFormatter.ISO_DATE_TIME); |
| | | parse = parse.plusHours(8); |
| | | parkingRecord.setInParkingTime(parse); |
| | | parkingRecord.setStatus(1); |
| | | parkingRecord.setCreateTime(LocalDateTime.now()); |
| | |
| | | query.setLicensePlate(order.getPlatenumber()); |
| | | query.setStatus(1); |
| | | TParkingRecord parkingRecord = parkingRecordClient.getParkingRecord(query).getData(); |
| | | LocalDateTime parse = LocalDateTime.parse(order.getLeavetime(), DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSSZ")); |
| | | parse.plusDays(8); |
| | | parkingRecord.setOutParkingTime(parse); |
| | | TParkingLot parkingLot = parkingLotClient.getParkingLotByAppKey(order.getAppkey()).getData(); |
| | | parkingRecord.setOutParkingTime(LocalDateTime.now()); |
| | | parkingRecord.setParkingDuration(Integer.valueOf(order.getLongTime())); |
| | | parkingRecord.setOrderAmount(new BigDecimal(order.getMoney())); |
| | | parkingRecord.setPayment(new BigDecimal(order.getMoney())); |
| | | BigDecimal payment = new BigDecimal(order.getMoney()); |
| | | parkingRecord.setStatus(BigDecimal.ZERO.compareTo(payment) == 0 ? 2 : 3); |
| | | parkingRecord.setOutParkingType(BigDecimal.ZERO.compareTo(payment) == 0 ? 2 : 1); |
| | | parkingRecord.setTitle("【停车缴费】" + payment + "元"); |
| | | TAppUserCar appUserCar = appUserCarClient.getAppUserCarByLicensePlate(parkingRecord.getLicensePlate()).getData(); |
| | | TChargingOrder chargingOrder = null; |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | if(null != appUserCar){ |
| | | List<TChargingOrder> data = chargingOrderClient.getCarChargingOrder(appUserCar.getId(), parkingRecord.getInParkingTime().format(formatter), LocalDateTime.now().format(formatter)).getData(); |
| | | if(null != data && data.size() > 0){ |
| | | chargingOrder = data.get(0); |
| | | } |
| | | }else if(StringUtils.isNotEmpty(parkingRecord.getLicensePlate())){ |
| | | List<TChargingOrder> data = chargingOrderClient.getCarChargingOrderByPlateNum(parkingRecord.getLicensePlate(), parkingRecord.getInParkingTime().format(formatter), LocalDateTime.now().format(formatter)).getData(); |
| | | if(null != data && data.size() > 0){ |
| | | chargingOrder = data.get(0); |
| | | } |
| | | } |
| | | |
| | | if(null != chargingOrder){ |
| | | parkingRecord.setAppUserId(chargingOrder.getAppUserId()); |
| | | parkingRecord.setChargingOrderId(chargingOrder.getId()); |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | parkingRecord.setPhone(appUser.getPhone()); |
| | | parkingRecord.setFreeDuration(parkingLot.getChargeFreeDuration()); |
| | | long m = parkingRecord.getParkingDuration() - parkingRecord.getFreeDuration(); |
| | | parkingRecord.setTimeoutAmount(m > parkingLot.getChargeFreeDuration() ? new BigDecimal(m - parkingLot.getChargeFreeDuration()).multiply(parkingLot.getChargeRate()) : BigDecimal.ZERO); |
| | | |
| | | }else{ |
| | | parkingRecord.setFreeDuration(parkingLot.getNonChargeFreeDuration()); |
| | | long m = parkingRecord.getParkingDuration() - parkingRecord.getFreeDuration(); |
| | | parkingRecord.setTimeoutAmount(m > parkingLot.getNonChargeFreeDuration() ? new BigDecimal(m - parkingLot.getNonChargeFreeDuration()).multiply(parkingLot.getChargeRate()) : BigDecimal.ZERO); |
| | | } |
| | | |
| | | parkingRecord.setFreeAmount(parkingRecord.getOrderAmount().subtract(parkingRecord.getPayment())); |
| | | parkingRecordClient.updateParkingRecord(parkingRecord); |
| | | } |
| | | |