package com.qs.mp.task;

import cn.hutool.core.codec.Base62;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.HashUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.DES;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qs.mp.admin.domain.Marketing;
import com.qs.mp.common.core.redis.DistributedLocker;
import com.qs.mp.common.core.redis.RedisCache;
import com.qs.mp.common.enums.UserTypeEnum;
import com.qs.mp.common.utils.AESUtil;
import com.qs.mp.common.utils.DateUtils;
import com.qs.mp.common.utils.RSAUtil;
import com.qs.mp.common.utils.WebhookService;
import com.qs.mp.common.utils.html.EscapeUtil;
import com.qs.mp.common.utils.uuid.IdUtils;
import com.qs.mp.common.utils.uuid.UUID;
import com.qs.mp.framework.service.IWxSubscribeMessage;
import com.qs.mp.pay.service.IWalletService;
import com.qs.mp.quartz.task.DayStatTask;
import com.qs.mp.quartz.task.MarketingTask;
import com.qs.mp.system.service.id.BizIdGenerator;
import com.qs.mp.user.domain.MarketingUserCode;
import com.qs.mp.user.service.IMarketingUserCodeService;
import com.qs.mp.utils.SecurityUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;

/**
 * @author Cup
 * @date 2022/4/26
 */
@SpringBootTest
public class MyTest {

    @Autowired
    private IWalletService walletService;

    @Autowired
    private MarketingTask marketingTask;

    @Autowired
    private RedisCache redisCache;

    @Autowired
    private BizIdGenerator bizIdGenerator;

    @Autowired
    private IWxSubscribeMessage wxSubscribeMessage;


    @Autowired
    private IMarketingUserCodeService marketingUserCodeService;


    @Autowired
    private DayStatTask dayStatTask;


    public static void main(String[] args) {
        WebhookService.sendAlertDing("mayday,mayday,上上下下,左右左右,BABA");

        String decrypt = AESUtil.decrypt("75213771c6c781d62136e39180303be03f0a99761114c1264f116051a9e95108");
        System.out.println("decrypt = " + decrypt);

    }

    @Test
    void test9() {

    }

    @Test
    void test8(){
        dayStatTask.stat("20220617");
    }


    @Test
    void test7() {
        String hellow = AESUtil.encrypt("hellow");
        System.out.println("hellow = " + hellow);
        String decrypt = AESUtil.decrypt("hahaha");
        System.out.println("decrypt = " + decrypt);
    }


    @Test
    void test6(){
//        List<MarketingUserCode> userCodeList = marketingUserCodeService.list(new LambdaQueryWrapper<MarketingUserCode>()
//                .select(MarketingUserCode::getUserId)
//                .eq(MarketingUserCode::getMarketingId, 102)
////                .eq(MarketingUserCode::getUserType, UserTypeEnum.ORDINARY.getValue())
//                .groupBy(MarketingUserCode::getUserId));
        List<MarketingUserCode> userCodeList = marketingUserCodeService.list(new LambdaQueryWrapper<MarketingUserCode>()
                .select(MarketingUserCode::getUserId)
                .eq(MarketingUserCode::getUserType, UserTypeEnum.ORDINARY.getValue())
                .groupBy(MarketingUserCode::getUserId));
        userCodeList.forEach(System.out::println);
    }

    @Test
    void test5() {
        Set<String> testSet =new HashSet<>();
        testSet.add("test1");
        testSet.add("test2");
        testSet.add("test3");
        testSet.add("test4");
        redisCache.setCacheSet("testSet",testSet);
        List<Object> list = new ArrayList<>();
        list.add("test1");
        list.add("test3");
        list.add("test5");
        list.add("test6");
        list.add("test7");
        redisCache.removeSetValueByKey("testSet",list);


    }

    @Test
    void test4() {
        Marketing marketing = new Marketing();
        marketing.setId(45L);
        marketing.setTitle("测试订阅通");
        wxSubscribeMessage.sendMarketingLottery(188L, marketing);
        wxSubscribeMessage.sendMarketingLottery(79L, marketing);

//        wxSubscribeMessage.sendMarketingStart(188L, marketing);
//        wxSubscribeMessage.sendMarketingStart(79L, marketing);

//        wxSubscribeMessage.sendMarketingHelp(188L, marketing);
//        wxSubscribeMessage.sendMarketingHelp(79L, marketing);
    }
    
    @Test
    void test2() throws IOException {
        marketingTask.lottery();

    }

    @Test
    void test3(){
        for (int i = 0; i < 20; i++) {
            System.out.println("bizIdGenerator = " + bizIdGenerator.newId());
        }

    }



    @Test
    void test1(){
        walletService.refund("968527112497659906",10,"测试");
    }

}
