import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.api.service.content.task.QywxGroupMsgTaskApiService;
import com.gic.haoban.manage.service.dao.mapper.content.TabHaobanInteractRecordMapper;
import com.gic.haoban.manage.service.entity.content.TabHaobanInteractRecord;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;

/**
 * @Author MUSI
 * @Date 2023/3/25 12:04 AM
 * @Description
 * @Version
 **/

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class MaterialReportServiceTest {

    public MaterialReportServiceTest(){

    }
    @Autowired
    private MaterialReportService materialReportService;
    @Autowired
    private QywxGroupMsgTaskApiService qywxGroupMsgTaskApiService;
    @Autowired
    private TabHaobanInteractRecordMapper interactRecordMapper;

    String eid = "ff8080815dacd3a2015dacd3ef5c0000";
    String wxEid = "ca66a01b79474c40b3e7c7f93daf1a3b";
    String staffId = "e608b51b267e4943b87e222a343b4f25";

    @Test
    public void handlerMaterialWeekReportTest() {
        System.setProperty("gic.module.name", "haoban-manage3-service");
        materialReportService.handlerMaterialReport(eid, staffId, MaterialReportType.WEEK.getCode());
        materialReportService.handlerMaterialReport(eid, staffId, MaterialReportType.MONTH.getCode());
    }

    @Test
    public void weekReport(){
        qywxGroupMsgTaskApiService.handlerMaterialMonthReport("");
    }

    @Test
    public void shardingTest(){
        TabHaobanInteractRecord temp = new TabHaobanInteractRecord();
        temp.setId(UniqueIdUtils.uniqueLong());
        temp.setEnterpriseId(eid);
        temp.setClerkId(staffId);
        temp.setMemberId(staffId);
        temp.setUnionId(staffId);
        temp.setTraceId(staffId);
        temp.setBizType(1);
        temp.setStoreId(staffId);
        temp.setChannelSource(1);
        temp.setEventType(1);
        temp.setDurationTime(111);
        temp.setTimes(1);
        temp.setDeleteFlag(0);
        temp.setCreateTime(new Date());
        temp.setUpdateTime(new Date());
        temp.setBizId(UniqueIdUtils.uniqueLong()+"");
        int insert = interactRecordMapper.insert(temp);
    }
}
