Commit 4739ab6f authored by hezhen's avatar hezhen

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

# Conflicts:
#	xx-tour/xx-tour-api/src/main/java/com/xxfc/platform/tour/entity/TourTag.java
#	xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/biz/TourTagBiz.java
parents 7b1be07e 8052c0a5
package com.github.wxiaoqi.security.common.vo; package com.github.wxiaoqi.security.common.vo;
import com.github.wxiaoqi.security.common.util.Query;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -10,5 +11,7 @@ public class PageParam { ...@@ -10,5 +11,7 @@ public class PageParam {
@ApiModelProperty("每页限制") @ApiModelProperty("每页限制")
Integer limit; Integer limit;
public Query initQuery() {
return new Query(this);
}
} }
...@@ -11,7 +11,8 @@ spring: ...@@ -11,7 +11,8 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver driverClassName: com.mysql.jdbc.Driver
#url: jdbc:mysql://10.5.52.3:3306/xxfc_vehicle?useUnicode=true&characterEncoding=UTF-8 #url: jdbc:mysql://10.5.52.3:3306/xxfc_vehicle?useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://10.5.52.3:3306/tiande_order?useUnicode=true&characterEncoding=UTF-8 #url: jdbc:mysql://10.5.52.3:3306/tiande_order?useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://10.5.52.4:3307/chw_vehicle?useUnicode=true&characterEncoding=UTF-8
username: root username: root
password: sslcloud123*() password: sslcloud123*()
jackson: jackson:
......
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F #\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
#\u5305\u540D #\u5305\u540D
package=com.xxfc.platform.order package=com.xxfc.platform.vehicle
#\u4F5C\u8005 #\u4F5C\u8005
author=libin author=libin
#Email #Email
......
...@@ -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;
/** /**
* 主键 * 主键
...@@ -43,9 +49,13 @@ public class ShuntApply implements Serializable { ...@@ -43,9 +49,13 @@ public class ShuntApply implements Serializable {
*/ */
@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;
/** /**
* 是否使用出租免费天数 * 是否使用出租免费天数
*/ */
...@@ -87,6 +93,6 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail ...@@ -87,6 +93,6 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
this.startDate = DateUtil.date(getStartTime()); this.startDate = DateUtil.date(getStartTime());
this.endDate = DateUtil.date(getEndTime()); this.endDate = DateUtil.date(getEndTime());
this.startDateStr = DateUtil.formatDate(this.startDate); this.startDateStr = DateUtil.formatDate(this.startDate);
this.startDateStr = DateUtil.formatDate(this.endDate); this.endDateStr = DateUtil.formatDate(this.endDate);
} }
} }
...@@ -127,6 +127,12 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{ ...@@ -127,6 +127,12 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{
@ApiModelProperty(value = "车辆id") @ApiModelProperty(value = "车辆id")
private String vehicleId; private String vehicleId;
@ApiModelProperty(value = "商品类型 1--房车;2--机车;3--游艇")
private Integer goodsType = 1;
@ApiModelProperty(value = "小时数")
private Integer hourNum;
public void setStartTime(Long startTime) { public void setStartTime(Long startTime) {
this.startTime = startTime; this.startTime = startTime;
this.bookStartDate = YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8))); this.bookStartDate = YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
......
...@@ -149,6 +149,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -149,6 +149,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
@Autowired @Autowired
CompanyInfoBiz companyInfoBiz; CompanyInfoBiz companyInfoBiz;
@Autowired
ShuntApplyBiz shuntApplyBiz;
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
...@@ -799,6 +802,19 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -799,6 +802,19 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
BeanUtil.copyProperties(this.updateSelectiveByIdReT(updateOrder), baseOrder); BeanUtil.copyProperties(this.updateSelectiveByIdReT(updateOrder), baseOrder);
//记录订单账款记录 //记录订单账款记录
Integer flag = orderAccountBiz.addOrderAccount(baseOrder.getId(), "订单支付", oad.getOriginOrderAmount().add(oad.getOriginDepositAmount()), oad.getOrderAmount().add(oad.getDepositAmount()), tradeNo, AccountTypeEnum.IN_ORDER_PAY.getCode(), JSONUtil.toJsonStr(oad)); Integer flag = orderAccountBiz.addOrderAccount(baseOrder.getId(), "订单支付", oad.getOriginOrderAmount().add(oad.getOriginDepositAmount()), oad.getOrderAmount().add(oad.getDepositAmount()), tradeNo, AccountTypeEnum.IN_ORDER_PAY.getCode(), JSONUtil.toJsonStr(oad));
//更新 申请状态
ShuntApply shuntApply = shuntApplyBiz.selectOne(new ShuntApply(){{
setOrderNo(baseOrder.getNo());
}});
if(null != shuntApply && shuntApply.getStatus() == ShuntApply.STATUS_ORDER) {
shuntApplyBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
setStatus(ShuntApply.STATUS_SUCC);
setOrderStatus(ShuntApply.ORDER_STATUS_PAY);
}});
}
} finally { } finally {
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData(); AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
......
...@@ -105,6 +105,7 @@ public class OrderRentVehicleBiz extends BaseBiz<OrderRentVehicleDetailMapper, O ...@@ -105,6 +105,7 @@ public class OrderRentVehicleBiz extends BaseBiz<OrderRentVehicleDetailMapper, O
public RentVehicleBO initRentVehicleBO(AddRentVehicleDTO vo) { public RentVehicleBO initRentVehicleBO(AddRentVehicleDTO vo) {
//计算天数 //计算天数
vo.setDayNum(orderCalculateBiz.getIncludeDays(vo.getStartTime(), vo.getEndTime())); vo.setDayNum(orderCalculateBiz.getIncludeDays(vo.getStartTime(), vo.getEndTime()));
vo.setHourNum(orderCalculateBiz.getIncludeHours(vo.getStartTime(), vo.getEndTime()));
if(null == vo.getEndCompanyId() || vo.getEndCompanyId().equals(0)) { if(null == vo.getEndCompanyId() || vo.getEndCompanyId().equals(0)) {
if(StrUtil.isBlank(vo.getEndAddr())) { if(StrUtil.isBlank(vo.getEndAddr())) {
......
...@@ -384,6 +384,40 @@ public class OrderCalculateBiz { ...@@ -384,6 +384,40 @@ public class OrderCalculateBiz {
return bookDays; return bookDays;
} }
/**
* 计算包含多少小时
* @param startLong
* @param endLong
* @return
*/
public Integer getIncludeHours(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
//Long dayLong = hourLong * 24;
Long bufferLong = 0L;
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong;
//默认 已使用了1小时
if(bookTimeLag <= 0) {
return 1;
}
log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
log.info("divide {}", new BigDecimal(hourLong+ ""));
Integer hourDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(hourLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%hourLong;
if(excess > bufferLong) {
hourDays += 1;
}
if(0 == hourDays) {
hourDays = 1;
}
return hourDays;
}
public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) { public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) {
//根据no 查订单 //根据no 查订单
......
...@@ -99,6 +99,9 @@ public class OrderCancelBiz { ...@@ -99,6 +99,9 @@ public class OrderCancelBiz {
@Autowired @Autowired
ActivityFeign activityFeign; ActivityFeign activityFeign;
@Autowired
ShuntApplyBiz shuntApplyBiz;
private static Map<Integer, List<Integer>> cancelAble; private static Map<Integer, List<Integer>> cancelAble;
static { static {
cancelAble = new HashMap<Integer, List<Integer>>(); cancelAble = new HashMap<Integer, List<Integer>>();
...@@ -419,6 +422,20 @@ public class OrderCancelBiz { ...@@ -419,6 +422,20 @@ public class OrderCancelBiz {
//发送队列消息 //发送队列消息
baseOrderBiz.sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_CANCEL); baseOrderBiz.sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_CANCEL);
//处理申请
//更新 申请状态
ShuntApply shuntApply = shuntApplyBiz.selectOne(new ShuntApply(){{
setOrderNo(baseOrder.getNo());
}});
if(null != shuntApply && shuntApply.getStatus() == ShuntApply.STATUS_ORDER) {
shuntApplyBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
setStatus(ShuntApply.STATUS_ERR);
setOrderStatus(ShuntApply.ORDER_STATUS_CANCEL);
}});
}
}else { }else {
throw new BaseException(ResultCode.FAILED_CODE); throw new BaseException(ResultCode.FAILED_CODE);
} }
......
...@@ -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,37 +24,71 @@ public class RabbitDelayConfig { ...@@ -23,37 +24,71 @@ 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 orderDelayQueue(){
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();
} }
/**
* 给延时队列绑定交换机
* @return
*/
@Bean("acqDelayBinding")
public Binding acqDelayBinding(@Qualifier(APPLY_CANCEL_QUE) Queue acqDelayQueue, @Qualifier(APPLY_CANCEL_EXC) CustomExchange acqUserDelayExchange){
return BindingBuilder.bind(acqDelayQueue).to(acqUserDelayExchange).with(APPLY_CANCEL_KEY).noargs();
}
// @Bean // @Bean
// public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory){ // public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory){
// SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); // SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
......
...@@ -3,8 +3,12 @@ package com.xxfc.platform.order.mqhandler; ...@@ -3,8 +3,12 @@ package com.xxfc.platform.order.mqhandler;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCancelBiz; import com.xxfc.platform.order.biz.inner.OrderCancelBiz;
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.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.service.OrderRentVehicleService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
...@@ -14,6 +18,7 @@ import org.springframework.stereotype.Component; ...@@ -14,6 +18,7 @@ import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static com.xxfc.platform.order.config.RabbitDelayConfig.APPLY_CANCEL_QUE;
import static com.xxfc.platform.order.config.RabbitDelayConfig.ORDER_CANCEL_QUE; import static com.xxfc.platform.order.config.RabbitDelayConfig.ORDER_CANCEL_QUE;
/** /**
...@@ -28,6 +33,12 @@ public class RabbitConsumer { ...@@ -28,6 +33,12 @@ public class RabbitConsumer {
@Autowired @Autowired
OrderCancelBiz orderCancelBiz; OrderCancelBiz orderCancelBiz;
@Autowired
ShuntApplyBiz shuntApplyBiz;
@Autowired
OrderRentVehicleService orderRentVehicleService;
/** /**
* 默认情况下,如果没有配置手动ACK, 那么Spring Data AMQP 会在消息消费完毕后自动帮我们去ACK * 默认情况下,如果没有配置手动ACK, 那么Spring Data AMQP 会在消息消费完毕后自动帮我们去ACK
...@@ -60,4 +71,49 @@ public class RabbitConsumer { ...@@ -60,4 +71,49 @@ public class RabbitConsumer {
channel.basicRecover(true); channel.basicRecover(true);
} }
} }
/**
* 默认情况下,如果没有配置手动ACK, 那么Spring Data AMQP 会在消息消费完毕后自动帮我们去ACK
* 存在问题:如果报错了,消息不会丢失,但是会无限循环消费,一直报错,如果开启了错误日志很容易就吧磁盘空间耗完
* 解决方案:手动ACK,或者try-catch 然后在 catch 里面将错误的消息转移到其它的系列中去
* spring.rabbitmq.listener.simple.acknowledge-mode = manual
*/
@RabbitListener(queues = APPLY_CANCEL_QUE)
public void applyCancelReceiveDealy(ShuntApply shuntApply, Message message, Channel channel) throws IOException {
log.info("===============接收队列接收消息====================");
log.info("接收时间:{},接受内容:{}", LocalDateTime.now(), shuntApply.toString());
//通知 MQ 消息已被接收,可以ACK(从队列中删除)了
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
try {
//设置自动取消标识
// baseOrder.setCancelReason("超时未付款,系统自动取消订单");
//orderCancelBiz.cancel(baseOrder, null);
//判断updateTime 是否一致(即乐观锁)
ShuntApply dbApply = shuntApplyBiz.selectById(shuntApply.getId());
if(dbApply.getUpdTime().equals(shuntApply.getUpdTime())) {
shuntApplyBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
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());
}
}catch (Exception e) {
log.error("============消费失败,尝试消息补发再次消费!==============");
log.error(e.getMessage());
/**
* basicRecover方法是进行补发操作,
* 其中的参数如果为true是把消息退回到queue但是有可能被其它的consumer(集群)接收到,
* 设置为false是只补发给当前的consumer
*/
channel.basicRecover(true);
}
}
} }
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,7 @@ import org.springframework.stereotype.Component; ...@@ -8,8 +9,7 @@ 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;
/** /**
* rabbitMq生产者类 * rabbitMq生产者类
...@@ -39,5 +39,22 @@ public class RabbitProduct { ...@@ -39,5 +39,22 @@ 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);
}
} }
...@@ -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
......
...@@ -82,7 +82,7 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or ...@@ -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); baseOrder.setNo(orderNo);
} else { } else {
baseOrder.setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID)); baseOrder.setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));
......
...@@ -19,6 +19,7 @@ import com.xxfc.platform.activity.feign.ActivityFeign; ...@@ -19,6 +19,7 @@ import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.OrderCostDetailBiz; import com.xxfc.platform.order.biz.OrderCostDetailBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz; import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.OrderTemplateBiz; 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.ItemTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderCostEnum; import com.xxfc.platform.order.contant.enumerate.OrderCostEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum; import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
...@@ -82,6 +83,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -82,6 +83,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@Autowired @Autowired
OrderTemplateBiz orderTemplateBiz; OrderTemplateBiz orderTemplateBiz;
@Autowired
OrderCalculateBiz orderCalculateBiz;
@Autowired @Autowired
ThirdFeign thirdFeign; ThirdFeign thirdFeign;
...@@ -247,9 +251,11 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -247,9 +251,11 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
} }
bo.setAccompanyItems(oads); bo.setAccompanyItems(oads);
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//获取可用车辆 //获取可用车辆
acquireVehicle(bo, null, null); acquireVehicle(bo, null, null);
cloudTransact = 1; cloudTransact = 1;
}
//添加随声物品项 //添加随声物品项
OrderItem accompanyItem = orderItemBiz.initOrderItem(BigDecimal.ZERO, 1, "随车物品", null, ACCOMPANY); OrderItem accompanyItem = orderItemBiz.initOrderItem(BigDecimal.ZERO, 1, "随车物品", null, ACCOMPANY);
...@@ -288,22 +294,29 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -288,22 +294,29 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
//判断分布式事务执行到哪里 //判断分布式事务执行到哪里
switch (cloudTransact) { switch (cloudTransact) {
case 1 : case 1 :
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//取消车辆预定 //取消车辆预定
//未支付,拒绝之前的预约 //未支付,拒绝之前的预约
errorRejectVehicle(bo); errorRejectVehicle(bo);
}
break; break;
case 2 : case 2 :
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//取消车辆预定 //取消车辆预定
//未支付,拒绝之前的预约 //未支付,拒绝之前的预约
errorRejectVehicle(bo); errorRejectVehicle(bo);
}
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW); useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW);
break; break;
case 3 : case 3 :
if(!SYS_TRUE.equals(bo.getApplyOrderSign())) {
//取消车辆预定 //取消车辆预定
//未支付,拒绝之前的预约 //未支付,拒绝之前的预约
errorRejectVehicle(bo); errorRejectVehicle(bo);
}
//退还天数 //退还天数
useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW); useOrBackFreeDays(bo, UserFeign.MEMBER_DAYS_WITHDRAW);
...@@ -341,7 +354,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -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()); RestResponse<Integer> restResponse = vehicleFeign.rentRejectVehicleBooking(bo.getBookRecordId());
...@@ -384,7 +397,15 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -384,7 +397,15 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
// for (VehicleHolidayPriceInfo vhpi : vhpis) { // for (VehicleHolidayPriceInfo vhpi : vhpis) {
// vhpi.getAllModelUse() // 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 //设置Item
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<if test="params.tagId != null and params.tagId != '' "> <if test="params.tagId != null and params.tagId != '' ">
and t.id in (SELECT tg.good_id from tour_good_tag tg and t.id in (SELECT tg.good_id from tour_good_tag tg
where tg.tag_id = #{params.tagId}) and t.recommend = 1 where tg.tag_id = #{params.tagId}) and t.recommend = 1
ORDER BY t.recommend
</if> </if>
order by t.rank DESC order by t.rank DESC
</select> </select>
......
...@@ -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;
...@@ -243,4 +244,7 @@ public interface VehicleFeign { ...@@ -243,4 +244,7 @@ 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);
} }
...@@ -24,25 +24,27 @@ public class BookVehicleVO { ...@@ -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; private String bookStartDate;
/** /**
* 预定目标日期(结束) * 预定目标日期(结束)
*/ */
@ApiModelProperty("预定目标日期(结束) yyyy-MM-dd HH:mm:ss") // @ApiModelProperty("预定目标日期(结束) yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("预定目标日期(结束) yyyy-MM-dd")
private String bookEndDate; private String bookEndDate;
/** /**
* 预定目标日期(开始) * 预定目标日期(开始)
*/ */
@ApiModelProperty("预定目标时间(开始)") @ApiModelProperty("预定目标时间(开始) yyyy-MM-dd HH:mm:ss")
private String bookStartDateTime; private String bookStartDateTime;
/** /**
* 预定目标日期(结束) * 预定目标日期(结束)
*/ */
@ApiModelProperty("预定目标时间(结束)") @ApiModelProperty("预定目标时间(结束) yyyy-MM-dd HH:mm:ss")
private String bookEndDateTime; private String bookEndDateTime;
/** /**
......
package com.xxfc.platform.vehicle.pojo;
import lombok.Data;
@Data
public class CompanySearchOldDTO {
Integer page;
Integer limit;
Integer addrCity;
String lon;
String lat;
Integer state;
Integer isShow = 1;
Integer isDel = 0;
}
\ No newline at end of file
...@@ -24,10 +24,7 @@ import com.xxfc.platform.vehicle.entity.BranchCompany; ...@@ -24,10 +24,7 @@ import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockInfo; import com.xxfc.platform.vehicle.entity.BranchCompanyStockInfo;
import com.xxfc.platform.vehicle.entity.SysRegion; import com.xxfc.platform.vehicle.entity.SysRegion;
import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper; import com.xxfc.platform.vehicle.mapper.BranchCompanyMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.CompanySearchVO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyListDTO;
...@@ -225,6 +222,12 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -225,6 +222,12 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
return PageDataVO.pageInfo(branchCompanyPageInfo); return PageDataVO.pageInfo(branchCompanyPageInfo);
} }
public PageDataVO<BranchCompany> searchOld(CompanySearchOldDTO vo) {
PageHelper.startPage(vo.getPage(), vo.getLimit());
PageInfo<BranchCompany> branchCompanyPageInfo = new PageInfo<>(mapper.searchOld(vo.getLon(), vo.getLat(), vo.getAddrCity(), vo.getState(), vo.getIsShow(), vo.getIsDel()));
return PageDataVO.pageInfo(branchCompanyPageInfo);
}
public PageDataVO<CompanySearchVO> search(CompanySearchDTO vo) { public PageDataVO<CompanySearchVO> search(CompanySearchDTO vo) {
PageHelper.startPage(vo.getPage(), vo.getLimit()); PageHelper.startPage(vo.getPage(), vo.getLimit());
PageInfo<CompanySearchVO> branchCompanyPageInfo = new PageInfo<>(getList(vo)); PageInfo<CompanySearchVO> branchCompanyPageInfo = new PageInfo<>(getList(vo));
......
...@@ -57,6 +57,9 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM ...@@ -57,6 +57,9 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
@Autowired @Autowired
VehicleCommonPriceInfoBiz vehicleCommonPriceInfoBiz; VehicleCommonPriceInfoBiz vehicleCommonPriceInfoBiz;
@Autowired
VehicleModelCalendarPriceBiz vehicleModelCalendarPriceBiz;
@Override @Override
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
......
...@@ -240,7 +240,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr ...@@ -240,7 +240,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @param endLong * @param endLong
* @return * @return
*/ */
private Integer getIncludeDays(Long startLong, Long endLong) { public Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L); Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24; Long dayLong = hourLong * 24;
......
...@@ -15,6 +15,7 @@ import java.util.List; ...@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdListMapper<BranchCompany,Integer> { public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdListMapper<BranchCompany,Integer> {
List<BranchCompany> searchOld(@Param("lon") String lon, @Param("lat") String lat, @Param("addrCity") Integer addrCity, Integer state, Integer isShow, Integer isDel);
List<CompanySearchVO> search(CompanySearchDTO companySearchDTO); List<CompanySearchVO> search(CompanySearchDTO companySearchDTO);
List<BranchCompany> selectByZoneId(Map<String, Object> param); List<BranchCompany> selectByZoneId(Map<String, Object> param);
......
...@@ -16,10 +16,7 @@ import com.xxfc.platform.vehicle.common.RestResponse; ...@@ -16,10 +16,7 @@ import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.Area; import com.xxfc.platform.vehicle.entity.Area;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVo; import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.CompanySearchVO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyAreaDTO;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo; import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
...@@ -248,4 +245,11 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> { ...@@ -248,4 +245,11 @@ public class BranchCompanyController extends BaseController<BranchCompanyBiz> {
return ObjectRestResponse.succ(baseBiz.getList(vo)); return ObjectRestResponse.succ(baseBiz.getList(vo));
} }
@RequestMapping(value ="/search",method = RequestMethod.GET)
@IgnoreUserToken
@IgnoreClientToken
public RestResponse<PageDataVO<BranchCompany>> search(@Validated CompanySearchOldDTO vo) {
return RestResponse.data(baseBiz.searchOld(vo));
}
} }
...@@ -38,6 +38,7 @@ import java.time.Instant; ...@@ -38,6 +38,7 @@ import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -166,21 +167,29 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -166,21 +167,29 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
//查询可车辆信息 //查询可车辆信息
PageDataVO<UsableVeicleVO> pageDataVO = vehicleBiz.searchUsableVehicle(rbd); PageDataVO<UsableVeicleVO> pageDataVO = vehicleBiz.searchUsableVehicle(rbd);
if(CollUtil.isNotEmpty(pageDataVO.getData())) { if(CollUtil.isNotEmpty(pageDataVO.getData())) {
data.setHasVehicle(SYS_TRUE);
for (UsableVeicleVO usableVeicleVO : pageDataVO.getData()) { for (UsableVeicleVO usableVeicleVO : pageDataVO.getData()) {
//判断是否预定时间内可租 //判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE); usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定 //如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(dto.getStartDateTamp()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) { if(null != usableVeicleVO.getToLiftMustAfterDate() ) {
//取结束End
usableVeicleVO.setToLiftMustAfterDate(DateUtil.endOfDay(usableVeicleVO.getToLiftMustAfterDate()));
if(DateUtil.date(dto.getStartDateTamp()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE); usableVeicleVO.setAllowRent(SYS_FALSE);
} }
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定 //如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(dto.getEndDateTamp()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) { if(null != usableVeicleVO.getToReturnMustBeforeDate() ) {
//取开始 begin
usableVeicleVO.setToReturnMustBeforeDate(DateUtil.beginOfDay(usableVeicleVO.getToReturnMustBeforeDate()));
if(DateUtil.date(dto.getEndDateTamp()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE); usableVeicleVO.setAllowRent(SYS_FALSE);
}else { }
data.setHasVehicle(SYS_TRUE);
} }
String priceStartDateStr = StrUtil.isNotBlank(dto.getPriceStartDate())? dto.getPriceStartDate(): dto.getStartDate(); String priceStartDateStr = StrUtil.isNotBlank(dto.getPriceStartDate())? dto.getPriceStartDate(): dto.getStartDate();
...@@ -191,10 +200,53 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -191,10 +200,53 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
data.setUsableVeicleVOList(pageDataVO.getData()); data.setUsableVeicleVOList(pageDataVO.getData());
} }
}); });
//车型排序
//uvmvpdvs.getData().parallelStream().sorted(Comparator.comparing(UsableVehicleModelVO::getHasVehicle).reversed());
} }
return ObjectRestResponse.succ(uvmvpdvs); return ObjectRestResponse.succ(uvmvpdvs);
} }
@ApiOperation("调车申请列表-可用车辆查询")
@RequestMapping(value = "/rent/apply/usable-vehicle", method = RequestMethod.POST)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> applyUsableVehicle(@RequestBody RentVehicleBookDTO rbd) {
// rbd.setModelId(data.getVehicleModel().getId());
// 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.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);
}
/** /**
* 后台查询可用车辆(车型) * 后台查询可用车辆(车型)
* *
......
...@@ -24,6 +24,35 @@ ...@@ -24,6 +24,35 @@
<result column="state" property="state"/> <result column="state" property="state"/>
</resultMap> </resultMap>
<select id="searchOld" resultType="com.xxfc.platform.vehicle.pojo.CompanySearchVO">
select *
<if test="lon != null and lat != null">
, st_distance_sphere(point(#{lon}, #{lat}), point(longitude, latitude)) as distance
</if>
from branch_company
<where>
<if test="addrCity != null">
and (addr_city = #{addrCity} or addr_province = #{addrCity} or addr_town = #{addrCity})
</if>
<if test="lon != null and lat != null">
and longitude is not null and latitude is not null
</if>
<if test="state != null">
and state = #{state}
</if>
<if test="isShow != null">
and is_show = #{isShow}
</if>
<if test="isDel != null">
and is_del = #{isDel}
</if>
</where>
<if test="lon != null and lat != null">
order by distance asc
</if>
</select>
<select id="search" parameterType="com.xxfc.platform.vehicle.pojo.CompanySearchDTO" resultType="com.xxfc.platform.vehicle.pojo.CompanySearchVO"> <select id="search" parameterType="com.xxfc.platform.vehicle.pojo.CompanySearchDTO" resultType="com.xxfc.platform.vehicle.pojo.CompanySearchVO">
select c.*,i.name as companyName select c.*,i.name as companyName
<if test="lon != null and lat != null"> <if test="lon != null and lat != null">
......
...@@ -1025,13 +1025,15 @@ ...@@ -1025,13 +1025,15 @@
,GROUP_CONCAT(vc.cata_id) as catas ,GROUP_CONCAT(vc.cata_id) as catas
</if> </if>
<!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 --> <!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 -->
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true"> <if test=" yearMonthAndParam !=null ">
,(max( ,
<if test="yearNo4Where != null and yearNo4Where == true">
(max(
ifnull(vbi.bit_str = #{yearMonthAndParamBitStr}, false) ifnull(vbi.bit_str = #{yearMonthAndParamBitStr}, false)
<!-- 租车列表 不过滤前后预约记录不符的车辆 但是合并标示车型是否有车 即 hasVehicle--> <!-- 租车列表 不过滤前后预约记录不符的车辆 但是合并标示车型是否有车 即 hasVehicle-->
<if test="withoutRecordWhere != null and withoutRecordWhere = 1 and startCompanyId != null and endCompanyId != null "> <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_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_return_company is null or abr.to_return_company = #{endCompanyId})-->
and ( and (
(IFNULL(abr.to_lift_company, v.park_branch_company_id) = #{startCompanyId}) (IFNULL(abr.to_lift_company, v.park_branch_company_id) = #{startCompanyId})
and and
...@@ -1039,7 +1041,13 @@ ...@@ -1039,7 +1041,13 @@
) )
</if> </if>
) )
) as hasVehicle )
</if>
<if test="yearNo4Where == null or yearNo4Where != true">
(if(count(*) > 1, 1 , 0))
</if>
as hasVehicle
</if> </if>
<if test="lon != null and lat != null"> <if test="lon != null and lat != null">
,st_distance_sphere(point(#{lon}, #{lat}), point(bc.longitude, bc.latitude)) as distance ,st_distance_sphere(point(#{lon}, #{lat}), point(bc.longitude, bc.latitude)) as distance
...@@ -1079,7 +1087,7 @@ ...@@ -1079,7 +1087,7 @@
<if test=" catas != null "> <if test=" catas != null ">
,null as catas ,null as catas
</if> </if>
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true"> <if test=" yearMonthAndParam !=null ">
,0 as hasVehicle ,0 as hasVehicle
</if> </if>
<if test="lon != null and lat != null"> <if test="lon != null and lat != null">
...@@ -1176,7 +1184,15 @@ ...@@ -1176,7 +1184,15 @@
<!-- 若需根据预定日期条件查询,针对换为位操作 --> <!-- 若需根据预定日期条件查询,针对换为位操作 -->
<!-- yearNo4Where 标识时间参数是否用于where条件 --> <!-- yearNo4Where 标识时间参数是否用于where条件 -->
<if test=" yearMonthAndParam !=null and yearMonthAndParam != null and yearNo4Where == null"> <if test=" yearMonthAndParam !=null and yearMonthAndParam != null and yearNo4Where == null">
vbi.bit_str = #{yearMonthAndParamBitStr} and 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> </if>
<!-- 根据前后record 过滤车辆 --> <!-- 根据前后record 过滤车辆 -->
......
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