预估价格联调

main
topsun 2 years ago
parent d8b4a33404
commit 7e5c29cc4d

@ -2,6 +2,7 @@ package com.taxi.apipassenger.controller;
import com.internal.dto.ResponseResult;
import com.internal.request.ForecastPriceDTO;
import com.taxi.apipassenger.remote.ServicePriceClient;
import com.taxi.apipassenger.service.ForecastPriceServcie;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -16,6 +17,8 @@ public class ForecastPriceController {
@Autowired
private ForecastPriceServcie forecastPriceServcie;
@PostMapping("/forecast-price")
public ResponseResult forecastPrice(@RequestBody ForecastPriceDTO forecastPriceDTO) {
log.info("出发经度," + forecastPriceDTO.getDepLongitude());
@ -29,6 +32,8 @@ public class ForecastPriceController {
log.info("目的地经度," + forecastPriceDTO.getDestLongitude());
log.info("目的地纬度," + forecastPriceDTO.getDestLatitude());
return forecastPriceServcie.forecastPrice(depLongitude,depLatitude,destLongitude,destLatitude);
}
}

@ -0,0 +1,19 @@
package com.taxi.apipassenger.remote;
import com.internal.dto.ResponseResult;
import com.internal.request.ForecastPriceDTO;
import com.internal.response.ForecastPriceResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient("service-price")
public interface ServicePriceClient {
@RequestMapping(method = RequestMethod.POST,value = "/forecast-price")
ResponseResult<ForecastPriceResponse> forecast(@RequestBody ForecastPriceDTO forecastPriceDTO);
}

@ -1,14 +1,18 @@
package com.taxi.apipassenger.service;
import com.internal.dto.ResponseResult;
import com.internal.request.ForecastPriceDTO;
import com.internal.response.ForecastPriceResponse;
import com.taxi.apipassenger.remote.ServicePriceClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class ForecastPriceServcie {
@Autowired
private ServicePriceClient servicePriceClient;
/**
*
* @param depLongitude
@ -23,11 +27,17 @@ public class ForecastPriceServcie {
log.info("出发纬度," + depLatitude);
log.info("目的地经度," + destLongitude);
log.info("目的地纬度," + destLatitude);
log.info("调用计价服务,计算价格");
ForecastPriceDTO forecastPriceDTO = new ForecastPriceDTO();
forecastPriceDTO.setDepLongitude(depLongitude);
forecastPriceDTO.setDepLatitude(depLatitude);
forecastPriceDTO.setDestLongitude(destLongitude);
forecastPriceDTO.setDestLatitude(destLatitude);
ResponseResult<ForecastPriceResponse> responseResult = servicePriceClient.forecast(forecastPriceDTO);
double price = responseResult.getData().getPrice();
ForecastPriceResponse forecastPriceResponse = new ForecastPriceResponse();
forecastPriceResponse.setPrice(12.121);
forecastPriceResponse.setPrice(price);
return ResponseResult.success(forecastPriceResponse);
}

Loading…
Cancel
Save