Commit 760c2c16 by 吕明尚

小程序退款增加判断是否有使用中的订单才断电,删除扫呗退款修改房间状态

parent bc8fb990
package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.saobei.open.sdk.model.response.trade.SaobeiTradeRefundResponse;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,15 +14,12 @@ import share.common.enums.*;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.common.utils.http.RestTemplateUtil;
import share.system.domain.SConsumptionRecords;
import share.system.domain.SOrder;
import share.system.domain.SRoom;
import share.system.domain.WechatPayInfo;
import share.system.domain.vo.SaobeiRefundVo;
import share.system.domain.vo.WxRefundVo;
import share.system.mapper.SOrderMapper;
import share.system.mapper.WechatPayInfoMapper;
import share.system.request.AdminRefundRequest;
import share.system.request.OrderRefundRequest;
import share.system.service.*;
......@@ -141,12 +137,6 @@ public class OrderRefundServiceImpl extends ServiceImpl<SOrderMapper, SOrder> im
order.setRefundPrice(request.getAmount());
order.setRefundReason(request.getRefundReason());
boolean update = sOrderService.updateById(order);
//更改房间状态
SRoom sRoom = new SRoom();
sRoom.setId(order.getRoomId());
sRoom.setStatus(RoomStatusEnum.FREE.getValue());
roomService.updateById(sRoom);
SConsumptionRecords sConsumptionRecords = new SConsumptionRecords();
sConsumptionRecords.setConsumerId(order.getConsumerId());
sConsumptionRecords.setOrderId(order.getId());
......
......@@ -423,7 +423,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setRefundReason(request.getRefundReason());
this.updateById(sOrder);
}
if (OrderStatusEnum.USED.getCode().equals(status)) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, sOrder.getRoomId());
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
List<SOrder> list = list(queryWrapper);
if (CollectionUtils.isEmpty(list)) {
// 使用中订单断电, 延时3分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(),
OpTypeEnum.CUT_ELECTRIC.getCode(), true, 180);
......@@ -1110,8 +1114,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 删除redis 缓存信息,防止退款订单自动开始及给用户发送提示短信
redisUtil.delete(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo());
redisUtil.delete(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo());
//房间断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, 5);
//查询是否有使用中的订单
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, sOrder.getRoomId());
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
List<SOrder> list = baseMapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(list)) {
//房间断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, 5);
}
}
} catch (Exception e) {
e.printStackTrace();
......
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