package com.fs.pay.pay;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.fs.pay.pay.domain.*;
import com.fs.pay.pay.dto.*;
import com.fs.pay.pay.service.impl.PayApiServiceImpl;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;

import java.util.Map;

public class test {
    public static void main(String[] args) {
        //测试
        aaaa();
    }

    public static void aaaa(){
        String jsonString = "{\"timeStamp\":\"1729158192\",\"package\":\"prepay_id=wx171743128046349ef84a7e4c9c86eb0001\",\"paySign\":\"W0I6ErE3Pzgr12sl22pfueU9jfBytUw+wZ14DjG2/u5f/5Pr4A8E3k3ZRtxNm2MGkBeZol1CksbQLA2GtxRXofBpOP+BwQtyJI37OvCkuHyyx1u9xi8XZOIFZAFVI977ova4qj+idT1/YPOr5G1dO212Aii0Z6a7RfoqgBrjxnrcX9+Y7q/0hOPyzwL5UnbNRrGO7RJu/3/1l0eTLaVQMt2vzttUoM7qShyfOh48mI80mhsP0CEkdyFOVjM4HR3H6e8HH7T5YXGSnrvxXFmk8czBLX03yo5LDMTPshYg1W8ip9Ux5DCbuS/llZAskWRr65gnv60+kZS7kKax5UYbvw==\",\"appId\":\"wx5e2e1e55be6c6e6d\",\"signType\":\"RSA\",\"nonceStr\":\"GxKHzHP7dzMXSFKU13ek3fI2VQphdpBz\"}";

        // 使用 Fastjson 解析字符串到 Map
        WxPayMpOrderResult map = JSON.parseObject(jsonString, WxPayMpOrderResult.class);
        // 输出Map中的内容
        System.out.println(map);
    }

    //获取订单信息
    public static void get(){
        PayApiServiceImpl payService = new PayApiServiceImpl();
        OrderQueryDTO o = new OrderQueryDTO();
//        o.setLowOrderId("payment-1696809795736043520");
        o.setUpOrderId("91759384058468634624");
        OrderResult order = payService.getOrder(o);
        System.out.println(order);
    }


    //查询退款
    public static void getTui(){
        PayApiServiceImpl payService = new PayApiServiceImpl();
        RefundOrderDTO o = new RefundOrderDTO();
        o.setRefundNo("refund-1759384058195869696");
        QueryRefundResult refundOrder = payService.getRefundOrder(o);
        System.out.println(refundOrder);
    }
    //查询退款列表
    public static void getTuiList(){
        PayApiServiceImpl payService = new PayApiServiceImpl();
        RefundOrderListDTO o = new RefundOrderListDTO();
        o.setUpOrderId("91702858656661639168");
        QueryRefundListResult refundOrderList = payService.getRefundOrderList(o);
        System.out.println(refundOrderList);
    }

    //退款
    public static void tui(){
        PayApiServiceImpl payService = new PayApiServiceImpl();
        RefundDTO refundDTO = new RefundDTO();
        refundDTO.setLowRefundNo("refund-1769963820127617024");
        refundDTO.setUpOrderId("91769963820878532608");
        refundDTO.setRefundMoney("0.1");
        RefundResult refund = payService.refund(refundDTO);
        System.out.println(refund);
    }



    //创建微信订单
    public static void createWx(){
        PayApiServiceImpl payService = new PayApiServiceImpl();
        WxJspayDTO p = new WxJspayDTO();
        // 使用setter方法为对象赋值
        p.setPayMoney("0.01");
        p.setLowOrderId("orderWx123456121");
        p.setBody("商品描述");
        p.setIsMinipg("1");
        p.setReturnUrl("http://dp2xf5.natappfree.cc/his/pay/xcx");
        p.setOpenId("oim255fXLTU65z1u_92YSw1LwfcA");
        p.setAttach("附加信息");
        p.setStoreid("0");
        CreateWxOrderResult wxOrder = payService.createWxOrder(p);
        System.out.println(wxOrder);
    }

}
