Commit 1464646a by YG8999

房间添加订单预定 时间

订单续费添加客服短信发送
parent 480fe45a
...@@ -17,6 +17,7 @@ public enum SmsTypeEnum { ...@@ -17,6 +17,7 @@ public enum SmsTypeEnum {
SMS_DEVICE_ABNORMAL_TEMP(7,"sms.device.abnormal.template","设备状态异常变更短信提醒"), SMS_DEVICE_ABNORMAL_TEMP(7,"sms.device.abnormal.template","设备状态异常变更短信提醒"),
SMS_DEVICE_GATEWAY_TEMP(8,"sms.device.gateway.template","网关设备离线提醒短信"), SMS_DEVICE_GATEWAY_TEMP(8,"sms.device.gateway.template","网关设备离线提醒短信"),
SMS_ORDER_PREDETERMINE_TEMP(9,"system.order.predetermine.template","订单预定短信提醒"), SMS_ORDER_PREDETERMINE_TEMP(9,"system.order.predetermine.template","订单预定短信提醒"),
SMS_ORDER_RENEW_TEMP(10,"system.order.renew.template","订单续费短信提醒"),
; ;
private Integer code; private Integer code;
......
...@@ -144,6 +144,21 @@ public class SRoomVo extends BaseEntity ...@@ -144,6 +144,21 @@ public class SRoomVo extends BaseEntity
*/ */
private List<RoomStatusVo> roomStatusList; private List<RoomStatusVo> roomStatusList;
/**
* 当天最后预定订单时间
*/
private Long orderTime;
/**
* 0-无,1-分钟,2-小时
*/
private Integer orderTimeType;
/**
* 当天最后预定订单类型
*/
private Integer orderType;
@Override @Override
public String toString() { public String toString() {
......
...@@ -66,4 +66,6 @@ public interface SOrderMapper extends BaseMapper<SOrder> ...@@ -66,4 +66,6 @@ public interface SOrderMapper extends BaseMapper<SOrder>
List<SOrder> queryList(Long roomId); List<SOrder> queryList(Long roomId);
SOrder getInfoByEntity(SOrder orderParam); SOrder getInfoByEntity(SOrder orderParam);
List<SOrder> selectSOrderByMaxTime(SOrder order);
} }
...@@ -211,4 +211,6 @@ public interface ISOrderService extends IService<SOrder> ...@@ -211,4 +211,6 @@ public interface ISOrderService extends IService<SOrder>
Boolean changeRoom(SOrderDto dto); Boolean changeRoom(SOrderDto dto);
List<SOrderVo> exportList(SOrder sOrder); List<SOrderVo> exportList(SOrder sOrder);
List<SOrder> selectSOrderByMaxTime(SOrder orderQuery);
} }
...@@ -695,6 +695,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -695,6 +695,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return sOrderVos; return sOrderVos;
} }
@Override
public List<SOrder> selectSOrderByMaxTime(SOrder orderQuery) {
return baseMapper.selectSOrderByMaxTime(orderQuery);
}
/** /**
* 新增订单 * 新增订单
* *
......
package share.system.service.impl; package share.system.service.impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -21,6 +23,7 @@ import share.system.mapper.SStoreConsumerMapper; ...@@ -21,6 +23,7 @@ import share.system.mapper.SStoreConsumerMapper;
import share.system.service.*; import share.system.service.*;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -133,6 +136,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -133,6 +136,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
wrapper.in(SOrder::getRoomId, roomIds); wrapper.in(SOrder::getRoomId, roomIds);
wrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode()); wrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
List<SOrder> list = orderService.list(wrapper); List<SOrder> list = orderService.list(wrapper);
// 查询每一个房间最后一条预定订单下单时间
Date now = DateUtil.date();
SOrder orderQuery = new SOrder();
orderQuery.setStoreId(store.getId());
orderQuery.setCreateTime(now);
List<SOrder> orderList = orderService.selectSOrderByMaxTime(orderQuery);
Map<Long, SOrder> roomOrder = Optional.ofNullable(orderList).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(SOrder::getRoomId, Function.identity()));
roomList.stream().forEach(sRoom -> { roomList.stream().forEach(sRoom -> {
SRoomVo vo = new SRoomVo(); SRoomVo vo = new SRoomVo();
BeanUtils.copyProperties(sRoom, vo); BeanUtils.copyProperties(sRoom, vo);
...@@ -162,6 +173,23 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -162,6 +173,23 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
} }
}); });
} }
// 计算当天预定最后预定时间
SOrder order = roomOrder.get(vo.getId());
if (order != null) {
long betweenMinute = DateUtil.between(order.getCreateTime(), now, DateUnit.MINUTE);
if (betweenMinute < 60) {
vo.setOrderTimeType(1);
vo.setOrderTime(betweenMinute);
} else {
long betweenHour = DateUtil.between(order.getCreateTime(), now, DateUnit.HOUR);
vo.setOrderTimeType(2);
vo.setOrderTime(betweenHour);
}
vo.setOrderType(order.getOrderType());
} else {
vo.setOrderTimeType(0);
vo.setOrderTime(0L);
}
voList.add(vo); voList.add(vo);
}); });
} }
......
...@@ -13,10 +13,7 @@ import org.springframework.stereotype.Service; ...@@ -13,10 +13,7 @@ import org.springframework.stereotype.Service;
import share.common.constant.Constants; import share.common.constant.Constants;
import share.common.constant.SmsConts; import share.common.constant.SmsConts;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.DeviceStatusEnum; import share.common.enums.*;
import share.common.enums.SmsStatusEnum;
import share.common.enums.SmsTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil; import share.common.utils.BaseUtil;
import share.common.utils.SmsUtil; import share.common.utils.SmsUtil;
...@@ -242,13 +239,18 @@ public class SmsServiceImpl implements SmsService { ...@@ -242,13 +239,18 @@ public class SmsServiceImpl implements SmsService {
*/ */
@Override @Override
public boolean sendSmsOrderPredetermine(List<String> phones, SOrder order, SStore store, SRoom room) { public boolean sendSmsOrderPredetermine(List<String> phones, SOrder order, SStore store, SRoom room) {
String key = SmsTypeEnum.SMS_ORDER_PREDETERMINE_TEMP.getValue();
Integer code = SmsTypeEnum.SMS_ORDER_PREDETERMINE_TEMP.getCode();
if (order.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
key = SmsTypeEnum.SMS_ORDER_RENEW_TEMP.getValue();
code = SmsTypeEnum.SMS_ORDER_RENEW_TEMP.getCode();
}
// 通过配置获取短信模版 // 通过配置获取短信模版
String configValue = sysConfigService.selectConfigByKey(SmsTypeEnum.SMS_ORDER_PREDETERMINE_TEMP.getValue()); String configValue = sysConfigService.selectConfigByKey(key);
if (StrUtil.isNotEmpty(configValue)) { if (StrUtil.isNotEmpty(configValue)) {
String content = MessageFormat.format(configValue, store.getName(), room.getName(), String content = MessageFormat.format(configValue, store.getName(), room.getName(),
DateUtil.formatDateTime(order.getPreStartDate()), DateUtil.formatDateTime(order.getPreEndDate())); DateUtil.formatDateTime(order.getPreStartDate()), DateUtil.formatDateTime(order.getPreEndDate()));
return sendManySms(phones, SmsTypeEnum.SMS_ORDER_PREDETERMINE_TEMP.getCode(), content, return sendManySms(phones, code, content, store.getId(), room.getId());
store.getId(), room.getId());
} else { } else {
return Boolean.FALSE; return Boolean.FALSE;
} }
......
...@@ -156,6 +156,51 @@ ...@@ -156,6 +156,51 @@
where out_trade_no=#{outTradeNo} and consumer_id=#{consumerId} where out_trade_no=#{outTradeNo} and consumer_id=#{consumerId}
</select> </select>
<select id="selectSOrderByMaxTime" parameterType="SOrder" resultMap="SOrderResult">
select s.id,
s.order_no,
s.out_trade_no,
s.historical_order_no,
s.order_type,
s.pay_type,
s.pay_status,
s.store_id,
s.room_id,
s.consumer_id,
s.consumer_name,
s.consumer_phone,
s.pack_id,
s.pack_price,
s.coupon_id,
s.coupon_price,
s.total_price,
s.pay_price,
s.pay_time,
s.time_long,
s.pre_start_date,
s.pre_end_date,
s.start_date,
s.end_date,
s.status,
s.refund_status,
s.refund_reason,
s.refund_reason_time,
s.refund_price,
s.is_delete,
s.create_by,
s.create_time,
s.update_by,
s.update_time,
s.arrival_time,
s.remark
from s_order s inner join (
select room_id, max(create_time) as create_time, max(id) as id from s_order
where store_id = #{storeId}
and pay_status = 1 and is_delete = 0 and refund_status = 0
and DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(#{createTime}, '%Y-%m-%d')
group by room_id) t on t.id = s.id;
</select>
<insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_order insert into s_order
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
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