Commit da96900c by 吕明尚

订单自动开始增加取电功能

parent 75068b31
......@@ -2,29 +2,29 @@ package share.common.enums;
public enum VoiceEnum {
//开门欢迎,续费提醒1,续费提醒2,续费成功提醒,送客
OPEN(1, "开门欢迎", ",您的好运时刻已开启,弘扬国粹文化,牌不落地,永不放弃,祝您玩的开心,找客服关注凑角微信小程序"),
RENEWAL_REMINDER1(2, "续费提醒1", "您的房间使用时间还剩15分钟,继续使用,请在小程序进行续单,或联系客服。"),
RENEWAL_REMINDER2(3, "续费提醒2", "您的房间使用时间还剩5分钟,系统届时会自动断电,提前拿好随身物品;继续使用,请在小程序进行续单,或联系客服"),
RENEWAL_SUCCESS(4, "续费成功提醒", "您的房间已成功续订,祝您玩的开心,找客服关注凑角微信小程序"),
SEND_CUSTOMER(5, "送客", ",您的满意是我们最大的动力,联系客服,送您小惊喜,期待下一次的相遇");
private Integer code;
OPEN("1", "开门欢迎", ",您的好运时刻已开启,弘扬国粹文化,牌不落地,永不放弃,祝您玩的开心,找客服关注凑角微信小程序"),
RENEWAL_REMINDER1("2", "续费提醒1", "您的房间使用时间还剩15分钟,继续使用,请在小程序进行续单,或联系客服。"),
RENEWAL_REMINDER2("3", "续费提醒2", "您的房间使用时间还剩5分钟,系统届时会自动断电,提前拿好随身物品;继续使用,请在小程序进行续单,或联系客服"),
RENEWAL_SUCCESS("4", "续费成功提醒", "您的房间已成功续订,祝您玩的开心,找客服关注凑角微信小程序"),
SEND_CUSTOMER("5", "送客", ",您的满意是我们最大的动力,联系客服,送您小惊喜,期待下一次的相遇");
private String code;
private String name;
private String value;
VoiceEnum() {
}
VoiceEnum(Integer code, String name, String value) {
VoiceEnum(String code, String name, String value) {
this.code = code;
this.name = name;
this.value = value;
}
public Integer getCode() {
public String getCode() {
return code;
}
public void setCode(Integer code) {
public void setCode(String code) {
this.code = code;
}
......
......@@ -233,6 +233,7 @@ public class OrderTask {
}
});
Boolean execute = transactionTemplate.execute(e -> {
//TODO 取电开始
orderService.updateBatchById(sOrders,sOrders.size());
roomService.updateBatchById(roomList,roomList.size());
return true;
......
......@@ -47,6 +47,14 @@ public class RedisTask {
@Autowired
private DeviceOpService deviceOpService;
//15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15;
//14分钟的常量
final long FOURTEEN_MINUTES = 60 * 14;
//5分钟的常量
final long FIVE_MINUTES = 60 * 5;
//4分钟的常量
final long FOUR_MINUTES = 60 * 4;
public void AuToReceiptCode() {
......@@ -98,14 +106,14 @@ public class RedisTask {
Date expirationTime = jsonObject.getDate("expirationTime");
//判断时间是否在15分钟到14分钟
long expire = (expirationTime.getTime() - new Date().getTime()) / 1000;
if (expire < 60 * 15 && expire > 60 * 14) {
if (expire < FIFTEEN_MINUTES && expire > FOURTEEN_MINUTES) {
//语音
getResult(o, jsonObject, VoiceEnum.RENEWAL_REMINDER1.getValue());
getResult(o, jsonObject, VoiceEnum.RENEWAL_REMINDER1.getCode());
return;
}
//判断时间是否在5分钟到4分钟
if (expire < 60 * 5 && expire > 60 * 4) {
getResult(o, jsonObject, VoiceEnum.RENEWAL_REMINDER2.getValue());
if (expire < FIVE_MINUTES && expire > FOUR_MINUTES) {
getResult(o, jsonObject, VoiceEnum.RENEWAL_REMINDER2.getCode());
return;
}
......@@ -150,7 +158,7 @@ public class RedisTask {
if (b) {
//删除redis中的值
redisUtil.delete(o);
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getValue(),
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(),
DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
......
......@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import share.common.constant.Constants;
import share.common.core.redis.RedisUtil;
......@@ -289,6 +290,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
@Override
@Transactional
public OrderPayResultResponse createOrder(CreateOrderRequest request) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (ObjectUtil.isNull(user)) {
......@@ -332,6 +334,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sConsumptionRecords.setSign(SignEnum.BURDEN.getValue());
sConsumptionRecordsService.insertSConsumptionRecords(sConsumptionRecords);
}
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate());
sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
save(sOrder);
return response;
}
......@@ -607,6 +619,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
public void paymentSuccessful(SOrder sOrder) {
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate());
sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
baseMapper.updateById(sOrder);
Long couponId = sOrder.getCouponId();
if (couponId != null && couponId > 0) {
......@@ -807,12 +829,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (ObjectUtils.isEmpty(device2)) {
throw new BaseException("设备不存在!");
}
SStore sStore = storeService.getById(sOrder.getStoreId());
deviceOpService.openDoor(sRoomVo.getId(), sOrder.getConsumerPhone());
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), "1",
//取电,语音
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.OPEN.getCode(),
cn.hutool.core.date.DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
//查询非当前用户,预约时间或使用时间为当前时间的订单,如果存在,房间不可开门
//开门
deviceOpService.openDoor(sRoomVo.getId(), sOrder.getConsumerPhone());
} else {
deviceOpService.openDoor(sRoomVo.getId(), sOrder.getConsumerPhone());
}
......
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