Commit 091db407 authored by 周健威's avatar 周健威

Merge branch 'master-vehicle-price' into dev-tiande

parents 7de4f6a2 3e7e40e7
......@@ -188,4 +188,11 @@ public class ShuntApply implements Serializable {
@ApiModelProperty(value = "确认申请的公司(门店)id", hidden = true )
private Integer confirmCompanyId;
/**
* 预约记录id
*/
@Column(name = "book_record_id")
@ApiModelProperty(value = "预约记录id", hidden = true )
private Long bookRecordId;
}
......@@ -22,6 +22,12 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
private BaseOrder order;
private VehicleModel vehicleModel;
private BookVehicleVO bookVehicleVO;
/**
* 是否调车申请下订单
*/
private Integer applyOrderSign = 0;
/**
* 是否使用出租免费天数
*/
......@@ -87,6 +93,6 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
this.startDate = DateUtil.date(getStartTime());
this.endDate = DateUtil.date(getEndTime());
this.startDateStr = DateUtil.formatDate(this.startDate);
this.startDateStr = DateUtil.formatDate(this.endDate);
this.endDateStr = DateUtil.formatDate(this.endDate);
}
}
......@@ -3,10 +3,13 @@ package com.xxfc.platform.order.mqhandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCancelBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.service.OrderRentVehicleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
......@@ -34,6 +37,9 @@ public class RabbitConsumer {
@Autowired
ShuntApplyBiz shuntApplyBiz;
@Autowired
OrderRentVehicleService orderRentVehicleService;
/**
* 默认情况下,如果没有配置手动ACK, 那么Spring Data AMQP 会在消息消费完毕后自动帮我们去ACK
......@@ -92,6 +98,10 @@ public class RabbitConsumer {
setStatus(ShuntApply.STATUS_AUTOCNL);
}});
}
//取消预订
orderRentVehicleService.errorRejectVehicle(new RentVehicleBO(){{
setBookRecordId(shuntApply.getBookRecordId());
}});
}catch (BaseException e) {
if(ResultCode.DB_OPERATION_FAIL_CODE == e.getStatus()) {
log.info("取消操作被取消;订单id:"+ shuntApply.getId());
......
......@@ -25,6 +25,7 @@ import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.github.wxiaoqi.security.common.vo.PageDataVO.pageInfo;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CNL;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
......@@ -62,7 +63,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
shuntApply.setStartCityCode(vehicleFeign.getCompanyDetail(shuntApply.getStartCompanyId()).getData().getAddrCity());
}
if(null != shuntApply.getEndCompanyId()) {
shuntApply.setStartCityCode(vehicleFeign.getCompanyDetail(shuntApply.getEndCompanyId()).getData().getAddrCity());
shuntApply.setEndCityCode(vehicleFeign.getCompanyDetail(shuntApply.getEndCompanyId()).getData().getAddrCity());
}
shuntApply.setUserId(getCurrentUserIdInt());
shuntApply.setStatus(STATUS_CRT);
......@@ -153,9 +154,19 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
// setDayNum(orderCalculateBiz.getIncludeDays(shuntApply.getStartTime(), shuntApply.getEndTime()));
// }};
dto.setVehicleId(shuntApply.getVehicleId());
dto.setStartTime(shuntApply.getStartTime());
dto.setEndTime(shuntApply.getEndTime());
dto.setStartCompanyId(shuntApply.getStartCompanyId());
dto.setEndCompanyId(shuntApply.getEndCompanyId());
RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(dto);
bo.setApplyOrderSign(SYS_TRUE);
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
orderRentVehicleService.applyCreateOrder(bo, shuntApply.getOrderNo());
baseBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
setStatus(ShuntApply.STATUS_ORDER);
}});
return ObjectRestResponse.succ(bo.getOrder());
}
......
......@@ -27,6 +27,7 @@ import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation;
......@@ -78,7 +79,7 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
public ObjectRestResponse<PageDataVO<StewardShuntApply>> stewardList(ListDTO dto) {
//获取该城市的申请最大和最小时间
//获取该店铺
PageDataVO<ShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
PageDataVO<StewardShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
if(null != dto.getCityCode()) {
w.andEqualTo(ShuntApply::getStartCityCode, dto.getCityCode());
}
......@@ -86,6 +87,10 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
return w;
}, " crt_time desc "), StewardShuntApply.class);
list.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
});
// List<StewardShuntApply> returnList = CollUtil.newArrayList();
//
// Integer companyId = getAdminUserInfo().getCompanyId();
......@@ -172,20 +177,30 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
RentVehicleBO detail = new RentVehicleBO();
detail.setStartTime(shuntApply.getStartTime());
detail.setEndTime(shuntApply.getEndTime());
detail.setVehicleId(shuntApply.getVehicleId());
detail.setVehicleId(dto.getVehicleId());
detail.setModelId(shuntApply.getModelId());
detail.setStartAddr(shuntApply.getStartCompanyName());
detail.setStartCompanyId(shuntApply.getStartCompanyId());
detail.setEndCompanyId(shuntApply.getEndCompanyId());
detail.setOrder(new BaseOrder(){{setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));}});
detail.setRentFreeDay(SYS_FALSE);
detail.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DateUtil.date(shuntApply.getStartTime()).toDateStr());
setBookEndDate(DateUtil.date(shuntApply.getEndTime()).toDateStr());
setBookStartDateTime(DateUtil.date(shuntApply.getStartTime()).toString());
setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toString());
}});
//预约车辆
orderRentVehicleService.acquireVehicle(detail, null , VehicleBookRecordStatus.APPROVE.getCode());
orderRentVehicleService.acquireVehicle(detail, null , null);
shuntApply.setVehicleId(dto.getVehicleId());
shuntApply.setStatus(STATUS_CONFIRM);
shuntApply.setOrderNo(detail.getOrder().getNo());
shuntApply.setOverTime(DateUtil.offsetHour(DateUtil.date(), 1).getTime());
shuntApply.setConfirmUserId(getAdminUserInfo().getId());
shuntApply.setConfirmCompanyId(getAdminUserInfo().getCompanyId());
shuntApply.setBookRecordId(detail.getBookRecordId());
baseBiz.updateSelectiveByIdRe(shuntApply);
rabbitProduct.sendApplyDelayMessage(baseBiz.selectById(shuntApply.getId()), 1000L * 3601L);
......
......@@ -82,7 +82,7 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or
}
//设置订单号
if(StrUtil.isBlank(orderNo)) {
if(StrUtil.isNotBlank(orderNo)) {
baseOrder.setNo(orderNo);
} else {
baseOrder.setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));
......
......@@ -19,6 +19,7 @@ import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.OrderCostDetailBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.OrderTemplateBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderCostEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
......@@ -82,6 +83,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@Autowired
OrderTemplateBiz orderTemplateBiz;
@Autowired
OrderCalculateBiz orderCalculateBiz;
@Autowired
ThirdFeign thirdFeign;
......@@ -247,9 +251,11 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
bo.setAccompanyItems(oads);
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//获取可用车辆
acquireVehicle(bo, null, null);
cloudTransact = 1;
}
//添加随声物品项
OrderItem accompanyItem = orderItemBiz.initOrderItem(BigDecimal.ZERO, 1, "随车物品", null, ACCOMPANY);
......@@ -288,22 +294,29 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
//判断分布式事务执行到哪里
switch (cloudTransact) {
case 1 :
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//取消车辆预定
//未支付,拒绝之前的预约
errorRejectVehicle(bo);
}
break;
case 2 :
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//取消车辆预定
//未支付,拒绝之前的预约
errorRejectVehicle(bo);
}
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW);
break;
case 3 :
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//取消车辆预定
//未支付,拒绝之前的预约
errorRejectVehicle(bo);
}
//退还天数
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW);
......@@ -341,7 +354,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
}
private void errorRejectVehicle(RentVehicleBO bo) {
public void errorRejectVehicle(RentVehicleBO bo) {
//取消车辆预定
//未支付,拒绝之前的预约
RestResponse<Integer> restResponse = vehicleFeign.rentRejectVehicleBooking(bo.getBookRecordId());
......@@ -384,7 +397,15 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
// for (VehicleHolidayPriceInfo vhpi : vhpis) {
// vhpi.getAllModelUse()
// }
List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds);
List<VMCalendarPriceCostDTO> vmcpds = CollUtil.newArrayList();
Integer includeDays = orderCalculateBiz.getIncludeDays(detail.getStartTime(), detail.getEndTime());
for (VehicleModelCalendarPriceDTO metaVmcpd : metaVmcpds) {
if(includeDays > 0) {
vmcpds.add(BeanUtil.toBean(metaVmcpd, VMCalendarPriceCostDTO.class));
includeDays = includeDays - 1;
}
}
//List<VMCalendarPriceCostDTO> vmcpds = Convert.toList(VMCalendarPriceCostDTO.class, metaVmcpds);
//设置Item
......
......@@ -24,25 +24,27 @@ public class BookVehicleVO {
/**
* 预定目标日期(开始)
*/
@ApiModelProperty("预定目标日期(开始) yyyy-MM-dd HH:mm:ss")
// @ApiModelProperty("预定目标日期(开始) yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("预定目标日期(开始) yyyy-MM-dd")
private String bookStartDate;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("预定目标日期(结束) yyyy-MM-dd HH:mm:ss")
// @ApiModelProperty("预定目标日期(结束) yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("预定目标日期(结束) yyyy-MM-dd")
private String bookEndDate;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty("预定目标时间(开始)")
@ApiModelProperty("预定目标时间(开始) yyyy-MM-dd HH:mm:ss")
private String bookStartDateTime;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("预定目标时间(结束)")
@ApiModelProperty("预定目标时间(结束) yyyy-MM-dd HH:mm:ss")
private String bookEndDateTime;
/**
......
......@@ -57,6 +57,9 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
@Autowired
VehicleCommonPriceInfoBiz vehicleCommonPriceInfoBiz;
@Autowired
VehicleModelCalendarPriceBiz vehicleModelCalendarPriceBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
......
......@@ -240,7 +240,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @param endLong
* @return
*/
private Integer getIncludeDays(Long startLong, Long endLong) {
public Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24;
......
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