Commit e2829fde authored by 周健威's avatar 周健威

修改内容

parent b6b38d76
...@@ -47,7 +47,11 @@ public class ObjectRestResponse<T> extends BaseResponse { ...@@ -47,7 +47,11 @@ public class ObjectRestResponse<T> extends BaseResponse {
this.data = data; this.data = data;
} }
public static ObjectRestResponse success() { public static ObjectRestResponse succ() {
return new ObjectRestResponse().status(RestCode.SUCCESS.getStatus()).msg(RestCode.SUCCESS.getMsg()).rel(true); return ObjectRestResponse.succ(null);
}
public static <T> ObjectRestResponse succ(T data) {
return new ObjectRestResponse().status(RestCode.SUCCESS.getStatus()).msg(RestCode.SUCCESS.getMsg()).data(data).rel(true);
} }
} }
...@@ -4,9 +4,15 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,9 +4,15 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.persistence.Column;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
@Data @Data
public class AddRentVehicleDTO{ public class AddRentVehicleDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间 //开始时间
@Column(name = "start_time") @Column(name = "start_time")
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
...@@ -17,6 +23,18 @@ public class AddRentVehicleDTO{ ...@@ -17,6 +23,18 @@ public class AddRentVehicleDTO{
@ApiModelProperty(value = "结束时间") @ApiModelProperty(value = "结束时间")
private Long endTime; private Long endTime;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty(value = "预定目标日期(开始)", hidden = true)
private String bookStartDate;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty(value = "预定目标日期(结束)", hidden = true)
private String bookEndDate;
//天数 //天数
@Column(name = "day_num") @Column(name = "day_num")
@ApiModelProperty(value = "天数") @ApiModelProperty(value = "天数")
...@@ -81,4 +99,14 @@ public class AddRentVehicleDTO{ ...@@ -81,4 +99,14 @@ public class AddRentVehicleDTO{
@Column(name = "model_id") @Column(name = "model_id")
@ApiModelProperty(value = "车型id") @ApiModelProperty(value = "车型id")
private Integer modelId; private Integer modelId;
public void setStartTime(Long startTime) {
this.startTime = startTime;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
this.bookEndDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneOffset.ofHours(8)));
}
} }
...@@ -23,7 +23,6 @@ import com.xxfc.platform.order.pojo.pay.RentVehicleOrderPayVO; ...@@ -23,7 +23,6 @@ import com.xxfc.platform.order.pojo.pay.RentVehicleOrderPayVO;
import com.xxfc.platform.universal.constant.enumerate.PayChannelEnum; import com.xxfc.platform.universal.constant.enumerate.PayChannelEnum;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.vehicle.entity.VehicleCata;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -34,8 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -34,8 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -145,7 +142,7 @@ public class BaseOrderController extends CommonBaseController { ...@@ -145,7 +142,7 @@ public class BaseOrderController extends CommonBaseController {
} }
dbBaseOrder.setCancelReason(cancelOrderDto.getCancelReason()); dbBaseOrder.setCancelReason(cancelOrderDto.getCancelReason());
baseOrderBiz.cancel(dbBaseOrder); baseOrderBiz.cancel(dbBaseOrder);
return ObjectRestResponse.success(); return ObjectRestResponse.succ();
} }
@RequestMapping(value = "/app/unauth/notifyUrl",method = RequestMethod.GET) @RequestMapping(value = "/app/unauth/notifyUrl",method = RequestMethod.GET)
......
...@@ -17,6 +17,7 @@ import com.xxfc.platform.order.pojo.order.RentVehicleBO; ...@@ -17,6 +17,7 @@ import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO; import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import lombok.extern.log4j.Log4j; import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -132,6 +133,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -132,6 +133,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
private String acquireVehicle(RentVehicleBO detail) { private String acquireVehicle(RentVehicleBO detail) {
//根据车型、时间、距离,门店,预定车辆 //根据车型、时间、距离,门店,预定车辆
// BookVehicleVO bookVehicleVO = new BookVehicleVO(){{
// setBookStartDate(detail);
// }};
// vehicleFeign.rentApplyVehicle()
String vehicleId = "0e9a88db-cb1b-48a4-b307-40f89eed906f"; String vehicleId = "0e9a88db-cb1b-48a4-b307-40f89eed906f";
detail.setVehicleId(vehicleId); detail.setVehicleId(vehicleId);
return vehicleId; return vehicleId;
......
...@@ -3,7 +3,7 @@ package com.xxfc.platform.vehicle.feign; ...@@ -3,7 +3,7 @@ package com.xxfc.platform.vehicle.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.pojo.BookVehicleVo; import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -20,5 +20,5 @@ public interface VehicleFeign { ...@@ -20,5 +20,5 @@ public interface VehicleFeign {
public RestResponse addScore(@RequestParam(value="id")Integer id, @RequestParam(value="score")Integer score); public RestResponse addScore(@RequestParam(value="id")Integer id, @RequestParam(value="score")Integer score);
@RequestMapping(value = "/rent/book/vehicle", method = RequestMethod.POST) @RequestMapping(value = "/rent/book/vehicle", method = RequestMethod.POST)
public RestResponse<Integer> rentApplyVehicle(@RequestBody BookVehicleVo bookVehicleVo); public ObjectRestResponse<String> rentApplyVehicle(@RequestBody BookVehicleVO bookVehicleVo);
} }
...@@ -6,7 +6,7 @@ import lombok.Data; ...@@ -6,7 +6,7 @@ import lombok.Data;
import java.util.Map; import java.util.Map;
@Data @Data
public class BookVehicleVo { public class BookVehicleVO {
/** /**
* 车辆id * 车辆id
*/ */
......
...@@ -44,7 +44,6 @@ public class UsableVeicleDTO extends PageParam { ...@@ -44,7 +44,6 @@ public class UsableVeicleDTO extends PageParam {
public void setStartDateTamp(Long startDateTamp) { public void setStartDateTamp(Long startDateTamp) {
this.startDateTamp = startDateTamp; this.startDateTamp = startDateTamp;
System.out.println(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8))));
this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8))); this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
} }
......
...@@ -272,7 +272,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -272,7 +272,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
* @return * @return
*/ */
@Transactional @Transactional
public void applyVehicle4Employee(Integer userId, BookVehicleVo bookVehicleVo, String userName) throws Exception{ public void applyVehicle4Employee(Integer userId, BookVehicleVO bookVehicleVo, String userName) throws Exception{
//检查车辆信息是否合法 //检查车辆信息是否合法
checkIfVehicleExists(bookVehicleVo.getVehicle()); checkIfVehicleExists(bookVehicleVo.getVehicle());
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
...@@ -367,7 +367,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -367,7 +367,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode()); return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
} }
//转换为相应预定参数 //转换为相应预定参数
BookVehicleVo bookVehicleVo = new BookVehicleVo(); BookVehicleVO bookVehicleVo = new BookVehicleVO();
BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord); BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord);
bookVehicleVo.setBookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setBookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER));
bookVehicleVo.setBookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setBookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER));
...@@ -409,7 +409,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -409,7 +409,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode()); return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
} }
//转换为相应取消预定参数 //转换为相应取消预定参数
BookVehicleVo bookVehicleVo = new BookVehicleVo(); BookVehicleVO bookVehicleVo = new BookVehicleVO();
BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord); BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord);
bookVehicleVo.setBookStartDate(null); bookVehicleVo.setBookStartDate(null);
bookVehicleVo.setBookEndDate(null); bookVehicleVo.setBookEndDate(null);
...@@ -471,7 +471,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -471,7 +471,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
* @return * @return
*/ */
@Transactional @Transactional
public Boolean bookedVehicle( BookVehicleVo bookVehicleVo) throws Exception{ public Boolean bookedVehicle( BookVehicleVO bookVehicleVo) throws Exception{
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
...@@ -578,7 +578,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -578,7 +578,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
* @return * @return
*/ */
@Transactional @Transactional
public Boolean unbookVehicle(BookVehicleVo bookVehicleVo){ public Boolean unbookVehicle(BookVehicleVO bookVehicleVo){
//提取日期参数,改为每月一份 //提取日期参数,改为每月一份
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
......
...@@ -7,7 +7,9 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; ...@@ -7,7 +7,9 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleBookRecordBiz; import com.xxfc.platform.vehicle.biz.VehicleBookRecordBiz;
...@@ -152,7 +154,7 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -152,7 +154,7 @@ public class VehicleController extends BaseController<VehicleBiz> {
* @return * @return
*/ */
@RequestMapping(value = "/book/4employee", method = RequestMethod.POST) @RequestMapping(value = "/book/4employee", method = RequestMethod.POST)
public RestResponse<Integer> applyVehicle(@RequestBody BookVehicleVo bookVehicleVo) throws Exception { public RestResponse<Integer> applyVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception {
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID()); Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName(); String userName = BaseContextHandler.getName();
baseBiz.applyVehicle4Employee(operatorId, bookVehicleVo, userName); baseBiz.applyVehicle4Employee(operatorId, bookVehicleVo, userName);
...@@ -305,20 +307,23 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -305,20 +307,23 @@ public class VehicleController extends BaseController<VehicleBiz> {
*/ */
@ApiOperation("租车触发的申请预定车辆") @ApiOperation("租车触发的申请预定车辆")
@RequestMapping(value = "/rent/book/vehicle", method = RequestMethod.POST) @RequestMapping(value = "/rent/book/vehicle", method = RequestMethod.POST)
public ObjectRestResponse<Integer> rentApplyVehicle(@RequestBody RentVehicleBookDTO dto) throws Exception { public ObjectRestResponse<String> rentApplyVehicle(@RequestBody RentVehicleBookDTO dto) throws Exception {
//默认USER_APP 预约 //默认USER_APP 预约
Integer operatorId = USER_APP; Integer operatorId = USER_APP;
String userName = BaseContextHandler.getName(); String userName = BaseContextHandler.getName();
BookVehicleVo bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVo.class); BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class);
dto.setLimit(1); dto.setLimit(1);
dto.setPage(1); dto.setPage(1);
//查询可车辆信息 //查询可车辆信息
PageDataVO<Vehicle> pageDataVO = vehicleBiz.searchUsableVehicle(dto); PageDataVO<Vehicle> pageDataVO = vehicleBiz.searchUsableVehicle(dto);
if(pageDataVO.getData().size() <= 0) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
}
bookVehicleVo.setVehicle(pageDataVO.getData().get(0).getId()); bookVehicleVo.setVehicle(pageDataVO.getData().get(0).getId());
baseBiz.applyVehicle4Employee(operatorId, bookVehicleVo, userName); baseBiz.applyVehicle4Employee(operatorId, bookVehicleVo, userName);
return ObjectRestResponse.success(); return ObjectRestResponse.succ(bookVehicleVo.getVehicle());
} }
} }
package com.xxfc.platform.vehicle.rest; package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleLicenseBiz; import com.xxfc.platform.vehicle.biz.VehicleLicenseBiz;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
...@@ -68,7 +67,7 @@ public class VehicleLicenseController extends VehicleBaseController<VehicleLicen ...@@ -68,7 +67,7 @@ public class VehicleLicenseController extends VehicleBaseController<VehicleLicen
List<VehicleUserLicense> list = baseBiz.selectByExample(new Example.Builder(VehicleUserLicense.class) List<VehicleUserLicense> list = baseBiz.selectByExample(new Example.Builder(VehicleUserLicense.class)
.where(WeekendSqls.<VehicleUserLicense>custom() .where(WeekendSqls.<VehicleUserLicense>custom()
.andIn(VehicleUserLicense::getId, Arrays.asList(dto.getIds().split(",")))).build()); .andIn(VehicleUserLicense::getId, Arrays.asList(dto.getIds().split(",")))).build());
return ObjectRestResponse.success().data(list); return ObjectRestResponse.succ().data(list);
} }
@RequestMapping(value = "/license/del", method = RequestMethod.GET) @RequestMapping(value = "/license/del", method = RequestMethod.GET)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment