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

import cn.newfeifan.mall.module.pay.fuiou.respVO.FuYouQueryPayOrderResponseVO;
import com.alibaba.fastjson.JSON;
import cn.newfeifan.mall.module.pay.fuiou.reqdata.CommonQueryDataReq;
import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
import com.fasterxml.jackson.databind.ObjectMapper;

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

/**
 * 2.3 订单查询接口
 * @author user
 *
 */
public class CommonQueryClient {
	
	public static void main(String[] args) throws Exception {
		FuiouHttpPoster http = new FuiouHttpPoster();
		http.setCharset("utf-8");
		http.setUrl("https://aipay.fuioupay.com/aggregatePay/commonQuery");
		CommonQueryDataReq req=new CommonQueryDataReq();
		req.setVersion("1.0");
		req.setMchnt_cd(mchnt_cd);
		req.setRandom_str("201707041112123456");
		req.setOrder_type("JSAPI");
		req.setMchnt_order_no("16103-202407112111001");
		req.setTerm_id("88888888");
		String data = MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getOrder_type() + "|" + 
				req.getMchnt_order_no() + "|" + req.getTerm_id() + "|" + req.getRandom_str() + "|" + 
				req.getVersion() + "|" + privateKey);
		req.setSign(data);
		String res = http.newPost(JSON.toJSONString(req));
		System.out.println("====resp====\n");
		System.out.println(res);

		ObjectMapper mapper = new ObjectMapper();
		FuYouQueryPayOrderResponseVO resp = mapper.readValue(res, FuYouQueryPayOrderResponseVO.class);
		System.out.println(resp.getResult_code());
	}

}
