| | |
| | | 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.*; |
| | | |
| | | /** |
| | | * 出租车订单控制器 |
| | |
| | | }) |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |