临时锁车、继续骑行
This commit is contained in:
parent
596ccfdfa7
commit
95d962edbe
@ -46,4 +46,6 @@ public interface CmdCode {
|
|||||||
String RESTART = "restart";
|
String RESTART = "restart";
|
||||||
|
|
||||||
String TEMP_LOCK = "temp_lock";
|
String TEMP_LOCK = "temp_lock";
|
||||||
|
|
||||||
|
String CONTINUE_CYCLING = "continue_cycling";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,30 @@ public class EbikeUserOrdersController {
|
|||||||
return JsonResult.success(userOrders);
|
return JsonResult.success(userOrders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时锁车。
|
||||||
|
*
|
||||||
|
* @param orderDto 骑行信息
|
||||||
|
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||||
|
*/
|
||||||
|
@PostMapping("tempLock")
|
||||||
|
public JsonResult<?> tempLock(@RequestBody @Validated ReqOrderDto orderDto) {
|
||||||
|
userOrdersService.tempLock(orderDto);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 继续骑行。
|
||||||
|
*
|
||||||
|
* @param orderDto 骑行信息
|
||||||
|
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||||
|
*/
|
||||||
|
@PostMapping("continueCycling")
|
||||||
|
public JsonResult<?> continueCycling(@RequestBody @Validated ReqOrderDto orderDto) {
|
||||||
|
userOrdersService.continueCycling(orderDto);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 完成骑行(关锁还车)。
|
* 完成骑行(关锁还车)。
|
||||||
*
|
*
|
||||||
@ -83,7 +107,6 @@ public class EbikeUserOrdersController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户订单表主键获取详细信。
|
* 根据用户订单表主键获取详细信。
|
||||||
*
|
*
|
||||||
@ -103,10 +126,10 @@ public class EbikeUserOrdersController {
|
|||||||
* @ 分页对象
|
* @ 分页对象
|
||||||
*/
|
*/
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
public JsonResult<?> page(@Validated PageParam pageParam,@RequestParam(value = "bikeId",required = false) Long bikeId) {
|
public JsonResult<?> page(@Validated PageParam pageParam, @RequestParam(value = "bikeId", required = false) Long bikeId) {
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
.from(USER_ORDERS)
|
.from(USER_ORDERS)
|
||||||
.where(USER_ORDERS.BIKE_ID.eq(bikeId,bikeId != null));
|
.where(USER_ORDERS.BIKE_ID.eq(bikeId, bikeId != null));
|
||||||
Page<UserOrders> page = userOrdersService.page(pageParam.getPage(), queryWrapper);
|
Page<UserOrders> page = userOrdersService.page(pageParam.getPage(), queryWrapper);
|
||||||
return JsonResult.success(page);
|
return JsonResult.success(page);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,4 +46,6 @@ public interface CmdCode {
|
|||||||
String RESTART = "restart";
|
String RESTART = "restart";
|
||||||
|
|
||||||
String TEMP_LOCK = "temp_lock";
|
String TEMP_LOCK = "temp_lock";
|
||||||
|
|
||||||
|
String CONTINUE_CYCLING = "continue_cycling";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,5 +40,22 @@ public interface UserOrdersService extends IService<UserOrders> {
|
|||||||
*/
|
*/
|
||||||
UserOrders checkHistoryOrder(String userId);
|
UserOrders checkHistoryOrder(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆位置列表
|
||||||
|
* @param bikeDto 位置i信息
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
List<RspBikeDto> bikeList(ReqBikeDto bikeDto);
|
List<RspBikeDto> bikeList(ReqBikeDto bikeDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时锁车
|
||||||
|
* @param orderDto 订单信息
|
||||||
|
*/
|
||||||
|
void tempLock(ReqOrderDto orderDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 继续骑行
|
||||||
|
* @param orderDto 订单信息
|
||||||
|
*/
|
||||||
|
void continueCycling(ReqOrderDto orderDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,7 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public Long doneRide(ReqOrderDto orderDto) {
|
public Long doneRide(ReqOrderDto orderDto) {
|
||||||
String userId = orderDto.getUserId();
|
String userId = orderDto.getUserId();
|
||||||
UserOrders userOrders = getOrder(orderDto);
|
UserOrders userOrders = getOrder(orderDto);
|
||||||
@ -190,6 +191,48 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void tempLock(ReqOrderDto orderDto) {
|
||||||
|
String userId = orderDto.getUserId();
|
||||||
|
UserOrders userOrders = getOrder(orderDto);
|
||||||
|
JsonResult<FeignEbikeBikeInfoDto> jsonResult = maintenanceFeignClient.getEbikeInfoByCode(orderDto.getBikeCode());
|
||||||
|
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||||
|
throw new RuntimeException("获取车辆信息失败");
|
||||||
|
}
|
||||||
|
FeignEbikeBikeInfoDto bikeInfoDto = jsonResult.getData();
|
||||||
|
FeignEbikeEcuInfo ecuInfo = bikeInfoDto.getEbikeEcuInfo();
|
||||||
|
CompletableFuture<String> stringCompletableFuture = ebikeCoreHandler.executeCommand(ecuInfo, CmdCode.TEMP_LOCK, Long.valueOf(bikeInfoDto.getBikeId()), userId);
|
||||||
|
String response = stringCompletableFuture.join();
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
if (jsonObject.getInteger("code") != 0) {
|
||||||
|
throw new RuntimeException("关锁失败");
|
||||||
|
}
|
||||||
|
userOrders.setTempLock(1);
|
||||||
|
userOrdersMapper.update(userOrders);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void continueCycling(ReqOrderDto orderDto) {
|
||||||
|
String userId = orderDto.getUserId();
|
||||||
|
UserOrders userOrders = getOrder(orderDto);
|
||||||
|
JsonResult<FeignEbikeBikeInfoDto> jsonResult = maintenanceFeignClient.getEbikeInfoByCode(orderDto.getBikeCode());
|
||||||
|
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||||
|
throw new RuntimeException("获取车辆信息失败");
|
||||||
|
}
|
||||||
|
FeignEbikeBikeInfoDto bikeInfoDto = jsonResult.getData();
|
||||||
|
FeignEbikeEcuInfo ecuInfo = bikeInfoDto.getEbikeEcuInfo();
|
||||||
|
CompletableFuture<String> stringCompletableFuture = ebikeCoreHandler.executeCommand(ecuInfo, CmdCode.CONTINUE_CYCLING, Long.valueOf(bikeInfoDto.getBikeId()), userId);
|
||||||
|
String response = stringCompletableFuture.join();
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||||
|
if (jsonObject.getInteger("code") != 0) {
|
||||||
|
throw new RuntimeException("开锁失败");
|
||||||
|
}
|
||||||
|
userOrders.setTempLock(0);
|
||||||
|
userOrdersMapper.update(userOrders);
|
||||||
|
}
|
||||||
|
|
||||||
boolean bikeInOperation(double lng, double lat, Long orgId, Long regionId) {
|
boolean bikeInOperation(double lng, double lat, Long orgId, Long regionId) {
|
||||||
return redisUtil.isPointInOperation(lng, lat, orgId, regionId);
|
return redisUtil.isPointInOperation(lng, lat, orgId, regionId);
|
||||||
}
|
}
|
||||||
@ -267,6 +310,7 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
|||||||
* @return 计费后总金额
|
* @return 计费后总金额
|
||||||
*/
|
*/
|
||||||
BigDecimal defaultCostCalculation(BigDecimal totalAmount,long minutes,ResFeignEbikeSysRcostsetDto feignEbikeSysRcostsetDto){
|
BigDecimal defaultCostCalculation(BigDecimal totalAmount,long minutes,ResFeignEbikeSysRcostsetDto feignEbikeSysRcostsetDto){
|
||||||
|
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user