Commit 680cbd7e by wuwenlong

order status opt;

parent 81bbee19
......@@ -8,9 +8,7 @@ public enum OrderStatusEnum {
UNUSED(0,"待使用/已预约"),
INUSE(1,"使用中"),
USED(2,"已使用"),
CANCEL(3,"已取消"),
AUDIT(4,"审核中"),
REFUNDED(5,"已退款");
CANCEL(3,"已取消");
private Integer code;
......@@ -30,6 +28,7 @@ public enum OrderStatusEnum {
return null;
}
public Integer getCode(){
return code;
}
......
......@@ -5,8 +5,8 @@ package share.common.enums;
* @Date 2023/10/18 17:33
*/
public enum RoomStatusEnum {
FREE(1,"空闲"),
HOLD(2,"占用");
FREE(0,"空闲"),
HOLD(1,"占用");
private Integer value;
private String name;
......
......@@ -13,20 +13,14 @@ import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.CollectionUtils;
import share.common.constant.Constants;
import share.common.core.redis.RedisUtil;
import share.common.enums.CouponStatusEnum;
import share.common.enums.OrderStatusEnum;
import share.common.enums.RefundStatusEnum;
import share.common.enums.YesNoEnum;
import share.common.enums.*;
import share.common.exception.base.BaseException;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SOrder;
import share.system.domain.SRoom;
import share.system.mapper.SRoomMapper;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISOrderService;
import share.system.service.ISysConfigService;
import share.system.service.SConsumerService;
import share.system.service.*;
import java.util.Date;
import java.util.List;
......@@ -61,7 +55,7 @@ public class OrderTask {
private TransactionTemplate transactionTemplate;
@Autowired
private SRoomMapper roomMapper;
private ISRoomService roomService;
public void autoCancel() {
String redisKey = Constants.ORDER_AUTO_CANCEL_KEY;
......@@ -179,7 +173,7 @@ public class OrderTask {
SOrder tempOrder = new SOrder();
tempOrder.setId(sOrder.getId());
tempOrder.setStatus(OrderStatusEnum.REFUNDED.getCode());
tempOrder.setStatus(OrderStatusEnum.CANCEL.getCode());
tempOrder.setRefundStatus(RefundStatusEnum.REFUNDED.getCode());
Boolean execute = Boolean.FALSE;
......@@ -208,29 +202,38 @@ public class OrderTask {
//预约订单到期自动更新订单状态,更新房间状态
public void autoToStore() {
//查询所有已支付的订单
SOrder order = new SOrder();
order.setPayStatus(1);
order.setStatus(0);
order.setRefundStatus(0);
List<SOrder> sOrders = orderService.selectSOrderList(order);
List<SOrder> sOrders = orderService.validOrder();
if (CollectionUtils.isEmpty(sOrders)) {
return;
}
sOrders.forEach(item -> {
List<Long> roomIds = sOrders.stream().map(SOrder::getRoomId).collect(Collectors.toList());
List<SRoom> roomList = roomService.listByIds(roomIds);
sOrders.stream().forEach(item -> {
//判断预约开始时间是否已到期
if ((Math.abs(item.getPreStartDate().getTime() - new Date().getTime())) / (60 * 1000) == 0) {
//更改订单状态,房间状态,开始时间,结束时间
item.setStatus(1);
item.setStatus(OrderStatusEnum.INUSE.getCode());
item.setUpdateTime(new Date());
item.setStartDate(item.getPreStartDate());
item.setEndDate(item.getPreEndDate());
orderService.updateSOrder(item);
SRoom sRoom = roomMapper.selectById(item.getRoomId());
sRoom.setStatus("2");
sRoom.setUpdateTime(new Date());
roomMapper.updateById(sRoom);
roomList.stream().forEach( room -> {
if(room.getId().compareTo(item.getRoomId())==0) {
room.setStatus(RoomStatusEnum.HOLD.getValue());
room.setUpdateTime(new Date());
}
});
}
});
boolean execute = transactionTemplate.execute( e -> {
orderService.updateBatchById(sOrders,sOrders.size());
roomService.updateBatchById(roomList,roomList.size());
return true;
});
if(!execute){
logger.error("预约订单到期自动更新订单状态失败!");
throw new BaseException("预约订单到期自动更新订单状态失败!");
}
}
}
......@@ -110,7 +110,7 @@ public class SOrder extends BaseEntity
private Date endDate;
/** 订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/退款中,4:审核中,5:已退费) */
@Excel(name = "订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/退款中,4:审核中,5:已退费)")
@Excel(name = "订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/申请退款,4:退款中,5:已退费)")
private Integer status;
@ApiModelProperty(value = "0 未退款 1 申请中 2 退款中 3 已退款 4 拒绝退款")
......
......@@ -46,9 +46,9 @@ public class SRoom extends BaseEntity
@Excel(name = "房间详情介绍")
private String info;
/** 房间状态(空闲、保洁中、使用中、维护中) */
@Excel(name = "房间状态(空闲、保洁中、使用中、维护中)")
private String status;
/** 房间状态(空闲、占用) */
@Excel(name = "房间状态(空闲、占用)")
private Integer status;
/** 房间单价(默认单位:元/小时) */
@Excel(name = "房间单价(默认单位:元/小时)")
......
......@@ -110,4 +110,10 @@ public interface ISOrderService extends IService<SOrder>
boolean refundAudit(OrderRefundRequest request);
List<SOrder> queryList();
/**
* 查询所有有效订单(未使用,申请退款未审批)
* @return
*/
List<SOrder> validOrder();
}
......@@ -235,7 +235,7 @@ public class CallbackServiceImpl implements CallbackService {
logger.warn("微信退款订单已确认成功==>" + refundRecord.getColumns() + ", rawData==>" + xmlInfo + ", data==>" + notifyRecord);
return refundRecord.getStr("returnXml");
}
sOrder.setStatus(OrderStatusEnum.AUDIT.getCode());
sOrder.setStatus(OrderStatusEnum.CANCEL.getCode());
sOrder.setRefundStatus(RefundStatusEnum.INREFUND.getCode());
boolean update = sOrderService.updateById(sOrder);
if (update) {
......
......@@ -312,11 +312,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
}
}
//修改订单退款状态,为退款中
sOrder.setStatus(OrderStatusEnum.AUDIT.getCode());
sOrder.setRefundStatus(RefundStatusEnum.INREFUND.getCode());
sOrder.setRefundPrice(request.getAmount());
break;
case REJECT:
//判断订单预约开始时间是否大于当前时间
if(sOrder.getPreStartDate().compareTo(new Date())>0){
sOrder.setStatus(OrderStatusEnum.USED.getCode());
}else{
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
}
sOrder.setRefundStatus(RefundStatusEnum.REJECT.getCode());
break;
default:
......@@ -362,6 +367,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
}
@Override
public List<SOrder> validOrder() {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getStatus,OrderStatusEnum.UNUSED.getCode());
queryWrapper.in(SOrder::getRefundStatus,RefundStatusEnum.getNotRefundStatus());
List<SOrder> result = list(queryWrapper);
return result;
}
@Override
public String openDoor(Long id) {
SOrder sOrder = sOrderMapper.selectSOrderById(id);
if (Objects.isNull(sOrder)) {
......
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