package com.fs.task;


import com.alibaba.fastjson.JSON;
import com.fs.FSAdminApplication;
import com.fs.common.core.page.TableDataInfo;
import com.fs.company.service.ICompanyService;
import com.fs.company.service.ICompanyTagService;
import com.fs.company.vo.RedPacketMoneyVO;
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
import com.fs.course.service.IFsCourseWatchLogService;
import com.fs.statis.service.FsStatisSalerWatchService;
import com.fs.store.param.h5.FsUserPageListParam;
import com.fs.store.service.IFsUserService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@RunWith(value = org.springframework.test.context.junit4.SpringRunner.class)
@SpringBootTest(classes = FSAdminApplication.class)
@Slf4j
public class StoreTaskTest {
    @Autowired
    private IFsCourseWatchLogService fsCourseWatchLogService;
    @Autowired
    private FsCourseTask fsCourseTask;
    @Autowired
    private FsStatisSalerWatchService fsStatisSalerWatchService;

    @Autowired
    private FsCourseRedPacketLogMapper fsCourseRedPacketLogMapper;

    @Autowired
    private ICompanyService companyService;
    @Autowired
    private ICompanyTagService companyTagService;

    @Autowired
    private IFsUserService fsUserService;
    @Test
    public void addQwWatchLog() {
        fsCourseWatchLogService.addCourseWatchLogDayNew();
    }
    @Test
    public void test() throws Exception {
        fsCourseTask.hyWorkTask();
    }

    @Test
    public void testWriteData(){
        fsStatisSalerWatchService.writeData();
    }

    @Test
    public void tag(){
//        log.info("tag: {}",companyTagService.queryAllTagMap());
        FsUserPageListParam param = new FsUserPageListParam();
        param.setPageNum(1);
        param.setPageSize(10);

        TableDataInfo tableDataInfo = fsUserService.selectFsUserPageListNew(param);
        log.info("数据：{}", JSON.toJSONString(tableDataInfo));
    }

    @Test
    public void redPacketSubMoney() throws Exception
    {
        List<RedPacketMoneyVO> redPacketMoneyVOS = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogByCompanyFix();
        for (RedPacketMoneyVO redPacketMoneyVO : redPacketMoneyVOS) {
            companyService.subtractCompanyMoney(redPacketMoneyVO.getMoney(),redPacketMoneyVO.getCompanyId());
        }
    }
}
