| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | @Autowired |
| | | private ISpecialAreaBillingService specialAreaBillingService; |
| | | |
| | | |
| | | @Value("${filePath}") |
| | |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | |
| | | // 查询起点或者终点在特殊区域中 |
| | | List<SpecialAreaBilling> specialAreaBillings = specialAreaBillingService.selectList(new EntityWrapper<SpecialAreaBilling>() |
| | | .eq("state", 1)); |
| | | if(!CollectionUtils.isEmpty(specialAreaBillings)){ |
| | | // 判断起点或者终点在特殊区域中 |
| | | Iterator<SpecialAreaBilling> iterator = specialAreaBillings.iterator(); |
| | | while (iterator.hasNext()) { |
| | | SpecialAreaBilling specialAreaBilling = iterator.next(); |
| | | // 起点 |
| | | Double startLon = orderPrivateCar.getStartLon(); |
| | | Double startLat = orderPrivateCar.getStartLat(); |
| | | boolean start = ElectricFenceUtil.monitorElectricFenc(specialAreaBilling.getCoordinate(), startLon + "," + startLat); |
| | | // 终点 |
| | | Double endLon = orderPrivateCar.getEndLon(); |
| | | Double endLat = orderPrivateCar.getEndLat(); |
| | | boolean end = ElectricFenceUtil.monitorElectricFenc(specialAreaBilling.getCoordinate(), endLon + "," + endLat); |
| | | if(!start && !end){ |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(specialAreaBillings)){ |
| | | // 拿到价格系数最高的特殊区域 |
| | | specialAreaBillings.sort(new Comparator<SpecialAreaBilling>() { |
| | | @Override |
| | | public int compare(SpecialAreaBilling o1, SpecialAreaBilling o2) { |
| | | return o2.getPriceCoefficient().compareTo(o1.getPriceCoefficient()); |
| | | } |
| | | }); |
| | | BigDecimal priceCoefficient = specialAreaBillings.get(0).getPriceCoefficient(); |
| | | orderPrivateCar.setOrderMoney(Objects.nonNull(orderPrivateCar.getOrderMoney())?new BigDecimal(orderPrivateCar.getOrderMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setStartMoney(Objects.nonNull(orderPrivateCar.getStartMoney())?new BigDecimal(orderPrivateCar.getStartMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setMileageMoney(Objects.nonNull(orderPrivateCar.getMileageMoney())?new BigDecimal(orderPrivateCar.getMileageMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setDurationMoney(Objects.nonNull(orderPrivateCar.getDurationMoney())?new BigDecimal(orderPrivateCar.getDurationMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setWaitMoney(Objects.nonNull(orderPrivateCar.getWaitMoney())?new BigDecimal(orderPrivateCar.getWaitMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setLongDistanceMoney(Objects.nonNull(orderPrivateCar.getLongDistanceMoney())?new BigDecimal(orderPrivateCar.getLongDistanceMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setParkMoney(Objects.nonNull(orderPrivateCar.getParkMoney())?new BigDecimal(orderPrivateCar.getParkMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | orderPrivateCar.setRoadTollMoney(Objects.nonNull(orderPrivateCar.getRoadTollMoney())?new BigDecimal(orderPrivateCar.getRoadTollMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D); |
| | | } |
| | | } |
| | | |
| | | orderPrivateCar.setPayManner(type); |
| | | orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee); |
| | | orderPrivateCar.setRoadTollMoney(null == crossingFee ? 0D : crossingFee); |
| | |
| | | // orderPrivateCar.setTelX(""); |
| | | // orderPrivateCar.setBindId(""); |
| | | // } |
| | | // 判断预估金额和订单金额差异是否大于3元 |
| | | if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(orderPrivateCar.getEstimatedPrice()).abs().doubleValue() > 3){ |
| | | orderPrivateCar.setIsException(1); |
| | | } |
| | | if(orderPrivateCar.getIsException() == 1){ |
| | | orderPrivateCar.setState(13); |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | |
| | |
| | | @Override |
| | | public boolean calculateMileage(Integer orderId, String lon, String lat) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | // 判断距离上一次推送时间是否超过1分钟 |
| | | if(Objects.nonNull(orderPrivateCar.getLastPushTime())){ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | if(Duration.between(orderPrivateCar.getLastPushTime(), now).toMinutes() > 1){ |
| | | orderPrivateCar.setIsException(1); |
| | | } |
| | | orderPrivateCar.setLastPushTime(now); |
| | | }else { |
| | | orderPrivateCar.setLastPushTime(LocalDateTime.now()); |
| | | } |
| | | OrderPosition orderPosition = orderPositionService.queryNew(orderId, 1); |
| | | String now = lon + "," + lat; |
| | | String old = null; |
| | |
| | | orderPrivateCar.setTrackId(String.valueOf(trackId)); |
| | | this.updateById(orderPrivateCar); |
| | | } |
| | | |
| | | @Override |
| | | public void updatePrice(Integer orderId, Integer priceType, BigDecimal updatePrice) { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | orderPrivateCar.setPriceType(priceType); |
| | | orderPrivateCar.setUpdatePrice(updatePrice); |
| | | orderPrivateCar.setPriceAuditState(1); |
| | | this.updateById(orderPrivateCar); |
| | | } |
| | | } |