3 files deleted
16 files modified
| | |
| | | } |
| | | |
| | | Logger log=Logger.getLogger(HttpRequest.class); |
| | | |
| | | |
| | | //表示请求器是否已经做了初始化工作 |
| | | private boolean hasInit = false; |
| | | |
| | |
| | | |
| | | //HTTP请求器 |
| | | private CloseableHttpClient httpClient; |
| | | //证书地址 |
| | | private String certLocalPath; |
| | | //商户号 |
| | | private String mchId; |
| | | |
| | | public HttpsRequest2() throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException { |
| | | init(); |
| | |
| | | |
| | | private void init() throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException { |
| | | |
| | | KeyStore keyStore = KeyStore.getInstance("PKCS12"); |
| | | FileInputStream instream = new FileInputStream(new File(WechatConfigure.certLocalPath));//加载本地的证书进行https加密传输 |
| | | KeyStore keyStore = KeyStore.getInstance("PKCS12"); |
| | | FileInputStream instream = new FileInputStream(new File(certLocalPath));//加载本地的证书进行https加密传输 |
| | | try { |
| | | keyStore.load(instream,WechatConfigure.certPassword.toCharArray());//设置证书密码 |
| | | keyStore.load(instream, mchId.toCharArray());//设置证书密码 |
| | | } catch (CertificateException e) { |
| | | e.printStackTrace(); |
| | | } catch (NoSuchAlgorithmException e) { |
| | |
| | | } |
| | | // Trust own CA and all self-signed certs |
| | | SSLContext sslcontext = SSLContexts.custom() |
| | | .loadKeyMaterial(keyStore, WechatConfigure.certPassword.toCharArray()) |
| | | .loadKeyMaterial(keyStore, mchId.toCharArray()) |
| | | .build(); |
| | | // Allow TLSv1 protocol only |
| | | SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( |
| | |
| | | null, |
| | | SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); |
| | | |
| | | |
| | | httpClient = HttpClients.custom() |
| | | |
| | | httpClient = HttpClients.custom() |
| | | .setSSLSocketFactory(sslsf) |
| | | .build(); |
| | | // httpClient = HttpClients.custom().build(); |
| | | // httpClient = HttpClients.custom().build(); |
| | | //根据默认超时限制初始化requestConfig |
| | | requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build(); |
| | | hasInit = true; |
| | |
| | | httpPost.setConfig(requestConfig); |
| | | |
| | | log.info("executing request" + httpPost.getRequestLine()); |
| | | |
| | | |
| | | try { |
| | | HttpResponse response = httpClient.execute(httpPost); |
| | | |
| | | HttpEntity entity = response.getEntity(); |
| | | |
| | | result = EntityUtils.toString(entity, "UTF-8"); |
| | | |
| | | |
| | | log.info("POST back date:" + httpPost.getRequestLine()); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } catch (ConnectionPoolTimeoutException e) { |
| | | // log.e("http get throw ConnectionPoolTimeoutException(wait time out)"); |
| | |
| | | // log.e("http get throw SocketTimeoutException"); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | e.printStackTrace(); |
| | | // log.e("http get throw Exception"); |
| | | |
| | | } finally { |
| | |
| | | * @param socketTimeout 连接时长,默认10秒 |
| | | */ |
| | | public void setSocketTimeout(int socketTimeout) { |
| | | this.socketTimeout = socketTimeout; |
| | | this.socketTimeout = socketTimeout; |
| | | resetRequestConfig(); |
| | | } |
| | | |
| | |
| | | * @param connectTimeout 传输时长,默认30秒 |
| | | */ |
| | | public void setConnectTimeout(int connectTimeout) { |
| | | this.connectTimeout = connectTimeout; |
| | | this.connectTimeout = connectTimeout; |
| | | resetRequestConfig(); |
| | | } |
| | | |
| | |
| | | * @param requestConfig 设置HttpsRequest的请求器配置 |
| | | */ |
| | | public void setRequestConfig(RequestConfig requestConfig) { |
| | | this.requestConfig = requestConfig; |
| | | this.requestConfig = requestConfig; |
| | | } |
| | | |
| | | |
| | | public String getMchId() { |
| | | return mchId; |
| | | } |
| | | |
| | | public void setMchId(String mchId) { |
| | | this.mchId = mchId; |
| | | } |
| | | |
| | | public String getCertLocalPath() { |
| | | return certLocalPath; |
| | | } |
| | | |
| | | public void setCertLocalPath(String certLocalPath) { |
| | | this.certLocalPath = certLocalPath; |
| | | } |
| | | } |
| | |
| | | * @return 签名 |
| | | * @throws IllegalAccessException |
| | | */ |
| | | public static String getSign(Object o) throws IllegalAccessException { |
| | | public static String getSign(Object o,String paySecret) throws IllegalAccessException { |
| | | ArrayList<String> list = new ArrayList<String>(); |
| | | Class<? extends Object> cls = o.getClass(); |
| | | Field[] fields = cls.getDeclaredFields(); |
| | |
| | | sb.append(arrayToSort[i]); |
| | | } |
| | | String result = sb.toString(); |
| | | result += "key=" + WechatConfigure.key; |
| | | result += "key=" +paySecret; |
| | | Util.log("Sign Before MD5:" + result); |
| | | result = MD5.MD5Encode(result).toUpperCase(); |
| | | Util.log("Sign Result:" + result); |
| | | return result; |
| | | } |
| | | |
| | | public static String getSign(Map<String, Object> map) { |
| | | public static String getSign(Map<String, Object> map,String paySecret) { |
| | | ArrayList<String> list = new ArrayList<String>(); |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | if (entry.getValue() != "") { |
| | |
| | | sb.append(arrayToSort[i]); |
| | | } |
| | | String result = sb.toString(); |
| | | result += "key=" + WechatConfigure.key; |
| | | result += "key=" + paySecret; |
| | | Util.log("Sign Before MD5:" + result); |
| | | result = MD5.MD5Encode(result).toUpperCase(); |
| | | Util.log("Sign Result:" + result); |
| | |
| | | * @throws IOException |
| | | * @throws SAXException |
| | | */ |
| | | public static String getSignFromResponseString(String responseString) |
| | | public static String getSignFromResponseString(String responseString,String paySecret) |
| | | throws IOException, SAXException, ParserConfigurationException { |
| | | Map<String, Object> map = XMLParser.getMapFromXML(responseString); |
| | | // 清掉返回数据对象里面的Sign数据(不能把这个数据也加进去进行签名),然后用签名算法进行签名 |
| | | map.put("sign", ""); |
| | | // 将API返回的数据根据用签名算法进行计算新的签名,用来跟API返回的签名进行比较 |
| | | return Signature.getSign(map); |
| | | return Signature.getSign(map,paySecret); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws IOException |
| | | * @throws SAXException |
| | | */ |
| | | public static boolean checkIsSignValidFromResponseString(String responseString) |
| | | public static boolean checkIsSignValidFromResponseString(String responseString,String paySecret) |
| | | throws ParserConfigurationException, IOException, SAXException { |
| | | |
| | | Map<String, Object> map = XMLParser.getMapFromXML(responseString); |
| | |
| | | // 清掉返回数据对象里面的Sign数据(不能把这个数据也加进去进行签名),然后用签名算法进行签名 |
| | | map.put("sign", ""); |
| | | // 将API返回的数据根据用签名算法进行计算新的签名,用来跟API返回的签名进行比较 |
| | | String signForAPIResponse = Signature.getSign(map); |
| | | String signForAPIResponse = Signature.getSign(map,paySecret); |
| | | |
| | | if (!signForAPIResponse.equals(signFromAPIResponse)) { |
| | | // 签名验不过,表示这个API返回的数据有可能已经被篡改了 |
| | |
| | | return true; |
| | | } |
| | | |
| | | public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException { |
| | | System.out.println(checkIsSignValidFromResponseString("<xml><appid><![CDATA[wx13515a9204ea669d]]></appid><attach><![CDATA[35f7170585ad4f09b5109cc985b1eec0]]></attach><bank_type><![CDATA[CFT]]></bank_type><cash_fee><![CDATA[1]]></cash_fee><fee_type><![CDATA[CNY]]></fee_type><is_subscribe><![CDATA[N]]></is_subscribe><mch_id><![CDATA[1486409192]]></mch_id><nonce_str><![CDATA[elqhnr10vzaq0wgalf9njjyqwyd7gyr7]]></nonce_str><openid><![CDATA[o8x8E5lqmD9c5rdsjTQ9KWN4-H40]]></openid><out_trade_no><![CDATA[2018090610284198419]]></out_trade_no><result_code><![CDATA[SUCCESS]]></result_code><return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[DD04172CDAA60F834163AF3F5B63BE3F]]></sign><time_end><![CDATA[20180906102853]]></time_end><total_fee>1</total_fee><trade_type><![CDATA[JSAPI]]></trade_type><transaction_id><![CDATA[4200000169201809067369627940]]></transaction_id></xml>")); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | |
| | | // 这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中) |
| | | // 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证 |
| | | // 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改 |
| | | public static final String PAY_NOTIFY_URL="https://xcxhive2.jyymatrix.cc/wxCommon/wxpayCallback"; |
| | | |
| | | // 交易类型 |
| | | public static final String TRADE_TYPE_JSAPI = "JSAPI"; |
| | | public static final String TRADE_TYPE_NATIVE = "NATIVE"; |
| | |
| | | public static final String SIGN_MD5 = "MD5"; |
| | | //域名 |
| | | |
| | | |
| | | // 微信支付秘钥 |
| | | public static String key = "3hbNHPOSXx85rC0QEqvGgIHu1wduT4Qc"; |
| | | |
| | | // 微信分配的公众号ID(开通公众号之后可以获取到) |
| | | public static String appID = "wx3836ab3c1490ff29"; |
| | | |
| | | |
| | | |
| | | // 微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到) |
| | | public static String mchID = "1573208361"; |
| | | |
| | | |
| | | public static String web_appID = "1486409192"; |
| | | |
| | | // 受理模式下给子商户分配的子商户号 |
| | | public static String subMchID = ""; |
| | | |
| | | // HTTPS证书的本地路径 |
| | | public static String certLocalPath = "/home/cert/apiclient_cert.p12"; |
| | | |
| | | // HTTPS证书密码,默认密码等于商户号MCHID |
| | | public static String certPassword = "1573208361"; |
| | | |
| | | |
| | | // 是否使用异步线程的方式来上报API测速,默认为异步模式 |
| | | public static boolean useThreadToDoReport = true; |
| | |
| | | private String signType = ""; |
| | | private String paySign = ""; |
| | | |
| | | public BrandWCPayRequestData(String prepay_id){ |
| | | public BrandWCPayRequestData(String prepay_id,String appID,String paySecret){ |
| | | //默认必须设置 |
| | | setAppId(WechatConfigure.appID); |
| | | setAppId(appID); |
| | | //随机字符串,不长于32 位 |
| | | setNonceStr(RandomStringGenerator.getRandomStringByLength(32)); |
| | | setTimeStamp(Long.toString(System.currentTimeMillis() / 1000L)); |
| | | setPrepay_id("prepay_id="+prepay_id); |
| | | //根据API给的签名规则进行签名 【 必须要放在本方法的最后】 |
| | | setSignType(WechatConfigure.SIGN_MD5); |
| | | String sign = Signature.getSign(toMap()); |
| | | String sign = Signature.getSign(toMap(),paySecret); |
| | | setPaySign(sign);//把签名数据设置到Sign这个属性中 |
| | | } |
| | | |
| | |
| | | * @param bankTrueName 收款号姓名 |
| | | * @param bankCode 收款号开户行 |
| | | */ |
| | | public JsApiPayComReqData(String desc, String outTradeNo, int totalFee, String bankNo, String bankTrueName, String bankCode) { |
| | | public JsApiPayComReqData(String mchID,String paySecret ,String desc, String outTradeNo, int totalFee, String bankNo, String bankTrueName, String bankCode) { |
| | | //默认必须设置 |
| | | setMch_id(WechatConfigure.mchID); |
| | | setMch_id(mchID); |
| | | setDesc(desc); |
| | | setPartner_trade_no(outTradeNo); |
| | | setAmount(totalFee); |
| | | //随机字符串,不长于32 位 |
| | | setNonce_str(RandomStringGenerator.getRandomStringByLength(32)); |
| | | //根据API给的签名规则进行签名 【 必须要放在本方法的最后】 |
| | | String sign = Signature.getSign(toMap()); |
| | | String sign = Signature.getSign(toMap(),paySecret); |
| | | setSign(sign);//把签名数据设置到Sign这个属性中 |
| | | // setEnc_bank_no(); |
| | | // setEnc_true_name(); |
| | |
| | | /** |
| | | * 接收微信支付异步通知回调地址 |
| | | */ |
| | | private String notify_url = WechatConfigure.PAY_NOTIFY_URL; |
| | | private String trade_type = WechatConfigure.TRADE_TYPE_JSAPI; |
| | | private String notify_url ; |
| | | private String openid = ""; |
| | | private String limit_pay = ""; |
| | | private String spbill_create_ip = ""; |
| | |
| | | public JsApiPayReqData() { |
| | | } |
| | | |
| | | /** |
| | | /**appID 收款应用id |
| | | * mchID 商户号 |
| | | * @param authCode 这个是扫码终端设备从用户手机上扫取到的支付授权号,这个号是跟用户用来支付的银行卡绑定的,有效期是1分钟 |
| | | * @param body 要支付的商品的描述信息,用户会在支付成功页面里看到这个信息 |
| | | * @param attach 支付订单里面可以填的附加数据,API会将提交的这个附加数据原样返回 |
| | |
| | | * @param timeExpire 订单失效时间,格式同上 |
| | | * @param goodsTag 商品标记,微信平台配置的商品标记,用于优惠券或者满减使用 |
| | | */ |
| | | public JsApiPayReqData(String body,String outTradeNo,int totalFee,String spBillCreateIP,String openid,String attach){ |
| | | public JsApiPayReqData(String appID, String mchID,String paySecret,String notify_url, String body,String outTradeNo,int totalFee,String spBillCreateIP,String openid,String attach){ |
| | | //默认必须设置 |
| | | setAppid(WechatConfigure.appID); |
| | | setMch_id(WechatConfigure.mchID); |
| | | setAppid(appID); |
| | | setMch_id(mchID); |
| | | setNotify_url(notify_url); |
| | | setBody(body); |
| | | setOut_trade_no(outTradeNo); |
| | | setTotal_fee(totalFee); |
| | |
| | | setNonce_str(RandomStringGenerator.getRandomStringByLength(32)); |
| | | setOpenid(openid); |
| | | //根据API给的签名规则进行签名 【 必须要放在本方法的最后】 |
| | | String sign = Signature.getSign(toMap()); |
| | | String sign = Signature.getSign(toMap(),paySecret); |
| | | setSign(sign);//把签名数据设置到Sign这个属性中 |
| | | |
| | | } |
| | | |
| | | public JsApiPayReqData(String body,String outTradeNo,int totalFee,String spBillCreateIP,String attach){ |
| | | public JsApiPayReqData(String appID, String mchID,String paySecret,String notify_url,String body,String outTradeNo,int totalFee,String spBillCreateIP,String attach){ |
| | | //默认必须设置 |
| | | setAppid(WechatConfigure.web_appID); |
| | | setMch_id(WechatConfigure.mchID); |
| | | setAppid(appID); |
| | | setMch_id(mchID); |
| | | setBody(body); |
| | | setNotify_url(notify_url); |
| | | setOut_trade_no(outTradeNo); |
| | | setTotal_fee(totalFee); |
| | | setSpbill_create_ip(spBillCreateIP); |
| | |
| | | //随机字符串,不长于32 位 |
| | | setNonce_str(RandomStringGenerator.getRandomStringByLength(32)); |
| | | //根据API给的签名规则进行签名 【 必须要放在本方法的最后】 |
| | | String sign = Signature.getSign(toMap()); |
| | | String sign = Signature.getSign(toMap(),paySecret); |
| | | setSign(sign);//把签名数据设置到Sign这个属性中 |
| | | } |
| | | |
| | |
| | | //-------------------------------------------------------------------- |
| | | |
| | | //微信分配的公众号ID(开通公众号之后可以获取到) |
| | | setAppid(WechatConfigure.appID); |
| | | //setAppid(WechatConfigure.appID); |
| | | |
| | | //微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到) |
| | | setMch_id(WechatConfigure.mchID); |
| | | // setMch_id(WechatConfigure.mchID); |
| | | |
| | | //transaction_id是微信系统为每一笔支付交易分配的订单号,通过这个订单号可以标识这笔交易,它由支付订单API支付成功时返回的数据里面获取到。 |
| | | setTransaction_id(transactionID); |
| | |
| | | setNonce_str(RandomStringGenerator.getRandomStringByLength(32)); |
| | | |
| | | //根据API给的签名规则进行签名 |
| | | String sign = Signature.getSign(toMap()); |
| | | //String sign = Signature.getSign(toMap()); |
| | | setSign(sign);//把签名数据设置到Sign这个属性中 |
| | | |
| | | |
| | |
| | | * @param opUserID 操作员帐号, 默认为商户号 |
| | | * @param refundFeeType 货币类型,符合ISO 4217标准的三位字母代码,默认为CNY(人民币) |
| | | */ |
| | | public RefundReqData(String outTradeNo,String outRefundNo,int totalFee,int refundFee,String opUserID){ |
| | | public RefundReqData(String mchID,String appID,String paySecret ,String outTradeNo,String outRefundNo,int totalFee,int refundFee,String opUserID){ |
| | | |
| | | //微信分配的公众号ID(开通公众号之后可以获取到) |
| | | setAppid(WechatConfigure.appID); |
| | | setAppid(mchID); |
| | | |
| | | //微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到) |
| | | setMch_id(WechatConfigure.mchID); |
| | | setMch_id(appID); |
| | | |
| | | //transaction_id是微信系统为每一笔支付交易分配的订单号,通过这个订单号可以标识这笔交易,它由支付订单API支付成功时返回的数据里面获取到。 |
| | | //setTransaction_id(transactionID); |
| | |
| | | setNonce_str(RandomStringGenerator.getRandomStringByLength(32)); |
| | | |
| | | //根据API给的签名规则进行签名 |
| | | String sign = Signature.getSign(toMap()); |
| | | String sign = Signature.getSign(toMap(),paySecret); |
| | | setSign(sign);//把签名数据设置到Sign这个属性中 |
| | | |
| | | } |
| | |
| | | public void setServiceRequest(IServiceRequest request){ |
| | | serviceRequest = request; |
| | | } |
| | | |
| | | public IServiceRequest getServiceRequest() { |
| | | return serviceRequest; |
| | | } |
| | | } |
| | |
| | | package com.matrix.component.wechat.externalInterface.weixinUtil; |
| | | |
| | | import com.matrix.component.wechat.externalInterface.common.HttpsRequest2; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | |
| | | import com.matrix.component.wechat.externalInterface.service.JsApiPayComService; |
| | | import com.matrix.component.wechat.externalInterface.service.RefundService; |
| | | import com.matrix.component.wechat.externalInterface.service.ScanPayQueryService; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.interceptor.HostInterceptor; |
| | | import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private WxShopOrderUtil wxShopOrderUtil; |
| | | |
| | | @Autowired |
| | | BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 支付"175.9.82.254" |
| | |
| | | // 创建微信支付预付接口 |
| | | JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); |
| | | String idAddr = getIpAddr(WebUtil.getRequest()); |
| | | JsApiPayReqData jsApiPayReqData = new JsApiPayReqData(desc, outTradeNo, price, idAddr, openId, attach); |
| | | |
| | | Long companyId=HostInterceptor.getCompanyId(); |
| | | |
| | | BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId); |
| | | BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId); |
| | | BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_NOTIFYURL, companyId); |
| | | |
| | | BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId); |
| | | |
| | | JsApiPayReqData jsApiPayReqData = new JsApiPayReqData(appId.getParamValue(),mchID.getParamValue(), |
| | | paySecret.getParamValue(), |
| | | notifyUrl.getParamValue(), |
| | | desc, outTradeNo, price, idAddr, openId, attach); |
| | | |
| | | // 创建预付订单并返回请求结果 |
| | | JsApiPayResData result = jsApiPayBusiness.createPrapareOrder(jsApiPayReqData); |
| | | // 把预付订单的信息存放在request域中 |
| | |
| | | LogUtil.info("#---签名信息:return_msg = {}" , result.getReturn_msg()); |
| | | if (result.getReturn_code().equals("SUCCESS")) { |
| | | // 请求成功, 构建BrandWCPayRequest发起支付需要的参数 |
| | | BrandWCPayRequestData payData = new BrandWCPayRequestData(result.getPrepay_id()); |
| | | BrandWCPayRequestData payData = new BrandWCPayRequestData(result.getPrepay_id(),appId.getParamValue(),paySecret.getParamValue()); |
| | | WebUtil.getRequest().setAttribute("payData", payData); |
| | | return payData; |
| | | }else{ |
| | |
| | | * @param desc 描述 |
| | | * @param outTradeNo 提现申请编号 |
| | | * @param totalFee 提现金额(分) |
| | | * @param spBillCreateIP 调用接口的IP |
| | | * @param openid |
| | | * @return |
| | | */ |
| | |
| | | try { |
| | | JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); |
| | | // TODO 企业付款 |
| | | JsApiPayComReqData jsApiPayComReqData=new JsApiPayComReqData("","",0,"","",""); |
| | | Long companyId=HostInterceptor.getCompanyId(); |
| | | BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId); |
| | | BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId); |
| | | |
| | | |
| | | JsApiPayComReqData jsApiPayComReqData=new JsApiPayComReqData(mchID.getParamValue(),paySecret.getParamValue(),"","",0,"","",""); |
| | | JsApiPayComService jsApiPayComService=new JsApiPayComService(); |
| | | result = jsApiPayBusiness.payComOrder(jsApiPayComService, jsApiPayComReqData); |
| | | LogUtil.info("#提现,企业付款到个人---result:{}",result); |
| | |
| | | int refundFee, String opUserID){ |
| | | LogUtil.info("#---outTradeNo:{}#---outRefundNo:{}#---totalFee:{}#---refundFee:{}", |
| | | outTradeNo,outRefundNo,totalFee,refundFee); |
| | | BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, HostInterceptor.getCompanyId()); |
| | | if(opUserID==null){ |
| | | opUserID=WechatConfigure.mchID; |
| | | opUserID=mchID.getParamValue(); |
| | | } |
| | | RefundResData result=null; |
| | | boolean flag=false; |
| | | try { |
| | | JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); |
| | | RefundReqData refundReqData=new RefundReqData(outTradeNo, outRefundNo, totalFee, refundFee,opUserID); |
| | | Long companyId=HostInterceptor.getCompanyId(); |
| | | BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId); |
| | | BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_APPID, companyId); |
| | | BusParameterSettings certLocalPath = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_CERTLOCAL_PATH, companyId); |
| | | |
| | | RefundReqData refundReqData=new RefundReqData(mchID.getParamValue(),appId.getParamValue(),paySecret.getParamValue(), outTradeNo, outRefundNo, totalFee, refundFee,opUserID); |
| | | RefundService refundService=new RefundService(); |
| | | HttpsRequest2 request2= (HttpsRequest2) refundService.getServiceRequest(); |
| | | request2.setCertLocalPath(certLocalPath.getParamValue()); |
| | | request2.setMchId(mchID.getParamValue()); |
| | | |
| | | result = jsApiPayBusiness.refundComOrder(refundService, refundReqData); |
| | | LogUtil.info("#退款,企业付款到个人---result:{}",result); |
| | | //如果返回余额不足时 |
| | |
| | | * @return |
| | | */ |
| | | public String getIpAddr(HttpServletRequest request) { |
| | | String ip = request.getHeader("x-forwarded-for"); |
| | | /* if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("Proxy-Client-IP"); |
| | | } |
| | | if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("WL-Proxy-Client-IP"); |
| | | String ip = request.getHeader("x-forwarded-for"); |
| | | /* if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("Proxy-Client-IP"); |
| | | } |
| | | if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("WL-Proxy-Client-IP"); |
| | | } */ |
| | | if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getRemoteAddr(); |
| | |
| | | */ |
| | | public static final String GZH_APPID = "gzhAppId"; |
| | | |
| | | /** |
| | | * 微信商户号 |
| | | */ |
| | | public static final String WECHARPAY_APPID = "wecharPayAppid"; |
| | | /** |
| | | * 支付秘钥 |
| | | */ |
| | | public static final String WECHARPAY_SECRET = "wecharPaySecret"; |
| | | |
| | | /** |
| | | * 支付通知地址 |
| | | */ |
| | | public static final String WECHARPAY_NOTIFYURL = "wecharPaynotifyUrl"; |
| | | /** |
| | | * 支付证书地址 |
| | | */ |
| | | public static final String WECHARPAY_CERTLOCAL_PATH = "certLocalPath"; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | int reMoney = b1.multiply(bb).intValue(); |
| | | LogUtil.info("退款退款金额{}", reMoney); |
| | | |
| | | //Double refundMoney = 0.1 * 100; |
| | | //用户ID |
| | | String userId = WechatConfigure.mchID; |
| | | |
| | | |
| | | if (isDebug) { |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, userId); |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, null); |
| | | flag = b; |
| | | } else { |
| | | LogUtil.info("开始调用退款接口。。。退款编号为{}", refundNo); |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, userId); |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, null); |
| | | flag = b; |
| | | } |
| | | |
| | |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.interceptor.HostInterceptor; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.ShoppingGoods; |
| | | import com.matrix.system.hive.dao.ShoppingGoodsDao; |
| | |
| | | import com.matrix.component.wechat.externalInterface.common.Signature; |
| | | import com.matrix.component.wechat.externalInterface.common.Util; |
| | | import com.matrix.component.wechat.externalInterface.protocol.queryProtocol.NotifyData; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.interceptor.HostInterceptor; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin; |
| | |
| | | @Autowired |
| | | private SysVipInfoDao sysVipInfoDao; |
| | | |
| | | @Autowired |
| | | BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @RequestMapping(value = "/wxpayCallback") |
| | | @RequestMapping(value = "/wxapi/wxpayCallback") |
| | | public void payCallBack(HttpServletResponse response, HttpServletRequest request) throws IOException { |
| | | LogUtil.info("微信支付回调start...."); |
| | | |
| | |
| | | // 返回状态码 SUCCESS/FAIL |
| | | if (AppConstance.CODE_SUCCESS.equals(data.getReturn_code())) { |
| | | // 校验签名 |
| | | if (Signature.checkIsSignValidFromResponseString(notityXml.toString())) { |
| | | BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, HostInterceptor.getCompanyId()); |
| | | if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret.getParamValue())) { |
| | | // 校验业务结果 |
| | | if (AppConstance.CODE_SUCCESS.equals(data.getResult_code())) { |
| | | // 返回SUCCESS报文 |
| | |
| | | |
| | | //Double refundMoney = 0.1 * 100; |
| | | //用户ID |
| | | String userId = WechatConfigure.mchID; |
| | | |
| | | if (isDebug) { |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, userId); |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, null); |
| | | flag = b; |
| | | } else { |
| | | LogUtil.info("开始调用退款接口。。。退款编号为", refundNo); |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, userId); |
| | | boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, orMoney, reMoney, null); |
| | | flag = b; |
| | | } |
| | | |
| | |
| | | #是否启用debug模式 |
| | | debug=true |
| | | debug=false |
| | | # 日志文件保存地址 |
| | | log_path=/mnt/hive/log-test |
| | | |