Commit c3070782 by wuwenlong

Merge remote-tracking branch 'origin/main'

parents ce23a0e9 0b1be224
package share.common.enums;
public enum MessageReminderEnum {
//预约到期通知:oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8,订单开始通知:K8fbcKVq46w9o7Ekpesn74WPjwxnbso947YZiYBQw9c,订单结单通知:HB2_moQRQrXC2cKw6zE08NU3AQO9Ggj3aAOg0lIgecg
RESERVER("预约到期通知", "oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8"),
START("订单开始通知", "K8fbcKVq46w9o7Ekpesn74WPjwxnbso947YZiYBQw9c"),
END("订单结单通知", "HB2_moQRQrXC2cKw6zE08NU3AQO9Ggj3aAOg0lIgecg");
private String name;
private String value;
MessageReminderEnum() {
}
MessageReminderEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getname() {
return name;
}
public void setname(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
...@@ -6,7 +6,8 @@ public enum ReceiptRdeisEnum { ...@@ -6,7 +6,8 @@ public enum ReceiptRdeisEnum {
MT_SESSION_KEY(2, "MT_SESSION_KEY"), MT_SESSION_KEY(2, "MT_SESSION_KEY"),
MT_SESSION_OBJECT_KEY(3, "MT_SESSION_OBJECT_KEY"), MT_SESSION_OBJECT_KEY(3, "MT_SESSION_OBJECT_KEY"),
ORDER_NO_KEY(4, "ORDER_NO_KEY."), ORDER_NO_KEY(4, "ORDER_NO_KEY."),
ACCESS_TOKEN_KEY(5, "ACCESS_TOKEN_KEY."); ACCESS_TOKEN_KEY(5, "ACCESS_TOKEN_KEY."),
ORDER_NO(6, "ORDER_NO.");
private Integer code; private Integer code;
......
...@@ -9,9 +9,9 @@ import cn.hutool.json.JSONObject; ...@@ -9,9 +9,9 @@ import cn.hutool.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.CollectionUtils;
import share.common.constant.Constants; import share.common.constant.Constants;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.*; import share.common.enums.*;
...@@ -20,7 +20,6 @@ import share.system.domain.SConsumer; ...@@ -20,7 +20,6 @@ import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon; import share.system.domain.SConsumerCoupon;
import share.system.domain.SOrder; import share.system.domain.SOrder;
import share.system.domain.SRoom; import share.system.domain.SRoom;
import share.system.mapper.SRoomMapper;
import share.system.service.*; import share.system.service.*;
import java.util.*; import java.util.*;
...@@ -32,7 +31,6 @@ import java.util.stream.Collectors; ...@@ -32,7 +31,6 @@ import java.util.stream.Collectors;
*/ */
@Component("orderTask") @Component("orderTask")
public class OrderTask { public class OrderTask {
private static final Logger logger = LoggerFactory.getLogger(OrderTask.class); private static final Logger logger = LoggerFactory.getLogger(OrderTask.class);
@Autowired @Autowired
...@@ -62,7 +60,15 @@ public class OrderTask { ...@@ -62,7 +60,15 @@ public class OrderTask {
@Autowired @Autowired
private DeviceOpService deviceOpService; private DeviceOpService deviceOpService;
@Autowired
private RedisTemplate redisTemplate;
final int ZERO = 0; final int ZERO = 0;
//10分钟的常量
final long TEN_MINUTES = 60 * 10;
//9分钟的常量
final long NINE_MINUTES = 60 * 9;
public void autoCancel() { public void autoCancel() {
String redisKey = Constants.ORDER_AUTO_CANCEL_KEY; String redisKey = Constants.ORDER_AUTO_CANCEL_KEY;
...@@ -209,10 +215,24 @@ public class OrderTask { ...@@ -209,10 +215,24 @@ public class OrderTask {
//预约订单到期自动更新订单状态,更新房间状态 //预约订单到期自动更新订单状态,更新房间状态
public void autoToStore() { public void autoToStore() {
//查询所有已支付的订单 //查询所有已支付的订单
List<SOrder> sOrders = orderService.validOrder(); Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.ORDER_NO.getValue() + "*");
if (CollectionUtils.isEmpty(sOrders)) { if (keys.size() == 0) {
return; return;
} }
List<SOrder> sOrders = new ArrayList<>();
keys.stream().forEach(o -> {
String value = redisUtil.get(String.valueOf(o));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
//时间到期前10分钟到9分
long expire = (expirationTime.getTime() - new Date().getTime()) / 1000;
if (expire < TEN_MINUTES && expire > NINE_MINUTES) {
}
if (expirationTime.getTime() < new Date().getTime()) {
sOrders.add(orderService.getByOrderNo(String.valueOf(o)));
}
});
List<Long> roomIds = sOrders.stream().map(SOrder::getRoomId).collect(Collectors.toList()); List<Long> roomIds = sOrders.stream().map(SOrder::getRoomId).collect(Collectors.toList());
List<SRoom> roomList = roomService.listByIds(roomIds); List<SRoom> roomList = roomService.listByIds(roomIds);
sOrders.stream().forEach(item -> { sOrders.stream().forEach(item -> {
......
package share.system.domain; package share.system.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel; import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity; import share.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data; import lombok.Data;
/** /**
* 设备信息对象 s_device * 设备信息对象 s_device
...@@ -16,6 +13,7 @@ import lombok.Data; ...@@ -16,6 +13,7 @@ import lombok.Data;
* @date 2023-11-04 * @date 2023-11-04
*/ */
@Data @Data
@TableName(value = "s_device")
public class Device extends BaseEntity public class Device extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -58,10 +56,12 @@ public class Device extends BaseEntity ...@@ -58,10 +56,12 @@ public class Device extends BaseEntity
/** 分组 */ /** 分组 */
@Excel(name = "分组") @Excel(name = "分组")
@TableField(value = "`group`")
private String group; private String group;
/** 设备状态: 0 在线、1 开门状态、2 反锁、3 门磁 */ /** 设备状态: 0 在线、1 开门状态、2 反锁、3 门磁 */
@Excel(name = "设备状态") @Excel(name = "设备状态")
@TableField(value = "`status`")
private String status; private String status;
/** 设备位置 */ /** 设备位置 */
......
...@@ -2,6 +2,7 @@ package share.system.mapper; ...@@ -2,6 +2,7 @@ package share.system.mapper;
import java.util.List; import java.util.List;
import share.system.domain.SConsumptionRecords; import share.system.domain.SConsumptionRecords;
import share.system.domain.vo.SConsumptionRecordsVo;
/** /**
* 消费记录Mapper接口 * 消费记录Mapper接口
...@@ -25,7 +26,7 @@ public interface SConsumptionRecordsMapper ...@@ -25,7 +26,7 @@ public interface SConsumptionRecordsMapper
* @param sConsumptionRecords 消费记录 * @param sConsumptionRecords 消费记录
* @return 消费记录集合 * @return 消费记录集合
*/ */
public List<SConsumptionRecords> selectSConsumptionRecordsList(SConsumptionRecords sConsumptionRecords); public List<SConsumptionRecordsVo> selectSConsumptionRecordsList(SConsumptionRecords sConsumptionRecords);
/** /**
* 新增消费记录 * 新增消费记录
......
...@@ -57,31 +57,27 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi ...@@ -57,31 +57,27 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi
@Override @Override
public List<SConsumptionRecordsVo> selectSConsumptionRecordsList(SConsumptionRecords sConsumptionRecords) public List<SConsumptionRecordsVo> selectSConsumptionRecordsList(SConsumptionRecords sConsumptionRecords)
{ {
List<SConsumptionRecords> sConsumptionRecordsList = sConsumptionRecordsMapper.selectSConsumptionRecordsList(sConsumptionRecords); List<SConsumptionRecordsVo> sConsumptionRecordsList = sConsumptionRecordsMapper.selectSConsumptionRecordsList(sConsumptionRecords);
//获取消费记录的用户id集合 //获取消费记录的用户id集合
List<Long> collect = sConsumptionRecordsList.stream().map(SConsumptionRecords::getConsumerId).collect(Collectors.toList()); List<Long> collect = sConsumptionRecordsList.stream().map(SConsumptionRecords::getConsumerId).collect(Collectors.toList());
//获取用户id集合的用户信息 //获取用户id集合的用户信息
List<SConsumer> sConsumers = sConsumerMapper.selectBatchIds(collect); List<SConsumer> sConsumers = sConsumerMapper.selectBatchIds(collect);
List<Long> oredrIds = sConsumptionRecordsList.stream().map(SConsumptionRecords::getOrderId).collect(Collectors.toList()); List<Long> oredrIds = sConsumptionRecordsList.stream().map(SConsumptionRecords::getOrderId).collect(Collectors.toList());
List<SOrder> sOrders = sOrderMapper.selectBatchIds(oredrIds); List<SOrder> sOrders = sOrderMapper.selectBatchIds(oredrIds);
List<SConsumptionRecordsVo> sConsumptionRecordsVoList = new ArrayList<>();
sConsumptionRecordsList.stream().forEach(item -> { sConsumptionRecordsList.stream().forEach(item -> {
SConsumptionRecordsVo sConsumptionRecordsVo = new SConsumptionRecordsVo();
BeanUtils.copyProperties(item, sConsumptionRecordsVo);
sConsumers.stream().forEach(vo -> { sConsumers.stream().forEach(vo -> {
if (sConsumptionRecordsVo.getConsumerId().equals(vo.getId())) { if (item.getConsumerId().equals(vo.getId())) {
sConsumptionRecordsVo.setNickName(vo.getNickName()); item.setNickName(vo.getNickName());
sConsumptionRecordsVo.setPhone(vo.getPhone()); item.setPhone(vo.getPhone());
} }
}); });
sOrders.stream().forEach(vo -> { sOrders.stream().forEach(vo -> {
if (sConsumptionRecordsVo.getOrderId().equals(vo.getId())) { if (item.getOrderId().equals(vo.getId())) {
sConsumptionRecordsVo.setOrderNo(vo.getOrderNo()); item.setOrderNo(vo.getOrderNo());
} }
}); });
sConsumptionRecordsVoList.add(sConsumptionRecordsVo);
}); });
return sConsumptionRecordsVoList; return sConsumptionRecordsList;
} }
/** /**
......
...@@ -628,6 +628,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -628,6 +628,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map.put("expirationTime", sOrder.getEndDate().toString()); map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString()); redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} else {
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} }
baseMapper.updateById(sOrder); baseMapper.updateById(sOrder);
Long couponId = sOrder.getCouponId(); Long couponId = sOrder.getCouponId();
......
...@@ -15,6 +15,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -15,6 +15,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<resultMap type="SConsumptionRecordsVo" id="SConsumptionRecordsResultVo">
<result property="id" column="id"/>
<result property="consumerId" column="consumer_id"/>
<result property="orderId" column="order_id"/>
<result property="name" column="name"/>
<result property="price" column="price"/>
<result property="payType" column="pay_type"/>
<result property="sign" column="sign"/>
<result property="createTime" column="create_time"/>
</resultMap>
<sql id="selectSConsumptionRecordsVo"> <sql id="selectSConsumptionRecordsVo">
select id, select id,
consumer_id, consumer_id,
...@@ -27,7 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -27,7 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from s_consumption_records from s_consumption_records
</sql> </sql>
<select id="selectSConsumptionRecordsList" parameterType="SConsumptionRecords" resultMap="SConsumptionRecordsResult"> <select id="selectSConsumptionRecordsList" parameterType="SConsumptionRecords"
resultMap="SConsumptionRecordsResultVo">
<include refid="selectSConsumptionRecordsVo"/> <include refid="selectSConsumptionRecordsVo"/>
<where> <where>
<if test="name != null and name != ''"> and name = #{name}</if> <if test="name != null and name != ''"> and name = #{name}</if>
......
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