|  |  |  | 
|---|
|  |  |  | import com.dsh.account.feignclient.other.model.SiteBooking; | 
|---|
|  |  |  | import com.dsh.account.mapper.RechargeRecordsMapper; | 
|---|
|  |  |  | import com.dsh.account.util.httpClinet.HttpClientUtil; | 
|---|
|  |  |  | import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReceiver; | 
|---|
|  |  |  | import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest; | 
|---|
|  |  |  | import com.github.binarywang.wxpay.service.ProfitSharingV3Service; | 
|---|
|  |  |  | import com.github.binarywang.wxpay.service.WxPayService; | 
|---|
|  |  |  | //import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReceiver; | 
|---|
|  |  |  | //import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest; | 
|---|
|  |  |  | //import com.github.binarywang.wxpay.service.ProfitSharingV3Service; | 
|---|
|  |  |  | //import com.github.binarywang.wxpay.service.WxPayService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.commons.collections.map.HashedMap; | 
|---|
|  |  |  | import org.apache.http.client.methods.CloseableHttpResponse; | 
|---|
|  |  |  | import org.bouncycastle.jce.provider.BouncyCastleProvider; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String key = "";//微信商户号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String callbackPath = "";//支付回调网关地址 | 
|---|
|  |  |  | private String callbackPath = "8.137.22.229:56666/account";//支付回调网关地址 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String app_cert_path = "C:/cert/alipay/user/app_cert_path.crt";//应用公钥证书路径 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private String certPath = "C:\\cert\\1523106371_20211206_cert\\apiclient_cert.p12";//微信证书 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付宝支付 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil alipay(String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl){ | 
|---|
|  |  |  | public ResultUtil alipay(String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) { | 
|---|
|  |  |  | //        //构造client | 
|---|
|  |  |  | //        CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); | 
|---|
|  |  |  | //        //设置网关地址 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //分账 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer    coursePackagePayments = coursePackageClient.queryByCode(outTradeNo); | 
|---|
|  |  |  | Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo); | 
|---|
|  |  |  | Integer siteBookings = siteClient.queryByCode(outTradeNo); | 
|---|
|  |  |  | List<Integer> stores = new ArrayList<>(); | 
|---|
|  |  |  | stores.add(coursePackagePayments); | 
|---|
|  |  |  | stores.add(paymentCompetitions); | 
|---|
|  |  |  | stores.add(siteBookings); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | OperatorUser operatorUser = siteClient.queryOperator(stores); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String alipayProportion = operatorUser.getAlipayProportion(); | 
|---|
|  |  |  | String alipayNum = operatorUser.getAlipayNum(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ExtendParams extendParams = new ExtendParams(); | 
|---|
|  |  |  | //        extendParams.setSysServiceProviderId("YOUR_SERVICE_PROVIDER_ID"); | 
|---|
|  |  |  | model.setExtendParams(extendParams); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RoyaltyInfo royaltyInfo = new RoyaltyInfo(); | 
|---|
|  |  |  | //        royaltyInfo.setRoyaltyType("transfer"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RoyaltyDetailInfos royaltyDetailInfo1 = new RoyaltyDetailInfos(); | 
|---|
|  |  |  | royaltyDetailInfo1.setTransOutType("userId"); | 
|---|
|  |  |  | royaltyDetailInfo1.setTransOut(aliAppid); | 
|---|
|  |  |  | royaltyDetailInfo1.setTransInType("loginName"); | 
|---|
|  |  |  | royaltyDetailInfo1.setTransIn("18398968484"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | royaltyDetailInfo1.setDesc("分账描述1"); | 
|---|
|  |  |  | royaltyDetailInfo1.setAmountPercentage(alipayProportion); | 
|---|
|  |  |  | List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | royaltyInfo.setRoyaltyDetailInfos(royaltyDetailInfos); | 
|---|
|  |  |  | model.setRoyaltyInfo(royaltyInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        Integer    coursePackagePayments = coursePackageClient.queryByCode(outTradeNo); | 
|---|
|  |  |  | //        Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo); | 
|---|
|  |  |  | //        Integer siteBookings = siteClient.queryByCode(outTradeNo); | 
|---|
|  |  |  | //        List<Integer> stores = new ArrayList<>(); | 
|---|
|  |  |  | //        stores.add(coursePackagePayments); | 
|---|
|  |  |  | //        stores.add(paymentCompetitions); | 
|---|
|  |  |  | //        stores.add(siteBookings); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        OperatorUser operatorUser = siteClient.queryOperator(stores); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        String alipayProportion = operatorUser.getAlipayProportion(); | 
|---|
|  |  |  | //        String alipayNum = operatorUser.getAlipayNum(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        ExtendParams extendParams = new ExtendParams(); | 
|---|
|  |  |  | ////        extendParams.setSysServiceProviderId("YOUR_SERVICE_PROVIDER_ID"); | 
|---|
|  |  |  | //        model.setExtendParams(extendParams); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        RoyaltyInfo royaltyInfo = new RoyaltyInfo(); | 
|---|
|  |  |  | ////        royaltyInfo.setRoyaltyType("transfer"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        RoyaltyDetailInfos royaltyDetailInfo1 = new RoyaltyDetailInfos(); | 
|---|
|  |  |  | //        royaltyDetailInfo1.setTransOutType("userId"); | 
|---|
|  |  |  | //        royaltyDetailInfo1.setTransOut(aliAppid); | 
|---|
|  |  |  | //        royaltyDetailInfo1.setTransInType("loginName"); | 
|---|
|  |  |  | //        royaltyDetailInfo1.setTransIn("18398968484"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        royaltyDetailInfo1.setDesc("分账描述1"); | 
|---|
|  |  |  | //        royaltyDetailInfo1.setAmountPercentage(alipayProportion); | 
|---|
|  |  |  | //        List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        royaltyInfo.setRoyaltyDetailInfos(royaltyDetailInfos); | 
|---|
|  |  |  | //        model.setRoyaltyInfo(royaltyInfo); | 
|---|
|  |  |  | //        System.err.println("=================="+royaltyInfo); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | request.setBizModel(model); | 
|---|
|  |  |  | request.setNotifyUrl(callbackPath + notifyUrl); | 
|---|
|  |  |  | 
|---|
|  |  |  | AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); | 
|---|
|  |  |  | Map<String, String> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("orderString", response.getBody()); | 
|---|
|  |  |  | map.put("returnId", passbackParams); | 
|---|
|  |  |  | System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。 | 
|---|
|  |  |  | return ResultUtil.success(map); | 
|---|
|  |  |  | } catch (AlipayApiException e) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付宝扫码支付下单 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param body | 
|---|
|  |  |  | * @param subject | 
|---|
|  |  |  | * @param outTradeNo | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param notifyUrl | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil aliScanCodePay(String body, String subject, String outTradeNo, String amount, String notifyUrl){ | 
|---|
|  |  |  | public ResultUtil aliScanCodePay(String body, String subject, String outTradeNo, String amount, String notifyUrl) { | 
|---|
|  |  |  | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); //获得初始化的AlipayClient | 
|---|
|  |  |  | AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();//创建API对应的request类 | 
|---|
|  |  |  | request.setBizContent("{" + | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付成功后的回调处理逻辑 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param request | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> alipayCallback(HttpServletRequest request){ | 
|---|
|  |  |  | public Map<String, String> alipayCallback(HttpServletRequest request) { | 
|---|
|  |  |  | //获取支付宝POST过来反馈信息 | 
|---|
|  |  |  | Map<String,String> params = new HashMap<String,String>(); | 
|---|
|  |  |  | Map<String, String> params = new HashMap<String, String>(); | 
|---|
|  |  |  | Map requestParams = request.getParameterMap(); | 
|---|
|  |  |  | for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { | 
|---|
|  |  |  | for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { | 
|---|
|  |  |  | String name = (String) iter.next(); | 
|---|
|  |  |  | String[] values = (String[]) requestParams.get(name); | 
|---|
|  |  |  | String valueStr = ""; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付宝查询订单支付状态 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param out_trade_no | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil queryALIOrder(String out_trade_no) throws Exception{ | 
|---|
|  |  |  | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliAppid, appPrivateKey,"json","UTF-8",alipay_public_key,"RSA2"); | 
|---|
|  |  |  | public AlipayTradeQueryResponse queryALIOrder(String out_trade_no) throws Exception { | 
|---|
|  |  |  | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); | 
|---|
|  |  |  | AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); | 
|---|
|  |  |  | request.setBizContent("{" + | 
|---|
|  |  |  | "  \"out_trade_no\":\"" + out_trade_no + "\"" + | 
|---|
|  |  |  | "}"); | 
|---|
|  |  |  | AlipayTradeQueryResponse response = alipayClient.execute(request); | 
|---|
|  |  |  | if(response.isSuccess()){ | 
|---|
|  |  |  | String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款) | 
|---|
|  |  |  | return ResultUtil.success(tradeStatus); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return ResultUtil.error(response.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return response; | 
|---|
|  |  |  | //        if(response.isSuccess()){ | 
|---|
|  |  |  | //            String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款) | 
|---|
|  |  |  | //            return ResultUtil.success(response); | 
|---|
|  |  |  | //        } else { | 
|---|
|  |  |  | //            return ResultUtil.error(response.getMsg()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信统一下单 | 
|---|
|  |  |  | * @param body          商品描述 | 
|---|
|  |  |  | * @param attach        附加数据 | 
|---|
|  |  |  | * @param out_trade_no  商户订单号 | 
|---|
|  |  |  | * @param total_fee     标价金额 | 
|---|
|  |  |  | * @param notify_url    通知地址 | 
|---|
|  |  |  | * @param tradeType     交易类型 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param body         商品描述 | 
|---|
|  |  |  | * @param attach       附加数据 | 
|---|
|  |  |  | * @param out_trade_no 商户订单号 | 
|---|
|  |  |  | * @param total_fee    标价金额 | 
|---|
|  |  |  | * @param notify_url   通知地址 | 
|---|
|  |  |  | * @param tradeType    交易类型 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil weixinpay(String body, String attach, String out_trade_no, String total_fee, String notify_url, String tradeType, String openId) throws Exception{ | 
|---|
|  |  |  | public ResultUtil weixinpay(String body, String attach, String out_trade_no, String total_fee, String notify_url, String tradeType, String openId) throws Exception { | 
|---|
|  |  |  | int i = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); | 
|---|
|  |  |  | String hostAddress = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | map.put("spbill_create_ip", hostAddress); | 
|---|
|  |  |  | map.put("notify_url", callbackPath + notify_url); | 
|---|
|  |  |  | map.put("trade_type", tradeType); | 
|---|
|  |  |  | if("JSAPI".equals(tradeType)){ | 
|---|
|  |  |  | if ("JSAPI".equals(tradeType)) { | 
|---|
|  |  |  | map.put("openid", openId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String s = this.weixinSignature(map); | 
|---|
|  |  |  | 
|---|
|  |  |  | keys = strings.toArray(keys); | 
|---|
|  |  |  | Arrays.sort(keys); | 
|---|
|  |  |  | xmlString.append("<xml>"); | 
|---|
|  |  |  | for(int l = 0; l < keys.length; l++){ | 
|---|
|  |  |  | for (int l = 0; l < keys.length; l++) { | 
|---|
|  |  |  | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | xmlString.append("</xml>"); | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, String> map1 = null; | 
|---|
|  |  |  | String body1 = HttpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()).getData(); | 
|---|
|  |  |  | //将结果xml解析成map | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | body1 = body1.replaceAll("]]>", ""); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map1 = this.xmlToMap(body1, "UTF-8"); | 
|---|
|  |  |  | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String return_code = map1.get("return_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map1.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | String type = map1.get("trade_type"); | 
|---|
|  |  |  | String prepay_id = map1.get("prepay_id"); | 
|---|
|  |  |  | switch (type){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | switch (type) { | 
|---|
|  |  |  | case "JSAPI": | 
|---|
|  |  |  | //重新进行签名后返回给前端 | 
|---|
|  |  |  | Map<String, Object> map2 = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return ResultUtil.success(map3); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.err.println(map1.get("err_code_des")); | 
|---|
|  |  |  | return ResultUtil.error(map1.get("err_code_des")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.err.println(map1.get("return_msg") + appid + "----" + mchId); | 
|---|
|  |  |  | return ResultUtil.error(map1.get("return_msg"), new JSONObject()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信支付成功后的回调处理 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param request | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> weixinpayCallback(HttpServletRequest request){ | 
|---|
|  |  |  | public Map<String, String> weixinpayCallback(HttpServletRequest request) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String param = this.getParam(request); | 
|---|
|  |  |  | param = param.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | param = param.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | param = param.replaceAll("]]>", ""); | 
|---|
|  |  |  | Map<String, String> map = this.xmlToMap(param, "UTF-8"); | 
|---|
|  |  |  | String return_code = map.get("return_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | Map<String, String> map1 = new HashedMap(); | 
|---|
|  |  |  | map1.put("nonce_str", map.get("nonce_str")); | 
|---|
|  |  |  | map1.put("out_trade_no", map.get("out_trade_no"));//存储的订单code | 
|---|
|  |  |  | 
|---|
|  |  |  | map1.put("result", result); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return map1; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.err.println(map.get("err_code_des")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.err.println(map.get("return_msg")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CoursePackageClient coursePackageClient; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CoursePackageClient coursePackageClient; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private DeductionCompetitionsClient competitionsClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private SiteClient siteClient; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxPayService wxPayService; | 
|---|
|  |  |  | //    @Autowired | 
|---|
|  |  |  | //    private WxPayService wxPayService; | 
|---|
|  |  |  | //分账 | 
|---|
|  |  |  | public ResultUtil order(String code) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer    coursePackagePayments = coursePackageClient.queryByCode(code); | 
|---|
|  |  |  | Integer paymentCompetitions = competitionsClient.queryByCode(code); | 
|---|
|  |  |  | Integer siteBookings = siteClient.queryByCode(code); | 
|---|
|  |  |  | List<Integer> stores = new ArrayList<>(); | 
|---|
|  |  |  | stores.add(coursePackagePayments); | 
|---|
|  |  |  | stores.add(paymentCompetitions); | 
|---|
|  |  |  | stores.add(siteBookings); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | OperatorUser operatorUser = siteClient.queryOperator(stores); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WxPayService myWxPayService = wxPayService.switchoverTo("mch_id"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ProfitSharingV3Service profitSharingV3Service = myWxPayService.getProfitSharingV3Service(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String nonceStr = RandomUtil.randomString(32); | 
|---|
|  |  |  | String appId = "您的appid"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加分账方 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    public ResultUtil order(String code) throws Exception { | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                  Integer    coursePackagePayments = coursePackageClient.queryByCode(code); | 
|---|
|  |  |  | //                  Integer paymentCompetitions = competitionsClient.queryByCode(code); | 
|---|
|  |  |  | //                  Integer siteBookings = siteClient.queryByCode(code); | 
|---|
|  |  |  | //        List<Integer> stores = new ArrayList<>(); | 
|---|
|  |  |  | //                stores.add(coursePackagePayments); | 
|---|
|  |  |  | //                stores.add(paymentCompetitions); | 
|---|
|  |  |  | //                stores.add(siteBookings); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                OperatorUser operatorUser = siteClient.queryOperator(stores); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////        WxPayService myWxPayService = wxPayService.switchoverTo("mch_id"); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | ////        ProfitSharingV3Service profitSharingV3Service = myWxPayService.getProfitSharingV3Service(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        String nonceStr = RandomUtil.randomString(32); | 
|---|
|  |  |  | //        String appId = "您的appid"; | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        //添加分账方 | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////        ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver(); | 
|---|
|  |  |  | ////        profitSharingReceiver.setAccount("appid对应的openId"); | 
|---|
|  |  |  | ////        profitSharingReceiver.setAmount(1l); | 
|---|
|  |  |  | ////        profitSharingReceiver.setAppid(appId); | 
|---|
|  |  |  | ////        profitSharingReceiver.setType("PERSONAL_OPENID"); | 
|---|
|  |  |  | ////        profitSharingReceiver.setRelationType("PARTNER"); | 
|---|
|  |  |  | ////        profitSharingV3Service.addProfitSharingReceiver(profitSharingReceiver); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        //分账 | 
|---|
|  |  |  | //        ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest(); | 
|---|
|  |  |  | //        profitSharingRequest.setAppid(appId); | 
|---|
|  |  |  | //        profitSharingRequest.setTransactionId("微信支付订单号"); | 
|---|
|  |  |  | //        profitSharingRequest.setOutOrderNo("业务系统唯一编号"); | 
|---|
|  |  |  | //        //分账完成后,剩余金额自动解冻并返回给商户账号,默认false | 
|---|
|  |  |  | //        profitSharingRequest.setUnfreezeUnsplit(true); | 
|---|
|  |  |  | //        //待分账金额1元 | 
|---|
|  |  |  | //        Long money = 1L; | 
|---|
|  |  |  | //        List<ProfitSharingReceiver> profitSharingReceivers = new ArrayList<>(); | 
|---|
|  |  |  | //        ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver(); | 
|---|
|  |  |  | //        profitSharingReceiver.setAccount("appid对应的openId"); | 
|---|
|  |  |  | //        profitSharingReceiver.setAmount(1l); | 
|---|
|  |  |  | //        profitSharingReceiver.setAccount("appid对应的openId,分账用户1"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        //分账百分之5 | 
|---|
|  |  |  | //        profitSharingReceiver.setAmount(money * 100 / 5); | 
|---|
|  |  |  | //        profitSharingReceiver.setAppid(appId); | 
|---|
|  |  |  | //        profitSharingReceiver.setType("PERSONAL_OPENID"); | 
|---|
|  |  |  | //        profitSharingReceiver.setRelationType("PARTNER"); | 
|---|
|  |  |  | //        profitSharingV3Service.addProfitSharingReceiver(profitSharingReceiver); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //分账 | 
|---|
|  |  |  | ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest(); | 
|---|
|  |  |  | profitSharingRequest.setAppid(appId); | 
|---|
|  |  |  | profitSharingRequest.setTransactionId("微信支付订单号"); | 
|---|
|  |  |  | profitSharingRequest.setOutOrderNo("业务系统唯一编号"); | 
|---|
|  |  |  | //分账完成后,剩余金额自动解冻并返回给商户账号,默认false | 
|---|
|  |  |  | profitSharingRequest.setUnfreezeUnsplit(true); | 
|---|
|  |  |  | //待分账金额1元 | 
|---|
|  |  |  | Long money = 1L; | 
|---|
|  |  |  | List<ProfitSharingReceiver> profitSharingReceivers = new ArrayList<>(); | 
|---|
|  |  |  | ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver(); | 
|---|
|  |  |  | profitSharingReceiver.setAccount("appid对应的openId,分账用户1"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //分账百分之5 | 
|---|
|  |  |  | profitSharingReceiver.setAmount(money * 100 / 5); | 
|---|
|  |  |  | profitSharingReceiver.setAppid(appId); | 
|---|
|  |  |  | profitSharingReceiver.setType("PERSONAL_OPENID"); | 
|---|
|  |  |  | profitSharingReceiver.setRelationType("PARTNER"); | 
|---|
|  |  |  | profitSharingReceiver.setDescription("test01"); | 
|---|
|  |  |  | profitSharingReceivers.add(profitSharingReceiver); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ProfitSharingReceiver receiver = new ProfitSharingReceiver(); | 
|---|
|  |  |  | receiver.setAccount("appid对应的openId,分账用户2"); | 
|---|
|  |  |  | //百分之10 | 
|---|
|  |  |  | receiver.setAmount(money * 100 / 10); | 
|---|
|  |  |  | receiver.setAppid(appId); | 
|---|
|  |  |  | receiver.setType("PERSONAL_OPENID"); | 
|---|
|  |  |  | receiver.setRelationType("PARTNER"); | 
|---|
|  |  |  | receiver.setDescription("test02"); | 
|---|
|  |  |  | profitSharingReceivers.add(receiver); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | profitSharingRequest.setReceivers(profitSharingReceivers); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | profitSharingV3Service.profitSharing(profitSharingRequest); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                    Map<String,String> headers = new HashMap<>(); | 
|---|
|  |  |  | //                    headers.put("Authorization",map.get("sign")); | 
|---|
|  |  |  | //                    headers.put("Accept","application/json"); | 
|---|
|  |  |  | //                    headers.put("Wechatpay-Serial",certPath); | 
|---|
|  |  |  | //        profitSharingReceiver.setDescription("test01"); | 
|---|
|  |  |  | //        profitSharingReceivers.add(profitSharingReceiver); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    List<Receivers> receivers = new ArrayList<>(); | 
|---|
|  |  |  | //        ProfitSharingReceiver receiver = new ProfitSharingReceiver(); | 
|---|
|  |  |  | //        receiver.setAccount("appid对应的openId,分账用户2"); | 
|---|
|  |  |  | //        //百分之10 | 
|---|
|  |  |  | //        receiver.setAmount(money * 100 / 10); | 
|---|
|  |  |  | //        receiver.setAppid(appId); | 
|---|
|  |  |  | //        receiver.setType("PERSONAL_OPENID"); | 
|---|
|  |  |  | //        receiver.setRelationType("PARTNER"); | 
|---|
|  |  |  | //        receiver.setDescription("test02"); | 
|---|
|  |  |  | //        profitSharingReceivers.add(receiver); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    Map<String,Object> body = new HashMap<>(); | 
|---|
|  |  |  | //                    body.put("appid",appid); | 
|---|
|  |  |  | //                    body.put("transaction_id",map.get("transaction_id")); | 
|---|
|  |  |  | //                    body.put("out_order_no",map.get("out_trade_no")); | 
|---|
|  |  |  | //                    body.put("receivers",receivers); | 
|---|
|  |  |  | //                    body.put("unfreeze_unsplit",true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //支付分账 | 
|---|
|  |  |  | //                    String url ="https://api.mch.weixin.qq.com/v3/profitsharing/orders"; | 
|---|
|  |  |  | //                    CloseableHttpResponse closeableHttpResponse = HttpClientUtil.setPostHttpRequset(url, body, headers, "application/json"); | 
|---|
|  |  |  | // | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return  null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        profitSharingRequest.setReceivers(profitSharingReceivers); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        profitSharingV3Service.profitSharing(profitSharingRequest); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////                    Map<String,String> headers = new HashMap<>(); | 
|---|
|  |  |  | ////                    headers.put("Authorization",map.get("sign")); | 
|---|
|  |  |  | ////                    headers.put("Accept","application/json"); | 
|---|
|  |  |  | ////                    headers.put("Wechatpay-Serial",certPath); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | ////                    List<Receivers> receivers = new ArrayList<>(); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | ////                    Map<String,Object> body = new HashMap<>(); | 
|---|
|  |  |  | ////                    body.put("appid",appid); | 
|---|
|  |  |  | ////                    body.put("transaction_id",map.get("transaction_id")); | 
|---|
|  |  |  | ////                    body.put("out_order_no",map.get("out_trade_no")); | 
|---|
|  |  |  | ////                    body.put("receivers",receivers); | 
|---|
|  |  |  | ////                    body.put("unfreeze_unsplit",true); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                    //支付分账 | 
|---|
|  |  |  | ////                    String url ="https://api.mch.weixin.qq.com/v3/profitsharing/orders"; | 
|---|
|  |  |  | ////                    CloseableHttpResponse closeableHttpResponse = HttpClientUtil.setPostHttpRequset(url, body, headers, "application/json"); | 
|---|
|  |  |  | //// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            return  null; | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信扫码收款 | 
|---|
|  |  |  | * @param body              商品描述 | 
|---|
|  |  |  | * @param attach            附加数据 | 
|---|
|  |  |  | * @param nonce_str         随机字符串 | 
|---|
|  |  |  | * @param out_trade_no      商户订单号 | 
|---|
|  |  |  | * @param total_fee         订单金额 | 
|---|
|  |  |  | * @param auth_code         授权码   扫码支付授权码,设备读取用户微信中的条码或者二维码信息(注:用户付款码条形码规则:18位纯数字,以10、11、12、13、14、15开头) | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param body         商品描述 | 
|---|
|  |  |  | * @param attach       附加数据 | 
|---|
|  |  |  | * @param nonce_str    随机字符串 | 
|---|
|  |  |  | * @param out_trade_no 商户订单号 | 
|---|
|  |  |  | * @param total_fee    订单金额 | 
|---|
|  |  |  | * @param auth_code    授权码   扫码支付授权码,设备读取用户微信中的条码或者二维码信息(注:用户付款码条形码规则:18位纯数字,以10、11、12、13、14、15开头) | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil wxScanQRCodePay(String body, String attach, String nonce_str, String out_trade_no, String total_fee, String auth_code){ | 
|---|
|  |  |  | public ResultUtil wxScanQRCodePay(String body, String attach, String nonce_str, String out_trade_no, String total_fee, String auth_code) { | 
|---|
|  |  |  | int i = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); | 
|---|
|  |  |  | String hostAddress = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | keys = strings.toArray(keys); | 
|---|
|  |  |  | Arrays.sort(keys); | 
|---|
|  |  |  | xmlString.append("<xml>"); | 
|---|
|  |  |  | for(int l = 0; l < keys.length; l++){ | 
|---|
|  |  |  | for (int l = 0; l < keys.length; l++) { | 
|---|
|  |  |  | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | xmlString.append("</xml>"); | 
|---|
|  |  |  | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //将结果xml解析成map | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | body1 = body1.replaceAll("]]>", ""); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map1 = this.xmlToMap(body1, "UTF-8"); | 
|---|
|  |  |  | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String return_code = map1.get("return_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map1.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | String type = map1.get("trade_type"); | 
|---|
|  |  |  | switch (type){ | 
|---|
|  |  |  | switch (type) { | 
|---|
|  |  |  | case "JSAPI": | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "NATIVE": | 
|---|
|  |  |  | 
|---|
|  |  |  | return ResultUtil.success(map2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //                System.err.println(map1.get("err_code_des")); | 
|---|
|  |  |  | return ResultUtil.error(map1.get("err_code_des")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //            System.err.println(map1.get("return_msg") + appid + "----" + mchId); | 
|---|
|  |  |  | return ResultUtil.error(map1.get("return_msg"), new JSONObject()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付宝扫码收款 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Object aliScanQRCodePay(String data){ | 
|---|
|  |  |  | public Object aliScanQRCodePay(String data) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信退款申请 | 
|---|
|  |  |  | * @param transaction_id    微信订单号。微信生成的订单号,在支付通知中有返回 | 
|---|
|  |  |  | * @param out_refund_no     商户退款单号。商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。 | 
|---|
|  |  |  | * @param total_fee         订单金额。订单总金额,单位为分,只能为整数 | 
|---|
|  |  |  | * @param refund_fee        退款金额。退款总金额,订单总金额,单位为分,只能为整数 | 
|---|
|  |  |  | * @param notify_url        退款结果通知url。异步接收微信支付退款结果通知的回调地址,通知URL必须为外网可访问的url,不允许带参数 如果参数中传了notify_url,则商户平台上配置的回调地址将不会生效。 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param transaction_id 微信订单号。微信生成的订单号,在支付通知中有返回 | 
|---|
|  |  |  | * @param out_refund_no  商户退款单号。商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。 | 
|---|
|  |  |  | * @param total_fee      订单金额。订单总金额,单位为分,只能为整数 | 
|---|
|  |  |  | * @param refund_fee     退款金额。退款总金额,订单总金额,单位为分,只能为整数 | 
|---|
|  |  |  | * @param notify_url     退款结果通知url。异步接收微信支付退款结果通知的回调地址,通知URL必须为外网可访问的url,不允许带参数 如果参数中传了notify_url,则商户平台上配置的回调地址将不会生效。 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> wxRefund(String transaction_id, String out_refund_no, String total_fee, String refund_fee, String notify_url){ | 
|---|
|  |  |  | public Map<String, String> wxRefund(String transaction_id, String out_refund_no, String total_fee, String refund_fee, String notify_url) { | 
|---|
|  |  |  | int tf = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); | 
|---|
|  |  |  | int rf = new BigDecimal(refund_fee).multiply(new BigDecimal("100")).intValue(); | 
|---|
|  |  |  | String nonce_str = UUIDUtil.getRandomCode(); | 
|---|
|  |  |  | 
|---|
|  |  |  | keys = strings.toArray(keys); | 
|---|
|  |  |  | Arrays.sort(keys); | 
|---|
|  |  |  | xmlString.append("<xml>"); | 
|---|
|  |  |  | for(int l = 0; l < keys.length; l++){ | 
|---|
|  |  |  | for (int l = 0; l < keys.length; l++) { | 
|---|
|  |  |  | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | xmlString.append("</xml>"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | System.err.println(body1); | 
|---|
|  |  |  | //将结果xml解析成map | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | body1 = body1.replaceAll("]]>", ""); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map1 = this.xmlToMap(body1, "UTF-8"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String return_code = map1.get("return_code"); | 
|---|
|  |  |  | Map<String, String> map2 = new HashMap<>(); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map1.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | map2.put("return_code", result_code); | 
|---|
|  |  |  | map2.put("refund_id", String.valueOf(map1.get("refund_id")));//微信退款订单号 | 
|---|
|  |  |  | map2.put("refund_fee", String.valueOf(map1.get("refund_fee")));//退款金额 | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map2.put("return_code", result_code); | 
|---|
|  |  |  | map2.put("return_msg", map1.get("err_code_des")); | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map2.put("return_code", return_code); | 
|---|
|  |  |  | map2.put("return_msg", map1.get("return_msg")); | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信退款成功后的回调处理 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param request | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> wxRefundCallback(HttpServletRequest request){ | 
|---|
|  |  |  | public Map<String, String> wxRefundCallback(HttpServletRequest request) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String param = this.getParam(request); | 
|---|
|  |  |  | param = param.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | param = param.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | param = param.replaceAll("]]>", ""); | 
|---|
|  |  |  | Map<String, String> map = this.xmlToMap(param, "UTF-8"); | 
|---|
|  |  |  | String return_code = map.get("return_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String req_info = map.get("req_info");//加密信息请用商户秘钥进行解密 | 
|---|
|  |  |  | String s = this.wxDecrypt(req_info); | 
|---|
|  |  |  | s = s.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | s = s.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | s = s.replaceAll("]]>", ""); | 
|---|
|  |  |  | map = this.xmlToMap(s, "UTF-8"); | 
|---|
|  |  |  | Map<String, String> map1 = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | String result = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"; | 
|---|
|  |  |  | map1.put("result", result); | 
|---|
|  |  |  | return map1; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //                System.err.println(map.get("return_msg")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付宝退款 | 
|---|
|  |  |  | * @param trade_no          支付宝交易号 | 
|---|
|  |  |  | * @param refund_amount     退款金额 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param trade_no      支付宝交易号 | 
|---|
|  |  |  | * @param refund_amount 退款金额 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws AlipayApiException | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> aliRefund(String trade_no, String refund_amount) throws AlipayApiException { | 
|---|
|  |  |  | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey,"json","UTF-8", alipay_public_key,"RSA2"); | 
|---|
|  |  |  | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); | 
|---|
|  |  |  | AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); | 
|---|
|  |  |  | JSONObject jsonObject = new JSONObject(); | 
|---|
|  |  |  | jsonObject.put("trade_no", trade_no); | 
|---|
|  |  |  | 
|---|
|  |  |  | request.setBizContent(jsonObject.toJSONString()); | 
|---|
|  |  |  | AlipayTradeRefundResponse response = alipayClient.execute(request); | 
|---|
|  |  |  | Map<String, String> map = new HashMap<>(); | 
|---|
|  |  |  | if(response.isSuccess()){ | 
|---|
|  |  |  | if (response.isSuccess()) { | 
|---|
|  |  |  | System.out.println("调用成功"); | 
|---|
|  |  |  | String outTradeNo = response.getOutTradeNo(); | 
|---|
|  |  |  | map.put("code", response.getCode());//10000 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询微信支付订单 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil<Map<String, String>> queryWXOrder(String out_trade_no, String transaction_id) throws Exception{ | 
|---|
|  |  |  | public ResultUtil<Map<String, String>> queryWXOrder(String out_trade_no, String transaction_id) throws Exception { | 
|---|
|  |  |  | String url = "https://api.mch.weixin.qq.com/pay/orderquery"; | 
|---|
|  |  |  | String nonce_str = UUIDUtil.getRandomCode(16); | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | keys = strings.toArray(keys); | 
|---|
|  |  |  | Arrays.sort(keys); | 
|---|
|  |  |  | xmlString.append("<xml>"); | 
|---|
|  |  |  | for(int l = 0; l < keys.length; l++){ | 
|---|
|  |  |  | for (int l = 0; l < keys.length; l++) { | 
|---|
|  |  |  | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | xmlString.append("</xml>"); | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, String> map1 = null; | 
|---|
|  |  |  | String body1 = HttpClientUtil.pushHttpRequsetXml(url, xmlString.toString(), new HashMap<>()).getData(); | 
|---|
|  |  |  | //将结果xml解析成map | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | body1 = body1.replaceAll("]]>", ""); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map1 = this.xmlToMap(body1, "UTF-8"); | 
|---|
|  |  |  | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String return_code = map1.get("return_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map1.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | Map<String, String> map2 = new HashMap<>(); | 
|---|
|  |  |  | map2.put("trade_type", map1.get("trade_type")); | 
|---|
|  |  |  | map2.put("trade_state", map1.get("trade_state"));//订单状态SUCCESS—支付成功,REFUND—转入退款,NOTPAY—未支付,CLOSED—已关闭,REVOKED—已撤销(刷卡支付),USERPAYING--用户支付中,PAYERROR--支付失败(其他原因,如银行返回失败) | 
|---|
|  |  |  | map2.put("transaction_id", map1.get("transaction_id")); | 
|---|
|  |  |  | return ResultUtil.success(map2); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.err.println(map1.get("err_code_des")); | 
|---|
|  |  |  | return ResultUtil.error(map1.get("err_code_des")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.err.println(map1.get("return_msg") + appid + "----" + mchId); | 
|---|
|  |  |  | return ResultUtil.error(map1.get("return_msg")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信转账功能(企业付款到零钱) | 
|---|
|  |  |  | * @param openid                商户appid下,某用户的openid | 
|---|
|  |  |  | * @param desc                  企业付款备注,必填。 | 
|---|
|  |  |  | * @param total_fee             企业付款金额 | 
|---|
|  |  |  | * @param partner_trade_no      商户订单号,需保持唯一性 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param openid           商户appid下,某用户的openid | 
|---|
|  |  |  | * @param desc             企业付款备注,必填。 | 
|---|
|  |  |  | * @param total_fee        企业付款金额 | 
|---|
|  |  |  | * @param partner_trade_no 商户订单号,需保持唯一性 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> wxTransfers(String openid, String desc, String total_fee, String partner_trade_no) throws Exception{ | 
|---|
|  |  |  | public Map<String, String> wxTransfers(String openid, String desc, String total_fee, String partner_trade_no) throws Exception { | 
|---|
|  |  |  | int amount = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); | 
|---|
|  |  |  | String nonce_str = UUIDUtil.getRandomCode(); | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | keys = strings.toArray(keys); | 
|---|
|  |  |  | Arrays.sort(keys); | 
|---|
|  |  |  | xmlString.append("<xml>"); | 
|---|
|  |  |  | for(int l = 0; l < keys.length; l++){ | 
|---|
|  |  |  | for (int l = 0; l < keys.length; l++) { | 
|---|
|  |  |  | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | xmlString.append("</xml>"); | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, String> map1 = null; | 
|---|
|  |  |  | String body1 = HttpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); | 
|---|
|  |  |  | //将结果xml解析成map | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | body1 = body1.replaceAll("]]>", ""); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map1 = this.xmlToMap(body1, "UTF-8"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String return_code = map1.get("return_code"); | 
|---|
|  |  |  | Map<String, String> map2 = new HashMap<>(); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map1.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | map2.put("return_code", result_code); | 
|---|
|  |  |  | map2.put("payment_no", String.valueOf(map1.get("payment_no")));//付款订单号 | 
|---|
|  |  |  | map2.put("payment_time", String.valueOf(map1.get("payment_time")));//付款时间 | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map2.put("return_code", result_code); | 
|---|
|  |  |  | map2.put("err_code", map1.get("err_code")); | 
|---|
|  |  |  | map2.put("err_code_des", map1.get("err_code_des")); | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map2.put("return_code", return_code); | 
|---|
|  |  |  | map2.put("return_msg", map1.get("return_msg")); | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信转账功能(企业付款到银行卡) | 
|---|
|  |  |  | * @param desc              备注信息 | 
|---|
|  |  |  | * @param total_fee         转账金额 | 
|---|
|  |  |  | * @param partner_trade_no  订单号 | 
|---|
|  |  |  | * @param enc_bank_no       银行卡号 | 
|---|
|  |  |  | * @param enc_true_name     收款方用户名 | 
|---|
|  |  |  | * @param bankName          银行名称 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param desc             备注信息 | 
|---|
|  |  |  | * @param total_fee        转账金额 | 
|---|
|  |  |  | * @param partner_trade_no 订单号 | 
|---|
|  |  |  | * @param enc_bank_no      银行卡号 | 
|---|
|  |  |  | * @param enc_true_name    收款方用户名 | 
|---|
|  |  |  | * @param bankName         银行名称 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, String> wxPayBank(String desc, String total_fee, String partner_trade_no, String enc_bank_no, String enc_true_name, String bankName) throws Exception{ | 
|---|
|  |  |  | public Map<String, String> wxPayBank(String desc, String total_fee, String partner_trade_no, String enc_bank_no, String enc_true_name, String bankName) throws Exception { | 
|---|
|  |  |  | int amount = new BigDecimal(total_fee).multiply(new BigDecimal("100")).intValue(); | 
|---|
|  |  |  | String nonce_str = UUIDUtil.getRandomCode(); | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | keys = strings.toArray(keys); | 
|---|
|  |  |  | Arrays.sort(keys); | 
|---|
|  |  |  | xmlString.append("<xml>"); | 
|---|
|  |  |  | for(int l = 0; l < keys.length; l++){ | 
|---|
|  |  |  | for (int l = 0; l < keys.length; l++) { | 
|---|
|  |  |  | xmlString.append("<" + keys[l] + ">" + map.get(keys[l]) + "</" + keys[l] + ">"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | xmlString.append("</xml>"); | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, String> map1 = null; | 
|---|
|  |  |  | String body1 = HttpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); | 
|---|
|  |  |  | //将结果xml解析成map | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[",""); | 
|---|
|  |  |  | body1 = body1.replaceAll("<!\\[CDATA\\[", ""); | 
|---|
|  |  |  | body1 = body1.replaceAll("]]>", ""); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map1 = this.xmlToMap(body1, "UTF-8"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String return_code = map1.get("return_code"); | 
|---|
|  |  |  | Map<String, String> map2 = new HashMap<>(); | 
|---|
|  |  |  | if("SUCCESS".equals(return_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(return_code)) { | 
|---|
|  |  |  | String result_code = map1.get("result_code"); | 
|---|
|  |  |  | if("SUCCESS".equals(result_code)){ | 
|---|
|  |  |  | if ("SUCCESS".equals(result_code)) { | 
|---|
|  |  |  | map2.put("return_code", result_code); | 
|---|
|  |  |  | map2.put("payment_no", String.valueOf(map1.get("payment_no")));//付款订单号 | 
|---|
|  |  |  | map2.put("cmms_amt", String.valueOf(map1.get("cmms_amt")));//手续费金额 RMB:分 | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map2.put("return_code", result_code); | 
|---|
|  |  |  | map2.put("err_code", map1.get("err_code")); | 
|---|
|  |  |  | map2.put("err_code_des", map1.get("err_code_des")); | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map2.put("return_code", return_code); | 
|---|
|  |  |  | map2.put("return_msg", map1.get("return_msg")); | 
|---|
|  |  |  | return map2; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信转账到银行卡不编号 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param bankName | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String findBankCode(String bankName){ | 
|---|
|  |  |  | public String findBankCode(String bankName) { | 
|---|
|  |  |  | String json = "{\"工商银行 \":1002,\"农业银行\":1005,\"建设银行\":1003,\"中国银行\":1026,\"交通银行 \":1020,\"招商银行 \":1001,\"邮储银行\":1066,\"民生银行 \":1006,\"平安银行 \":1010,\"中信银行\":1021,\"浦发银行 \":1004,\"兴业银行 \":1009,\"光大银行 \":1022,\"广发银行\":1027,\"华夏银行\":1025,\"宁波银行\":1056,\"北京银行\":4836,\"上海银行\":1024,\"南京银行\":1054,\"长子县融汇村镇银行\":4755,\"长沙银行\":4216,\"浙江泰隆商业银行\":4051,\"中原银行 \":4753,\"企业银行(中国)\":4761,\"顺德农商银行 \":4036,\"衡水银行\":4752,\"长治银行\":4756,\"大同银行\":4767,\"河南省农村信用社\":4115,\"宁夏黄河农村商业银行\":4150,\"山西省农村信用社\":4156,\"安徽省农村信用社\":4166,\"甘肃省农村信用社\":4157,\"天津农村商业银行\":4153,\"广西壮族自治区农村信用社\":4113,\"陕西省农村信用社\":4108,\"深圳农村商业银行\":4076,\"宁波鄞州农村商业银行\":4052,\"浙江省农村信用社联合社\":4764,\"江苏省农村信用社联合社\":4217,\"江苏紫金农村商业银行股份有限公司 \":4072,\"北京中关村银行股份有限公司 \":4769,\"星展银行( 中国) 有限公司 \":4778,\"枣庄银行股份有限公司 \":4766,\"海口联合农村商业银行股份有限公司 \":4758,\"南洋商业银行( 中国) 有限公司 \":4763}"; | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(json); | 
|---|
|  |  |  | Set<String> strings = jsonObject.keySet(); | 
|---|
|  |  |  | for(String key : strings){ | 
|---|
|  |  |  | if(key.indexOf(bankName) >= 0){ | 
|---|
|  |  |  | for (String key : strings) { | 
|---|
|  |  |  | if (key.indexOf(bankName) >= 0) { | 
|---|
|  |  |  | return jsonObject.getString(key); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付宝转账 | 
|---|
|  |  |  | * @param out_biz_no        商家侧唯一订单号,由商家自定义。对于不同转账请求,商家需保证该订单号在自身系统唯一。 | 
|---|
|  |  |  | * @param trans_amount      订单总金额,单位为元,精确到小数点后两位 | 
|---|
|  |  |  | * @param order_title       转账业务的标题,用于在支付宝用户的账单里显示 | 
|---|
|  |  |  | * @param identity          参与方的唯一标识(收款方支付宝账号) | 
|---|
|  |  |  | * @param name              参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。 | 
|---|
|  |  |  | * @param remark            业务备注 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param out_biz_no   商家侧唯一订单号,由商家自定义。对于不同转账请求,商家需保证该订单号在自身系统唯一。 | 
|---|
|  |  |  | * @param trans_amount 订单总金额,单位为元,精确到小数点后两位 | 
|---|
|  |  |  | * @param order_title  转账业务的标题,用于在支付宝用户的账单里显示 | 
|---|
|  |  |  | * @param identity     参与方的唯一标识(收款方支付宝账号) | 
|---|
|  |  |  | * @param name         参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。 | 
|---|
|  |  |  | * @param remark       业务备注 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map<String, Object> aliTransfer(String out_biz_no, Double trans_amount, String order_title, String identity, String name, String remark) throws Exception{ | 
|---|
|  |  |  | public Map<String, Object> aliTransfer(String out_biz_no, Double trans_amount, String order_title, String identity, String name, String remark) throws Exception { | 
|---|
|  |  |  | CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); | 
|---|
|  |  |  | certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");  //gateway:支付宝网关(固定)https://openapi.alipay.com/gateway.do | 
|---|
|  |  |  | certAlipayRequest.setAppId(aliAppid);  //APPID 即创建应用后生成,详情见创建应用并获取 APPID | 
|---|
|  |  |  | 
|---|
|  |  |  | "}"); | 
|---|
|  |  |  | AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request); | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | if(response.isSuccess()){ | 
|---|
|  |  |  | if (response.isSuccess()) { | 
|---|
|  |  |  | String status = response.getStatus(); | 
|---|
|  |  |  | if(status.equals("SUCCESS")){//成功 | 
|---|
|  |  |  | if (status.equals("SUCCESS")) {//成功 | 
|---|
|  |  |  | map.put("code", response.getCode()); | 
|---|
|  |  |  | map.put("order_id", response.getOrderId());//支付宝订单号 | 
|---|
|  |  |  | map.put("pay_fund_order_id", response.getPayFundOrderId());//支付宝流水号 | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | map.put("code", response.getCode()); | 
|---|
|  |  |  | map.put("sub_msg", response.getSubMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取请求内容 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param request | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws IOException | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信下单的签名算法 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param map | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String weixinSignature(Map<String, Object> map){ | 
|---|
|  |  |  | private String weixinSignature(Map<String, Object> map) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Set<Map.Entry<String, Object>> entries = map.entrySet(); | 
|---|
|  |  |  | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信下单的签名算法 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param map | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String weixinSignature(Map<String, Object> map, String key_){ | 
|---|
|  |  |  | private String weixinSignature(Map<String, Object> map, String key_) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Set<Map.Entry<String, Object>> entries = map.entrySet(); | 
|---|
|  |  |  | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 微信退款成功后的解密 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param req_info | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | InvalidKeyException, BadPaddingException, IllegalBlockSizeException { | 
|---|
|  |  |  | byte[] decode = Base64.getDecoder().decode(req_info); | 
|---|
|  |  |  | String sign = MD5AndKL.MD5Encode(key, "UTF-8").toLowerCase(); | 
|---|
|  |  |  | if (Security.getProvider("BC") == null){ | 
|---|
|  |  |  | if (Security.getProvider("BC") == null) { | 
|---|
|  |  |  | Security.addProvider(new BouncyCastleProvider()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * xml转map | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param xml | 
|---|
|  |  |  | * @param charset | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | return respMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static Map<String, String> xmlToMap(Element tmpElement, Map<String, String> respMap){ | 
|---|
|  |  |  | public static Map<String, String> xmlToMap(Element tmpElement, Map<String, String> respMap) { | 
|---|
|  |  |  | if (tmpElement.isTextOnly()) { | 
|---|
|  |  |  | respMap.put(tmpElement.getName(), tmpElement.getText()); | 
|---|
|  |  |  | return respMap; | 
|---|