package com.tmerclub.cloud.systemtest.api.store;

import com.alibaba.fastjson2.JSON;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.util.Json;
import com.tmerclub.cloud.multishop.mongo.MongoShopWalletLogBO;
import com.tmerclub.cloud.order.vo.OrderDetailVO;
import com.moyuer.cloud.systemtest.constants.Constant;
import com.moyuer.cloud.systemtest.util.HttpUtil;
import com.moyuer.cloud.systemtest.util.UrlEnum;

import java.util.List;

/**
 * @author lpj
 */
public class ShopWalletApi {
    /**
     * 根据订单号查询结算记录
     */
    public static List<MongoShopWalletLogBO> getMongoShopWalletLogBO(Long orderId, Boolean isMainShop) {
        String url = Constant.API_URL + "/tmerclub_admin/ma/shopWallet/page?shopIoType=&amountType=&orderId=" + orderId + "&refundId=&reason=&pageNum=1&pageSize=10";
        if(isMainShop) {
            return JSON.parseArray(JSON.toJSONString(Json.parseObject(JSON.toJSONString(HttpUtil.get(url, PageVO.class, UrlEnum.SHOP)), PageVO.class).getList()), MongoShopWalletLogBO.class);
        } else {
            return JSON.parseArray(JSON.toJSONString(Json.parseObject(JSON.toJSONString(HttpUtil.get(url, PageVO.class, UrlEnum.SHOP_OTHER)), PageVO.class).getList()), MongoShopWalletLogBO.class);
        }
    }

    /**
     * 根据订单号查询结算明细
     */
    public static OrderDetailVO getOrderDetailVO(Long orderId, Boolean isMainShop) {
        String url = Constant.API_URL + "/tmerclub_order/mp/order_item/get_order_detail?orderId=" + orderId + "&refundId";
        if(isMainShop) {
            return HttpUtil.get(url, OrderDetailVO.class, UrlEnum.SHOP);
        } else {
            return HttpUtil.get(url, OrderDetailVO.class, UrlEnum.SHOP_OTHER);
        }
    }

    /**
     * 根据订单号与退款单号查询结算明细
     */
    public static OrderDetailVO getOrderDetailVO(Long orderId, Long refundId, Boolean isMainShop) {
        String url = Constant.API_URL + "/tmerclub_order/mp/order_item/get_order_detail?orderId=" + orderId + "&refundId=" + refundId;
        if(isMainShop) {
            return HttpUtil.get(url, OrderDetailVO.class, UrlEnum.SHOP);
        } else {
            return HttpUtil.get(url, OrderDetailVO.class, UrlEnum.SHOP_OTHER);
        }
    }
}
