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;

import static cn.newfeifan.mall.module.pay.enums.DictTypeConstants.*;

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


	public static void main(String[] args) throws Exception {
		FuiouHttpPoster http = new FuiouHttpPoster();
		http.setCharset("utf-8");
		http.setUrl("https://aipay.fuioupay.com/aggregatePay/commonRefund");
		RefundDataReq req = new RefundDataReq();
		req.setVersion("1.0");
		req.setMchnt_cd(mchnt_cd);
		req.setTerm_id(term_id);
		req.setRandom_str("20240713175056568974");
		req.setMchnt_order_no("16103-202408301647291");
		req.setRefund_order_no("16103-202408301647299");
		req.setOrder_type("WECHAT");
		req.setTotal_amt("2");
		req.setRefund_amt("2");
		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);
		req.setSign(MD5.MD5Encode(sb.toString(), "UTF-8"));
		String res = http.newPost(JSON.toJSONString(req));
		System.out.println(res);
	}
}
