This commit is contained in:
Carl 2022-01-30 13:26:41 +08:00
parent 59c3378371
commit 3deeab7bc2
2 changed files with 1 additions and 24 deletions

View File

@ -132,7 +132,7 @@ public class OrderController {
returnMap.put("orderNumber", ordersEntity.getOrderNo());
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
// return ResponseDTO.succData(returnMap,wxpayService.generateQRCode(wxPayEntity));
return ResponseDTO.succData(returnMap, wxpayService.testGenerateQRCode(wxPayEntity));
return ResponseDTO.succData(returnMap, wxpayService.generateQRCode(wxPayEntity));
}
}catch (Exception e){
System.out.println(e.getMessage());

View File

@ -48,29 +48,6 @@ public class WxpayService {
String url = "https://miniapp-test.royalcanin.com.cn/rcmini/h5/";
// String url = "https://miniapp-product.royalcanin.com.cn/rcmini2020";
private String urlNative = "https://api.mch.weixin.qq.com/v3/pay/transactions/native";
public String testGenerateQRCode(WxPayEntity wxPayEntity)throws Exception{
String Authorization = "WECHATPAY2-SHA256-RSA2048";
long timestamp = System.currentTimeMillis();
SortedMap<String,String> data = new TreeMap<>();
SortedMap<String, Integer> amount = new TreeMap<>();
amount.put("total",Integer.parseInt(getMoney(wxPayEntity.getTotal_fee())));
data.put("out_trade_no",wxPayEntity.getOut_trade_no());
data.put("notify_url",config.notify_url);
data.put("description","皇家宠物食品官方商城");
data.put("appid",config.getAppID());
data.put("mchid",config.getMchID());
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(data);
jsonObject.put("amount",amount);
SortedMap<String ,String>hearder = new TreeMap<>();
hearder.put("Accept","application/json");
hearder.put("Authorization",Authorization +" mchid="+config.getMchID() +",nonce_str=" + WXPayUtil.generateNonceStr() + ",timestamp=" + timestamp + ",signature=" + WXPayUtil.generateSignature(data, config.getKey()) + ",serial_no=" + config.getKey());
String sb = SmartHttpUtil.httpPostRaw(urlNative,jsonObject.toString(),hearder,"utf-8");
return sb;
}
public String generateQRCode(WxPayEntity wxPayEntity) throws Exception {
WXPay wxpay = new WXPay(config);