|
|
@@ -75,6 +75,9 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
@Value("${wx.small.appid}")
|
|
|
private String appid;
|
|
|
|
|
|
+ @Value("${wx.gzh.appid}")
|
|
|
+ private String gzhAppid;
|
|
|
+
|
|
|
@Value("${wx.wepay.mchid}")
|
|
|
private String mchid;
|
|
|
|
|
|
@@ -147,6 +150,42 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, String> paymentGzh(String out_trade_no, String openid, String body, String price) {
|
|
|
+ WxSmallConfig config = new WxSmallConfig(gzhAppid,mchid,key);
|
|
|
+ try {
|
|
|
+ WXPay wxpay = new WXPay(config);
|
|
|
+ SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
+
|
|
|
+ Map<String, String> data = new HashMap<String, String>();
|
|
|
+ data.put("body", body);
|
|
|
+ data.put("out_trade_no", out_trade_no);
|
|
|
+ data.put("device_info", "");
|
|
|
+ data.put("fee_type", "CNY");
|
|
|
+ data.put("total_fee", "1");
|
|
|
+ data.put("openid", openid);
|
|
|
+ data.put("spbill_create_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ data.put("notify_url", notifyUrl);
|
|
|
+ data.put("trade_type", "JSAPI");
|
|
|
+ Map<String, String> resp = wxpay.unifiedOrder(data);
|
|
|
+
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
+ // result.put("provider","wxpay");
|
|
|
+ result.put("appId",gzhAppid);
|
|
|
+ result.put("timeStamp",String.valueOf(DateUtils.getNowTime()));
|
|
|
+ result.put("nonceStr",resp.get("nonce_str"));
|
|
|
+ result.put("package","prepay_id="+resp.get("prepay_id"));
|
|
|
+ result.put("signType","MD5");
|
|
|
+ result.put("sign", WXPayUtil.generateSignature(result, key, WXPayConstants.SignType.MD5));
|
|
|
+ // System.out.println(resp);
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String paymentCallBack(String notifyData) {
|
|
|
WxSmallConfig config = new WxSmallConfig(appid,mchid,key);
|