Commit 37e63ed8 authored by hezhen's avatar hezhen

Merge branch 'dev-chw' of http://113.105.137.151:22280/youjj/cloud-platform into dev-chw

parents 54e8ab85 8826c862
package com.xxfc.platform.vehicle.pojo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.YMR_SLASH_FORMATTER;
......@@ -130,6 +132,20 @@ public class RentVehicleBookDTO extends PageParam {
@ApiModelProperty(hidden = true)
Boolean recordIntersection;
@ApiModelProperty("城市")
Integer addrCity;
@ApiModelProperty("经度")
Double lon;
@ApiModelProperty("纬度")
Double lat;
@ApiModelProperty("商品类型 1--房车;2--机车;3--游艇")
Integer goodsType;
@ApiModelProperty("分类逗号分割")
String catasStr;
@ApiModelProperty(value = "分类列表", hidden = true)
Map<Integer, List<VehiclePlatCata>> catas;
public void setBookStartDate(String bookStartDate) {
this.bookStartDate = bookStartDate;
//首次设置
......
......@@ -80,6 +80,9 @@ public class UsableVeicleDTO extends PageParam {
*/
String priceEndDate;
@ApiModelProperty("商品类型 1--房车;2--机车;3--游艇")
Integer goodsType;
// @ApiModelProperty(hidden = true)
// Integer withoutRecordWhere = 1;
......
......@@ -2,9 +2,11 @@ package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
......@@ -23,4 +25,8 @@ public class UsableVeicleVO extends Vehicle {
private Integer allowRent;
private List<VehicleModelCalendarPriceDTO> priceDTOS;
@ApiModelProperty(value = "公里数")
BigDecimal distance;
}
......@@ -195,6 +195,67 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
return ObjectRestResponse.succ(uvmvpdvs);
}
/**
* 可用车辆查询
*
* @param dto
* @return
*/
@ApiOperation("可用车辆查询")
@RequestMapping(value = "/rent/usable-vehicle/v2", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> rentUsableVehicleV2(UsableVeicleDTO dto) throws Exception {
//根据时间 获得 可用车辆
//结合车型
if (StringUtils.isNotBlank(dto.getCatasStr())) {
dto.setCatas(vehiclePlatCataBiz.groupCatasByParent(dto.getCatasStr()));
}
RentVehicleBookDTO rbd = new RentVehicleBookDTO();
rbd.setLimit(dto.getLimit());
rbd.setPage(dto.getPage());
rbd.setLon(dto.getLon());
rbd.setLat(dto.getLat());
rbd.setAddrCity(dto.getAddrCity());
rbd.setParkBranchCompanyId(dto.getStartCompanyId());
rbd.setStartCompanyId(dto.getStartCompanyId());
rbd.setEndCompanyId(dto.getEndCompanyId());
rbd.setBookStartDate(dto.getStartDate());
rbd.setBookEndDate(dto.getEndDate());
rbd.setBookStartDateTime(dto.getStartDateTime());
rbd.setBookEndDateTime(dto.getEndDateTime());
rbd.setCatas(dto.getCatas());
rbd.setGoodsType(dto.getGoodsType());
rbd.setRecordIntersection(Boolean.TRUE);
rbd.setYearNo4Where(Boolean.TRUE);
//查询可车辆信息
PageDataVO<UsableVeicleVO> pageDataVO = vehicleBiz.searchUsableVehicle(rbd);
if(CollUtil.isNotEmpty(pageDataVO.getData())) {
for (UsableVeicleVO usableVeicleVO : pageDataVO.getData()) {
//判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(dto.getStartDateTamp()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(dto.getEndDateTamp()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
String priceStartDateStr = StrUtil.isNotBlank(dto.getPriceStartDate())? dto.getPriceStartDate(): dto.getStartDate();
String priceEndDateStr = StrUtil.isNotBlank(dto.getPriceEndDate())? dto.getPriceEndDate(): dto.getEndDate();
usableVeicleVO.setPriceDTOS(vehicleHolidayPriceInfoBiz.getSynthesizePrice(usableVeicleVO.getId(), priceStartDateStr, priceEndDateStr, null, usableVeicleVO.getSubordinateBranch()));
}
}
return ObjectRestResponse.succ(pageDataVO);
}
/**
* 后台查询可用车辆(车型)
*
......
......@@ -1025,13 +1025,15 @@
,GROUP_CONCAT(vc.cata_id) as catas
</if>
<!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 -->
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
,(max(
<if test=" yearMonthAndParam !=null ">
,
<if test="yearNo4Where != null and yearNo4Where == true">
(max(
ifnull(vbi.bit_str = #{yearMonthAndParamBitStr}, false)
<!-- 租车列表 不过滤前后预约记录不符的车辆 但是合并标示车型是否有车 即 hasVehicle-->
<if test="withoutRecordWhere != null and withoutRecordWhere = 1 and startCompanyId != null and endCompanyId != null ">
<!-- and (abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId})-->
<!-- and (abr.to_return_company is null or abr.to_return_company = #{endCompanyId})-->
<!-- and (abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId})-->
<!-- and (abr.to_return_company is null or abr.to_return_company = #{endCompanyId})-->
and (
(IFNULL(abr.to_lift_company, v.park_branch_company_id) = #{startCompanyId})
and
......@@ -1039,7 +1041,13 @@
)
</if>
)
) as hasVehicle
)
</if>
<if test="yearNo4Where == null or yearNo4Where != true">
(if(count(*) > 1, 1 , 0))
</if>
as hasVehicle
</if>
<if test="lon != null and lat != null">
,st_distance_sphere(point(#{lon}, #{lat}), point(bc.longitude, bc.latitude)) as distance
......@@ -1079,7 +1087,7 @@
<if test=" catas != null ">
,null as catas
</if>
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
<if test=" yearMonthAndParam !=null ">
,0 as hasVehicle
</if>
<if test="lon != null and lat != null">
......@@ -1100,7 +1108,7 @@
</if>
<if test="lon != null and lat != null">
order by
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
<if test=" yearMonthAndParam !=null ">
hasVehicle desc,
</if>
distance asc, model_id asc
......@@ -1153,7 +1161,7 @@
</if>
left join vehicle_model vm on v.model_id = vm.id
left join branch_company bc on v.park_branch_company_id = bc.id
<if test="startCompanyId != null and endCompanyId != null ">
<!-- <if test="startCompanyId != null and endCompanyId != null ">-->
<!--
* 原(大于预约结束时间,小于预约开始时间的预约记录)
* 相交叉(大于预约开始时间,小于预约结束时间的预约记录)
......@@ -1168,7 +1176,7 @@
<include refid="aroundBookRecordIntersection"></include>
) abr on v.`id` = abr.vehicle_id
</if>
</if>
<!-- </if>-->
<if test=" catas != null ">
left join vehicle_cata vc on vm.id = vc.vehicle_model_id
</if>
......@@ -1179,6 +1187,14 @@
vbi.bit_str = #{yearMonthAndParamBitStr}
</if>
<if test=" yearNo4Where != null and recordIntersection != null and recordIntersection == true">
<!-- 1、最后还车时间(天) 大于 最早提车时间(天) 并且多于一天-->
and if((abr.to_lift_must_after_date is null or abr.to_return_must_before_date is null), true
, (str_to_date(DATE_FORMAT(abr.to_return_must_before_date,'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s')
> DATE_ADD(DATE_ADD(str_to_date(DATE_FORMAT(abr.to_lift_must_after_date,'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s'),INTERVAL 2 DAY),INTERVAL -1 SECOND))
)
</if>
<!-- 根据前后record 过滤车辆 -->
<if test="startCompanyId != null and endCompanyId != null ">
<if test="withoutRecordWhere == null">
......@@ -1201,6 +1217,9 @@
<if test=" parkBranchCompanyId != null ">
and v.park_branch_company_id = #{parkBranchCompanyId}
</if>
<if test=" goodsType != null ">
and v.goods_type = #{goodsType}
</if>
and v.is_del = 0
and v.status != 3
<if test="useType != null">
......
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