package com.miaxis.test;

import com.alibaba.fastjson.JSONObject;
import com.miaxis.ZzjsApplication;
import com.miaxis.common.enums.OrderStatusEnum;
import com.miaxis.common.exception.CustomException;
import com.miaxis.feign.dto.FilmDTO;
import com.miaxis.feign.dto.FilmMcpData;
import com.miaxis.feign.dto.FilmXdResult;
import com.miaxis.wx.domain.WxOrder;
import com.miaxis.wx.dto.WxNotifyReturnDTO;
import com.miaxis.wx.dto.WxOrderCreateDTO;
import com.miaxis.wx.service.IWxOrderService;
import com.miaxis.wx.service.IRefundRecordService;
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
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.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import java.math.BigInteger;
import java.security.cert.X509Certificate;

import static com.miaxis.common.utils.OrderCodeFactory.getOrderCode;

//@ActiveProfiles("prod")
@SpringBootTest(classes = ZzjsApplication.class)
@RunWith(SpringRunner.class)
public class NormalTest {
    @Autowired
    private IWxOrderService wxOrderService;

    @Autowired
    private IRefundRecordService refundRecordService;

    @Autowired
    private AutoUpdateCertificatesVerifier verifier;

    @Autowired
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;

    @Test
    public void test1() throws Exception {
        WxOrder wxOrder = wxOrderService.getByOutTradeNo("12021060816391765454799220937462");
        WxNotifyReturnDTO refund = refundRecordService.refund(wxOrder, "12021060816391765454799220937463","商品购买失败");
        System.out.println(JSONObject.toJSONString(refund));
//        WxOrder wxOrder1 = wxOrderService.getByOutTradeNo("12021052415260767148145493655617");
//        refundRecordService.refund(wxOrder1,"12021051815333778448136985596489");
    }

    @Test
    public void test11() throws Exception {
        threadPoolTaskExecutor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread()+"aaa");

            }
        });

        if (true){
            System.out.println("低分段");
            threadPoolTaskExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        System.out.println(Thread.currentThread()+"bbb");
                    } catch (Exception e) {
                        throw new CustomException("订单:推送消息失败");
                    }
                }
            });

        }

    }











}
