Commit f7d476d0 by 吕明尚

分享订单信息增加实际支付金额,修改续单逻辑

parent b3f86d3f
......@@ -10,6 +10,8 @@ public enum ReceiptRdeisEnum {
ORDER_NO(6, "ORDER_NO."),
TIKTOK_CLIENT_TOKEN(7, "TIKTOK_CLIENT_TOKEN"),
TIKTOK_CLIENT_TOKEN_KEY(8, "TIKTOK_CLIENT_TOKEN_KEY"),
//房间15分钟过期
ROOM_EXPIRE_TIME(9, "ROOM_EXPIRE_TIME."),
;
......
......@@ -28,10 +28,7 @@ import share.system.domain.*;
import share.system.domain.vo.MqttxVo;
import share.system.service.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -89,8 +86,8 @@ public class RedisTask {
final long FIVE_MINUTES = 60 * 5;
//4分钟的常量
final long FOUR_MINUTES = 60 * 4;
//3分钟的常量
final long THREE_MINUTES = 60 * 3;
//1分钟的常量
final long ONE_MINUTES = 60;
/**
......@@ -287,14 +284,56 @@ public class RedisTask {
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1",
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
//延时3分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, THREE_MINUTES,
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), false, 0L,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
//延时一分钟通电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), true, ONE_MINUTES,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
//当前时间加15分钟
Date date = DateUtil.offsetMinute(new Date(), 15);
map.put("expirationTime", date.toString());
JSONObject json = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + sOrder.getOrderNo(), json.toString());
logger.info("订单号为:" + sOrder.getOrderNo() + "的订单已结束,更改订单状态为已使用");
}
});
}
public void autoRoomExpireTime() {
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + "*");
if (keys.size() == 0) {
return;
}
keys.stream().forEach(key -> {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
String orderNo = jsonObject.getStr("orderNo");
SOrder sOrder = isOrderService.getOne(new LambdaQueryWrapper<SOrder>().eq(SOrder::getOrderNo, orderNo));
if (expirationTime.getTime() > new Date().getTime()) {
List<SOrder> orderList = orderService.list(new LambdaQueryWrapper<SOrder>()
.eq(SOrder::getRoomId, sOrder.getRoomId())
.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode())
.eq(SOrder::getOrderType, OrderTypeEnum.RENEW.getCode())
);
if (!CollectionUtils.isEmpty(orderList)) {
redisUtil.delete(key);
}
} else {
SCleanRecords sCleanRecords = isCleanRecordsService.getOne(new LambdaQueryWrapper<SCleanRecords>().
eq(SCleanRecords::getRoomId, sOrder.getRoomId()).
eq(SCleanRecords::getStatus, CleaningStatusEnum.CLEANING.getCode()));
if (ObjectUtils.isEmpty(sCleanRecords)) {
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), false, 0L,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
}
redisUtil.delete(key);
}
});
}
private boolean extracted(String o, List<SOrder> sOrders, SOrder sOrder) {
List<SOrder> sOrders1 = sOrders.stream().filter(item ->
item.getStoreId().equals(sOrder.getStoreId()) &&
......
package share.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
......@@ -105,5 +105,7 @@ public class OrderVo {
private Integer status;
private BigDecimal payPrice;
}
......@@ -455,7 +455,6 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
isCleaner(sCleanRecords);
sCleanRecords.setEndDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode());
SRoom sRoom = new SRoom();
SCleanRecords records = baseMapper.selectSCleanRecordsById(sCleanRecords.getId());
if (records == null) {
throw new RuntimeException("当前保洁任务不存在!");
......
......@@ -871,8 +871,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate());
sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
if (room.getStatus().equals(RoomStatusEnum.FREE.getValue())) {
room.setStatus(RoomStatusEnum.HOLD.getValue());
roomService.updateById(room);
}
//支付金额为0的
if (request.getPayFee().compareTo(BigDecimal.ZERO) <= 0) {
SCleanRecords sCleanRecords = isCleanRecordsService.getOne(new LambdaQueryWrapper<SCleanRecords>().eq(SCleanRecords::getRoomId, sOrder.getRoomId()));
if (ObjectUtil.isNotEmpty(sCleanRecords)) {
isCleanRecordsService.removeById(sCleanRecords.getId());
}
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
baseMapper.updateById(sOrder);
......@@ -1291,6 +1299,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
public void paymentSuccessful(SOrder sOrder) {
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
SRoom room = roomService.getById(sOrder.getRoomId());
if (room.getStatus().equals(RoomStatusEnum.FREE.getValue())) {
room.setStatus(RoomStatusEnum.HOLD.getValue());
roomService.updateById(room);
}
SCleanRecords sCleanRecords = isCleanRecordsService.getOne(new LambdaQueryWrapper<SCleanRecords>()
.eq(SCleanRecords::getRoomId, sOrder.getRoomId())
.ne(SCleanRecords::getStatus, CleaningStatusEnum.CLEANED.getCode())
);
if (ObjectUtil.isNotEmpty(sCleanRecords)) {
isCleanRecordsService.removeById(sCleanRecords.getId());
}
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate());
......
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