| | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | 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.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.order.mangodb.model.OrderTrajectory; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | 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.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; |
| | | import com.xiaopeng.order.vo.XpOrderInfoVo; |
| | | import com.xiaopeng.unifiedverification.interceptor.XpClientCheck; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private VehicleMacClient vehicleMacClient; |
| | | @Resource |
| | | private SysGroupMenuClient groupMenuClient; |
| | | |
| | | @Resource |
| | | private XpWhiteListClient xpWhiteListClient; |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Autowired |
| | | private BluetoothDebugConfig bluetoothDebugConfig; |
| | | |
| | | @Resource |
| | | private XpSystemSettingClient xpSystemSettingClient; |
| | | |
| | | @Resource |
| | | @Lazy |
| | | private BootCommonService bootCommonService; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * @param query 分页查询参数 |
| | | * @return 分页结果 |
| | | */ |
| | | @ApiOperation(value = "订单分页列表", tags = {"管理后台-交易管理-订单管理"}) |
| | | @ApiOperation(value = "订单分页列表", tags = {"管理后台-交易管理-订单管理", "管理后台-活动管理"}) |
| | | @PostMapping("/api/v1/order/pageList") |
| | | public R<PageInfo<XpOrderPageVO>> pageList( @RequestBody XpOrderPageQuery query) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | PageInfo<XpOrderPageVO> pageInfo = xpOrderService.pageList(query); |
| | | if(!loginUser.getPhoneDesensitizationExempt()){ |
| | | pageInfo.getRecords().forEach(s->s.setPhoneNumber(DesensitizedUtil.mobilePhone(s.getPhoneNumber()))); |
| | | } |
| | | |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "订单详情", tags = {"管理后台-交易管理-订单管理"}) |
| | | @GetMapping("/api/v1/order/queryById") |
| | | public R<XpOrderDetailVO> queryById(@ApiParam(value = "订单id", required = true) @RequestParam Long id) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | XpOrderDetailVO detail = xpOrderService.getOrderDetail(id); |
| | | if(!loginUser.getPhoneDesensitizationExempt()){ |
| | | detail.setPhoneNumber(DesensitizedUtil.mobilePhone(detail.getPhoneNumber())); |
| | | } |
| | | |
| | | return R.ok(detail); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation(value = "删除订单", tags = {"管理后台-交易管理-订单管理"}) |
| | | @DeleteMapping("/api/v1/order/deleteById") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.DELETE, |
| | | contentExpression = "'删除订单,id=' + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | public R<?> deleteById(@ApiParam(value = "订单id", required = true) @RequestParam Long id) { |
| | | xpOrderService.deleteOrder(id); |
| | | return R.ok(); |
| | |
| | | */ |
| | | @ApiOperation(value = "订单导出", tags = {"管理后台-交易管理-订单管理"}) |
| | | @PostMapping("/api/v1/order/exportExcel") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.EXPORT, |
| | | content = "订单导出", |
| | | appendRequestData = true |
| | | ) |
| | | public void exportExcel(@RequestBody XpOrderExcelQuery query) { |
| | | // 1. 查询导出数据 |
| | | List<XpOrderPageVO> dataList = xpOrderService.exportList(query); |
| | |
| | | */ |
| | | @ApiOperation(value = "取消/关闭订单", tags = {"管理后台-交易管理-订单管理"}) |
| | | @PostMapping("/api/v1/order/cancelAndCloseById") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | content = "取消/关闭订单", |
| | | appendRequestData = true |
| | | ) |
| | | public R<?> cancelAndCloseById(@Validated @RequestBody XpOrderOperateDTO dto) { |
| | | xpOrderService.cancelOrCloseOrder(dto.getOrderId(), dto.getType(),dto.getIsFree()); |
| | | return R.ok(); |
| | |
| | | */ |
| | | @ApiOperation(value = "改派订单", tags = {"管理后台-交易管理-订单管理"}, notes = "车辆列表在 vehicleConvoy.availableList 服务") |
| | | @PostMapping("/api/v1/order/reassignById") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | content = "改派订单", |
| | | appendRequestData = true |
| | | ) |
| | | public R<?> reassignById(@Validated @RequestBody XpOrderReassignDTO dto) { |
| | | xpOrderService.reassignOrder( |
| | | dto.getOrderId(), |
| | |
| | | @ApiImplicitParam(name = "id", value = "订单ID", required = true, dataType = "Long"), |
| | | @ApiImplicitParam(name = "amount", value = "新的订单金额", required = true, dataType = "BigDecimal") |
| | | }) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | contentExpression = "'订单改价,id=' + #p0 + ',amount=' + #p1", |
| | | appendRequestData = false |
| | | ) |
| | | public R<?> changeAmount(@RequestParam("id") Long id, @RequestParam("amount") BigDecimal amount) { |
| | | xpOrderService.changeAmount(id, amount); |
| | | return R.ok(); |
| | |
| | | @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) { |
| | |
| | | * + |
| | | * 获取行程费用明细 |
| | | */ |
| | | @PutMapping("/api/v1/mini-program/order/fare-breakdown/{orderId}") |
| | | @PostMapping("/api/v1/mini-program/order/fare-breakdown") |
| | | @ApiOperation(value = "获取行程费用明细", tags = {"小程序-获取行程费用明细"}) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<FareBreakdownVo> fareBreakdown(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | public R<FareBreakdownVo> fareBreakdown(@RequestBody com.xiaopeng.order.vo.FareBreakdownVo vo, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return xpOrderService.fareBreakdown(orderId, uid); |
| | | return xpOrderService.fareBreakdown(vo, uid); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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); |
| | | 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); |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | 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}") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<BluetoothTokenVo> getBluetoothToken(@PathVariable("orderId") Long orderId, HttpServletRequest request) { |
| | | |
| | | // ========== 联调临时逻辑:通过 Nacos 配置返回固定蓝牙信息(bluetooth-debug.enabled=true 时生效) ========== |
| | | if (bluetoothDebugConfig.isEnabled()) { |
| | | BluetoothTokenVo vo = new BluetoothTokenVo(); |
| | | vo.setToken(bluetoothDebugConfig.getToken()); |
| | | vo.setMacAddress(bluetoothDebugConfig.getMacAddress()); |
| | | vo.setSlaveMacList(bluetoothDebugConfig.getSlaveMacList()); |
| | | return R.ok(vo); |
| | | } |
| | | // ========== 联调临时逻辑结束 ========== |
| | | |
| | | // 原逻辑 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | XpOrder xpOrder = xpOrderService.getById(orderId); |
| | | if (!Objects.equals(xpOrder.getAppUserId(), Long.valueOf(uid))) { |
| | |
| | | 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(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); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断用户类型 |
| | | * @param userId |
| | | * @return 2=老用户,3=新用户,4=流失用户 |
| | | */ |
| | | @PostMapping("/logan/inner/order/determineUserType") |
| | | public R<Integer> determineUserType(@RequestParam Long userId){ |
| | | //判断流失用户 |
| | | XpOrder one = xpOrderService.getOne(new QueryWrapper<XpOrder>().eq("app_user_id", userId).in("status", Arrays.asList(9, 10)).last(" order by create_time desc limit 1")); |
| | | if(null != one){ |
| | | long time = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) - one.getCreateTime().toEpochSecond(ZoneOffset.of("+8")); |
| | | if(time >= 60 * 60 * 24 * 5){ |
| | | return R.ok(4); |
| | | } |
| | | return R.ok(2); |
| | | }else{ |
| | | return R.ok(3); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断用户类型 |
| | | * @param userType |
| | | * @return 2=老用户,3=新用户,4=流失用户 |
| | | */ |
| | | @PostMapping("/logan/inner/order/getUserTypeIdList") |
| | | public R<List<Long>> getUserTypeIdList(@RequestParam Integer userType){ |
| | | List<XpWhitelist> data = xpWhiteListClient.getXpWhitelistByName("").getData(); |
| | | //判断流失用户 |
| | | if(4 == userType){ |
| | | Set<Long> collect = data.stream().map(XpWhitelist::getAppUserId).collect(Collectors.toSet()); |
| | | List<XpOrder> one = xpOrderService.list(new QueryWrapper<XpOrder>().in("app_user_id", collect).in("status", Arrays.asList(9, 10)).last(" order by create_time desc limit 1")); |
| | | if(one.isEmpty()){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | List<Long> appUserIds = new ArrayList<>(); |
| | | for (XpOrder order : one) { |
| | | long time = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) - order.getCreateTime().toEpochSecond(ZoneOffset.of("+8")); |
| | | if(time >= 60 * 60 * 24 * 5){ |
| | | appUserIds.add(order.getAppUserId()); |
| | | } |
| | | } |
| | | return R.ok(appUserIds); |
| | | } |
| | | //新用户 |
| | | if(3 == userType){ |
| | | Set<Long> collect = data.stream().map(XpWhitelist::getAppUserId).collect(Collectors.toSet()); |
| | | List<XpOrder> one = xpOrderService.list(new QueryWrapper<XpOrder>().in("app_user_id", collect).in("status", Arrays.asList(9, 10)).last(" order by create_time desc limit 1")); |
| | | if(one.isEmpty()){ |
| | | return R.ok(new ArrayList<>(collect)); |
| | | } |
| | | collect.removeAll(one.stream().map(XpOrder::getAppUserId).collect(Collectors.toList())); |
| | | return R.ok(new ArrayList<>(collect)); |
| | | } |
| | | |
| | | |
| | | //老用户 |
| | | if(2 == userType){ |
| | | Set<Long> collect = data.stream().map(XpWhitelist::getAppUserId).collect(Collectors.toSet()); |
| | | List<XpOrder> one = xpOrderService.list(new QueryWrapper<XpOrder>().in("app_user_id", collect).in("status", Arrays.asList(9, 10)).last(" order by create_time desc limit 1")); |
| | | if(one.isEmpty()){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | List<Long> appUserIds = new ArrayList<>(); |
| | | for (XpOrder order : one) { |
| | | appUserIds.add(order.getAppUserId()); |
| | | } |
| | | return R.ok(appUserIds); |
| | | } |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户订单数量 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/order/getUserOrderNum") |
| | | public R<Long> getUserOrderNum(@RequestParam Long userId){ |
| | | long count = xpOrderService.count(new QueryWrapper<XpOrder>().eq("app_user_id", userId) |
| | | .ne("status", 0).eq("is_deleted", 0)); |
| | | return R.ok(count); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/drainage/v1/order/updateOrderStatus") |
| | | @ApiOperation(value = "更新订单状态", notes = "流量接入-订单信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "token", name = "token", required = true, paramType = "header") |
| | | }) |
| | | public R<?> officialPartnerUpdateOrderStatus(@RequestBody UpdateOrderStatusVo vo, HttpServletRequest request){ |
| | | XpOfficialPartner officialPartner = tokenService.getOfficialPartner(); |
| | | return xpOrderService.officialPartnerUpdateOrderStatus(vo, officialPartner.getId()); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/drainage/v1/order/getOrderNavigation") |
| | | @ApiOperation(value = "获取订单导航数据", notes = "流量接入-订单信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "token", name = "token", required = true, paramType = "header") |
| | | }) |
| | | public R<NavigationVo> getOrderNavigation(@RequestBody OrderNavigationDto dto, HttpServletRequest request){ |
| | | XpOfficialPartner officialPartner = tokenService.getOfficialPartner(); |
| | | XpOrder xpOrder = xpOrderService.getById(dto.getOrderId()); |
| | | if(!xpOrder.getOfficialPartnerId().equals(officialPartner.getId())){ |
| | | return R.fail("无权限"); |
| | | } |
| | | NavigationVo navigationVo = null; |
| | | if(1 == dto.getNavigationType()){ |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId()); |
| | | if(null != cacheObject){ |
| | | navigationVo = JSON.parseObject(cacheObject.toString(), NavigationVo.class); |
| | | } |
| | | } |
| | | if(2 == dto.getNavigationType()){ |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId()); |
| | | if(null != cacheObject){ |
| | | navigationVo = JSON.parseObject(cacheObject.toString(), NavigationVo.class); |
| | | } |
| | | } |
| | | return R.ok(navigationVo); |
| | | } |
| | | |
| | | |
| | | @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({ |
| | | @ApiImplicitParam(value = "token", name = "token", required = true, paramType = "header") |
| | | }) |
| | | public R<XpOrderInfoVo> getOfficialPartnerOrderInfo(@PathVariable Long orderId){ |
| | | XpOfficialPartner officialPartner = tokenService.getOfficialPartner(); |
| | | XpOrder xpOrder = xpOrderService.getById(orderId); |
| | | if(!xpOrder.getOfficialPartnerId().equals(officialPartner.getId())){ |
| | | return R.fail("无权限"); |
| | | } |
| | | 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); |
| | | } |
| | | } |