package com.stylefeng.guns.modular.specialTrain.controller;
|
|
|
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
|
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
|
import com.stylefeng.guns.modular.system.service.IUserInfoService;
|
import com.stylefeng.guns.modular.system.util.PushUtil;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
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.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
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 OrderPrivateCarController {
|
|
@Autowired
|
private IOrderPrivateCarService orderPrivateCarService;
|
|
@Autowired
|
private IUserInfoService userInfoService;
|
|
|
@Autowired
|
private PushUtil pushUtil;
|
|
/**
|
* 专车下单
|
* @param serverCarModelId
|
* @param travelTime
|
* @param orderType
|
* @param substitute
|
* @param placementLon
|
* @param placementLat
|
* @param startLon
|
* @param startLat
|
* @param startAddress
|
* @param endLon
|
* @param endLat
|
* @param endAddress
|
* @param passengers
|
* @param passengersPhone
|
* @param orderSource
|
* @param driverId
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/orderPrivateCar/saveOrderPrivateCar")
|
@ApiOperation(value = "专车下单/扫码下单", tags = {"用户端-专车"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单类型(1=普通订单,2=摆渡订单)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "服务车型id(扫码下单不用上传)", name = "serverCarModelId", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "出行时间(2020-08-20 10:10)", name = "travelTime", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "是否预约(1=否,2=是)", name = "orderType", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "是否代下单(0=否,1=是)", name = "substitute", required = true, dataType = "int"),
|
@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 = "订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)", name = "orderSource", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "司机id(扫码下单必传)", name = "driverId", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "乘客姓名(代下单必传)", name = "passengers", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "乘客电话(代下单必传)", name = "passengersPhone", required = false, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<BaseWarpper> saveOrderPrivateCar(Integer serverCarModelId, Date travelTime, Integer orderType, Integer substitute, String placementLon, String placementLat, String startLon, String startLat,
|
String startAddress, String endLon, String endLat, String endAddress, String passengers, String passengersPhone, Integer orderSource, Integer driverId,
|
Integer type, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return orderPrivateCarService.saveOrderPrivateCar(serverCarModelId, travelTime, orderType, substitute, placementLon, placementLat,
|
startLon, startLat, startAddress, endLon, endLat, endAddress, passengers, passengersPhone, orderSource, driverId, type, uid, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 分享成功后添加红包操作
|
* @param orderId
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/orderPrivateCar/updateEndAddress")
|
@ApiOperation(value = "修改目的地", tags = {"用户端-出租车", "用户端-专车", "用户端-跨城"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
|
@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(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil updateEndAddress(Integer orderId, String endLon, String endLat, String endAddress, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
|
orderPrivateCar.setEndAddress(endAddress);
|
orderPrivateCar.setEndLat(Double.valueOf(endLat));
|
orderPrivateCar.setEndLon(Double.valueOf(endLon));
|
orderPrivateCarService.updateById(orderPrivateCar);
|
//推送
|
pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 15, 1);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
}
|