package com.fs.tzBankPay;

import cn.jpush.api.TestOrder;
import com.fs.tzBankPay.TzBankService.TzBankServiceImpl.TzBankServiceImpl;
import com.fs.tzBankPay.doman.*;

import java.util.ArrayList;
import java.util.List;

public class test {

    public static void main(String[] args) throws Exception {
        orderShare();
    }

    public static TzBankResult<orderShareQueryResult> orderShareQuery() {
        TzBankServiceImpl tzBankService = new TzBankServiceImpl();
        orderShareQueryParam orderShareQueryParam = new orderShareQueryParam();
        orderShareQueryParam.setOutOrderNo("922387027507284471");
        TzBankResult<orderShareQueryResult> result = tzBankService.orderShareQuery(orderShareQueryParam);
        System.out.println(result);
        return result;
    }



    public static  TzBankResult<PayCreateOrderResult> createOrder(){
        TzBankServiceImpl tzBankService = new TzBankServiceImpl();
        PayCreateOrder o = new PayCreateOrder();
        o.setOrderNo("ceshi001111211"); // 业务系统订单号
        o.setTrxAmt(0.01); // 交易金额
        o.setBusinessCstNo("1234567"); // 业务平台客户号
        o.setPayerName("用户");
        o.setGoodsInfo("订单信息"); // 订单信息
        TzBankResult<PayCreateOrderResult> result = tzBankService.createOrder(o);
        System.out.println(result);
        System.out.println(result.getBody().getUrl());
        return result;
    }

    public static TzBankResult<QueryOrderResult> queryOrder() {
        TzBankServiceImpl tzBankService = new TzBankServiceImpl();
        payQueryOrder payQueryOrder = new payQueryOrder();
        payQueryOrder.setOrderFlowNo("922387027507284471");
        TzBankResult<QueryOrderResult> result = tzBankService.queryOrder(payQueryOrder);
        System.out.println(result);
        return result;
    }
    public static TzBankResult<OrderShareResult> orderShare() {
        TzBankServiceImpl tzBankService = new TzBankServiceImpl();
        OrderShareParam orderShareParam = new OrderShareParam();
        //// 传的分账订单号
        orderShareParam.setOutOrderNo("L1750083709425418240");
        //旧的支付外部订单号 支付时上上传的
        orderShareParam.setOldPayOutOrderNo("ceshi1750083709425418240");
        //交易金额
        orderShareParam.setTrxAmt(0.1);
        OrderShareParam.sharers sharer = new OrderShareParam.sharers();
        //分账金额
        sharer.setShareAmt(0.1);
        sharer.setSharerCstName("重庆云联融智科技有限公司");
        sharer.setSharerCstNo("943103603046907709");
        List<OrderShareParam.sharers> sharers = new ArrayList<>();
        sharers.add(sharer);
        orderShareParam.setSharers(sharers);
        TzBankResult<OrderShareResult> r = tzBankService.orderShare(orderShareParam);
        return r;
    }

    public static TzBankResult tui() throws Exception {
        TzBankServiceImpl tzBankService = new TzBankServiceImpl();
        RefundParam tzBankResult = new RefundParam();
           tzBankResult.setOldPayOutOrderNo("inquiry"+"173911137306679312384");
      //  tzBankResult.setOldPayOutOrderNo("package"+"1739897302174138368");
        tzBankResult.setRefundOrderNo("tui1739137306679312384");


        tzBankResult.setRefundOrdTransAmt(30.00);
        TzBankResult<RefundResult> result = tzBankService.refund(tzBankResult);
        System.out.println(result);
        return result;
    }


    public static TzBankResult getTui() throws Exception {
        TzBankServiceImpl tzBankService = new TzBankServiceImpl();
        QueryRefundOrderParam r = new QueryRefundOrderParam();
        // 使用 setter 方法为对象赋值
        r.setRefundOrderNo("ceshitui001");
        TzBankResult<QueryRefundResult> result = tzBankService.queryRefundOrder(r);
        return result;
    }


}
