package common;

import com.CWebApplication;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.QRCodeGenerator;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.IDGenerator;
import com.hai.config.MqttProviderConfig;
import com.hai.config.ZkcPrinterTemplate;
import com.hai.entity.*;
import com.hai.service.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import javax.annotation.Resource;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;

/**
 * @ClassName RegionTest
 * @Description: TODO ()
 * @Author 胡锐
 * @Date 2020/12/29
 **/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = CWebApplication.class)
@WebAppConfiguration
public class test {

    @Resource
    private HighOrderService highOrderService;

    @Resource
    private MqttProviderConfig mqttProviderConfig;

    @Test
    public void test() throws Exception{

    }




    public static void main(String[] args) {
        // 获取当前正在执行线程的引用，当前正在执行的线程是主线程，也就是获取主线程的引用
        Thread t1 = Thread.currentThread();
        System.out.println("主线程的编号是：" + t1.getId() + ", 名称是：" + t1.getName());
        requestOrder();
    }

    public static void requestOrder(){

        Map<String, Object> heard = new HashMap<>();
        heard.put("Cookie", "_ida=oArhO6XxKSvjI9wLP3cTK-iSG8yY");


        Map<String, Object> map = new HashMap<>();;
        map.put("goodsId", "23423529");
        map.put("goodsType", "1");
        map.put("saleCount", "1");

        List<Map<String, Object>> orderList = new ArrayList<>();
        orderList.add(map);

        Map<String, Object> param = new HashMap<>();
        param.put("highChildOrderList", orderList);

        int success = 0 ;
        int fail = 0;

        JSONObject object = HttpsUtils.doPost("https://hsgcs.dctpay.com/crest/highOrder/addOrder", param, heard);
        if (object.getString("return_code").equals("000000")) {
            success++;
            System.out.println("提交订单成功");
        } else {
            fail++;
            System.out.println(object.getString("return_msg"));
        }

        System.out.println("成功数量" + success);
        System.out.println("失败数量" + fail);

    }

}
