package com.seamew.lottery.test.application;

import com.alibaba.fastjson2.JSON;
import com.seamew.lottery.application.process.IActivityProcess;
import com.seamew.lottery.application.process.req.DrawProcessReq;
import com.seamew.lottery.application.process.res.DrawProcessResult;
import com.seamew.lottery.common.Constants;
import com.seamew.lottery.domain.activity.model.vo.InvoiceVO;
import com.seamew.lottery.domain.activity.service.partake.IActivityPartake;
import com.seamew.middleware.db.router.strategy.IDBRouterStrategy;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.ResponseStatus;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: seamew
 * @Title: ActivityProcessTest
 * @CreateTime: 2023年02月24日 16:33:00
 * @Description:
 * @Version: 1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class ActivityProcessTest {
    @Resource
    private IActivityProcess activityProcess;

    @Resource
    IDBRouterStrategy dbRouter;

    @Resource
    private IActivityPartake activityPartake;

    @Test
    public void test_doDrawProcess() throws Exception {
        DrawProcessReq req = new DrawProcessReq();
        req.setUId("xiaofuge");
        req.setActivityId(100001L);
        DrawProcessResult drawProcessResult = activityProcess.doDrawProcess(req);

        log.info("请求入参：{}", JSON.toJSONString(req));
        log.info("测试结果：{}", JSON.toJSONString(drawProcessResult));

        Thread.sleep(10000);

    }

    @Test
    public void test_router() throws Exception {
        // DrawProcessReq req = new DrawProcessReq();
        // req.setUId("fustack");
        // req.setActivityId(100001L);
        // DrawProcessResult drawProcessResult = activityProcess.doDrawProcess(req);
        //
        // log.info("请求入参：{}", JSON.toJSONString(req));
        // log.info("测试结果：{}", JSON.toJSONString(drawProcessResult));
        //
        // while (true) {
        //     Thread.sleep(30000);
        // }
        List<InvoiceVO> invoiceVOList = activityPartake.scanInvoiceMqState(2, 0);
        log.info("size:{}", invoiceVOList.size());
    }

    @Test
    public void test_update() {
        activityPartake.updateInvoiceMqState("fustack", 1630424938135584768L, Constants.MQState.COMPLETE.getCode());

    }

}
