package com.liquidnet.service.goblin.test;


import com.liquidnet.common.third.sqb.biz.SqbBiz;
import com.liquidnet.common.third.sqb.param.request.CommonRequest;
import com.liquidnet.common.third.sqb.param.request.MallListQueryRequest;
import com.liquidnet.common.third.sqb.param.request.MallProductsQueryRequest;
import com.liquidnet.common.third.sqb.param.response.data.MallListQueryData;
import com.liquidnet.common.third.sqb.param.response.data.MallProductsQueryData;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
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.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class GoblinShouQianBaServiceImplTest {

    @Autowired
    private SqbBiz sqbBiz;


    @Test
    public void queryMallListTest(){

        CommonRequest.Seller seller = new CommonRequest.Seller();
        seller.setRole(sqbBiz.getSqbConfig().getRole());
        seller.setMerchantId(sqbBiz.getSqbConfig().getMerchantId());
        seller.setMerchantUserId(sqbBiz.getSqbConfig().getMerchantUserId());

        MallListQueryRequest.Filter filter = new MallListQueryRequest.Filter();
        filter.setSeller(seller);

        MallListQueryRequest.Cursor cursor = new MallListQueryRequest.Cursor();
        cursor.setCount(10);
        cursor.setCursorField("id");

        MallListQueryRequest.Sort sort = new MallListQueryRequest.Sort();
        sort.setSort("DESC");
        sort.setSortField("id");

        MallListQueryRequest mallListQueryRequest = new MallListQueryRequest();
        mallListQueryRequest.setAppid(sqbBiz.getSqbConfig().getAppId());
        mallListQueryRequest.setFilter(filter);
        mallListQueryRequest.setCursor(cursor);
        mallListQueryRequest.setSort(sort);

        List<MallListQueryData> mallListQueryData = sqbBiz.queryMallList(mallListQueryRequest);
        Assert.assertNotNull(mallListQueryData);
    }

    @Test
    public void queryMallProductsTest(){

        CommonRequest.Seller seller = new CommonRequest.Seller();
        seller.setMerchantId(sqbBiz.getSqbConfig().getMerchantId());
        seller.setMerchantUserId(sqbBiz.getSqbConfig().getMerchantUserId());
        seller.setRole("super_admin");

        CommonRequest.Mall mall = new CommonRequest.Mall();
        mall.setMallSn("2025082811504809748");
        mall.setSignature("9GB99V5iqvg-J_mhjYzs");

        MallProductsQueryRequest mallProductsQueryRequest = new MallProductsQueryRequest();
        mallProductsQueryRequest.setAppid(sqbBiz.getSqbConfig().getAppId());
        mallProductsQueryRequest.setSeller(seller);
        mallProductsQueryRequest.setMallID(mall);

        List<MallProductsQueryData> queryData = sqbBiz.queryMallProducts(mallProductsQueryRequest);
        Assert.assertNotNull(queryData);
    }

}
