@Override
    public void handle(SeckillWebMockRequestDTO request) {
        // 状态机初始化
        stateMachineService.initStateMachine(request.getSeckillId());
        // 初始化库存数量
        // 使用状态机控制活动状态
        if (!stateMachineService.feedMachine(Events.ACTIVITY_RESET, request.getSeckillId())) {
            throw new RuntimeException("活动尚未结束，请等待活动结束后再次操作");
        }
        stateMachineService.feedMachine(Events.ACTIVITY_START, request.getSeckillId());
    }
@Test
    public void shouldThrowExceptionWhenActivityNotEnded() {
        SeckillWebMockRequestDTO request = new SeckillWebMockRequestDTO();
        request.setSeckillId(123L);
        when(stateMachineService.feedMachine(Events.ACTIVITY_RESET, request.getSeckillId())).thenReturn(false);

        try {
            stateMachinePreRequestHandler.handle(request);
        } catch (RuntimeException e) {
            verify(stateMachineService, times(1)).initStateMachine(request.getSeckillId());
            verify(stateMachineService, times(1)).feedMachine(Events.ACTIVITY_RESET, request.getSeckillId());
            verify(stateMachineService, times(0)).feedMachine(Events.ACTIVITY_START, request.getSeckillId());
        }
    }