From 2103c9676bf98087aee3032c3f6cc15ed2837d0c Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 13 六月 2025 10:51:20 +0800 Subject: [PATCH] 价格计算修改 --- UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java | 64 ++++++++++++++++++++++++++++--- 1 files changed, 57 insertions(+), 7 deletions(-) diff --git a/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java b/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java index fbc5480..9d92623 100644 --- a/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java +++ b/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/controller/OrderTaxiController.java @@ -1,23 +1,28 @@ package com.stylefeng.guns.modular.taxi.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.stylefeng.guns.modular.system.dao.SystemPriceMapper; +import com.stylefeng.guns.modular.system.model.Company; import com.stylefeng.guns.modular.system.service.*; +import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil; import com.stylefeng.guns.modular.system.util.MD5AndKL; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; +import com.stylefeng.guns.modular.taxi.warpper.ForecastPriceWarpper; import com.stylefeng.guns.modular.taxi.warpper.OrderTaxiWarpper; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; /** * 出租车订单控制器 @@ -49,19 +54,64 @@ }) public ResultUtil<BaseWarpper> taxiOrder(OrderTaxiWarpper orderTaxiWarpper, HttpServletRequest request){ try { + System.err.println(orderTaxiWarpper); OrderTaxi orderTaxi = OrderTaxiWarpper.getOrderTaxi(orderTaxiWarpper); + System.err.println(orderTaxiWarpper); Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } - return orderTaxiService.taxiOrder(orderTaxi, uid); + return orderTaxiService.taxiOrder(orderTaxi, uid, orderTaxiWarpper.getAreaCode()); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } - - + + + + @ResponseBody + @PostMapping("/api/taxi/getForecastPrice") + @ApiOperation(value = "出租车获取预估费用【1.1】", tags = {"用户端-出租车"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<Double> getForecastPrice(ForecastPriceWarpper warpper){ + return orderTaxiService.getForecastPrice(warpper); + } + + + + + @ResponseBody + @PostMapping("/api/taxi/getAllForecastPrice") + @ApiOperation(value = "出租车获取两种计费预估费用【1.1】", tags = {"用户端-出租车"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<Map<String, Double>> getAllForecastPrice(ForecastPriceWarpper warpper){ + try { + warpper.setPayManner(1); + ResultUtil<Double> resultUtil = orderTaxiService.getForecastPrice(warpper); + if(resultUtil.getCode() != 200){ + return ResultUtil.error(resultUtil.getMsg()); + } + double amount = resultUtil.getData(); + Map<String, Double> map = new HashMap<>(); + map.put("online", amount); + amount = amount + (new BigDecimal(Math.random()).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); + map.put("offline", amount); + return ResultUtil.success(map); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } + + + + + -- Gitblit v1.7.1