| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | * 退款 |
| | | * |
| | | * @param outTradeNo |
| | | * @param refundAmount |
| | | * @return |
| | | */ |
| | | public boolean orderRefund(String outTradeNo, Double refundAmount/*, Long userId, String username*/) { |
| | | public boolean orderRefund(String outTradeNo, Double amt) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | String username = SecurityUtils.getUsername(); |
| | | C3mOrder orderByOutTradeNo = c3mOrderMapper.getOrderByOutTradeNo(outTradeNo); |
| | | Double refundAmount = orderByOutTradeNo.getSurplusAmount(); |
| | | if (orderByOutTradeNo.getTotalAmount() < refundAmount) { |
| | | throw new BusinessException("退款金额错误,不能大于付款金额"); |
| | | } |
| | |
| | | C3mOrder.setRefundMsg(msg); |
| | | if (b) { |
| | | C3mOrder.setOrderStatus(OrderStatus.REFUND.getStatus()); |
| | | c3mOrderMapper.updateRefundOrder(C3mOrder); |
| | | c3mOrderMapper.updateRefundOrder(C3mOrder); // TODO: 退款日志 |
| | | |
| | | /* logService.log( |
| | | userId, |
| | | ServerTask.SERVER_TASK, |
| | |
| | | } |
| | | //查询充电桩是否存在正在进行中的订单 |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class) |
| | | .eq(C3mOrder::getC3Udid, c3m.getMcuUdid()).eq(C3mOrder::getChargingStates, 1).last("limit 1")); |
| | | .eq(C3mOrder::getC3Udid, c3m.getMcuUdid()).eq(C3mOrder::getChargingStates, 0).last("limit 1")); |
| | | |
| | | if (c3mOrder != null && !c3mOrder.getUserCode().equals(wxCode)) { |
| | | throw new BusinessException("该充电桩正在被别人使用"); |
| | | } |
| | | if (c3mOrder != null) { |
| | | throw new BusinessException("该充电桩已存在正在进行中的订单"); |
| | | } |
| | | Pole pole = poleService.getById(streetlightId); |
| | | if (null == pole) { |
| | |
| | | */ |
| | | public void updateOrderStatusByHeartbeat(A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage dataPackage) { |
| | | //充电中的心跳包需要去更新订单数据,否则不处理! |
| | | if(dataPackage.getStatusBit().equals("02")){ |
| | | if (dataPackage.getStatusBit().equals("02")) { |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class).eq(C3mOrder::getC3Mac, dataPackage.getC3Mac()) |
| | | .eq(C3mOrder::getChargingStates, 1).last("limit 1")); |
| | | if (c3mOrder == null) { |
| | |
| | | * @param baseConditionVO |
| | | * @return |
| | | */ |
| | | public List<C3mOrderBo> orderList(BaseConditionVO baseConditionVO) { |
| | | public List<C3mOrderBo> orderList(BaseConditionVO baseConditionVO, String keyword, |
| | | Integer orderStatus, Integer timeType) { |
| | | if (orderStatus != null && (orderStatus > 5 || orderStatus < 0)) { |
| | | throw new BusinessException("订单状态不正确"); |
| | | } |
| | | Long userId = SecurityUtils.getClientId(); |
| | | //查询近一个月的订单 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime startTime = null; |
| | | ; |
| | | Long startTimeStamp = null; |
| | | Long nowTimeStamp = null; |
| | | if (timeType != null) { |
| | | if (timeType == 1) { |
| | | //查询近一个月的订单 |
| | | startTime = now.minusMonths(1); |
| | | } else if (timeType == 2) { |
| | | //查询近三个月的订单 |
| | | startTime = now.minusMonths(3); |
| | | } else if (timeType == 3) { |
| | | //查询近半年的订单 |
| | | startTime = now.minusMonths(6); |
| | | } else { |
| | | throw new BusinessException("时间类型不正确"); |
| | | } |
| | | //startTime转换为时间戳 |
| | | startTimeStamp = startTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
| | | //endTime转换为时间戳 |
| | | nowTimeStamp = now.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
| | | } |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | List<C3mOrderBo> list = baseMapper.orderList(userId); |
| | | List<C3mOrderBo> list = baseMapper.orderList(userId, keyword, orderStatus, startTimeStamp, nowTimeStamp); |
| | | return list; |
| | | } |
| | | |