| | |
| | | package com.stylefeng.guns.modular.CharteredCar.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.CharteredCar.dto.CharteredCarDto; |
| | | import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; |
| | | import com.stylefeng.guns.modular.system.model.ServerCarModel; |
| | | import com.stylefeng.guns.modular.system.model.TCharteredService; |
| | | import com.stylefeng.guns.modular.system.service.IServerCarModelService; |
| | | import com.stylefeng.guns.modular.system.service.ITCharteredServiceService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import io.swagger.annotations.Api; |
| | |
| | | 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 org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Api |
| | | @RestController |
| | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Autowired |
| | | private IServerCarModelService serverCarModelService; |
| | | @Autowired |
| | | private ITCharteredServiceService charteredService; |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/list", method = RequestMethod.POST) |
| | | @ApiOperation(value = "根据tag查询包车,全部传-1", tags = {"用户端-包车"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int") |
| | | }) |
| | | public ResultUtil<List<TCharteredService>> list(Integer serverCarModelId){ |
| | | EntityWrapper<TCharteredService> tCharteredServiceEntityWrapper = new EntityWrapper<>(); |
| | | tCharteredServiceEntityWrapper.eq("status",1); |
| | | if (serverCarModelId!=-1){ |
| | | tCharteredServiceEntityWrapper.eq("serverCarModelId",serverCarModelId); |
| | | } |
| | | List<TCharteredService> tCharteredServices = charteredService.selectList(tCharteredServiceEntityWrapper); |
| | | for (TCharteredService tCharteredService : tCharteredServices) { |
| | | ServerCarModel serverCarModel = serverCarModelService.selectById(tCharteredService.getServerCarModelId()); |
| | | if (serverCarModel!=null) { |
| | | tCharteredService.setServerCarModelName(serverCarModel.getName()); |
| | | } |
| | | } |
| | | return ResultUtil.success(tCharteredServices); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/tag", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取包车tag", tags = {"用户端-包车"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<ServerCarModel>> orderCharteredCar(){ |
| | | List<ServerCarModel> serverCarModels = serverCarModelService.selectList(new EntityWrapper<ServerCarModel>().eq("type", 3).eq("state", 1)); |
| | | return ResultUtil.success(serverCarModels); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/orderCharteredCar", method = RequestMethod.POST) |
| | | @ApiOperation(value = "提交包车订单", tags = {"用户端-包车"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "出行时间(2020-09-21 16:00:00)", name = "travelTime", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "用车时长", name = "carTime", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "服务车型id", name = "serverCarModelId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "车型用途", name = "modelUse", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "出行人数", name = "peopleNumber", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "联系人", name = "contactPerson", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "联系电话", name = "contactPhone", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "下单地点经纬度(103.1233,30.135412)", name = "placeLonLat", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil orderCharteredCar(Date travelTime, Integer carTime, Integer serverCarModelId, String modelUse, Integer peopleNumber, |
| | | String contactPerson, String contactPhone, String placeLonLat, HttpServletRequest request){ |
| | | public ResultUtil orderCharteredCar(@RequestBody CharteredCarDto charteredCarDto, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return orderCharteredCarService.orderCharteredCar(travelTime, carTime, serverCarModelId, modelUse, peopleNumber, contactPerson, contactPhone, placeLonLat, uid); |
| | | charteredCarDto.setUserId(uid); |
| | | return orderCharteredCarService.createOrder(charteredCarDto); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |