package com.miaxis.test;


import com.miaxis.JsjpApplication;
import com.miaxis.common.utils.DateUtils;
import com.miaxis.common.utils.OrderCodeFactory;
import com.miaxis.newgzpt.domain.GzptUserInfo;
import com.miaxis.newgzpt.domain.GzptVideoVip;
import com.miaxis.newgzpt.dto.GzptVideoVipDTO;
import com.miaxis.newgzpt.service.IGzptSchActivationService;
import com.miaxis.newgzpt.service.IGzptUserInfoService;
import com.miaxis.newgzpt.service.IGzptVideoVipService;
import com.miaxis.wx.domain.WxJsOrder;
import com.miaxis.wx.service.IRefundRecordService;
import com.miaxis.wx.service.IWxJsOrderService;
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.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

@ActiveProfiles("prodtest")
@SpringBootTest(classes = JsjpApplication.class)
@RunWith(SpringRunner.class)
public class NewGzptTest {

    @Autowired
    private IGzptUserInfoService gzptUserInfoService;

    @Autowired
    private IGzptVideoVipService gzptVideoVipService;

    @Autowired
    private IWxJsOrderService wxJsOrderService;

    @Autowired
    private IRefundRecordService refundRecordService;

    @Autowired
    private IGzptSchActivationService activationService;


    @Test
    public void test1() throws Exception {
       // int reuslt = activationService.isSchActivation(350101318159l);
       // System.out.println(reuslt);
        activationService.upDelSchActivationByUserId(350101318159l,0);
    }

    @Test
    public void test2() throws Exception {
        GzptVideoVip videoVip = new GzptVideoVip();
        videoVip.setUserId(70l);
        videoVip.setUserName("测试");
        videoVip.setSubject2(new Date());
        videoVip.setSubject3(null);
        System.out.println(videoVip);
       // videoVip.setSubject3(new Date());
        gzptVideoVipService.saveGzptVideoVip(videoVip);
    }


    @Test
    public void test3() throws Exception {
        GzptVideoVip videoVip = new GzptVideoVip();
        videoVip.setUserId(69l);
        videoVip.setUserName("测试2");

        Date d2 = DateUtils.parseDate("2022-01-01 12:00:00");
        Date d3 = DateUtils.parseDate("2023-01-01 12:00:00");
        videoVip.setSubject2(d2);
        videoVip.setSubject3(d3);
        gzptVideoVipService.updateGzptVideoVipByUserId(videoVip);
    }
    @Test
    public void test4() throws Exception {
        GzptVideoVipDTO gzptVideoVipDTO = new GzptVideoVipDTO();
        gzptVideoVipDTO.setUserId(68l);
        GzptVideoVip gv = gzptVideoVipService.getGzptVideoVipByUserId(gzptVideoVipDTO);
        System.out.println(gv);
    }

    @Test
    public void test5() throws Exception {
        WxJsOrder wxJsOrder = wxJsOrderService.getByOutTradeNo("12022060718161790123480791741559");
        refundRecordService.refund(wxJsOrder, OrderCodeFactory.getOrderCode(null), "测试退款111BBQ");
    }



    public static void main(String[] args) {
        long oneYearLong = 1000*60*60*24*365l;
        Date now = new Date();
        long x = now.getTime() + oneYearLong;
        Date new1 =new Date(x);
        System.out.println(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",now));
        System.out.println(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",new1));


    }
}
