Compare commits
2 Commits
86affc4437
...
46c1445737
| Author | SHA1 | Date | |
|---|---|---|---|
| 46c1445737 | |||
| e8869e61bc |
@ -106,6 +106,30 @@ public class EbikeUserOrdersController {
|
|||||||
return JsonResult.success(orderId);
|
return JsonResult.success(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查车辆是否在运营区内。
|
||||||
|
*
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||||
|
*/
|
||||||
|
@GetMapping("checkBikeInOperation")
|
||||||
|
public JsonResult<?> checkBikeInOperation(@RequestParam("bikeCode")String bikeCode) {
|
||||||
|
boolean inOperation = userOrdersService.checkBikeInOperation(bikeCode);
|
||||||
|
return JsonResult.success(inOperation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查车辆是否在停车区内。
|
||||||
|
*
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @ {@code 200} 添加成功,{@code 500} 添加失败
|
||||||
|
*/
|
||||||
|
@GetMapping("checkBikeInParking")
|
||||||
|
public JsonResult<?> checkBikeInParking(@RequestParam("bikeCode")String bikeCode) {
|
||||||
|
boolean inParking = userOrdersService.checkBikeInParking(bikeCode);
|
||||||
|
return JsonResult.success(inParking);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户订单表主键获取详细信。
|
* 根据用户订单表主键获取详细信。
|
||||||
|
|||||||
@ -58,4 +58,18 @@ public interface UserOrdersService extends IService<UserOrders> {
|
|||||||
* @param orderDto 订单信息
|
* @param orderDto 订单信息
|
||||||
*/
|
*/
|
||||||
void continueCycling(ReqOrderDto orderDto);
|
void continueCycling(ReqOrderDto orderDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断车辆当前位置是否在运营区内
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
boolean checkBikeInOperation(String bikeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断车辆当前位置是否在停车区内
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
boolean checkBikeInParking(String bikeCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -238,6 +238,42 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
|||||||
userOrdersMapper.update(userOrders);
|
userOrdersMapper.update(userOrders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkBikeInOperation(String bikeCode) {
|
||||||
|
JsonResult<FeignEbikeBikeInfoDto> jsonResult = maintenanceFeignClient.getEbikeInfoByCode(bikeCode);
|
||||||
|
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||||
|
throw new RuntimeException("获取车辆信息失败");
|
||||||
|
}
|
||||||
|
FeignEbikeBikeInfoDto bikeInfoDto = jsonResult.getData();
|
||||||
|
FeignEbikeEcuInfo ecuInfo = bikeInfoDto.getEbikeEcuInfo();
|
||||||
|
JsonResult<FeignEbikeRegionDto> regionResult = operateFeignClient.getOperationById(bikeInfoDto.getReginId());
|
||||||
|
if (regionResult.getCode() != Code.SUCCESS) {
|
||||||
|
throw new RuntimeException("获取运营区信息失败");
|
||||||
|
}
|
||||||
|
FeignEbikeRegionDto regionDto = regionResult.getData();
|
||||||
|
String jsonString = JSONObject.toJSONString(redisUtil.get(ecuInfo.getEcuSn()));
|
||||||
|
ResGPSDto resGpsDto = JSONObject.parseObject(jsonString, ResGPSDto.class);
|
||||||
|
return bikeInOperation(resGpsDto.getLongitude(),resGpsDto.getLatitude(),regionDto.getOrgId(),bikeInfoDto.getReginId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkBikeInParking(String bikeCode) {
|
||||||
|
JsonResult<FeignEbikeBikeInfoDto> jsonResult = maintenanceFeignClient.getEbikeInfoByCode(bikeCode);
|
||||||
|
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||||
|
throw new RuntimeException("获取车辆信息失败");
|
||||||
|
}
|
||||||
|
FeignEbikeBikeInfoDto bikeInfoDto = jsonResult.getData();
|
||||||
|
FeignEbikeEcuInfo ecuInfo = bikeInfoDto.getEbikeEcuInfo();
|
||||||
|
JsonResult<FeignEbikeRegionDto> regionResult = operateFeignClient.getOperationById(bikeInfoDto.getReginId());
|
||||||
|
if (regionResult.getCode() != Code.SUCCESS) {
|
||||||
|
throw new RuntimeException("获取运营区信息失败");
|
||||||
|
}
|
||||||
|
FeignEbikeRegionDto regionDto = regionResult.getData();
|
||||||
|
String jsonString = JSONObject.toJSONString(redisUtil.get(ecuInfo.getEcuSn()));
|
||||||
|
ResGPSDto resGpsDto = JSONObject.parseObject(jsonString, ResGPSDto.class);
|
||||||
|
return redisUtil.isPointInParking(resGpsDto.getLongitude(),resGpsDto.getLatitude(),regionDto.getOrgId());
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -254,8 +290,8 @@ public class UserOrdersServiceImpl extends ServiceImpl<UserOrdersMapper, UserOrd
|
|||||||
BigDecimal totalAmount = new BigDecimal(0);
|
BigDecimal totalAmount = new BigDecimal(0);
|
||||||
//是否在运营区内
|
//是否在运营区内
|
||||||
boolean pointInOperation = bikeInOperation(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOrgId(), regionDto.getRegionId());
|
boolean pointInOperation = bikeInOperation(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOrgId(), regionDto.getRegionId());
|
||||||
boolean pointInParking = redisUtil.isPointInParking(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOrgId());
|
|
||||||
//是否在停车区内
|
//是否在停车区内
|
||||||
|
boolean pointInParking = redisUtil.isPointInParking(resGpsDto.getLongitude(), resGpsDto.getLatitude(), regionDto.getOrgId());
|
||||||
long minutes = TimeUtils.betweenMinutes(userOrders.getStartTime(), userOrders.getEndTime());
|
long minutes = TimeUtils.betweenMinutes(userOrders.getStartTime(), userOrders.getEndTime());
|
||||||
//是否取消订单
|
//是否取消订单
|
||||||
if (pointInOperation && pointInParking && minutes < feignEbikeSysRcostsetDto.getFreeDuration()){
|
if (pointInOperation && pointInParking && minutes < feignEbikeSysRcostsetDto.getFreeDuration()){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user