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

添加申请调车

parent 9a80a78a
...@@ -25,6 +25,12 @@ public class ShuntApply implements Serializable { ...@@ -25,6 +25,12 @@ public class ShuntApply implements Serializable {
public static final int STATUS_CONFIRM = 3; public static final int STATUS_CONFIRM = 3;
public static final int STATUS_ORDER = 4; public static final int STATUS_ORDER = 4;
public static final int STATUS_AUTOCNL = 5; public static final int STATUS_AUTOCNL = 5;
public static final int STATUS_ERR = 6;
public static final int STATUS_SUCC = 7;
public static final int ORDER_STATUS_TOPAY = 1;
public static final int ORDER_STATUS_PAY = 2;
public static final int ORDER_STATUS_CANCEL = 3;
/** /**
* 主键 * 主键
...@@ -36,16 +42,20 @@ public class ShuntApply implements Serializable { ...@@ -36,16 +42,20 @@ public class ShuntApply implements Serializable {
/** /**
* 状态 * 状态
0--删除 0--删除
1--创建 1--创建
2--取消 2--取消
3--申请成功 3--申请成功
*/ */
@Column(name = "status") @Column(name = "status")
@ApiModelProperty(value = "状态 0--删除 1--创建 2--取消 3--申请成功 ") @ApiModelProperty(value = "状态 0--删除 1--创建 2--取消 3--接单中 4--已下单 5--接单成功 6--接单失败")
private Integer status; private Integer status;
@Column(name = "order_status")
@ApiModelProperty(value = "状态 1--待支付 2--已支付 3--已取消 ")
private Integer orderStatus;
/** /**
* 创建时间 * 创建时间
*/ */
...@@ -158,4 +168,41 @@ public class ShuntApply implements Serializable { ...@@ -158,4 +168,41 @@ public class ShuntApply implements Serializable {
@ApiModelProperty(value = "超时时间戳", hidden = true ) @ApiModelProperty(value = "超时时间戳", hidden = true )
private Long overTime; private Long overTime;
/**
* 开始城市编码
*/
@Column(name = "start_city_code")
@ApiModelProperty(value = "开始城市编码")
private Integer startCityCode;
/**
* 结束城市编码
*/
@Column(name = "end_city_code")
@ApiModelProperty(value = "结束城市编码", hidden = true )
private Integer endCityCode;
/**
* 确认申请的后台用户id
*/
@Column(name = "confirm_user_id")
@ApiModelProperty(value = "确认申请的后台用户id", hidden = true )
private Integer confirmUserId;
/**
* 确认申请的公司(门店)id
*/
@Column(name = "confirm_company_id")
@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 ...@@ -22,6 +22,12 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
private BaseOrder order; private BaseOrder order;
private VehicleModel vehicleModel; private VehicleModel vehicleModel;
private BookVehicleVO bookVehicleVO; private BookVehicleVO bookVehicleVO;
/**
* 是否调车申请下订单
*/
private Integer applyOrderSign = 0;
/** /**
* 是否使用出租免费天数 * 是否使用出租免费天数
*/ */
......
...@@ -5,6 +5,7 @@ import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFacto ...@@ -5,6 +5,7 @@ import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFacto
import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory; import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -23,44 +24,69 @@ public class RabbitDelayConfig { ...@@ -23,44 +24,69 @@ public class RabbitDelayConfig {
public static final String ORDER_CANCEL_EXC = "order_cancel_delay_exchange"; public static final String ORDER_CANCEL_EXC = "order_cancel_delay_exchange";
public static final String ORDER_CANCEL_QUE = "order_cancel_delay_queue"; public static final String ORDER_CANCEL_QUE = "order_cancel_delay_queue";
public static final String ORDER_CANCEL_KEY = "order_cancel_delay_key"; public static final String ORDER_CANCEL_KEY = "order_cancel_delay_key";
public static final String APPLY_CANCEL_EXC = "apply_cancel_delay_exchange";
public static final String APPLY_CANCEL_QUE = "apply_cancel_delay_queue";
public static final String APPLY_CANCEL_KEY = "apply_cancel_delay_key";
/** /**
* 延时队列交换机 * 延时队列交换机
* 注意这里的交换机类型:CustomExchange * 注意这里的交换机类型:CustomExchange
* @return * @return
*/ */
@Bean @Bean(ORDER_CANCEL_EXC)
public CustomExchange delayExchange(){ public CustomExchange orderDelayExchange(){
Map<String, Object> args = new HashMap<>(); Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct"); args.put("x-delayed-type", "direct");
return new CustomExchange(ORDER_CANCEL_EXC,"x-delayed-message",true, false, args); return new CustomExchange(ORDER_CANCEL_EXC,"x-delayed-message",true, false, args);
} }
/**
* 延时队列交换机
* 注意这里的交换机类型:CustomExchange
* @return
*/
@Bean(APPLY_CANCEL_EXC)
public CustomExchange applyDelayExchange(){
Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct");
return new CustomExchange(APPLY_CANCEL_EXC,"x-delayed-message",true, false, args);
}
/** /**
* 延时队列 * 延时队列
* @return * @return
*/ */
@Bean @Bean(ORDER_CANCEL_QUE)
public Queue delayQueue(){ public Queue delayQueue(){
return new Queue(ORDER_CANCEL_QUE,true); return new Queue(ORDER_CANCEL_QUE,true);
} }
/**
* 延时队列
* @return
*/
@Bean(APPLY_CANCEL_QUE)
public Queue applyDelayQueue(){
return new Queue(APPLY_CANCEL_QUE,true);
}
/** /**
* 给延时队列绑定交换机 * 给延时队列绑定交换机
* @return * @return
*/ */
@Bean @Bean("cfgDelayBinding")
public Binding cfgDelayBinding(Queue cfgDelayQueue, CustomExchange cfgUserDelayExchange){ public Binding cfgDelayBinding(@Qualifier(ORDER_CANCEL_QUE) Queue cfgDelayQueue, @Qualifier(ORDER_CANCEL_EXC) CustomExchange cfgUserDelayExchange){
return BindingBuilder.bind(cfgDelayQueue).to(cfgUserDelayExchange).with(ORDER_CANCEL_KEY).noargs(); return BindingBuilder.bind(cfgDelayQueue).to(cfgUserDelayExchange).with(ORDER_CANCEL_KEY).noargs();
} }
// @Bean /**
// public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory){ * 给延时队列绑定交换机
// SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); * @return
// factory.setConnectionFactory(connectionFactory); */
//// factory.setMessageConverter(new Jackson2JsonMessageConverter()); @Bean("acqDelayBinding")
// factory.setAcknowledgeMode(AcknowledgeMode.MANUAL); public Binding acqDelayBinding(@Qualifier(APPLY_CANCEL_QUE) Queue acqDelayQueue, @Qualifier(APPLY_CANCEL_EXC) CustomExchange acqUserDelayExchange){
// return factory; return BindingBuilder.bind(acqDelayQueue).to(acqUserDelayExchange).with(APPLY_CANCEL_KEY).noargs();
// } }
} }
package com.xxfc.platform.order.mqhandler; package com.xxfc.platform.order.mqhandler;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -8,8 +9,8 @@ import org.springframework.stereotype.Component; ...@@ -8,8 +9,8 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static com.xxfc.platform.order.config.RabbitDelayConfig.ORDER_CANCEL_EXC; import static com.xxfc.platform.order.config.RabbitDelayConfig.*;
import static com.xxfc.platform.order.config.RabbitDelayConfig.ORDER_CANCEL_KEY; import static com.xxfc.platform.order.config.RabbitDelayConfig.APPLY_CANCEL_KEY;
/** /**
* rabbitMq生产者类 * rabbitMq生产者类
...@@ -39,5 +40,23 @@ public class RabbitProduct { ...@@ -39,5 +40,23 @@ public class RabbitProduct {
); );
log.info("{}ms后执行", delayTime); log.info("{}ms后执行", delayTime);
} }
public void sendApplyDelayMessage(ShuntApply shuntApply, Long delayTime) {
//这里的消息可以是任意对象,无需额外配置,直接传即可
log.info("===============延时队列生产消息====================");
log.info("发送时间:{},发送内容:{}", LocalDateTime.now(), shuntApply.toString());
this.rabbitTemplate.convertAndSend(
APPLY_CANCEL_EXC,
APPLY_CANCEL_KEY,
shuntApply,
message -> {
//注意这里时间可以使long,而且是设置header
message.getMessageProperties().setHeader("x-delay", delayTime);
return message;
}
);
log.info("{}ms后执行", delayTime);
}
} }
...@@ -131,7 +131,7 @@ public class AppOrderController extends CommonBaseController implements UserRest ...@@ -131,7 +131,7 @@ public class AppOrderController extends CommonBaseController implements UserRest
companyIds.clear(); companyIds.clear();
companyIds.add(dto.getStartCompanyId()); companyIds.add(dto.getStartCompanyId());
} else { } else {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ(new PageDataVO<>());
} }
} else { } else {
companyIds.add(dto.getStartCompanyId()); companyIds.add(dto.getStartCompanyId());
......
...@@ -14,6 +14,7 @@ import com.xxfc.platform.order.biz.OrderRentVehicleBiz; ...@@ -14,6 +14,7 @@ import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.ShuntApplyBiz; import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz; import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.ShuntApply; import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO; import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO; import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO; import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
...@@ -25,6 +26,7 @@ import lombok.Data; ...@@ -25,6 +26,7 @@ import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; 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.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_CNL;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT; import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
...@@ -51,13 +53,19 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -51,13 +53,19 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
@RequestMapping(value = "/addApply", method = RequestMethod.POST) @RequestMapping(value = "/addApply", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "申请列表") @ApiOperation(value = "添加申请")
public ObjectRestResponse addApply(@RequestBody ShuntApply shuntApply) { public ObjectRestResponse addApply(@RequestBody ShuntApply shuntApply) {
//查询列表数据 //查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) { if (StrUtil.isBlank(getCurrentUserId())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE); throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
} }
if(null != shuntApply.getStartCompanyId()) {
shuntApply.setStartCityCode(vehicleFeign.getCompanyDetail(shuntApply.getStartCompanyId()).getData().getAddrCity());
}
if(null != shuntApply.getEndCompanyId()) {
shuntApply.setEndCityCode(vehicleFeign.getCompanyDetail(shuntApply.getEndCompanyId()).getData().getAddrCity());
}
shuntApply.setUserId(getCurrentUserIdInt()); shuntApply.setUserId(getCurrentUserIdInt());
shuntApply.setStatus(STATUS_CRT); shuntApply.setStatus(STATUS_CRT);
return add(shuntApply); return add(shuntApply);
...@@ -125,6 +133,10 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -125,6 +133,10 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE); throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
} }
if(ShuntApply.STATUS_ORDER == shuntApply.getStatus()) {
throw new BaseException("该申请已下单", ResultCode.PARAM_ILLEGAL_CODE);
}
// BgAddRentDTO bgAddRentDTO = new BgAddRentDTO(); // BgAddRentDTO bgAddRentDTO = new BgAddRentDTO();
// bgAddRentDTO.setAppUserId(shuntApply.getUserId()); // bgAddRentDTO.setAppUserId(shuntApply.getUserId());
// bgAddRentDTO.setStartTime(shuntApply.getStartTime()); // bgAddRentDTO.setStartTime(shuntApply.getStartTime());
...@@ -147,9 +159,20 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -147,9 +159,20 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
// setDayNum(orderCalculateBiz.getIncludeDays(shuntApply.getStartTime(), shuntApply.getEndTime())); // 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); RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(dto);
bo.setApplyOrderSign(SYS_TRUE);
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData()); bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
orderRentVehicleService.applyCreateOrder(bo, shuntApply.getOrderNo()); orderRentVehicleService.applyCreateOrder(bo, shuntApply.getOrderNo());
baseBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
setStatus(ShuntApply.STATUS_ORDER);
setOrderStatus(ShuntApply.ORDER_STATUS_TOPAY);
}});
return ObjectRestResponse.succ(bo.getOrder()); return ObjectRestResponse.succ(bo.getOrder());
} }
...@@ -161,6 +184,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -161,6 +184,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
@Data @Data
public static class ShuntApplyVO extends ShuntApply { public static class ShuntApplyVO extends ShuntApply {
VehicleModel vehicleModel; VehicleModel vehicleModel;
OrderPageVO orderPageVO;
} }
@Data @Data
......
package com.xxfc.platform.order.rest.background; package com.xxfc.platform.order.rest.background;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
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.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
...@@ -11,28 +16,40 @@ import com.github.wxiaoqi.security.common.util.Query; ...@@ -11,28 +16,40 @@ import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; 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.github.wxiaoqi.security.common.vo.PageParam; import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz; import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.ShuntApplyBiz; import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz; import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply; import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO; import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO; import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
import com.xxfc.platform.order.rest.ShuntApplyController;
import com.xxfc.platform.order.service.OrderRentVehicleService; import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
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 com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CONFIRM; import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CONFIRM;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT; import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
@RestController @RestController
@RequestMapping("/background/shuntApply") @RequestMapping("/background/shuntApply")
public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> { public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> implements UserRestInterface {
@Autowired @Autowired
...@@ -50,10 +67,42 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA ...@@ -50,10 +67,42 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
@Autowired @Autowired
OrderRentVehicleService orderRentVehicleService; OrderRentVehicleService orderRentVehicleService;
@RequestMapping(value = "/confirmApply", method = RequestMethod.POST) @Autowired
RabbitProduct rabbitProduct;
@Autowired
BaseOrderBiz baseOrderBiz;
@Override
public UserFeign getUserFeign() {
return this.userFeign;
}
@RequestMapping(value = "/steward/list", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据城市查询待确认申请列表")
public ObjectRestResponse<PageDataVO<StewardShuntApply>> stewardList(ListDTO dto) {
//获取该城市的申请最大和最小时间
//获取该店铺
PageDataVO<StewardShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
if(null != dto.getCityCode()) {
w.andEqualTo(ShuntApply::getStartCityCode, dto.getCityCode());
}
w.andEqualTo(ShuntApply::getStatus, STATUS_CRT);
return w;
}, " crt_time desc "), StewardShuntApply.class);
list.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
});
return ObjectRestResponse.succ(list);
}
@RequestMapping(value = "/steward/confirmApply", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "后台确认申请") @ApiOperation(value = "后台确认申请")
public ObjectRestResponse confirmApply(@RequestBody confirmApplyDTO dto) { public ObjectRestResponse stewardConfirmApply(@RequestBody ConfirmApplyDTO dto) {
//查询列表数据 //查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) { if (StrUtil.isBlank(getCurrentUserId())) {
...@@ -72,27 +121,142 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA ...@@ -72,27 +121,142 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
RentVehicleBO detail = new RentVehicleBO(); RentVehicleBO detail = new RentVehicleBO();
detail.setStartTime(shuntApply.getStartTime()); detail.setStartTime(shuntApply.getStartTime());
detail.setEndTime(shuntApply.getEndTime()); detail.setEndTime(shuntApply.getEndTime());
detail.setVehicleId(shuntApply.getVehicleId()); detail.setVehicleId(dto.getVehicleId());
detail.setModelId(shuntApply.getModelId()); detail.setModelId(shuntApply.getModelId());
detail.setStartAddr(shuntApply.getStartCompanyName()); detail.setStartAddr(shuntApply.getStartCompanyName());
detail.setStartCompanyId(shuntApply.getStartCompanyId()); detail.setStartCompanyId(shuntApply.getStartCompanyId());
detail.setEndCompanyId(shuntApply.getEndCompanyId()); detail.setEndCompanyId(shuntApply.getEndCompanyId());
detail.setOrder(new BaseOrder(){{setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));}}); 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.setVehicleId(dto.getVehicleId());
shuntApply.setStatus(STATUS_CONFIRM); shuntApply.setStatus(STATUS_CONFIRM);
shuntApply.setOrderNo(detail.getOrder().getNo()); shuntApply.setOrderNo(detail.getOrder().getNo());
baseBiz.updateSelectiveById(shuntApply); 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);
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
@RequestMapping(value = "/steward/applyDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "申请的详情")
public ObjectRestResponse stewardApplyDetail(Integer applyId) {
Integer companyId = getAdminUserInfo().getCompanyId();
ShuntApply shuntApply = baseBiz.selectById(applyId);
StewardShuntApply shuntApplyVO = BeanUtil.toBean(shuntApply, StewardShuntApply.class);
shuntApplyVO.setVehicleModel(vehicleFeign.get(shuntApply.getModelId()).getData());
RentVehicleBookDTO rbd = new RentVehicleBookDTO();
rbd.setModelId(shuntApply.getModelId());
rbd.setParkBranchCompanyId(companyId);
rbd.setStartCompanyId(companyId);
rbd.setEndCompanyId(companyId);
rbd.setBookStartDate(DateUtil.date(shuntApply.getStartTime()).toDateStr());
rbd.setBookEndDate(DateUtil.date(shuntApply.getEndTime()).toDateStr());
rbd.setBookStartDateTime(DateUtil.date(shuntApply.getStartTime()).toString());
rbd.setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toString());
//查询本公司时间段内可用车辆
ObjectRestResponse<PageDataVO<UsableVeicleVO>> usableVehiclePage = vehicleFeign.applyUsableVehicle(rbd);
if(CollUtil.isNotEmpty(usableVehiclePage.getData().getData())) {
List<UsableVeicleVO> vehicles = CollUtil.newArrayList();
usableVehiclePage.getData().getData().forEach(usableVeicleVO -> {
//判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(shuntApply.getStartTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(shuntApply.getEndTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
if(SYS_TRUE.equals(usableVeicleVO.getAllowRent())) {
vehicles.add(BeanUtil.toBean(usableVeicleVO, UsableVeicleVO.class));
}
});
if(CollUtil.isNotEmpty(vehicles)) {
shuntApplyVO.setVehicles(vehicles);
}
}
return ObjectRestResponse.succ(shuntApplyVO);
}
@RequestMapping(value = "/steward/myApplyList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "我的申请")
public ObjectRestResponse myApplyList(PageDTO dto) {
UserDTO userDTO = getAdminUserInfo();
PageDataVO<ShuntApplyController.ShuntApplyVO> pages = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
w.andEqualTo(ShuntApply::getConfirmUserId, userDTO.getId());
if(StrUtil.isNotBlank(dto.getMultiStatus())) {
w.andIn(ShuntApply::getStatus, CollUtil.toList(dto.getMultiStatus().split(",")));
}
return w;
}), ShuntApplyController.ShuntApplyVO.class);
pages.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
if(StrUtil.isNotBlank(data.getOrderNo())) {
Map<String, Object> map = CollUtil.newHashMap();
map.put("no", data.getOrderNo());
List<OrderPageVO> list = baseOrderBiz.pageByParm(map);
if(CollUtil.isNotEmpty(list)) {
data.setOrderPageVO(list.get(0));
}
}
});
return ObjectRestResponse.succ(pages);
}
@Data @Data
public static class confirmApplyDTO { public static class ConfirmApplyDTO {
Integer applyId; Integer applyId;
String vehicleId; String vehicleId;
} }
@Data
public static class ListDTO extends PageParam {
Integer cityCode;
}
@Data
public static class PageDTO extends PageParam {
String multiStatus;
}
@Data
public static class StewardShuntApply extends ShuntApply {
List<UsableVeicleVO> vehicles;
VehicleModel vehicleModel;
public VehicleModel getVehicleModel() {
return vehicleModel;
}
public void setVehicleModel(VehicleModel vehicleModel) {
this.vehicleModel = vehicleModel;
}
}
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; ...@@ -13,6 +13,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo; import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo; import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO; import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -246,4 +247,8 @@ public interface VehicleFeign { ...@@ -246,4 +247,8 @@ public interface VehicleFeign {
@RequestMapping(value = "/vehicleInfo/selectByCompanyIds", method = RequestMethod.GET) @RequestMapping(value = "/vehicleInfo/selectByCompanyIds", method = RequestMethod.GET)
public ObjectRestResponse<List<Vehicle>> vehicleSelectByCompanyIds(@RequestParam("companyIds") String companyIds); public ObjectRestResponse<List<Vehicle>> vehicleSelectByCompanyIds(@RequestParam("companyIds") String companyIds);
@RequestMapping(value = "/vehicleInfo/rent/apply/usable-vehicle", method = RequestMethod.POST)
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> applyUsableVehicle(@RequestBody RentVehicleBookDTO rbd);
} }
package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
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.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.biz.*;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.jobhandler.VehicleJobHandler;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindAppDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
@RestController
@RequestMapping("/chw/app/vehicle")
@Slf4j
@IgnoreClientToken
@Api(value="超惠玩车辆controller",tags={"超惠玩车辆接口"})
public class ChwAppVehicleController extends BaseController<VehicleBiz> implements UserRestInterface {
@Autowired
UserFeign userFeign;
@Autowired
VehicleBrandBiz vehicleBrandBiz;
@Autowired
VehicleCategoryBiz vehicleCategoryBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@ApiOperation("vehicleBrand查询所有")
@RequestMapping(value = "/vehicleBrand/all",method = RequestMethod.GET)
@ResponseBody
@IgnoreUserToken
public List<VehicleBrand> all() {
return vehicleBrandBiz.selectListAll();
}
@ApiOperation("vehicleCategory查询分页")
@RequestMapping(value = "/vehicleCategory/page",method = RequestMethod.GET)
@ResponseBody
@IgnoreUserToken
public TableResultResponse<VehicleCategory> list(@RequestParam Map<String, Object> params){
//查询列表数据
Query query = new Query(params);
return vehicleCategoryBiz.selectPageByQuery(query);
}
}
...@@ -267,6 +267,39 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -267,6 +267,39 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
return ObjectRestResponse.succ(pageDataVO); return ObjectRestResponse.succ(pageDataVO);
} }
@ApiOperation("调车申请列表-可用车辆查询")
@RequestMapping(value = "/rent/apply/usable-vehicle", method = RequestMethod.POST)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> applyUsableVehicle(@RequestBody RentVehicleBookDTO rbd) {
rbd.setRecordIntersection(Boolean.TRUE);
rbd.setLimit(100);
rbd.setPage(1);
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.parse(rbd.getBookStartDateTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.parse(rbd.getBookEndDateTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
}
}
return ObjectRestResponse.succ(pageDataVO);
}
/** /**
* 后台查询可用车辆(车型) * 后台查询可用车辆(车型)
* *
......
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