All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.ealenxie.goodcang.GoodCangClient Maven / Gradle / Ivy

The newest version!
package io.github.ealenxie.goodcang;

import io.github.ealenxie.goodcang.assistant.*;
import io.github.ealenxie.goodcang.base.*;
import io.github.ealenxie.goodcang.finance.*;
import io.github.ealenxie.goodcang.product.*;
import io.github.ealenxie.goodcang.warehouse.*;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;
import java.util.Collections;
import java.util.List;

/**
 * @author EalenXie created on 2023/6/25 17:38
 */
public class GoodCangClient {
    protected static final String HOST = "https://oms.goodcang.net/public_open";
    protected static final String TEST_HOST = "https://uat-oms.eminxing.com/public_open";
    private final String appKey;
    private final String appToken;
    /**
     * 当前是否沙箱环境
     */
    private boolean sandBox = true;

    public boolean isSandBox() {
        return sandBox;
    }

    public void setSandBox(boolean sandBox) {
        this.sandBox = sandBox;
    }

    private final RestOperations restOperations;

    public GoodCangClient(String appKey, String appToken) {
        this(appKey, appToken, new RestTemplate());
    }

    public GoodCangClient(String appKey, String appToken, RestOperations restOperations) {
        this.appKey = appKey;
        this.appToken = appToken;
        this.restOperations = restOperations;
    }

    /**
     * 获取国家/地区列表
     */
    public ResponseAsk> getCountry() {
        return postGoodCang("/base_data/get_country", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取仓库信息
     */
    public ResponseAsk> getWarehouse() {
        return postGoodCang("/base_data/get_warehouse", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取物流产品
     *
     * @param warehouseCode 尾程仓库代码
     */
    public ResponseAsk> getShippingMethod(String warehouseCode) {
        return postGoodCang("/base_data/get_shipping_method", new WarehouseCodePayload(warehouseCode), new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取公司账户
     */
    public ResponseAsk getAccountList() {
        return postGoodCang("/base_data/get_account_list", null, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取费用类型
     *
     * @param signBusinessType 费用业务类型
     */
    public ResponseAsk> costTypeList(Integer signBusinessType) {
        return postGoodCang("/base_data/cost_type_list", new SignBusinessTypePayload(signBusinessType), new ParameterizedTypeReference>>() {
        });
    }


    /**
     * 获取燃油费率
     *
     * @param payload 费用业务类型
     */
    public ResponseAsk> fuelRateList(FuelRatePayload payload) {
        return postGoodCang("/base_data/fuel_rate_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取异步任务结果列表
     *
     * @param requestIdList 请求id数组
     */
    public ResponseAsk> taskStatusList(List requestIdList) {
        return postGoodCang("/base_data/task_status_list", new TaskStatusListPayload(requestIdList), new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取业务基础数据信息
     */
    public ResponseAsk sysBaseInfo() {
        return postGoodCang("/base_data/sys_base_info", null, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 上传附件
     *
     * @param payload 请求参数
     */
    public ResponseAsk uploadAttachment(UploadAttachmentPayload payload) {
        return postGoodCang("/base_data/upload_attachment", payload, new ParameterizedTypeReference>() {
        });
    }


    /**
     * 运费试算
     *
     * @param payload 请求参数
     */
    public ResponseAsk> getCalculateDeliveryFee(CalculateDeliveryFeePayload payload) {
        return postGoodCang("/inventory/get_calculate_delivery_fee", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 地址校验
     *
     * @param payload 请求参数
     */
    public ResponseAsk verifyAddressInfo(VerifyAddressInfoPayload payload) {
        return postGoodCang("/address/verify_address_info", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取商品品类
     */
    public ResponseAsk> getCategory() {
        return postGoodCang("/product/get_category", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取建议中文申报品名
     */
    public ResponseAsk getDeclareCommodityNameList() {
        return postGoodCang("/product/get_declare_commodity_name_list", null, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取建议材质
     */
    public ResponseAsk getMaterialList() {
        return postGoodCang("/product/get_material_list", null, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 新建商品
     *
     * @param payload 请求参数
     */
    public ProductResponse addProduct(AddProductPayload payload) {
        return postGoodCang("/product/add_product", payload, new ParameterizedTypeReference() {
        });
    }

    /**
     * 修改商品
     *
     * @param payload 请求参数
     */
    public ProductResponse editProduct(EditProductPayload payload) {
        return postGoodCang("/product/edit_product", payload, new ParameterizedTypeReference() {
        });
    }

    /**
     * 获取商品列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> getProductSkuList(ProductSkuListPayload payload) {
        return postGoodCang("/product/get_product_sku_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取SKU标签文件
     *
     * @param payload 请求参数
     */
    public ResponseAsk printSku(PrintSkuPayload payload) {
        return postGoodCang("/product/print_sku", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 新增商品进口国数据
     *
     * @param payload 请求参数
     */
    public ResponseAsk addImportCountry(AddImportCountryPayload payload) {
        return postGoodCang("/product/add_import_country", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 更新商品清关信息
     *
     * @param payload 请求参数
     */
    public ResponseAsk updateCustomsClearance(UpdateCustomsClearancePayload payload) {
        return postGoodCang("/product/update_customs_clearance", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 修改商品状态
     *
     * @param payload 请求参数
     */
    public ResponseAsk modifyProductStatus(ModifyProductStatusPayload payload) {
        return postGoodCang("/product/modify_product_status", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取冻结商品列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> productFreezeList(ProductFreezeListPayload payload) {
        return postGoodCang("/product/product_freeze_list", payload, new ParameterizedTypeReference>>() {
        });
    }


    /**
     * 获取冻结商品详情
     *
     * @param id 冻结Id
     */
    public ResponseAsk productFreezeDetail(String id) {
        return postGoodCang("/product/product_freeze_detail", new IdPayload(id), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 新增序列号
     *
     * @param payload 请求参数
     */
    public ResponseAsk> createSerialNumber(SnListPayload payload) {
        return postGoodCang("/product/create_serial_number", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 废弃序列号
     *
     * @param payload 请求参数
     */
    public ResponseAsk> discardSerialNumber(SnListPayload payload) {
        return postGoodCang("/product/discard_serial_number", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取序列号列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> serialNumberList(SerialNumberListPayload payload) {
        return postGoodCang("/product/serial_number_list", payload, new ParameterizedTypeReference>>() {
        });
    }


    /**
     * 进出口商列表
     */
    public ResponseAsk> getVatList(PagePayload payload) {
        return postGoodCang("/inbound_order/get_vat_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取物流产品与目的仓中转仓
     */
    public ResponseAsk getSmCodeTwcToWarehouse() {
        return postGoodCang("/inbound_order/get_smcode_twc_to_warehouse", null, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 创建入库单
     *
     * @param payload 请求参数
     */
    public ResponseAsk createGrn(CreateGrnPayload payload) {
        return postGoodCang("/inbound_order/create_grn", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 编辑入库单
     *
     * @param payload 请求参数
     */
    public ResponseAsk modifyGrn(ModifyGrnPayload payload) {
        return postGoodCang("/inbound_order/modify_grn", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 废弃入库单
     *
     * @param receivingCode 入库单号
     */
    public ResponseAsk delGrn(String receivingCode) {
        return postGoodCang("/inbound_order/del_grn", new ReceivingCodePayload(receivingCode), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取入库单列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> getGrnList(GrnListPayload payload) {
        return postGoodCang("/inbound_order/get_grn_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取入库单明细
     *
     * @param receivingCode 入库单号
     */
    public ResponseAsk getGrnDetail(String receivingCode) {
        return postGoodCang("/inbound_order/get_grn_detail", new ReceivingCodePayload(receivingCode), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 删除入库单箱唛
     *
     * @param payload 请求参数
     */
    public ResponseAsk> delAsnBox(DelAsnBoxPayload payload) {
        return postGoodCang("/inbound_order/del_asn_box", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 打印箱唛
     *
     * @param payload 请求参数
     */
    public ResponseAsk printGcReceivingBox(PrintGcReceivingBoxPayload payload) {
        return postGoodCang("/inbound_order/print_gc_receiving_box", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取上架批次
     *
     * @param receivingCode 入库单号
     */
    public ResponseAsk> getBatch(String receivingCode) {
        return postGoodCang("/inbound_order/get_batch", new ReceivingCodePayload(receivingCode), new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取收货批次
     *
     * @param receivingCode 入库单号
     */
    public ReceiptBatchResponse getReceiptBatch(String receivingCode) {
        return postGoodCang("/inbound_order/get_receipt_batch", new ReceivingCodePayload(receivingCode), new ParameterizedTypeReference() {
        });
    }

    /**
     * 获取车型
     */
    public ResponseAsk> carsModel() {
        return postGoodCang("/inbound_order/cars_model", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 上传清关文件
     *
     * @param payload 请求参数
     */
    public ResponseAsk uploadClearanceDocument(UploadClearanceDocumentPayload payload) {
        return postGoodCang("/inbound_order/upload_clearance_document", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取清关文件上传状态
     *
     * @param receivingList 入库单号列表
     */
    public ResponseAsk> getClearanceDocument(List receivingList) {
        return postGoodCang("/inbound_order/get_clearance_document", new ReceivingListPayload(receivingList), new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 上传报关资料
     *
     * @param payload 请求参数
     */
    public ResponseAsk> uploadCustomsDocs(UploadCustomsDocsPayload payload) {
        return postGoodCang("/inbound_order/upload_customs_docs", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 新建出库单
     *
     * @param payload 请求参数
     */
    public OrderCodeResponse createOrder(CreateOrderPayload payload) {
        return postGoodCang("/order/create_order", payload, new ParameterizedTypeReference() {
        });
    }

    /**
     * 修改出库单
     *
     * @param payload 请求参数
     */
    public OrderCodeResponse modifyOrder(ModifyOrderPayload payload) {
        return postGoodCang("/order/modify_order", payload, new ParameterizedTypeReference() {
        });
    }

    /**
     * 根据订单号获取单票订单信息
     *
     * @param orderCode 订单号
     */
    public ResponseAsk getOrderByCode(String orderCode) {
        return postGoodCang("/order/get_order_by_code", new OrderCodePayload(orderCode), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 根据参考号获取单票订单信息
     *
     * @param referenceNo 参考号
     */
    public ResponseAsk getOrderByRefCode(String referenceNo) {
        return postGoodCang("/order/get_order_by_ref_code", new ReferenceNoPayload(referenceNo), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取订单列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> getOrderList(OrderListPayload payload) {
        return postGoodCang("/order/get_order_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取草稿和暂存订单列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> getDraftOrderList(DraftOrderListPayload payload) {
        return postGoodCang("/order/get_draft_order_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 取消订单
     *
     * @param payload 请求参数
     */
    public CancelOrderResponse cancelOrder(CancelOrderPayload payload) {
        return postGoodCang("/order/cancel_order", payload, new ParameterizedTypeReference() {
        });
    }

    /**
     * 轨迹查询
     *
     * @param referenceNo 参考号
     */
    public ResponseAsk queryTrackingStatus(String referenceNo) {
        return postGoodCang("/order/query_tracking_status", new ReferenceNoPayload(referenceNo), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 批量轨迹查询
     *
     * @param codeType  查询参数类型 order_code 订单号(默认) reference_no 订单参考号 tracking_number 跟踪号
     * @param valueList 包含订单号的字符串列表
     */
    public ResponseAsk batchQueryTrackingStatus(String codeType, List valueList) {
        return postGoodCang("/order/batch_query_tracking_status", new QueryTrackingStatusPayload(codeType, valueList), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 异常订单修改物流
     *
     * @param payload 请求参数
     */
    public ResponseAsk modifyExFulfilment(ModifyExFulfilmentPayload payload) {
        return postGoodCang("/order/modify_ex_fulfilment", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 上传面单
     *
     * @param payload 请求参数
     */
    public ResponseAsk uploadOrderLabel(UploadOrderLabelPayload payload) {
        return postGoodCang("/order/upload_order_label", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 创建退货单
     *
     * @param payload 请求参数
     */
    public ResponseAsk returnOrderCreate(ReturnOrderCreatePayload payload) {
        return postGoodCang("/return_order/create", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 修改退货单
     *
     * @param payload 请求参数
     */
    public ResponseAsk returnOrderUpdate(ReturnOrderUpdatePayload payload) {
        return postGoodCang("/return_order/update", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 废弃退货单
     *
     * @param roCode  退件单号
     * @param newDesc 退件原因
     */
    public ResponseAsk returnOrderDiscard(String roCode, String newDesc) {
        return postGoodCang("/return_order/discard", new ReturnOrderDiscardPayload(roCode, newDesc), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 退货单查询
     *
     * @param payload 请求参数
     */
    public ResponseAsk> returnOrderSearch(ReturnOrderSearchPayload payload) {
        return postGoodCang("/return_order/search", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 退货单列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> returnOrderList(ReturnOrderListPayload payload) {
        return postGoodCang("/return_order/list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 售后退件标签
     *
     * @param asroCode 退件号
     */
    public ResponseAsk returnOrderLabel(String asroCode) {
        return postGoodCang("/return_order/label", new AsroCodePayload(asroCode), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取待确认退货列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> unauthorizedList(UnauthorizedListPayload payload) {
        return postGoodCang("/return_order/unauthorized_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 处理待确认退货
     *
     * @param payload 请求参数
     */
    public ResponseAsk unauthorizedConfirm(UnauthorizedConfirmPayload payload) {
        return postGoodCang("/return_order/unauthorized_confirm", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 退货认领
     *
     * @param payload 请求参数
     */
    public ResponseAsk claimOrderSave(ClaimOrderSavePayload payload) {
        return postGoodCang("/return_order/claim_order_save", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 退货认领列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> claimOrderList(ClaimOrderListPayload payload) {
        return postGoodCang("/return_order/claim_order_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 退货认领详情
     *
     * @param claimCode 认领单号
     */
    public ResponseAsk claimOrderDetail(String claimCode) {
        return postGoodCang("/return_order/claim_order_details", new ClaimCodePayload(claimCode), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 客服留言
     *
     * @param returnOrderCodes 退件订单号
     * @param message          留言说明
     */
    public ResponseAsk returnOrderMessage(List returnOrderCodes, String message) {
        return postGoodCang("/return_order/message", new ReturnOrderMessagePayload(returnOrderCodes, message), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取退货配置
     */
    public ResponseAsk> getServiceConfig() {
        return postGoodCang("/return_order/get_service_config", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 新建计划单
     *
     * @param payload 请求参数
     */
    public ResponseAsk planOrderCreate(PlanOrderCreatePayload payload) {
        return postGoodCang("/plan_order/create", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 计划单列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> planOrderList(PlanOrderListPayload payload) {
        return postGoodCang("/plan_order/list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 取消计划单
     *
     * @param planOrderCode 计划单号
     * @param reason        取消原因
     */
    public ResponseAsk planOrderCancel(String planOrderCode, String reason) {
        return postGoodCang("/plan_order/cancel", new PlanOrderCancelPayload(planOrderCode, reason), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 装箱列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> planOrderBoxList(PlanOrderBoxListPayload payload) {
        return postGoodCang("/plan_order/box_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取库存
     *
     * @param payload 请求参数
     */
    public ResponsePage> getProductInventory(GetProductInventoryPayload payload) {
        return postGoodCang("/inventory/get_product_inventory", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取库存动态列表
     *
     * @param payload 请求参数
     */
    public ResponsePage> getInventoryLog(GetInventoryLogPayload payload) {
        return postGoodCang("/inventory/get_inventory_log", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取库龄列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> inventoryAgeList(InventoryAgeListPayload payload) {
        return postGoodCang("/inventory/inventory_age_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 设置库龄预警
     *
     * @param payload 请求参数
     */
    public ResponseAsk setInventoryWarning(ListPayload payload) {
        return postGoodCang("/inventory/set_inventory_warning", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取查件列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> logisticTicketList(LogisticTicketListPayload payload) {
        return postGoodCang("/assistant/logistic_ticket_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取查件单类型列表
     *
     * @param smCode 请求参数
     */
    public ResponseAsk> logisticTicketTypeList(String smCode) {
        return postGoodCang("/assistant/logistic_ticket_type_list", new SmCodePayload(smCode), new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 新增查件单
     *
     * @param payload 请求参数
     */
    public ResponseAsk createLogisticTicket(CreateLogisticTicketPayload payload) {
        return postGoodCang("/assistant/create_logistic_ticket", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 编辑查件单
     *
     * @param payload 请求参数
     */
    public ResponseAsk modifyLogisticTicket(ModifyLogisticTicketPayload payload) {
        return postGoodCang("/assistant/modify_logistic_ticket", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取查件单详情
     *
     * @param ioCode 查件单号
     */
    public ResponseAsk logisticTicketDetail(String ioCode) {
        return postGoodCang("/assistant/logistic_ticket_detail", new IoCodePayload(ioCode), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 查件单状态变更
     *
     * @param ioCodeList 查件单号列表
     * @param status     修改的状态
     */
    public ResponseAsk modifyLogisticTicketStatus(List ioCodeList, Integer status) {
        return postGoodCang("/assistant/modify_logistic_ticket_status", new ModifyLogisticTicketStatusPayload(ioCodeList, status), new ParameterizedTypeReference>() {
        });
    }

    /**
     * 复查查件单
     *
     * @param payload 请求参数
     */
    public ResponseAsk recheckLogisticTicket(RecheckLogisticTicketPayload payload) {
        return postGoodCang("/assistant/recheck_logistic_ticket", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取仓租信息
     *
     * @param payload 请求参数
     */
    public ResponsePage> getWhInventoryStorage(GetWhInventoryStoragePayload payload) {
        return postGoodCang("/finance/get_wh_inventory_storage", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取货币列表
     */
    public ResponseAsk> currencyRateList() {
        return postGoodCang("/finance/currency_rate_list", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取银行列表
     */
    public ResponseAsk> myBankList() {
        return postGoodCang("/finance/my_bank_list", null, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取仓租明细
     *
     * @param wisCode 仓租单号
     */
    public ResponsePage> getWhInventoryStorageDetail(String wisCode) {
        return postGoodCang("/finance/get_wh_inventory_storage_detail", new WisCodePayload(wisCode), new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取费用流水
     *
     * @param payload 请求参数
     */
    public ResponseAsk costFlowList(CostFlowListPayload payload) {
        return postGoodCang("/finance/cost_flow_list", payload, new ParameterizedTypeReference>() {
        });
    }

    /**
     * 获取充值明细
     *
     * @param payload 请求参数
     */
    public ResponseAsk> topUpRecord(TopUpRecordPayload payload) {
        return postGoodCang("/finance/top_up_record", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 获取账单列表
     *
     * @param payload 请求参数
     */
    public ResponseAsk> billingList(BillingListPayload payload) {
        return postGoodCang("/finance/billing_list", payload, new ParameterizedTypeReference>>() {
        });
    }

    /**
     * 下载账单文件
     *
     * @param billNumberList 账单号列表
     */
    public ResponseAsk billingExport(List billNumberList) {
        return postGoodCang("/finance/billing_export", new BillingExportPayload(billNumberList), new ParameterizedTypeReference>() {
        });
    }

    /**
     * post调用goodcang接口
     *
     * @param urlNotPrefix               无环境前缀的url路径
     * @param payload                    请求参数
     * @param parameterizedTypeReference 参数返回类型
     */
    @SuppressWarnings("all")
    private  T postGoodCang(String urlNotPrefix, @Nullable Object payload, ParameterizedTypeReference parameterizedTypeReference) {
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(String.format("%s%s", isSandBox() ? TEST_HOST : HOST, urlNotPrefix));
        URI uri = builder.build().encode().toUri();
        HttpHeaders headers = new HttpHeaders();
        headers.add("app-key", appKey);
        headers.add("app-token", appToken);
        headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
        headers.setContentType(MediaType.APPLICATION_JSON);
        return restOperations.exchange(uri, HttpMethod.POST, new HttpEntity<>(payload, headers), parameterizedTypeReference).getBody();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy