package org.jeecg.modules.finance;

import cn.com.ctop.common.module.mapper.MailLogMapper;
import cn.com.ctop.common.module.utils.CorpWexinUtils;
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.JeecgSystemApplication;
import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
import org.jeecg.ctop.finance.policy.service.ICwjsPolicyInfoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * zian Y
 * 2021/8/3
 **/


@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
public class FinanceTest {
    @Resource
    CorpWexinUtils corpWexinUtils;
    @Resource
    MailLogMapper mailLogMapper;
    @Test
    public void weixin(){
        JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("26bbe90edc5b475ca41ec3f76aa65067");
        StringBuilder text = new StringBuilder();
        text.append("您有一条销售政策需要审核，该客户为：");
        text.append("测试");
        text.append("，请及时登录助手平台-销售政策页面进行审核，谢谢！");
        corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
    }

    @Resource
    ICwjsPolicyInfoService policyInfoService;
    @Test
    public void ICwjsPolicyInfoServiceTest(){
        CwjsPolicyInfo cwjsPolicyInfo = new CwjsPolicyInfo();
        cwjsPolicyInfo.setAdvertiserName("厕所");
        cwjsPolicyInfo.setProductName("厕所");
        cwjsPolicyInfo.setMediaType(2);
        cwjsPolicyInfo.setCreateUserId("26bbe90edc5b475ca41ec3f76aa65067");
        cwjsPolicyInfo.setPolicyStartDate("2021-08-10");
        cwjsPolicyInfo.setPolicyEndDate("2021-08-15");
        boolean ok = policyInfoService.isExistCwjsPolicyInfo(cwjsPolicyInfo);

        cwjsPolicyInfo.setPolicyStartDate("2021-08-08");
        cwjsPolicyInfo.setPolicyEndDate("2021-08-09");

        cwjsPolicyInfo.setPolicyStartDate("2021-08-08");
        cwjsPolicyInfo.setPolicyEndDate("2021-08-10");

        cwjsPolicyInfo.setPolicyStartDate("2021-08-11");
        cwjsPolicyInfo.setPolicyEndDate("2021-08-12");

    }

    @Autowired
    IKuaishouAudienceReportDailyGenderService audienceReportDailyGenderService;
    @Test
    public void IKuaishouAudienceReportDailyGenderServiceTest(){
        audienceReportDailyGenderService.mergeAudienceReportDailyDate("2021-07-20");
    }
}