cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cn.ksource.web.controller.wxpay;
 
 
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.core.util.HttpCharset;
import cn.ksource.core.util.HttpUtil;
import cn.ksource.web.controller.wxpay.paybean.OrderBean;
import cn.ksource.web.controller.wxpay.paybean.RequestData;
import cn.ksource.web.controller.wxpay.util.CommonUtil;
 
 
public class Demo {
 
    public static void main(String[] args) {
         //解决XStream对出现双下划线的bug
        
        OrderBean orderBean = new OrderBean();
        orderBean.setBody("商品描述");
        orderBean.setAttach("回传参数");
        orderBean.setDetail("商品详情");
        orderBean.setFee_type("CNY");
        orderBean.setGoods_tag("");
        orderBean.setLimit_pay("");
        orderBean.setOpenid("");
        orderBean.setOut_trade_no("code123465");
        orderBean.setProduct_id("pro123456");
        orderBean.setTime_start(DateUtil.getCurrentDate14().toString());
        orderBean.setTime_expire("");
        orderBean.setTotal_fee(ConvertUtil.obj2Int(CommonUtil.getMoney("123")));
        
        
        RequestData requestData = new RequestData(orderBean);
        //将要提交给API的数据对象转换成XML格式数据Post给API
        String postDataXML = CommonUtil.toXML(requestData);
        System.out.println(postDataXML);
        /*String code_url = new GetWxOrderno().getCodeUrl(WxNativeConfig.ewmInterfaceUrl, postDataXML);
        System.out.println("code_url----------------"+code_url);*/
        String result = HttpUtil.doPost(WxNativeConfig.ewmInterfaceUrl, postDataXML, HttpCharset.UTF8);
        System.out.println(result);
        
    }
}