package com.live.xmutils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.testng.annotations.Test;

/**
 * Created by wujie on  2020/09/22
 */
public class ConsumerSchedule extends ApiBaseTest {

    @Override
    protected String getApiName() {
        return "API_createSignUpVoucher";
    }

//    @BeforeMethod
//    public void beforeTest() {
//        //设置测试信息：env、Apimodule、Apiname、接口账号信息、端口位
//        xmAppApi.setApiModule(ApiModele.God_B) // API 所属模块
//                .setApiName("API_saveStudent") // API 名称
//                .setEnv("rc")            // 运行环境
//                .setLoginUser("wujie_b")         // 测试账号
//                .setTerminal(Terminal.B);             // 所属端位（B端，C端，M端等, 必传）
//
//        /*dal.setCase_owner("wujie")
//            .setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);*/
//
//        super.beforeTest();
//    }

    @Test(enabled = false)
    public static void testStudentSchedule() throws InterruptedException {
//        String data1 = "{\"arrearsDetails\":[],\"buyerId\":-1,\"signUpVoucherDetails\":[{\"actualAmount\":50.5," +
//                "\"commodityNum\":1,\"commoditySpecId\":\"1308283055693492226\",\"purchaseItemType\":\"COURSE\"," +
//                "\"classId\":\"\",\"courseId\":\"1308283055347929090\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":100,\"commodityNum\":1," +
//                "\"commoditySpecId\":\"1290133296260833282\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
//                "\"courseId\":\"1290133295924903937\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":660,\"commodityNum\":1," +
//                "\"commoditySpecId\":\"1308287173149454338\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
//                "\"courseId\":\"1308287172824862721\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"}],\"receivableAmount\":810.5,\"paidAmount\":810.5," +
//                "\"studentId\":\"1308415293825691649\",\"paymentFlows\":[{\"paymentType\":\"CASH\",\"paymentAmount\":810.5}]," +
//                "\"bizAccountId\":\"1291247057398218754\",\"operationDate\":1600786027972,\"businessOwners\":[]," +
//                "\"objectId\":\"fAd2dQDWXiYwEwPAy3xY64wXpAsyTR6X\",\"userCouponIds\":[],\"validVoucher\":true}";

        //添加学员
        /*String data = "{\"studentBasicRequest\":{\"bakPhoneRemark\":\"DAD\",\"genderEnum\":\"UNKNOWN\",\"name\":\"10000000000\"," +
                "\"onlyAge\":false,\"phone\":\"  \",\"phoneRemark\":\"MOM\",\"statusEnum\":\"NORMAL\"}," +
                "\"studentExpandRequest\":{\"attrList\":[]},\"studentHistoryRequest\":{}," +
                "\"studentSaleRequest\":{\"position\":\"UN_SPECIFIED\"}}";

        JSONObject obj = JSONObject.parseObject(data);

        // set name
        String name = obj.getJSONObject("studentBasicRequest").getString("name");
        Long nameInt = Long.valueOf(name);

        System.out.println(nameInt);

        */


        String data1 = "{\"arrearsDetails\":[],\"buyerId\":-1,\"signUpVoucherDetails\":[{\"actualAmount\":50.5," +
                "\"commodityNum\":1,\"commoditySpecId\":\"1308283055693492226\",\"purchaseItemType\":\"COURSE\"," +
                "\"classId\":\"\",\"courseId\":\"1308283055347929090\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":100,\"commodityNum\":1," +
                "\"commoditySpecId\":\"1290133296260833282\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
                "\"courseId\":\"1290133295924903937\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":660,\"commodityNum\":1," +
                "\"commoditySpecId\":\"1308287173149454338\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
                "\"courseId\":\"1308287172824862721\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"}],\"receivableAmount\":810.5,\"paidAmount\":810.5," +
                "\"studentId\":\"1308415293825691649\",\"paymentFlows\":[{\"paymentType\":\"CASH\",\"paymentAmount\":810.5}]," +
                "\"bizAccountId\":\"1291247057398218754\",\"operationDate\":1600786027972,\"businessOwners\":[]," +
                "\"objectId\":\"fAd2dQDWXiYwEwPAy3xY64wXpAsyTR6X\",\"userCouponIds\":[],\"validVoucher\":true}";

        JSONObject obj1 = JSONObject.parseObject(data1);

        //String objectId = obj1.getString("objectId");

        String [] studenId = new String[]{"1308601157298106370","1308601158363459586","1308601159495921665"
//                "1308601160473194498","1308601161580490753","1308601162364825602","1308601163295961089",
//                "1308601119255769089","1308601164201930754","1308601166110339074","1308601167184080897",
//                "1308601170543718402","1308601169805520898","1308601168882774018","1308601168102633473",
//                "1308601171550351361","1308601172359852034","1308601177736949761","1308601179766992897",
//                "1308601187287379969","1308601186196860930","1308601183999045634","1308601181868339201",
//                "1308601188159795202","1308601188952518657","1308601190034649090","1308601190701543426",
//                "1308601092940705794","1308601091791466498","1308601090768056322","1308601191481683970",
//                "1308601195080396801","1308601194266701825","1308601193222320129","1308601192542842882",
//                "1308601195944423426","1308601196850393089","1308601197693448193","1308601198511337473",
//                "1308601082186510338","1308601081175683074","1308601080282296321","1308601200528797698",
//                "1308601203313815554","1308601202386874370","1308601201589956609","1308601199404724225",
//                "1308601068290781185","1308601204194619394","1308601204911845378","1308601205868146690",
//                "1308601209215201281","1308601208485392385","1308601207571034113","1308601206715396098",
//                "1308601210150531073","1308601210855174146","1308601212021190657","1308601214953009154",
//                "1308601226491539458","1308601225694621697","1308601219189256194","1308601217104687105"
//                "1308601136657936386","1308601137349996546","1308601138478264321","1308601139279376386",
//                "1308601140172763138","1308601141070344194","1308601141829513218","1308601144463536129",
//                "1308601146539716610","1308601148662034433","1308601150960513026","1308601152017477634",
//                "1308601152936030210","1308601154190127106","1308601155179982850","1308601156446662657"
                };

        int size = studenId.length;

//        Long start = Long.valueOf("10000000200");
//        Long stop = Long.valueOf("10000000201");





        for (int i = 0; i < size; ++i) {
//            String newName = String.valueOf(nameInt + i);
//            System.out.println(newName);
//
//            obj.getJSONObject("studentBasicRequest").put("name", newName);
//            obj.getJSONObject("studentBasicRequest").put("phone", newName);


            //String mdId = String.valueOf(studenId[i]);

            //System.out.println(mdId);

            System.out.println(studenId[i]);

            obj1.put("objectId",studenId[i]);
            obj1.put("studentId",studenId[i]);


            String requestBody = JSON.toJSONString(obj1);

            //
            okHttpClient.doPostRequest(url, requestBody, headers);

            //Thread.currentThread().sleep(1000);

            //JSONObject jsonBody = okHttpClient.getBodyInJSON();
            //String getstudentId = jsonBody.getJSONObject("result").getJSONObject("studentBasicVO").getString("studentId");

            //System.out.println(jsonBody);

//            String data1 = "{\"arrearsDetails\":[],\"buyerId\":-1,\"signUpVoucherDetails\":[{\"actualAmount\":50.5," +
//                    "\"commodityNum\":1,\"commoditySpecId\":\"1308283055693492226\",\"purchaseItemType\":\"COURSE\"," +
//                    "\"classId\":\"\",\"courseId\":\"1308283055347929090\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                    "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":100,\"commodityNum\":1," +
//                    "\"commoditySpecId\":\"1290133296260833282\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
//                    "\"courseId\":\"1290133295924903937\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                    "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":660,\"commodityNum\":1," +
//                    "\"commoditySpecId\":\"1308287173149454338\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
//                    "\"courseId\":\"1308287172824862721\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                    "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"}],\"receivableAmount\":810.5,\"paidAmount\":810.5," +
//                    "\"studentId\":\"1308415293825691649\",\"paymentFlows\":[{\"paymentType\":\"CASH\",\"paymentAmount\":810.5}]," +
//                    "\"bizAccountId\":\"1291247057398218754\",\"operationDate\":1600786027972,\"businessOwners\":[]," +
//                    "\"objectId\":\"fAd2dQDWXiYwEwPAy3xY64wXpAsyTR6X\",\"userCouponIds\":[],\"validVoucher\":true}";
//
//            JSONObject obj1 = JSONObject.parseObject(data1);
//
//            String newstudentId = getstudentId;
//            obj1.getJSONObject("studentId").put("studentId",newstudentId);
//            String reBody = JSON.toJSONString(obj1);
//
//            okHttpClient.doPostRequest("/business/public/order/createSignUpVoucher", params, reBody, headers);


        }
        //okHttpClient.doPostRequest(url,params,data1,headers);


    }

    //StudentData student = new StudentData();


}

//class StudentData {
//    String name;
//    String phone;
//    String statusEnum = "NORMAL";
//    String phoneBak = "99800009999";
//    String school = "哇哈哈小学";
//    String birthday = "1268718248968";
//    boolean onlyAge = true;
//    String address = "哇哈哈小区3单元";
//    String phoneRemark = "MOM";
//    String gradeName = "一年级";
//    String genderEnum = "MAN";
//    String grade = "1";
//    String bakPhoneRemark = "DAD";
//    String remark = "创建学员";
//}
//
//class AddScheduleData {
//    String[] arrearsDetails = new String[]{};
//    int buyerId = -1;
//    List<Map<String, Object>> signUpVoucherDetails = new ArrayList<>();
//
//    public
//
//    // signUpVoucherDetails.a
//            // signUpVoucherDetails[0]={"actualAmount":50.5,"commodityNum":1,"commoditySpecId":"1308283055693492226","purchaseItemType":"COURSE","classId":"","courseId":"1308283055347929090","courseFeeType":"CLASS_HOUR","courseTag":"NEW","giftUnit":"CLASS_HOUR","unit":"CLASS_HOUR"};
//
//
//            //String [] signUpVoucherDetails = new String[]{"actualAmount":50.5,"commodityNum":1,"commoditySpecId":"1308283055693492226","purchaseItemType":"COURSE","classId":"","courseId":"1308283055347929090","courseFeeType":"CLASS_HOUR","courseTag":"NEW","giftUnit":"CLASS_HOUR","unit":"CLASS_HOUR"},{"actualAmount":100,"commodityNum":1,"commoditySpecId":"1290133296260833282","purchaseItemType":"COURSE","classId":"","courseId":"1290133295924903937","courseFeeType":"CLASS_HOUR","courseTag":"NEW","giftUnit":"CLASS_HOUR","unit":"CLASS_HOUR"};
//            float receivableAmount;
//    float paidAmount;
//    String StudentId;
//    String bizAccountId;
//    String operationDate;
//    String[] businessOwners = new String[]{};
//    String objectId = "fAd2dQDWXiYwEwPAy3xY64wXpAsyTR6X";
//
//
//}
//
//class ScheduleData {
//    double actualAmount = 50.5;
//    int commodityNum = 1;
//    String commoditySpecId = "1308283055693492226";
//    String purchaseItemType = "COURSE";
//    String classId = "";
//    String courseId = "1308283055347929090";
//    String courseFeeType = "CLASS_HOUR";
//    String courseTag = "NEW";
//    String giftUnit = "CLASS_HOUR";
//    String unit = "CLASS_HOUR";
//}


//package com.live.cases.baseapi;
//
//import org.testng.annotations.Test;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by wujie on  2020/09/22
// */
//public class ConsumerSchedule extends ApiBaseTest {
//
//    @Override
//    protected String getApiName(){
//        return "API_createLessonSchedule";
//    }
//
//    @Test
//    public static void testStudentSchedule(){
//        String data1 = "{\"arrearsDetails\":[],\"buyerId\":-1,\"signUpVoucherDetails\":[{\"actualAmount\":50.5," +
//                "\"commodityNum\":1,\"commoditySpecId\":\"1308283055693492226\",\"purchaseItemType\":\"COURSE\"," +
//                "\"classId\":\"\",\"courseId\":\"1308283055347929090\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":100,\"commodityNum\":1," +
//                "\"commoditySpecId\":\"1290133296260833282\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
//                "\"courseId\":\"1290133295924903937\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"},{\"actualAmount\":660,\"commodityNum\":1," +
//                "\"commoditySpecId\":\"1308287173149454338\",\"purchaseItemType\":\"COURSE\",\"classId\":\"\"," +
//                "\"courseId\":\"1308287172824862721\",\"courseFeeType\":\"CLASS_HOUR\",\"courseTag\":\"NEW\"," +
//                "\"giftUnit\":\"CLASS_HOUR\",\"unit\":\"CLASS_HOUR\"}],\"receivableAmount\":810.5,\"paidAmount\":810.5," +
//                "\"studentId\":\"1308415293825691649\",\"paymentFlows\":[{\"paymentType\":\"CASH\",\"paymentAmount\":810.5}]," +
//                "\"bizAccountId\":\"1291247057398218754\",\"operationDate\":1600786027972,\"businessOwners\":[]," +
//                "\"objectId\":\"fAd2dQDWXiYwEwPAy3xY64wXpAsyTR6X\",\"userCouponIds\":[],\"validVoucher\":true}";
//
//        String data2 = "{\"studentBasicRequest\":{\"bakPhoneRemark\":\"DAD\",\"genderEnum\":\"UNKNOWN\",\"name\":\"10000000000\"," +
//                "\"onlyAge\":false,\"phone\":\"  \",\"phoneRemark\":\"MOM\",\"statusEnum\":\"NORMAL\"}," +
//                "\"studentExpandRequest\":{\"attrList\":[]},\"studentHistoryRequest\":{}," +
//                "\"studentSaleRequest\":{\"position\":\"UN_SPECIFIED\"}}";
//
//        okHttpClient.doPostRequest(url,params,data2,headers);
//        okHttpClient.doPostRequest(url,params,data1,headers);
//
//
//
//
//    }
//    StudentData student = new StudentData();
//
//
//
//}
//
//class StudentData{
//    String name;
//    String phone;
//    String statusEnum = "NORMAL";
//    String phoneBak ="99800009999";
//    String school ="哇哈哈小学";
//    String birthday="1268718248968";
//    boolean onlyAge = true;
//    String address ="哇哈哈小区3单元";
//    String phoneRemark="MOM";
//    String gradeName="一年级";
//    String genderEnum="MAN";
//    String grade="1";
//    String bakPhoneRemark="DAD";
//    String remark="创建学员";
//}
//
//class AddScheduleData{
//    String [] arrearsDetails = new String[]{};
//    int buyerId = -1;
//    List<Map<String, Object>> signUpVoucherDetails = new ArrayList<>();
//
//    public
//
//    // signUpVoucherDetails.a
//    // signUpVoucherDetails[0]={"actualAmount":50.5,"commodityNum":1,"commoditySpecId":"1308283055693492226","purchaseItemType":"COURSE","classId":"","courseId":"1308283055347929090","courseFeeType":"CLASS_HOUR","courseTag":"NEW","giftUnit":"CLASS_HOUR","unit":"CLASS_HOUR"};
//
//
//    //String [] signUpVoucherDetails = new String[]{"actualAmount":50.5,"commodityNum":1,"commoditySpecId":"1308283055693492226","purchaseItemType":"COURSE","classId":"","courseId":"1308283055347929090","courseFeeType":"CLASS_HOUR","courseTag":"NEW","giftUnit":"CLASS_HOUR","unit":"CLASS_HOUR"},{"actualAmount":100,"commodityNum":1,"commoditySpecId":"1290133296260833282","purchaseItemType":"COURSE","classId":"","courseId":"1290133295924903937","courseFeeType":"CLASS_HOUR","courseTag":"NEW","giftUnit":"CLASS_HOUR","unit":"CLASS_HOUR"};
//    float receivableAmount;
//    float paidAmount;
//    String StudentId;
//    String bizAccountId;
//    String operationDate;
//    String [] businessOwners = new String[] {};
//    String objectId = "fAd2dQDWXiYwEwPAy3xY64wXpAsyTR6X";
//
//
//}
//
//class ScheduleData{
//    double actualAmount = 50.5;
//    int commodityNum =1;
//    String commoditySpecId = "1308283055693492226";
//    String purchaseItemType = "COURSE";
//    String classId = "";
//    String courseId = "1308283055347929090";
//    String courseFeeType = "CLASS_HOUR";
//    String courseTag = "NEW";
//    String giftUnit = "CLASS_HOUR";
//    String unit = "CLASS_HOUR";
//}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
