package com.stylefeng.guns.modular.crossCity.controller; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityScanWarpper; import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityWarpper; import com.stylefeng.guns.modular.crossCity.warpper.ScanOrderDetailWarpper; import com.stylefeng.guns.modular.system.service.IUserInfoService; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.util.SystemException; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import io.swagger.annotations.Api; 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.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.Date; @Api @RestController @RequestMapping("") public class OrderCrossCityController { @Autowired private IOrderCrossCityService orderCrossCityService; @Autowired private IUserInfoService userInfoService; @ResponseBody @RequestMapping(value = "/base/orderCrossCity/queryOrderMoney", method = RequestMethod.POST) @ApiOperation(value = "获取跨城的支付金额", tags = {"用户端-跨城"}, notes = "distance:距离数(米),price:支付金额") @ApiImplicitParams({ @ApiImplicitParam(value = "起点坐标(103.32123,30.6232)", name = "startLonLat", required = true, dataType = "string"), @ApiImplicitParam(value = "终点坐标(103.32123,30.6232)", name = "endLonLat", required = true, dataType = "string"), @ApiImplicitParam(value = "乘车人数", name = "peopleNumber", required = true, dataType = "int"), @ApiImplicitParam(value = "出行方式(1=拼车,2=包车)", name = "travelMode", required = true, dataType = "int"), @ApiImplicitParam(value = "线路id", name = "lineId", required = true, dataType = "int"), @ApiImplicitParam(value = "线路目的地id", name = "lineDestinationId", required = false, dataType = "int"), @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int"), @ApiImplicitParam(value = "车辆总座位数", name = "totalSeat", required = true, dataType = "int"), @ApiImplicitParam(value = "座位编号(1,3,4)", name = "seatNumber", required = true, dataType = "int") }) public ResultUtil queryOrderMoney(String startLonLat, String endLonLat, Integer peopleNumber, Integer travelMode, Integer lineId, Integer lineDestinationId, Integer serverCarModelId, Integer totalSeat, String seatNumber){ try { return orderCrossCityService.queryOrderMoney(startLonLat, endLonLat, peopleNumber, travelMode, lineId, lineDestinationId, serverCarModelId, totalSeat, seatNumber); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 跨城出行下单操作 * @param orderCrossCityWarpper * @param request * @return */ @ResponseBody @RequestMapping(value = "/api/orderCrossCity/orderCrossCity", method = RequestMethod.POST) @ApiOperation(value = "跨城出行下单操作", tags = {"用户端-跨城"}, notes = "先进行下单操作,再根据返回的订单id进行支付") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil orderCrossCity(OrderCrossCityWarpper orderCrossCityWarpper, HttpServletRequest request){ try { String startAddress = orderCrossCityWarpper.getStartAddress(); orderCrossCityWarpper.setStartAddress(cleanXSS(startAddress)); orderCrossCityWarpper.setEndAddress(cleanXSS(orderCrossCityWarpper.getEndAddress())); Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return orderCrossCityService.orderCrossCity(orderCrossCityWarpper, uid); } catch (SystemException se){ return ResultUtil.error(se.getMessage()); } catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } private static String cleanXSS(String value) { //You'll need to remove the spaces from the html entities below value = value.replaceAll("& #40;", "\\("); value = value.replaceAll("& #41;", "\\)"); return value; } /** * 摆渡车下单 * @param serverCarModelIds * @param travelTime * @param placementLon * @param placementLat * @param startLon * @param startLat * @param startAddress * @param endLon * @param endLat * @param endAddress * @param orderSource * @param request * @return */ @ResponseBody @RequestMapping(value = "/api/orderCrossCity/saveOrderFerry", method = RequestMethod.POST) @ApiOperation(value = "摆渡车下单", tags = {"用户端-跨城"}, notes = "车型id多个以逗号分隔,出租车传0") @ApiImplicitParams({ @ApiImplicitParam(value = "服务车型id(多个以逗号分隔,出租车传0)", name = "serverCarModelIds", required = false, dataType = "string"), @ApiImplicitParam(value = "出行时间(2020-08-20 10:10)", name = "travelTime", required = true, dataType = "string"), @ApiImplicitParam(value = "下单地点经度", name = "placementLon", required = true, dataType = "string"), @ApiImplicitParam(value = "下单地点纬度", name = "placementLat", required = true, dataType = "string"), @ApiImplicitParam(value = "起点经度", name = "startLon", required = true, dataType = "string"), @ApiImplicitParam(value = "起点纬度", name = "startLat", required = true, dataType = "string"), @ApiImplicitParam(value = "起点地址", name = "startAddress", required = true, dataType = "string"), @ApiImplicitParam(value = "终点经度", name = "endLon", required = true, dataType = "string"), @ApiImplicitParam(value = "终点纬度", name = "endLat", required = true, dataType = "string"), @ApiImplicitParam(value = "终点地址", name = "endAddress", required = true, dataType = "string"), @ApiImplicitParam(value = "跨城订单id", name = "crossCityOrderId", required = true, dataType = "int"), @ApiImplicitParam(value = "摆渡方位(1=跨城起点,2=跨城终点)", name = "place", required = true, dataType = "int"), @ApiImplicitParam(value = "订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)", name = "orderSource", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil saveOrderFerry(String serverCarModelIds, Date travelTime, String placementLon, String placementLat, String startLon, String startLat, String startAddress, String endLon, String endLat, String endAddress, Integer crossCityOrderId, Integer place, Integer orderSource, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return orderCrossCityService.saveOrderFerry(serverCarModelIds, travelTime, placementLon, placementLat, startLon, startLat, startAddress, endLon, endLat, endAddress, crossCityOrderId, place, orderSource, uid); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } /** * 【202601】获取扫码下单详情 * @param lineShiftDriverId 司机排班记录ID * @return 扫码下单详情 */ @ResponseBody @RequestMapping(value = "/api/orderCrossCity/queryScanOrderDetail", method = RequestMethod.POST) @ApiOperation(value = "【202601】获取扫码下单详情", tags = {"用户端-跨城"}, notes = "根据扫码内容获取下单页面详情数据,包含司机信息、线路信息、站点信息等") @ApiImplicitParam(value = "司机排班记录ID", name = "lineShiftDriverId", required = true, dataType = "int") public ResultUtil queryScanOrderDetail(Integer lineShiftDriverId, HttpServletRequest request) { try { Integer uid = userInfoService.getUserIdFormRedis(request); if(null == uid){ return ResultUtil.tokenErr(); } return orderCrossCityService.queryScanOrderDetail(lineShiftDriverId); } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } /** * 【202601】跨城出行扫码下单操作 *

用户扫描司机二维码后进行下单,系统自动分配座位号

*

与普通下单的区别:仅支持拼车模式,座位自动分配,支持其他费用

* * @param orderCrossCityScanWarpper 扫码下单参数 * @param request HTTP请求 * @return 订单ID */ @ResponseBody @RequestMapping(value = "/api/orderCrossCity/orderCrossCityScan", method = RequestMethod.POST) @ApiOperation(value = "【202601】跨城出行扫码下单操作", tags = {"用户端-跨城"}, notes = "用户扫描司机二维码下单,系统自动分配座位,仅支持拼车模式。返回订单ID后进行支付") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResultUtil orderCrossCityScan(OrderCrossCityScanWarpper orderCrossCityScanWarpper, HttpServletRequest request){ try { // XSS过滤地址信息 String startAddress = orderCrossCityScanWarpper.getStartAddress(); orderCrossCityScanWarpper.setStartAddress(cleanXSS(startAddress)); orderCrossCityScanWarpper.setEndAddress(cleanXSS(orderCrossCityScanWarpper.getEndAddress())); // 获取用户ID Integer uid = userInfoService.getUserIdFormRedis(request); if (null == uid) { return ResultUtil.tokenErr(); } return orderCrossCityService.orderCrossCityScan(orderCrossCityScanWarpper, uid); } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } }