Commit 9a6cb077 authored by libin's avatar libin

Merge remote-tracking branch 'origin/dev' into dev

parents 9bc6b75e 0b9a5ef8
......@@ -24,4 +24,19 @@ public class CommonConstants {
public static final String CONTEXT_KEY_USER_TOKEN = "currentUserToken";
public static final String JWT_KEY_USER_ID = "userId";
public static final String JWT_KEY_NAME = "name";
// 时间相关
public static final String DEFAULT = "yyyy/MM/dd";
public static final String YM = "yyyy/MM";
public static final String YMR_SLASH = "yyyy-MM-dd";
public static final String NO_SLASH = "yyyyMMdd";
public static final String YM_NO_SLASH = "yyyyMM";
public static final String DATE_TIME = "yyyy/MM/dd HH:mm:ss";
public static final String DATE_TIME_NO_SLASH = "yyyyMMddHHmmss";
public static final String DATE_HM = "yyyy/MM/dd HH:mm";
public static final String TIME = "HH:mm:ss";
public static final String HM = "HH:mm";
public static final String LONG_TIME = "HHmmss";
public static final String SHORT_TIME = "HHmm";
public static final String DATE_TIME_LINE = "yyyy-MM-dd HH:mm:ss";
}
......@@ -293,31 +293,37 @@ public class BackStageOrderController extends CommonBaseController implements Us
@ResponseBody
public ObjectRestResponse<OrderPageVO> changeVehicle(@RequestBody ChangeVehicleDTO dto) {
checkAdminUser();
// //根据订单号获取订单
// //查询列表数据
// Query query = baseOrderBiz.initQuery(dto.getNo());
// PageDataVO<OrderPageVO> page = PageDataVO.pageInfo(query, () -> baseOrderBiz.pageByParm(query.getSuper()));
// OrderPageVO orderPageVO = page.getData().get(0);
// if(null == orderPageVO) {
// throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet("订单不存在"));
// }
// //预约新的车辆
// RentVehicleBO bo = BeanUtil.toBean(orderPageVO.getOrderRentVehicleDetail(), RentVehicleBO.class);
// bo.setOrder(orderPageVO);
// bo.setBookVehicleVO(new BookVehicleVO(){{
// setBookStartDate(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
// setBookEndDate(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
// }});
//
// List<OrderAccompanyDTO> oads = JSONUtil.toList(JSONUtil.parseArray(orderItemBiz.selectOne(new OrderItem(){{
// setOrderId(orderPageVO.getId());
// setType(ItemTypeEnum.ACCOMPANY.getCode());
// }}).getDetail()), OrderAccompanyDTO.class);
// bo.setAccompanyItems(oads);
// orderRentVehicleService.acquireVehicle(bo);
// //如果成功则取消旧车的预约
//
// orderRentVehicle
//根据订单号获取订单
//查询列表数据
Query query = baseOrderBiz.initQuery(dto.getNo());
PageDataVO<OrderPageVO> page = PageDataVO.pageInfo(query, () -> baseOrderBiz.pageByParm(query.getSuper()));
OrderPageVO orderPageVO = page.getData().get(0);
if(null == orderPageVO) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet("订单不存在"));
}
//预约新的车辆
RentVehicleBO bo = BeanUtil.toBean(orderPageVO.getOrderRentVehicleDetail(), RentVehicleBO.class);
bo.setOrder(orderPageVO);
bo.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
setBookEndDate(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
}});
List<OrderAccompanyDTO> oads = JSONUtil.toList(JSONUtil.parseArray(orderItemBiz.selectOne(new OrderItem(){{
setOrderId(orderPageVO.getId());
setType(ItemTypeEnum.ACCOMPANY.getCode());
}}).getDetail()), OrderAccompanyDTO.class);
bo.setAccompanyItems(oads);
Long oldBookRecordId = bo.getBookRecordId();
orderRentVehicleService.acquireVehicle(bo);
//如果成功则取消旧车的预约
vehicleFeign.rentUnbookVehicle(oldBookRecordId);
//设置新的vehicleId 和 record
orderRentVehicleBiz.updateSelectiveByIdRe(new OrderRentVehicleDetail(){{
setId(bo.getId());
setVehicleId(bo.getVehicleId());
setBookRecordId(bo.getBookRecordId());
}});
return ObjectRestResponse.succ();
}
......
......@@ -415,7 +415,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
checkIfVehicleExists(bookVehicleVo.getVehicleId());
//提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(),DATE_TIME_FORMATTER);
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
......
package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
......@@ -25,8 +26,14 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.DATE_TIME_LINE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
......@@ -156,7 +163,13 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
add("可用车辆不存在");
}});
}
dto.setBookStartDate(dto.getBookStartDate()+ " 00:00:00");
//判断是否为今天,如果是则设置为一分钟后开始
if(DateUtil.today().equals(dto.getBookStartDate())) {
LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()), ZoneOffset.ofHours(8)).plusSeconds(30L);
dto.setBookStartDate(DateTimeFormatter.ofPattern(DATE_TIME_LINE).format(ldt));
}else {
dto.setBookStartDate(dto.getBookStartDate()+ " 00:00:00");
}
dto.setBookEndDate(dto.getBookEndDate()+ " 23:59:59");
BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class);
bookVehicleVo.setBookType(BookType.USER_RENT.getCode());
......
......@@ -637,6 +637,8 @@
and v.park_branch_company_id = #{parkBranchCompanyId}
</if>
and v.is_del = 0
and v.status != 3
and v.use_type = 1
</where>
</sql>
......
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