package com.platform.yijia.controller;

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

import com.alibaba.fastjson.JSON;
import com.saobei.open.sdk.DefaultSaobeiApiClient;
import com.saobei.open.sdk.SaobeiApiClient;
import com.saobei.open.sdk.model.requst.fund.SaobeiAllocateCancelRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiAllocateDoRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiAllocateOrderQueryRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiAllocateTotalQueryRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiContractGenerateRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiContractQueryRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiContractSignRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiTransferDoRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiTransferOpenRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiTransferQueryRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiWithDrawApplyRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiWithDrawQueryFeeRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiWithDrawQueryRequest;
import com.saobei.open.sdk.model.requst.fund.SaobeiWithDrawSettleQueryRequest;
import com.saobei.open.sdk.model.requst.merchant.SaobeiBillDownloadRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiAppPayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiAuthCodeToOpenidRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiBarcodePayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiFaceInfoRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiFacePayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiJsPayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiMiniPayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiPrePayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiQrPayRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiTradeCancelRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiTradeCloseRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiTradeQueryRefundRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiTradeQueryRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiTradeRefundRequest;
import com.saobei.open.sdk.model.requst.trade.SaobeiWapPayRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiBarcodePayRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiJsPayRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiMiniPayRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiPrePayRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiTradeCancelRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiTradeCloseRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiTradeQueryRefundRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiTradeQueryRequest;
import com.saobei.open.sdk.model.requst.trade.fenqi.SaobeiFenqiTradeRefundRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthBarRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthCancelRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthFacePayRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthFinishRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthJsPayRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthMiniPayRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthQrH5Request;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthQrRequest;
import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthQueryRequest;
import com.saobei.open.sdk.model.requst.trade.wechat.WxAuthAccessTokenRequest;
import com.saobei.open.sdk.model.requst.trade.wechat.WxAuthOpenidRequest;
import com.saobei.open.sdk.model.requst.trade.wechat.WxScanOrderSyncRequest;
import com.saobei.open.sdk.model.requst.trade.wechat.dish.DishBean;
import com.saobei.open.sdk.model.requst.trade.wechat.dish.PropertiesBean;
import com.saobei.open.sdk.model.response.fund.SaobeiAllocateCancelResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiAllocateDoResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiAllocateOrderQueryResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiAllocateTotalQueryResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiContractGenerateResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiContractQueryResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiContractSignResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiTransferDoResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiTransferOpenResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiTransferQueryResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiWithDrawApplyResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiWithDrawQueryFeeResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiWithDrawQueryResponse;
import com.saobei.open.sdk.model.response.fund.SaobeiWithDrawSettleQueryResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiAppPayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiAuthCodeToOpenidResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiBarcodePayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiFaceInfoResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiFacePayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiJsPayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiMiniPayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiPrePayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiQrPayResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiTradeCancelResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiTradeCloseResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiTradeQueryRefundResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiTradeQueryResponse;
import com.saobei.open.sdk.model.response.trade.SaobeiTradeRefundResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiBarcodePayResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiJsPayResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiMiniPayResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiPrePayResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiTradeCancelResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiTradeCloseResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiTradeQueryRefundResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiTradeQueryResponse;
import com.saobei.open.sdk.model.response.trade.fenqi.SaobeiFenqiTradeRefundResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthBarResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthCancelResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthFacePayResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthFinishResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthJsPayResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthMiniPayResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthQrResponse;
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthQueryResponse;
import com.saobei.open.sdk.model.response.trade.wechat.WxScanOrderSyncResponse;

public class Demo {
	public static final String PAY_VER = "110";//版本号
	public static final String KEY = "";//机构秘钥
	public static final String ACCESS_TOKEN = "";//支付秘钥
	public static final String INST_NO = "";//机构号
	public static final String MERCHANT_NO = "";//商户号
	public static final String TERMINAL_ID = "";//终端号

//	public static void main(String[] args) throws Exception {
//
//		/****************支付接口********************/
//		barcodepay();//1.1 付款码支付
//
////		prepay();//1.2  扫码支付
//
////		jspay();//1.3 公众号预支付
//
////		authopenid();//1.3.1. 微信公众号JSAPI支付授权
//
////		authAccessToken();//1.3.2. 微信获取access_token(扫码点餐的登录票据)
//
////		apppay();//1.4. APP统一下单
//
////		minipay();//1.5. 小程序支付接口
//
////		facepay();//1.6. 自助收银支付接口
//
////		faceinfo();//1.7. 自助收银SDK调用凭证获取接口
//
////		authcodetoopenid();//1.8. 授权码查询 OPENID 接口
//
////		orderfoodSync();//1.9. 扫码点餐数据上传
//
////		query();//2.1. 支付查询
//
////		refund();//2.2. 退款申请
//
////		cancel();//2.4. 撤销交易(只针对刷卡支付)
//
////		close();//2.5. 关闭订单
//
////		queryrefund();//2.7. 退款订单查询
//
////		wappay();//WAP SDK入口
//
////		qrpay();// 聚合码支付接口
//
//		/****************提现接口********************/
//
////		withdrawQuery();//1.1. 查询余额
//
////		withdrawQueryFee();//1.2. 查询提现手续费
//
////		withdrawApply();//1.2. 发起提现
//
////		withdrawSettleQuery();//1.4. 查询清算
//
//		/****************订单分账接口***************/
//
////		contractGenerate();//分账规则电子协议生成
//
////		contractSign();//分账规则电子协议签署
//
////		contractQuery();//分账电子协议查询
//
////		allocateDo();//订单分账
//
////		allocateCancel();//撤销分账
//
////		allocateQuery();//分账交易查询
//
////		allocateTotalQuery();//入帐户资金汇总查询
//
//		/****************营销转账接口********************/
////		transferOpen();//记帐户转账功能开通
//
////		transferDo();//记帐户转账接口
//
////		transferQuery();//记帐户转账流水查询接口
//
//		/****************分期支付接口********************/
//
////		fenqiBarcodepay();//付款码支付
//
////		fenqiPrepay();//扫码支付
////
////		fenqiJspay();// 公众号预支付
////
////		fenqiMinipay();//小程序支付接口
////
////		fenqiQuery();//支付查询
////
////		fenqiRefund();//退款申请
////
////		fenqiCancel();//撤销交易(只针对刷卡支付)
////
////		fenqiClose();// 关闭订单
////
////		fenqiQueryrefund();//退款订单查询
//
//		/****************预授权支付接口********************/
////		preAuthBar();//条码预授权
//
////		preAuthQr();//获取预授权聚合码
//
////		preAuthQrH5pay();//预授权聚合码
//
////		preAuthJsPay();//公众号预授权
//
////		preAuthMiniPay();//小程序预授权
//
////		preAuthFacePay();//刷脸预授权
//
////		preAuthFinish();//预授权完成
//
////		preAuthCancel();//预授权撤销
//
////		preAuthQuery();//预授权订单查询
//
//		/****************商户接口********************/
//
////		billDownload();//对账单下载
//	}
	//对账单下载
	private static void billDownload() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiBillDownloadRequest,String> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiBillDownloadRequest requst = new SaobeiBillDownloadRequest();
		requst.setInst_no(INST_NO);
		requst.setDay("20200301");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		String url = client.executeMerchant(requst);
		System.out.println(url);

	}
	//预授权订单查询
	private static void preAuthQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthQueryRequest,SaobeiPreAuthQueryResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthQueryRequest requst = new SaobeiPreAuthQueryRequest();
		requst.setPay_ver(PAY_VER);
		requst.setService_id("015");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		requst.setOrder_type("03");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthQueryResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//预授权撤销
	private static void preAuthCancel() throws Exception{
		//创建client
		SaobeiApiClient<SaobeiPreAuthCancelRequest,SaobeiPreAuthCancelResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthCancelRequest requst = new SaobeiPreAuthCancelRequest();
		requst.setPay_ver(PAY_VER);
		requst.setService_id("015");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthCancelResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//预授权完成
	private static void preAuthFinish() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthFinishRequest,SaobeiPreAuthFinishResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthFinishRequest requst = new SaobeiPreAuthFinishRequest();
		requst.setPay_ver(PAY_VER);
		requst.setService_id("015");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		requst.setFinish_amt("1");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthFinishResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//刷脸预授权
	private static void preAuthFacePay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthFacePayRequest,SaobeiPreAuthFacePayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthFacePayRequest requst = new SaobeiPreAuthFacePayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("016");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setAuth_no("123");
		requst.setOrder_body("sdk测试");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthFacePayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//小程序预授权
	private static void preAuthMiniPay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthMiniPayRequest,SaobeiPreAuthMiniPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthMiniPayRequest requst = new SaobeiPreAuthMiniPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("010");
		requst.setService_id("015");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOpen_id("obnG9jhDLvom5fGwuhYysmQTW4qQ");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		requst.setSub_appid("wxe568c727d466aef9");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthMiniPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//公众号预授权
	private static void preAuthJsPay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthJsPayRequest,SaobeiPreAuthJsPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthJsPayRequest requst = new SaobeiPreAuthJsPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("012");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOpen_id("2088912310322292");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthJsPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//预授权聚合码
	private static void preAuthQrH5pay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthQrH5Request,String> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthQrH5Request requst = new SaobeiPreAuthQrH5Request();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		String url = client.execute(requst);
		System.out.println(url);

	}
	//获取预授权聚合码
	private static void preAuthQr() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthQrRequest,SaobeiPreAuthQrResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthQrRequest requst = new SaobeiPreAuthQrRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("010");
		requst.setService_id("016");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthQrResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));
	}

	//条码预授权
	private static void preAuthBar() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPreAuthBarRequest,SaobeiPreAuthBarResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPreAuthBarRequest requst = new SaobeiPreAuthBarRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("010");
		requst.setService_id("010");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setAuth_no("134710461034729972");
		requst.setTotal_fee("1");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPreAuthBarResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//退款订单查询
	private static void fenqiQueryrefund() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiTradeQueryRefundRequest,SaobeiFenqiTradeQueryRefundResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiTradeQueryRefundRequest requst = new SaobeiFenqiTradeQueryRefundRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("041");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_refund_no("109065001011020033011414707236");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiTradeQueryRefundResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	// 关闭订单
	private static void fenqiClose() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiTradeCloseRequest,SaobeiFenqiTradeCloseResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiTradeCloseRequest requst = new SaobeiFenqiTradeCloseRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("040");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiTradeCloseResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//撤销交易(只针对刷卡支付)
	private static void fenqiCancel() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiTradeCancelRequest,SaobeiFenqiTradeCancelResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiTradeCancelRequest requst = new SaobeiFenqiTradeCancelRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("040");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiTradeCancelResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));
	}

	//退款申请
	private static void fenqiRefund() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiTradeRefundRequest,SaobeiFenqiTradeRefundResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiTradeRefundRequest requst = new SaobeiFenqiTradeRefundRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("030");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		requst.setRefund_fee("1");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiTradeRefundResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//分期支付查询
	private static void fenqiQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiTradeQueryRequest,SaobeiFenqiTradeQueryResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiTradeQueryRequest requst = new SaobeiFenqiTradeQueryRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("020");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiTradeQueryResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//小程序支付分期
	private static void fenqiMinipay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiMiniPayRequest,SaobeiFenqiMiniPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiMiniPayRequest requst = new SaobeiFenqiMiniPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("015");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOpen_id("2088912310322292");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		requst.setFenqi_num("6");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiMiniPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//公众号支付分期
	private static void fenqiJspay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiJsPayRequest,SaobeiFenqiJsPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiJsPayRequest requst = new SaobeiFenqiJsPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("012");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOpen_id("2088912310322292");
		requst.setOrder_body("sdk测试");
		requst.setFenqi_num("3");
		requst.setNotify_url("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiJsPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//扫码支付分期
	private static void fenqiPrepay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiPrePayRequest,SaobeiFenqiPrePayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiPrePayRequest requst = new SaobeiFenqiPrePayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("011");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOrder_body("sdk测试");
		requst.setFenqi_num("3");
		requst.setNotify_url("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiPrePayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//付款码支付分期
	private static void fenqiBarcodepay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFenqiBarcodePayRequest,SaobeiFenqiBarcodePayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFenqiBarcodePayRequest requst = new SaobeiFenqiBarcodePayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("010");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setAuth_no("286184372963124813");
		requst.setTotal_fee("1");
		requst.setFenqi_num("3");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFenqiBarcodePayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	private static void allocateCancel() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiAllocateCancelRequest,SaobeiAllocateCancelResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiAllocateCancelRequest requst = new SaobeiAllocateCancelRequest();
		requst.setPay_ver(PAY_VER);
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiAllocateCancelResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//入帐户资金汇总查询
	private static void allocateTotalQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiAllocateTotalQueryRequest,SaobeiAllocateTotalQueryResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiAllocateTotalQueryRequest requst = new SaobeiAllocateTotalQueryRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		requst.setAccount_in("123123");
		requst.setStart_date("20200329");
		requst.setEnd_date("20200330");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiAllocateTotalQueryResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//分账交易查询
	private static void allocateQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiAllocateOrderQueryRequest,SaobeiAllocateOrderQueryResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiAllocateOrderQueryRequest requst = new SaobeiAllocateOrderQueryRequest();
		requst.setPay_ver(PAY_VER);
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiAllocateOrderQueryResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));
	}
	//订单分账
	private static void allocateDo() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiAllocateDoRequest,SaobeiAllocateDoResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiAllocateDoRequest requst = new SaobeiAllocateDoRequest();
		requst.setPay_ver(PAY_VER);
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("123123");
		requst.setContract_no("123123");
		requst.setRule_no("0001");
		String rule_list_json = "[{\"account_in\":\"0000510F2329133\",\"allocate_amt\":\"111\"},{\"account_in\":\"0000510F2329628\",\"allocate_amt\":\"1\"}]";
		requst.setRule_list_json(rule_list_json);
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiAllocateDoResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//分账电子协议查询
	private static void contractQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiContractQueryRequest,SaobeiContractQueryResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiContractQueryRequest requst = new SaobeiContractQueryRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		requst.setContract_no("123123");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiContractQueryResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));
	}

	//分账规则电子协议签署



	private static void contractSign() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiContractSignRequest,SaobeiContractSignResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiContractSignRequest requst = new SaobeiContractSignRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		requst.setContract_no("123123");
		requst.setVerify_no("1234");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiContractSignResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//分账规则电子协议生成
	private static void contractGenerate() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiContractGenerateRequest,SaobeiContractGenerateResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiContractGenerateRequest requst = new SaobeiContractGenerateRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		String rule_list_json ="[{\"rule_no\":\"0001\",\"rules\":[{\"account_in\":\"0000510F2330288\",\"allocate_scale\":\"1000\"}]},{\"rule_no\":\"0002\",\"rules\":[{\"account_in\":\"0000510F2329133\",\"allocate_scale\":\"2000\"},{\"account_in\":\"0000510F2329628\",\"allocate_scale\":\"1500\"}]}]";
		requst.setRule_list_json(rule_list_json);
		requst.setStart_date("20190703");
		requst.setEnd_date("20991231");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiContractGenerateResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//记帐户转账流水查询接口
	private static void transferQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiTransferQueryRequest,SaobeiTransferQueryResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTransferQueryRequest requst = new SaobeiTransferQueryRequest();
		requst.setPay_ver(PAY_VER);
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_transfer_no("123123");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTransferQueryResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//记帐户转账接口
	private static void transferDo() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiTransferDoRequest,SaobeiTransferDoResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTransferDoRequest requst = new SaobeiTransferDoRequest();
		requst.setPay_ver(PAY_VER);
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setTrans_type("1");
		requst.setAccount_out("12123");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTransferDoResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));
	}
	//记帐户转账功能开通
	private static void transferOpen() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiTransferOpenRequest,SaobeiTransferOpenResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiTransferOpenRequest requst = new SaobeiTransferOpenRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTransferOpenResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.4. 查询清算
	private static void withdrawSettleQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiWithDrawSettleQueryRequest,SaobeiWithDrawSettleQueryResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiWithDrawSettleQueryRequest requst = new SaobeiWithDrawSettleQueryRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		requst.setBegin_date("20200321");
		requst.setEnd_date("20200330");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiWithDrawSettleQueryResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}
	//1.2. 发起提现
	private static void withdrawApply() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiWithDrawApplyRequest,SaobeiWithDrawApplyResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiWithDrawApplyRequest requst = new SaobeiWithDrawApplyRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		requst.setAmt("100");
		requst.setFee_amt("1");
		//requst.setApply_type("2");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiWithDrawApplyResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));


	}

	//1.2. 查询提现手续费
	private static void withdrawQueryFee() throws Exception{
		//创建client
		SaobeiApiClient<SaobeiWithDrawQueryFeeRequest,SaobeiWithDrawQueryFeeResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiWithDrawQueryFeeRequest requst = new SaobeiWithDrawQueryFeeRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);
		requst.setAmt("100");

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiWithDrawQueryFeeResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.1. 查询余额
	private static void withdrawQuery() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiWithDrawQueryRequest,SaobeiWithDrawQueryResponse> client = new DefaultSaobeiApiClient<>(KEY);
		//创建requst
		SaobeiWithDrawQueryRequest requst = new SaobeiWithDrawQueryRequest();
		requst.setInst_no(INST_NO);
		requst.setTrace_no(UUID.randomUUID().toString().replace("-",""));
		requst.setMerchant_no(MERCHANT_NO);

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiWithDrawQueryResponse response = client.executeFund(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}


	// 聚合码支付接口
	private static void qrpay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiQrPayRequest,SaobeiQrPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiQrPayRequest requst = new SaobeiQrPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("016");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiQrPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//WAP SDK入口
	private static void wappay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiWapPayRequest,String> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiWapPayRequest requst = new SaobeiWapPayRequest();
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setNotify_url("");
		requst.setOrder_body("");
		requst.setAttach("");
		requst.setAuto_pay("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		String url = client.execute(requst);
		System.out.println(url);

	}

	//2.7. 退款订单查询
	private static void queryrefund() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiTradeQueryRefundRequest,SaobeiTradeQueryRefundResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTradeQueryRefundRequest requst = new SaobeiTradeQueryRefundRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("041");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_refund_no("109065001011020033011414707236");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTradeQueryRefundResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//2.5. 关闭订单
	private static void close()  throws Exception{
		//创建client
		SaobeiApiClient<SaobeiTradeCloseRequest,SaobeiTradeCloseResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTradeCloseRequest requst = new SaobeiTradeCloseRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("041");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065005222320033011383407178");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTradeCloseResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//2.4. 撤销交易(只针对刷卡支付)
	private static void cancel() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiTradeCancelRequest,SaobeiTradeCancelResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTradeCancelRequest requst = new SaobeiTradeCancelRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("040");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTradeCancelResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//2.1. 退款申请
	private static void refund() throws Exception  {
		//创建client
		SaobeiApiClient<SaobeiTradeRefundRequest,SaobeiTradeRefundResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTradeRefundRequest requst = new SaobeiTradeRefundRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("030");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		requst.setRefund_fee("1");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTradeRefundResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));


	}

	//2.1. 支付查询
	private static void query() throws Exception  {
		//创建client
		SaobeiApiClient<SaobeiTradeQueryRequest,SaobeiTradeQueryResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiTradeQueryRequest requst = new SaobeiTradeQueryRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("020");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setOut_trade_no("109065003611120033011263904341");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiTradeQueryResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));


	}

	//1.9. 扫码点餐数据上传
	private static void orderfoodSync() throws Exception {
		//创建client
		SaobeiApiClient<WxScanOrderSyncRequest,WxScanOrderSyncResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		WxScanOrderSyncRequest requst = new WxScanOrderSyncRequest();
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setOpenid("123123");
		//菜品信息
		List<DishBean> dish_list = new ArrayList<DishBean>();
		DishBean dishBean = new DishBean();
		dishBean.setDiscount(1);
		PropertiesBean properties = new PropertiesBean();
		dishBean.setProperties(properties);
		dish_list.add(dishBean);

		requst.setDish_list(dish_list);

		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		WxScanOrderSyncResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.8. 授权码查询 OPENID 接口
	private static void authcodetoopenid() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiAuthCodeToOpenidRequest,SaobeiAuthCodeToOpenidResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiAuthCodeToOpenidRequest requst = new SaobeiAuthCodeToOpenidRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("000");
		requst.setService_id("080");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setAuth_no("134696973500077386");
		requst.setAttach("1111");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiAuthCodeToOpenidResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}


	//1.7. 自助收银SDK调用凭证获取接口
	private static void faceinfo() throws Exception  {
		//创建client
		SaobeiApiClient<SaobeiFaceInfoRequest,SaobeiFaceInfoResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFaceInfoRequest requst = new SaobeiFaceInfoRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("00");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_no(TERMINAL_ID);
		requst.setTerminal_time("20200325220431");
		requst.setRawdata("111");
		requst.setTrace_no("79461CC9493911561F187EA751181B85");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFaceInfoResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.6. 自助收银支付接口
	private static void facepay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiFacePayRequest,SaobeiFacePayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiFacePayRequest requst = new SaobeiFacePayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("016");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setAuth_no("");
		requst.setOrder_body("sdk测试");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiFacePayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.5. 小程序支付接口
	private static void minipay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiMiniPayRequest,SaobeiMiniPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("010");
		requst.setService_id("015");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOpen_id("obnG9jhDLvom5fGwuhYysmQTW4qQ");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		requst.setSub_appid("wxe568c727d466aef9");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiMiniPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.4. APP统一下单
	private static void apppay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiAppPayRequest,SaobeiAppPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiAppPayRequest requst = new SaobeiAppPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("010");
		requst.setService_id("013");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiAppPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//1.3.2. 微信获取access_token(扫码点餐的登录票据)
	private static void authAccessToken() throws Exception {
		//创建client
		SaobeiApiClient<WxAuthAccessTokenRequest,String> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		WxAuthAccessTokenRequest requst = new WxAuthAccessTokenRequest();
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_no(TERMINAL_ID);
		requst.setRedirect_uri("http://test.lcsw.cn:8045/demo/redirect?");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		String url = client.execute(requst);
		System.out.println(url);

	}
	//微信公众号JSAPI支付授权
	private static void authopenid() throws Exception {
		//创建client
		SaobeiApiClient<WxAuthOpenidRequest,String> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		WxAuthOpenidRequest requst = new WxAuthOpenidRequest();
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_no(TERMINAL_ID);
		requst.setRedirect_uri("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		String url = client.execute(requst);
		System.out.println(url);

	}

	//公众号预支付
	private static void jspay() throws Exception  {
		//创建client
		SaobeiApiClient<SaobeiJsPayRequest,SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("012");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOpen_id("2088912310322292");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiJsPayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//扫码支付
	private static void prepay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiPrePayRequest,SaobeiPrePayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiPrePayRequest requst = new SaobeiPrePayRequest();
		requst.setPay_ver(PAY_VER);
		requst.setPay_type("020");
		requst.setService_id("011");
		requst.setMerchant_no(MERCHANT_NO);
		requst.setTerminal_id(TERMINAL_ID);
		requst.setTerminal_trace("202003252204310000");
		requst.setTerminal_time("20200325220431");
		requst.setTotal_fee("1");
		requst.setOrder_body("sdk测试");
		requst.setNotify_url("");
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiPrePayResponse response = client.execute(requst);
		System.out.println("返回报文:"+JSON.toJSONString(response));

	}

	//付款码支付
	private static void barcodepay() throws Exception {
		//创建client
		SaobeiApiClient<SaobeiBarcodePayRequest,SaobeiBarcodePayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN);
		//创建requst
		SaobeiBarcodePayRequest requst = new SaobeiBarcodePayRequest();
		requst.setPay_ver(PAY_VER);//版本号
		requst.setPay_type("010");//支付方式010微信，020 支付宝
		requst.setService_id("010");//接口类型
		requst.setMerchant_no(MERCHANT_NO);//商户号
		requst.setTerminal_id(TERMINAL_ID);//终端号
		requst.setTerminal_trace("202003252204310000");//终端流水号
		requst.setTerminal_time("20200325220431");//终端交易时间
		requst.setAuth_no("134710461034729972");//授权码
		requst.setTotal_fee("1");//金额
		//发送请求
		System.out.println("请求报文:"+JSON.toJSONString(requst));
		SaobeiBarcodePayResponse response = client.execute(requst);
        if ("01".equals(response.getReturn_code())&&"01".equals(response.getResult_code())) {
            System.out.println("调用成功");
        } else {
            System.err.println("调用失败，原因：" + response.getReturn_msg());
        }
		System.out.println("返回报文:"+JSON.toJSONString(response));
	}

}
