package io.renren.demo;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;

import io.renren.common.security.RSASign;
import io.renren.common.utils.DateUtils;
import io.renren.common.utils.HttpClientUtil;
import io.renren.vo.TransferMorepyeeParams;
import io.renren.vo.TransferMorepyeeParams.OrderInfo;
import io.renren.vo.TransferMorepyeeParams.PayeeInfo;
import io.renren.vo.TransferMorepyeeParams.PayerInfo;

/**
 * 内部代发申请 Demo
 */
public class TransferMorepyeeDemo {
    public static void main(String[] args) throws Exception {
    	String timestamp = DateUtils.getTimestamp();
    	
    	TransferMorepyeeParams params = new TransferMorepyeeParams();
        params.setTimestamp(timestamp);
        params.setOid_partner(Constant.OidPartner);
        params.setNotify_url("https://test.lianlianpay/notify");
        
        OrderInfo orderInfo = params.new OrderInfo();
        orderInfo.setTxn_seqno("NBDF_"+timestamp);
        orderInfo.setTxn_time(timestamp);
        orderInfo.setTotal_amount(new BigDecimal("17"));
        orderInfo.setTxn_purpose("服务费");
        params.setOrderInfo(orderInfo);
        
        PayerInfo payerInfo = params.new PayerInfo();
        payerInfo.setPayer_type("USER");
        payerInfo.setPayer_id("LLianPayTest-En-User-123");
        //payerInfo.setPayer_accttype("USEROWN");
        payerInfo.setPassword(RSASign.getInstance().encrypt("112233",Constant.LLianPayPublicKey));
        params.setPayerInfo(payerInfo);
        
        List<PayeeInfo> list = new ArrayList<>();
        PayeeInfo payeeInfo = params.new PayeeInfo();
//        payeeInfo.setPayee_type("USER");//用户：USER;平台商户：MERCHANT
//        payeeInfo.setPayee_id("LLianPayTest-In-User-12345");
        payeeInfo.setPayee_type("MERCHANT");
        payeeInfo.setPayee_id("2020042200284052");
        payeeInfo.setPayee_accttype("MCHOWN");
        
        //payeeInfo.setPayee_accttype("MCHFEE");
        payeeInfo.setPayee_amount("17");
        list.add(payeeInfo);
        params.setPayeeInfo(list);

        // 测试环境URL
        String url = "https://accpapi-ste.lianlianpay-inc.com/v1/txn/transfer-morepyee";
        String resultJsonStr = HttpClientUtil.sendRequest(url, JSON.toJSONString(params),Constant.MerchantPrivateKey,Constant.LLianPayPublicKey);
        System.out.println(resultJsonStr);

        
    }
}
