mitao
2024-08-14 07057a9a0c8624ec1876670e69b0631b1213793f
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*package com.ruoyi.order.util.tencent.service;
 
import java.util.HashMap;
import java.util.Map;
 
import com.tencent.WXPay;
import com.tencent.common.WXPayUtil;
 
public class WXPayPerformance {
 
 
    private WXPay wxpay;
    private WXPayConfigImpl config;
 
    public WXPayPerformance() throws Exception {
        config = WXPayConfigImpl.getInstance();
        wxpay = new WXPay(config);
    }
 
    *//**
     * 商户 扫码抢 扫码支付
     * @param out_trade_no
     * @param body
     * @param total_fee
     * @param auth_code
     *//*
    public Map<String, String> doMicropayWithPos(String out_trade_no,String body,String total_fee,String auth_code) {
        HashMap<String, String> data = new HashMap<String, String>();
        data.put("out_trade_no", out_trade_no);
        data.put("body", body);
        data.put("total_fee", total_fee);
        data.put("auth_code", auth_code);
        Map<String, String> r=new HashMap<>();
        try {
             r = wxpay.microPayWithPos(data);
            System.out.println(r);
        } catch (Exception e) {            
            e.printStackTrace();
            return r;
        }
        return r;
    }
 
    
    *//**
     * 统一 下单2.0
     *//*
    public Map<String, String> doUnifiedOrder(String out_trade_no,String total_fee,String notify_url) {
        HashMap<String, String> data = new HashMap<String, String>();
        data.put("body", "超级教材");
        data.put("out_trade_no", out_trade_no);
        data.put("device_info", "");
        data.put("fee_type", "CNY");
        data.put("total_fee", total_fee);
        //data.put("spbill_create_ip", "123.12.12.123");
        data.put("notify_url", notify_url);
        data.put("trade_type", "APP");
        //data.put("product_id", "12");
        // data.put("time_expire", "20170112104120");
 
        try {
            Map<String, String> r = wxpay.unifiedOrder(data);
            System.out.println(r);
            return r;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
 
 
    //    public void doReport() {
    //        HashMap<String, String> data = new HashMap<String, String>();
    //        data.put("interface_url", "20160822");
    //        data.put("bill_type", "ALL");
    //    }
 
    *//**
     * 小测试
     *//*
    public void test001() {
        String xmlStr="<xml><return_code><![CDATA[SUCCESS]]></return_code>\n" +
                "<return_msg><![CDATA[OK]]></return_msg>\n" +
                "<appid><![CDATA[wx273fe72f2db863ed]]></appid>\n" +
                "<mch_id><![CDATA[1228845802]]></mch_id>\n" +
                "<nonce_str><![CDATA[lCXjx3wNx45HfTV2]]></nonce_str>\n" +
                "<sign><![CDATA[68D7573E006F0661FD2A77BA59124E87]]></sign>\n" +
                "<result_code><![CDATA[SUCCESS]]></result_code>\n" +
                "<openid><![CDATA[oZyc_uPx_oed7b4q1yKmj_3M2fTU]]></openid>\n" +
                "<is_subscribe><![CDATA[N]]></is_subscribe>\n" +
                "<trade_type><![CDATA[NATIVE]]></trade_type>\n" +
                "<bank_type><![CDATA[CFT]]></bank_type>\n" +
                "<total_fee>1</total_fee>\n" +
                "<fee_type><![CDATA[CNY]]></fee_type>\n" +
                "<transaction_id><![CDATA[4008852001201608221983528929]]></transaction_id>\n" +
                "<out_trade_no><![CDATA[20160822162018]]></out_trade_no>\n" +
                "<attach><![CDATA[]]></attach>\n" +
                "<time_end><![CDATA[20160822202556]]></time_end>\n" +
                "<trade_state><![CDATA[SUCCESS]]></trade_state>\n" +
                "<cash_fee>1</cash_fee>\n" +
                "</xml>";
        try {
            System.out.println(xmlStr);
            System.out.println("+++++++++++++++++");
            System.out.println(WXPayUtil.isSignatureValid(xmlStr, config.getKey()));
            Map<String, String> hm = WXPayUtil.xmlToMap(xmlStr);
            System.out.println("+++++++++++++++++");
            System.out.println(hm);
            System.out.println(hm.get("attach").length());
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
 
    public void testHelloWorld() throws Exception {
        for (int i=0; i<1000; ++i) {
            System.out.println("hi");
            Thread.sleep(1000);
        }
    }
 
 
    public static void main(String[] args) throws Exception {        
       //测试商户扫码支付
        WXPayPerformance dodo = new WXPayPerformance();
        Map<String, String> r =dodo.doMicropayWithPos("11151521","测试","1","130226992988325162");
        if(r.isEmpty()){
            System.out.println("--------------->");
        }else{
            if(r.containsKey("err_code_des")){
                System.out.println("支付失败:"+r.get("err_code_des"));
            }else{
                if(r.get("return_msg").equals("OK")){
                    System.out.println("支付成功:"+r.get("err_code_des"));
                }
            }
        }
         //测试app支付
        WXPayPerformance dodo1 = new WXPayPerformance();
        dodo1.doUnifiedOrder("12121", "1", "http://192.168.1.90:8080/textbook/app/pay/wxpay/notify");
 
    }
}
 
 
*/