| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.DesensitizedUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.dto.QueryOrderRouteDTO; |
| | |
| | | import com.xiaopeng.api.dto.statistics.OrderStatisticsDTO; |
| | | import com.xiaopeng.api.dto.statistics.StatisticsQueryDTO; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.BaseVehicleUserDto; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.BleInfoResponseDto; |
| | | import com.xiaopeng.api.feignClient.account.SysGroupMenuClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpSystemSettingClient; |
| | | import com.xiaopeng.api.feignClient.operation.XpWhiteListClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.BluetoothUnlockClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.VehicleMacClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.operation.XpOfficialPartner; |
| | | import com.xiaopeng.api.model.operation.XpSystemSetting; |
| | | import com.xiaopeng.api.model.operation.XpWhitelist; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.account.LoginUser; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.operation.NavigationVo; |
| | | import com.xiaopeng.api.vo.operation.NearestNextVo; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.api.vo.order.*; |
| | | import com.xiaopeng.api.vo.vehicleConvoy.GetBleInfoVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.enums.OrderStatusEnum; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.utils.SensitiveDataCryptoUtil; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.common.core.utils.WebUtils; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | |
| | | import com.xiaopeng.order.config.BluetoothDebugConfig; |
| | | import com.xiaopeng.order.dto.OrderNavigationDto; |
| | | import com.xiaopeng.api.model.order.OrderTrajectory; |
| | | import com.xiaopeng.order.mangodb.service.OrderTrajectoryService; |
| | | import com.xiaopeng.order.model.dto.XpOrderCommentDto; |
| | | import com.xiaopeng.order.model.dto.XpOrderOperateDTO; |
| | | import com.xiaopeng.order.model.dto.XpOrderPayDto; |
| | |
| | | import com.xiaopeng.order.model.vo.XpOrderHistoryVO; |
| | | import com.xiaopeng.order.model.vo.XpOrderPageVO; |
| | | import com.xiaopeng.order.service.IXpOrderService; |
| | | import com.xiaopeng.order.service.impl.BootCommonService; |
| | | import com.xiaopeng.order.vo.BluetoothTokenVo; |
| | | import com.xiaopeng.order.vo.OrderDetailVo; |
| | | import com.xiaopeng.order.vo.UpdateOrderStatusVo; |
| | |
| | | |
| | | @Autowired |
| | | private BluetoothDebugConfig bluetoothDebugConfig; |
| | | |
| | | @Resource |
| | | private XpSystemSettingClient xpSystemSettingClient; |
| | | |
| | | @Resource |
| | | @Lazy |
| | | private BootCommonService bootCommonService; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<NearestNextVo> quickCapsule(@RequestParam Long startPointId,HttpServletRequest request) { |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.quickCapsule(uid,startPointId)); |
| | | NearestNextVo nearestNextVo = xpOrderService.quickCapsule(uid, startPointId); |
| | | return R.ok(nearestNextVo); |
| | | |
| | | } |
| | | |
| | |
| | | String uid = request.getHeader("XP-Uid"); |
| | | try { |
| | | Boolean b = xpOrderService.endTrip(orderId, uid); |
| | | //判断是否测试免费 |
| | | XpSystemSetting xpSystemSetting = xpSystemSettingClient.getSystemSettingOne().getData(); |
| | | if (xpSystemSetting != null && xpSystemSetting.getOperateFree() == 1) { |
| | | //将支付金额修改成0 并将状态修改成 订单状态9 |
| | | XpOrder xpOrder1 = new XpOrder(); |
| | | xpOrder1.setId(orderId); |
| | | xpOrder1.setIsFree(true);//豁免 |
| | | xpOrder1.setPayMoney(BigDecimal.ZERO); |
| | | xpOrder1.setStatus(OrderStatusEnum.PENDING_PAYMENT.getCode()); |
| | | xpOrder1.setUpdateTime(LocalDateTime.now()); |
| | | xpOrderService.updateById(xpOrder1); |
| | | bootCommonService.setCache_orderStatus(xpOrder1.getId(), xpOrder1, null); |
| | | } |
| | | return R.ok(b); |
| | | |
| | | } catch (Exception e) { |
| | |
| | | @ApiOperation(value = "订单状态推送修改") |
| | | @PostMapping("/logan/inner/v1/order/updateOrderStatus") |
| | | public R<String> updateOrderStatus(@RequestParam Long orderId, |
| | | @RequestParam Integer status, |
| | | @RequestParam Boolean orderException) { |
| | | return xpOrderService.updateOrderStatus(orderId, status, orderException); |
| | | @RequestParam Integer status) { |
| | | return xpOrderService.updateOrderStatus(orderId, status); |
| | | } |
| | | |
| | | /** |
| | |
| | | String uid = request.getHeader("XP-Uid"); |
| | | // 查询订单信息 |
| | | XpOrder xpOrder = xpOrderService.getById(dto.getOrderId()); |
| | | // 获取路线规划 |
| | | // RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType()); |
| | | |
| | | String key = ""; |
| | | //接驾情况,获取车辆位置到起点的导航 |
| | | if (xpOrder.getStatus() < 5) { |
| | |
| | | Object cacheObject = redisService.getCacheObject(key); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | // VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | // routeVo.setDirection(null != vehiclePosition ? vehiclePosition.getCourse() : 90); |
| | | |
| | | Long vehicleId = xpOrder.getVehicleId(); |
| | | XpOrder one = xpOrderService.getOne(new QueryWrapper<XpOrder>().eq("vehicle_id", vehicleId).in("status", Arrays.asList(6, 7)).eq("is_deleted", 0)); |
| | | if(null != one){ |
| | | routeVo.setEndLongitude(one.getEndLon()); |
| | | routeVo.setEndLatitude(one.getEndLat()); |
| | | } |
| | | |
| | | String vin = SensitiveDataCryptoUtil.decryptIfPossible(xpVehicle.getVehicleVin()); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | routeVo.setDirection(null != vehiclePosition ? vehiclePosition.getCourse() : 90); |
| | | routeVo.setEndLongitude(xpOrder.getEndLon()); |
| | | routeVo.setEndLatitude(xpOrder.getEndLat()); |
| | | return R.ok(routeVo); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | routeVo.setPolyline(polyline); |
| | | XpOrder xpOrder = xpOrderService.getById(orderId); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | String vin = SensitiveDataCryptoUtil.decryptIfPossible(xpVehicle.getVehicleVin()); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | routeVo.setDirection(null != vehiclePosition ? vehiclePosition.getCourse() : 0); |
| | | return R.ok(routeVo); |
| | | } |
| | | |
| | |
| | | * @param |
| | | * @return 订单数量 |
| | | */ |
| | | @PostMapping("/inner/order/todayCancellationCount") |
| | | public R<Integer> todayCancellationCount(@RequestParam Long userId) { |
| | | @PostMapping("/logan/inner/order/todayCancellationCount") |
| | | public R<Integer> todayCancellationCount(@RequestParam Long userId){ |
| | | long count = xpOrderService.count(new QueryWrapper<XpOrder>().eq("app_user_id", userId).eq("status", 0) |
| | | .eq("is_deleted", 0).last(" and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')")); |
| | | return R.ok((int) count); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建巡游单和推送车端报文 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/order/addNewCruiseMission") |
| | | public R<?> addNewCruiseMission(@RequestParam("orderId") String orderId){ |
| | | XpOrder xpOrder = xpOrderService.getById(orderId); |
| | | xpOrderService.addCruiseMission(xpOrder.getVehicleId(), xpOrder); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "通过订单id获取蓝牙开锁秘钥", tags = {"小程序-业务流程"}) |
| | | @GetMapping("/api/v1/mini-program/bluetooth/getUnlocktToken/{orderId}") |
| | |
| | | return R.ok(); |
| | | } |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | String vin = SensitiveDataCryptoUtil.decryptIfPossible(xpVehicle.getVehicleVin()); |
| | | GetBleInfoVo getBleInfoVo = new GetBleInfoVo(); |
| | | getBleInfoVo.setVin(xpVehicle.getVehicleVin()); |
| | | BaseVehicleUserDto baseVehicleUserDto = vehicleMacClient.getBleInfo(uid, getBleInfoVo); |
| | | if(null == baseVehicleUserDto || 200 != baseVehicleUserDto.getCode()){ |
| | | getBleInfoVo.setVin(vin); |
| | | BleInfoResponseDto bleInfoResponseDto = vehicleMacClient.getBleInfo(uid, getBleInfoVo); |
| | | if (null == bleInfoResponseDto || 200 != bleInfoResponseDto.getCode()) { |
| | | throw new ServiceException("获取蓝牙信息失败"); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(baseVehicleUserDto.getData().toString()); |
| | | BluetoothTokenVo vo = new BluetoothTokenVo(); |
| | | vo.setToken(token); |
| | | vo.setMacAddress(jsonObject.getString("macAddress")); |
| | | vo.setSlaveMacList(jsonObject.getList("slaveMacList", String.class)); |
| | | vo.setMacAddress(bleInfoResponseDto.getData().getMacAddress()); |
| | | vo.setSlaveMacList(bleInfoResponseDto.getData().getSlaveMacList().stream() |
| | | .map(s -> s.getMac()).collect(java.util.stream.Collectors.toList())); |
| | | return R.ok(vo); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/test/bluetooth/getBleInfo") |
| | | @ApiOperation(value = "[测试] 直接调用蓝牙信息接口验证DTO解析", notes = "仅用于本地联调验证,生产环境请勿使用") |
| | | public R<BleInfoResponseDto> testGetBleInfo(@RequestParam String uid, @RequestParam String vin) { |
| | | GetBleInfoVo vo = new GetBleInfoVo(); |
| | | vo.setVin(vin); |
| | | BleInfoResponseDto result = vehicleMacClient.getBleInfo(uid, vo); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private BluetoothUnlockClient bluetoothUnlockClient; |
| | | |
| | | @PostMapping("/test/bluetooth/deliver") |
| | | @ApiOperation(value = "[测试] 直接调用蓝牙token下发接口验证响应", notes = "仅用于本地联调验证,生产环境请勿使用") |
| | | public R<BaseVehicleUserDto> testDeliver(@RequestBody com.xiaopeng.api.vo.vehicleConvoy.BluetoothDeliverVo vo) { |
| | | BaseVehicleUserDto result = bluetoothUnlockClient.deliver(vo); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @PostMapping("/drainage/v1/order/getOrderInfo") |
| | | @ApiOperation(value = "获取订单详情", notes = "流量接入-订单信息") |
| | | @ApiImplicitParams({ |
| | |
| | | XpOrderInfoVo xpOrderInfoVo = BeanUtil.copyProperties(xpOrder, XpOrderInfoVo.class); |
| | | return R.ok(xpOrderInfoVo); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "获取订单支付状态", tags = {"小程序-业务流程"}) |
| | | @GetMapping("/api/v1/mini-program/order/queryOrderStatusFromOrderId") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<OrderStatusFromOrderIdVo> queryOrderStatusFromOrderId(Long orderId) { |
| | | XpOrder order = xpOrderService.getById(orderId); |
| | | OrderStatusFromOrderIdVo orderStatusFromOrderIdVo = new OrderStatusFromOrderIdVo(); |
| | | orderStatusFromOrderIdVo.setOrderId(order.getId()); |
| | | orderStatusFromOrderIdVo.setStatus(order.getStatus()); |
| | | return R.ok(orderStatusFromOrderIdVo); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询是否有未支付订单 |
| | | */ |
| | | @PostMapping("/logan/inner/order/has-unpay-order") |
| | | public R<Long> hasUnPayOrder(@RequestParam String uid){ |
| | | long count = xpOrderService.count(new QueryWrapper<XpOrder>().eq("app_user_id", Long.valueOf(uid)) |
| | | .eq("status", 8).eq("is_deleted", 0)); |
| | | return R.ok(count); |
| | | } |
| | | } |