package cn.newfeifan.mall.module.pay.fuiou.client;

import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
import com.alibaba.fastjson.JSON;
import cn.newfeifan.mall.module.pay.fuiou.reqdata.RefundDataReq;

/**
 * 类功能描述
 * RefundClient.java
 * 2.4 退款
 * 
 * @author user
 * @version 0.1.0
 */
public class RefundClient {

	public static String privateKey = "4e092f20607e11e71d2214ad47a356fa";
	
	public static void main(String[] args) throws Exception {
		FuiouHttpPoster http = new FuiouHttpPoster();
		http.setCharset("utf-8");
		http.setUrl("http://192.168.8.45:45002/aggregatePay/commonRefund");
		RefundDataReq req = new RefundDataReq();
		req.setVersion("1.0");
		req.setMchnt_cd("0002900F0370586");
		req.setTerm_id("0a1b0000");
		req.setRandom_str("123456");
		req.setMchnt_order_no("100000000000005");
		req.setRefund_order_no("10000000006");
		req.setOrder_type("WECHAT");
		req.setTotal_amt("1");
		req.setRefund_amt("1");
		StringBuilder sb = new StringBuilder();
		sb.append(req.getMchnt_cd()).append("|").append(req.getOrder_type()).append("|")
		.append(req.getMchnt_order_no()).append("|").append(req.getRefund_order_no())
		.append("|").append(req.getTotal_amt()).append("|").append(req.getRefund_amt())
		.append("|").append(req.getTerm_id()).append("|").append(req.getRandom_str())
		.append("|").append(req.getVersion()).append("|").append(privateKey);
		System.out.println("请求sign："+ sb.toString());
		req.setSign(MD5.MD5Encode(sb.toString(), "UTF-8"));
		String res = http.newPost(JSON.toJSONString(req));
		System.out.println(res);
	}
}
