Commit cfb2ad8a by 吕明尚

15分钟续单增加限制

parent 480fe45a
package share.system.domain.vo; package share.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.core.domain.BaseEntity;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -50,6 +46,5 @@ public class RoomStatusVo implements Serializable { ...@@ -50,6 +46,5 @@ public class RoomStatusVo implements Serializable {
@ApiModelProperty(value = "占用结束时间") @ApiModelProperty(value = "占用结束时间")
private Date endHoldTime; private Date endHoldTime;
private Boolean isAvailable;
} }
package share.system.service.impl; package share.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import share.common.constant.Constants; import share.common.constant.Constants;
import share.common.enums.*; import share.common.enums.*;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
...@@ -90,6 +92,23 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -90,6 +92,23 @@ public class RoomStatusServiceImpl implements RoomStatusService {
private List<RoomStatusVo> generatorRoomStatusList(SStore store,SRoom room,List<SOrder> orderList,SCleanRecords cleanRecords,Date day, Integer orderType, SConsumer user){ private List<RoomStatusVo> generatorRoomStatusList(SStore store,SRoom room,List<SOrder> orderList,SCleanRecords cleanRecords,Date day, Integer orderType, SConsumer user){
String nowTime = "00:00"; String nowTime = "00:00";
Boolean isAvailable;
if (orderType.equals(OrderTypeEnum.RENEW.getCode())) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, room.getId());
queryWrapper.eq(SOrder::getConsumerId, user.getId());
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.USED.getCode());
//当前时间减15分钟前的订单
queryWrapper.ge(SOrder::getEndDate, DateUtils.addMinutes(DateUtils.getNowDate(), -15));
SOrder one = orderService.getOne(queryWrapper);
if (!ObjectUtils.isEmpty(one)) {
isAvailable = true;
} else {
isAvailable = false;
}
} else {
isAvailable = false;
}
String dayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day); String dayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day);
Boolean isToday = StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day) Boolean isToday = StringUtils.equals(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day)
,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate())); ,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate()));
...@@ -111,6 +130,7 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -111,6 +130,7 @@ public class RoomStatusServiceImpl implements RoomStatusService {
vo.setStoreId(store.getId()); vo.setStoreId(store.getId());
vo.setRoomId(room.getId()); vo.setRoomId(room.getId());
vo.setTimeHour(timeHour); vo.setTimeHour(timeHour);
vo.setIsAvailable(isAvailable);
Date timeHourDate = DateUtils.parseDate(timeHour); Date timeHourDate = DateUtils.parseDate(timeHour);
setTimeHourStatus(vo,timeHourDate,store,room,orderList,cleanRecords,dayStr,finalNowTime,isToday,orderType, user); setTimeHourStatus(vo,timeHourDate,store,room,orderList,cleanRecords,dayStr,finalNowTime,isToday,orderType, user);
voList.add(vo); voList.add(vo);
...@@ -159,6 +179,9 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -159,6 +179,9 @@ public class RoomStatusServiceImpl implements RoomStatusService {
}else{ }else{
isHold = true; isHold = true;
} }
if (vo.getIsAvailable()) {
isHold = false;
}
} }
//次日 //次日
if(StringUtils.equals(day,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.addDays(DateUtils.getNowDate(),1)))){ if(StringUtils.equals(day,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.addDays(DateUtils.getNowDate(),1)))){
...@@ -167,6 +190,9 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -167,6 +190,9 @@ public class RoomStatusServiceImpl implements RoomStatusService {
&& timeHourDate.getTime() < DateUtils.parseDate(day+" "+cleaningPeriod).getTime()){ && timeHourDate.getTime() < DateUtils.parseDate(day+" "+cleaningPeriod).getTime()){
isHold = true; isHold = true;
} }
if (vo.getIsAvailable()) {
isHold = false;
}
} }
break; break;
case CLEANED: case CLEANED:
......
...@@ -842,37 +842,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -842,37 +842,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, sOrder.getOrderNo()); redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, sOrder.getOrderNo());
} }
save(sOrder); save(sOrder);
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
if (Objects.nonNull(byId)) {
SConsumerCoupon consumerCoupon = new SConsumerCoupon();
consumerCoupon.setId(request.getCouponId());
consumerCoupon.setUseDate(new Date());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
}
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
sConsumptionRecordsService.insertSConsumptionRecords(sOrder);
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
// 订单预定成功, 发送短信通知运维客服
List<String> phones = new ArrayList<>();
SConsumerVo sConsumer = new SConsumerVo();
sConsumer.setStoreId(sStore.getId());
sConsumer.setPosition(3);
List<SConsumer> consumers = sConsumerService.selectAllocatedList(sConsumer);
if (consumers.size() > 0) {
consumers.forEach(o->{
phones.add(o.getPhone());
});
smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, room);
}
}
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) { if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
if (!redisUtil.exists(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + request.getPreOrderNo())
&& getOne(new LambdaQueryWrapper<SOrder>().eq(SOrder::getOrderNo, request.getPreOrderNo())).getStatus().equals(OrderStatusEnum.USED.getCode()))
throw new BaseException("原订单已过期,请重新预约");
sOrder.setStartDate(sOrder.getPreStartDate()); sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate()); sOrder.setEndDate(sOrder.getPreEndDate());
sOrder.setStatus(OrderStatusEnum.INUSE.getCode()); sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
...@@ -910,6 +883,36 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -910,6 +883,36 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString()); redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} }
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
if (Objects.nonNull(byId)) {
SConsumerCoupon consumerCoupon = new SConsumerCoupon();
consumerCoupon.setId(request.getCouponId());
consumerCoupon.setUseDate(new Date());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
}
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
sConsumptionRecordsService.insertSConsumptionRecords(sOrder);
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
// 订单预定成功, 发送短信通知运维客服
List<String> phones = new ArrayList<>();
SConsumerVo sConsumer = new SConsumerVo();
sConsumer.setStoreId(sStore.getId());
sConsumer.setPosition(3);
List<SConsumer> consumers = sConsumerService.selectAllocatedList(sConsumer);
if (consumers.size() > 0) {
consumers.forEach(o -> {
phones.add(o.getPhone());
});
smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, room);
}
}
return response; return response;
}catch (BaseException e){ }catch (BaseException e){
throw e; throw e;
......
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