|
@@ -17,6 +17,10 @@ import org.springframework.stereotype.Service;
|
17
|
17
|
import org.springframework.transaction.annotation.Transactional;
|
18
|
18
|
|
19
|
19
|
import javax.xml.ws.soap.Addressing;
|
|
20
|
+import java.io.ByteArrayOutputStream;
|
|
21
|
+import java.io.InputStream;
|
|
22
|
+import java.net.HttpURLConnection;
|
|
23
|
+import java.net.URL;
|
20
|
24
|
import java.time.Instant;
|
21
|
25
|
import java.time.LocalDateTime;
|
22
|
26
|
import java.util.HashMap;
|
|
@@ -51,6 +55,9 @@ public class WxPayServiceImpl implements IWxPayService {
|
51
|
55
|
@Autowired
|
52
|
56
|
private TaOrderMapper taOrderMapper;
|
53
|
57
|
|
|
58
|
+ @Autowired
|
|
59
|
+ private TaPersonMapper taPersonMapper;
|
|
60
|
+
|
54
|
61
|
/**
|
55
|
62
|
* 微信支付-统一下单
|
56
|
63
|
*
|
|
@@ -76,6 +83,9 @@ public class WxPayServiceImpl implements IWxPayService {
|
76
|
83
|
String tradeNo = prefix + System.currentTimeMillis() + taOrder.getTargetId();
|
77
|
84
|
taOrder.setTradeNo(tradeNo);
|
78
|
85
|
|
|
86
|
+ //获取personxinx
|
|
87
|
+ TaPerson person = taPersonMapper.getById(taOrder.getPersonId());
|
|
88
|
+
|
79
|
89
|
//下单
|
80
|
90
|
Map<String, String> data = new HashMap<String, String>();
|
81
|
91
|
data.put("body", taOrder.getTargetType().equals(CommConstant.ORDER_TARGET_TYPE_HOUSE) ? "房源认筹" : "微信支付");
|
|
@@ -91,6 +101,8 @@ public class WxPayServiceImpl implements IWxPayService {
|
91
|
101
|
data.put("notify_url", payNotify+taOrder.getTargetType());
|
92
|
102
|
// 此处指定为APP支付
|
93
|
103
|
data.put("trade_type", "JSAPI");
|
|
104
|
+ //openid
|
|
105
|
+ data.put("openid", person.getMiniOpenid());
|
94
|
106
|
Map<String, String> resp = wxpay.unifiedOrder(data);
|
95
|
107
|
log.info("下单成功:{}", resp);
|
96
|
108
|
if (resp.get("result_code").equalsIgnoreCase(WXPayConstants.FAIL)){
|
|
@@ -394,10 +406,23 @@ public class WxPayServiceImpl implements IWxPayService {
|
394
|
406
|
}
|
395
|
407
|
log.info("正在配置orgId为{}的微信支付参数,商户号为{}",orgId,taWxPayConfig.getMchId());
|
396
|
408
|
//把库里的值赋值给微信
|
|
409
|
+ URL urlConet = new URL(taWxPayConfig.getApiPath());
|
|
410
|
+ HttpURLConnection con = (HttpURLConnection)urlConet.openConnection();
|
|
411
|
+ con.setRequestMethod("GET");
|
|
412
|
+ con.setConnectTimeout(4 * 1000);
|
|
413
|
+ InputStream inStream = con .getInputStream();
|
|
414
|
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
|
415
|
+ byte[] buffer = new byte[2048];
|
|
416
|
+ int len = 0;
|
|
417
|
+ while( (len=inStream.read(buffer)) != -1 ){
|
|
418
|
+ outStream.write(buffer, 0, len);
|
|
419
|
+ }
|
|
420
|
+ inStream.close();
|
|
421
|
+
|
397
|
422
|
WxConfig config = new WxConfig();
|
398
|
423
|
config.setAppid(taWxPayConfig.getAppid());
|
399
|
424
|
config.setMachId(taWxPayConfig.getMchId());
|
400
|
|
- config.setApiPath(taWxPayConfig.getApiPath());
|
|
425
|
+ config.setCertData(outStream.toByteArray());
|
401
|
426
|
config.setKey(taWxPayConfig.getMchKey());
|
402
|
427
|
return config;
|
403
|
428
|
}
|