package com.xiaomai.cases.polar.finance.axf;

import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class TestAggDeduction extends BaseTestImpl {
    @BeforeMethod
    @Override
    public void beforeTest(){
        setTestInfo(ApiModule.Polar_Finance,"API_aggDeduction", LoginAccount.GYM_PROD, Terminal.B,"yff");
        super.beforeTest();
    }

    @DataProvider
    public Object[][] dataProvider(){
        return new Object[][]{
                {"SUCCESS"},
                {"FAIL"},
                {"REFUND"},
                {"REFUND_F"}
        };
    }
    @Test(description = "获取先享后付扣款明细统计值",dataProvider = "dataProvider")
    public void testAggDeduction(String state){

        //  如果运行的环境为灰度则不执行，原因是灰度环境先享后付没有数据
        if (xmAppApi.getUrl().contains("canary-fit.xiaomai5.com"))
            return;
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
        jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
        jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
        jsonObject.put("current",1);
        jsonObject.put("size",10);
        jsonObject.put("state",state);
        jsonObject.put("businessNo",null);
        jsonObject.put("thirdOrderNo",null);
        xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(true);
        JSONObject response=xmAppApi.getBodyInJSON();
        String success=response.getString("success");
        Assert.assertEquals(success,"true","获取先享后付扣款明细统计值接口失败");
    }


}
