AliPayUtil.java 33.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
//package com.zteits.pay.allipay;
//
//import java.math.BigDecimal;
//import java.net.URLEncoder;
//import java.security.KeyFactory;
//import java.security.PrivateKey;
//import java.security.spec.PKCS8EncodedKeySpec;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import org.apache.commons.lang3.StringUtils;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.alipay.api.AlipayApiException;
//import com.alipay.api.internal.util.AlipaySignature;
//import com.clouds.common.utils.AmountUtils;
//import com.clouds.common.web.SpringContextUtil;
//import com.zteits.clouds.api.apibase.constants.OrderEnum;
//import com.zteits.clouds.api.apibase.constants.PayOrderEnum;
//import com.zteits.clouds.api.dto.pay.param.AliPayOrderRequest;
//import com.zteits.clouds.api.dto.pay.param.AlipayTradeRefundQueryRequest;
//import com.zteits.pay.util.Base64;
//import com.zteits.pay.util.PayNotifyUrl;
///**
// * 支付宝支付工具类.<br/>
// *
// * Copyright: Copyright (c) 2017  zteits
// *
// * @ClassName: AliPayUtil.java
// * @Description:
// * @version: v1.0.0
// * @author: wangfs
// * @date: 2017年5月16日   下午5:00:46
// * Modification History:
// * Date             Author          Version            Description
// *---------------------------------------------------------*
// * 2017年5月16日      wangfs           v1.0.0               创建
// */
//public class AliPayUtil {
//
//	private static PayNotifyUrl payNotifyUrl;
//
//    static {
//        if (AliPayUtil.payNotifyUrl == null) {
//        	AliPayUtil.payNotifyUrl = (PayNotifyUrl)SpringContextUtil.getBean("payNotifyUrl");
//        }
//    }
//
//
//
//	private static final Logger logger = LoggerFactory.getLogger(AliPayUtil.class);
//	/**
//	 * 获取支付请求参数.<br/>
//	 * @param aliPayOrderRequest
//	 * @return
//	 * @throws Exception
//	 */
//	public static String getPayOutMessage(AliPayOrderRequest aliPayOrderRequest) throws Exception {
//		logger.info("【{}】开始获取支付请求参数AliPayUtil.getPayOutMessage()方法,入参={}",aliPayOrderRequest.getBaseRequest().getRequestId(),JSONObject.toJSON(aliPayOrderRequest).toString());
//		SimpleDateFormat formart = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
//		String timestamp = formart.format(new Date());
//		//公共参数
//        Map<String, String> map = new HashMap<String, String>();
//        map.put("app_id", AlipayConfig.APPID);
//        map.put("method", AlipayConfig.METHOD);
//        map.put("format", AlipayConfig.FORMAT_JSON);
//        map.put("charset", AlipayConfig.CHARSET);
//        map.put("sign_type", AlipayConfig.SIGN_TYPE);
//        map.put("timestamp", timestamp);
//        map.put("version", AlipayConfig.VERSION);
//        /**微信-购买会员卡-异步回调*/
//		if(aliPayOrderRequest.getPaySrcType()==OrderEnum.ORDER_PAY_SRC_TYPE_CARD_A.value() || aliPayOrderRequest.getPaySrcType()==OrderEnum.ORDER_PAY_SRC_TYPE_CARD_M.value()){
//			logger.info("购买会员卡:"+payNotifyUrl.getAlipay_paycard_notifu_url());
//			map.put("notify_url",  payNotifyUrl.getAlipay_paycard_notifu_url());
//		}else{
//			/**微信-支付停车订单-异步回调*/
//			logger.info("支付停车订单:"+payNotifyUrl.getALIPAY_PAYORDER_NOTIFY_URL());
//			map.put("notify_url",  payNotifyUrl.getALIPAY_PAYORDER_NOTIFY_URL());
//		}
//        //业务参数分装
//        Map<String,String> bizContentMap = AliPayUtil.createOrderInfo(aliPayOrderRequest);
//
//        //转换成json
//        Object json ="";
//        if(bizContentMap != null && bizContentMap.size() > 0){
//            json = JSONArray.toJSON(bizContentMap);
//        }
//       //添加业务参数
//        map.put("biz_content", json+"");
//        String returnJson = AliPayUtil.createLinkString(map);
//        logger.info("签名前 串:"+returnJson);
//      //对未签名原始字符串进行签名
//        String rsaSign = AliPayUtil.createSigin(returnJson, AlipayConfig.APP_PRIVATE_KEY, AlipayConfig.CHARSET);
//
//
//       // returnJson+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("签名 后:"+returnJson);
//
//        //最后对请求字符串的所有一级value(biz_content作为一个value)进行encode
//        Map<String, String> mapcode = new HashMap<String, String>();
//        mapcode.put("app_id", AlipayConfig.APPID);
//        mapcode.put("method", AlipayConfig.METHOD);
//        mapcode.put("format", AlipayConfig.FORMAT_JSON);
//        mapcode.put("charset", AlipayConfig.CHARSET);
//        mapcode.put("sign_type", AlipayConfig.SIGN_TYPE);
//        mapcode.put("timestamp", URLEncoder.encode(timestamp,AlipayConfig.CHARSET));
//        mapcode.put("version", AlipayConfig.VERSION);
//
//        /**微信-购买会员卡-异步回调*/
//		if(aliPayOrderRequest.getPaySrcType()==OrderEnum.ORDER_PAY_SRC_TYPE_CARD_A.value() || aliPayOrderRequest.getPaySrcType()==OrderEnum.ORDER_PAY_SRC_TYPE_CARD_M.value()){
//			logger.info("购买会员卡:"+payNotifyUrl.getAlipay_paycard_notifu_url());
//			mapcode.put("notify_url",  URLEncoder.encode(payNotifyUrl.getAlipay_paycard_notifu_url(),AlipayConfig.CHARSET));
//		}else{
//			/**微信-支付停车订单-异步回调*/
//			logger.info("支付停车订单:"+payNotifyUrl.getALIPAY_PAYORDER_NOTIFY_URL());
//			mapcode.put("notify_url",  URLEncoder.encode(payNotifyUrl.getALIPAY_PAYORDER_NOTIFY_URL(),AlipayConfig.CHARSET));
//		}
//
//        mapcode.put("biz_content", URLEncoder.encode(json+"",AlipayConfig.CHARSET));
//
//        String returnJso2 = AliPayUtil.createLinkString(mapcode);
//       // Map<String,String> par = AliPayUtil.paraFilter(mapcode); //除去数组中的空值和签名参数
//        //拼接
//
//        returnJso2+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("【{}】编码后返回={}",aliPayOrderRequest.getBaseRequest().getRequestId(),returnJso2);
//
//        logger.info("【{}】结束获取支付请求参数AliPayUtil.getPayOutMessage()方法.",aliPayOrderRequest.getBaseRequest().getRequestId());
//
//		return  returnJso2;
//
//	}
//
//	/**
//	 * 获取app充值支付请求参数 <br/>
//	 * added by hxz 20170822 <br/>
//	 * @param aliPayOrderRequest
//	 * @return
//	 * @throws Exception
//	 */
//	public static String getAcctRechargePayOutMessage(AliPayOrderRequest aliPayOrderRequest) throws Exception {
//		logger.info("【{}】开始获取支付请求参数AliPayUtil.getPayOutMessage()方法,入参={}",aliPayOrderRequest.getBaseRequest().getRequestId(),JSONObject.toJSON(aliPayOrderRequest).toString());
//		SimpleDateFormat formart = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
//		String timestamp = formart.format(new Date());
//		//公共参数
//        Map<String, String> map = new HashMap<String, String>();
//        map.put("app_id", AlipayConfig.APPID);
//        map.put("method", AlipayConfig.METHOD);
//        map.put("format", AlipayConfig.FORMAT_JSON);
//        map.put("charset", AlipayConfig.CHARSET);
//        map.put("sign_type", AlipayConfig.SIGN_TYPE);
//        map.put("timestamp", timestamp);
//        map.put("version", AlipayConfig.VERSION);
//        map.put("notify_url",  payNotifyUrl.getALIPAY_RECHARGE_NOTIFY_URL());
//
//        //业务参数分装
//        Map<String,String> bizContentMap = AliPayUtil.createAcctRechargeOrderInfo(aliPayOrderRequest);
//
//        //转换成json
//        Object json ="";
//        if(bizContentMap != null && bizContentMap.size() > 0){
//            json = JSONArray.toJSON(bizContentMap);
//        }
//       //添加业务参数
//        map.put("biz_content", json + "");
//        String returnJson = AliPayUtil.createLinkString(map);
//        logger.info("签名前 串:"+returnJson);
//      //对未签名原始字符串进行签名
//        String rsaSign = AliPayUtil.createSigin(returnJson, AlipayConfig.APP_PRIVATE_KEY, AlipayConfig.CHARSET);
//
//
//       // returnJson+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("签名 后:"+returnJson);
//
//        //最后对请求字符串的所有一级value(biz_content作为一个value)进行encode
//        Map<String, String> mapcode = new HashMap<String, String>();
//        mapcode.put("app_id", AlipayConfig.APPID);
//        mapcode.put("method", AlipayConfig.METHOD);
//        mapcode.put("format", AlipayConfig.FORMAT_JSON);
//        mapcode.put("charset", AlipayConfig.CHARSET);
//        mapcode.put("sign_type", AlipayConfig.SIGN_TYPE);
//        mapcode.put("timestamp", URLEncoder.encode(timestamp,AlipayConfig.CHARSET));
//        mapcode.put("version", AlipayConfig.VERSION);
//        mapcode.put("notify_url",  URLEncoder.encode(payNotifyUrl.getALIPAY_RECHARGE_NOTIFY_URL(), AlipayConfig.CHARSET));
//        mapcode.put("biz_content", URLEncoder.encode(json+"", AlipayConfig.CHARSET));
//
//        String returnJso2 = AliPayUtil.createLinkString(mapcode);
//       // Map<String,String> par = AliPayUtil.paraFilter(mapcode); //除去数组中的空值和签名参数
//        //拼接
//
//        returnJso2+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("【{}】编码后返回={}",aliPayOrderRequest.getBaseRequest().getRequestId(),returnJso2);
//
//        logger.info("【{}】结束获取支付请求参数AliPayUtil.getPayOutMessage()方法.",aliPayOrderRequest.getBaseRequest().getRequestId());
//
//		return  returnJso2;
//	}
//
//	/**
//	public static String getPayOutMessage(AliPayOrderRequest aliPayOrderRequest) throws Exception {
//		String returnJSON="";
//		//实例化客户端
//		AlipayClient alipayClient = new DefaultAlipayClient(
//				AlipayConfig.METHOD,
//				AlipayConfig.APPID,
//				AlipayConfig.APP_PRIVATE_KEY,
//				"json",
//				AlipayConfig.CHARSET,
//				AlipayConfig.ALIPAY_PUBLIC_KEY,
//				AlipayConfig.SIGN_TYPE);
//		//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
//		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//		//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
//		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
//		model.setBody("我是测试数据");
//		model.setSubject("任你听-停车支付");
//		model.setOutTradeNo(aliPayOrderRequest.getPayOrderId());
//		model.setTimeoutExpress("30m");
//		model.setTotalAmount("1.00");
//		model.setSellerId(AlipayConfig.PARTNER);
//		model.setProductCode(AlipayConfig.PRODUCT_CODE);
//		request.setNotifyUrl(AlipayConfig.SERVICE);
//		request.setBizModel(model);
//
//		try {
//		        //这里和普通的接口调用不同,使用的是sdkExecute
//		        AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
//		        returnJSON = response.getBody();//就是orderString 可以直接给客户端请求,无需再做处理。
//		    } catch (AlipayApiException e) {
//		        e.printStackTrace();
//		}
//		return returnJSON;
//	}
//    **/
//	/**
//	 * 用私钥对信息生成数字签名
//	 * @param params  需要在map中加入sign_type=RSA这个key-value对
//	 * @param privateKey
//	 * @param charset
//	 * @return
//	 */
//	private static String createSigin(Map<String,String> params,String privateKey,String charset){
//		logger.info("开始生成数字签名信息..");
//		String rsaSign = "";
//		try {
//			if(params != null && params.size() > 0){
//				rsaSign = AlipaySignature.rsaSign(params, privateKey, charset);
//			}else{
//				logger.info("签名的数据为空,无法签名");
//				throw new NullPointerException("签名的数据为空,无法签名.");
//			}
//
//		} catch (AlipayApiException e) {
//			e.printStackTrace();
//		}
//		logger.info("签名信息={}",rsaSign);
//		logger.info("结束生成数字签名信息..");
//		return rsaSign;
//	}
//
//
//	/**
//	 * 用私钥对信息生成数字签名
//	 * @param params  需要在map中加入sign_type=RSA这个key-value对
//	 * @param privateKey
//	 * @param charset
//	 * @return
//	 */
//	@SuppressWarnings("unused")
//	private static String createSigin(String params,String privateKey,String charset){
//		logger.info("开始生成数字签名信息..");
//		String rsaSign = "";
//		try {
//			if(params!=null){
//				rsaSign = AlipaySignature.rsaSign(params, privateKey, charset,"RSA2");
//			}else{
//				logger.info("签名的数据为空,无法签名");
//				throw new NullPointerException("签名的数据为空,无法签名.");
//			}
//
//		} catch (AlipayApiException e) {
//			e.printStackTrace();
//		}
//		logger.info("签名信息={}",rsaSign);
//		logger.info("结束生成数字签名信息..");
//		return rsaSign;
//	}
//
//	private static final String ALGORITHM = "RSA2";
//
//	private static final String SIGN_ALGORITHMS = "SHA1WithRSA";
//
//	private static final String DEFAULT_CHARSET = "UTF-8";
//
//	public static String sign(String content, String privateKey) {
//		   try {
//		      PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
//		            Base64.decode(privateKey));
//		      KeyFactory keyf = KeyFactory.getInstance(ALGORITHM);
//		      PrivateKey priKey = keyf.generatePrivate(priPKCS8);
//
//		      java.security.Signature signature = java.security.Signature
//		            .getInstance(SIGN_ALGORITHMS);
//
//		      signature.initSign(priKey);
//		      signature.update(content.getBytes(DEFAULT_CHARSET));
//
//		      byte[] signed = signature.sign();
//
//		      return Base64.encode(signed);
//		   } catch (Exception e) {
//		      e.printStackTrace();
//		   }
//
//		   return null;
//		}
//
//	/**
//	 *  通过签名及公钥 校验数据是否改动- 同步请求时.<br/>
//	 * @param content  待验签字符串
//	 * @param sign 签名值
//	 * @param publicKey 验签公钥
//	 * @param charset 验签字符集
//	 * @return
//	 */
//	public static boolean rsaCheckContent(Map<String,String> content, String sign, String publicKey, String charset,String signType){
//		boolean flg = false;
//		try {
//			//获取签名的原始数据
//			String con = AliPayUtil.getSignContent(content);
//			flg =  AlipaySignature.rsaCheckContent(con, sign,publicKey,charset);
//
//
//		} catch (AlipayApiException e) {
//			e.printStackTrace();
//		}
//		return flg;
//	}
//
//	/**
//	 * 获取签名的原始数据.<br/>
//	 * @param content map
//	 * @return
//	 */
//	public static String getSignContent(Map<String,String> content){
//		String con = "";
//		if(content != null && content.size() >0){
//			con= AlipaySignature.getSignContent(content);
//		}
//		return con;
//	}
//
//	/**
//	 * 验签方法(会自动去除 sign sign_type  )
//	@param params 参数列表(包括待验签参数和签名值sign) key-参数名称 value-参数值
//	@param publicKey 验签公钥
//	@param charset 验签字符集
//	**/
//	public static boolean rsaCheckV1(Map<String, String> params, String publicKey, String charset,String signType){
//
//		boolean flg = false;
//		try {
//			flg =  AlipaySignature.rsaCheckV1(params, publicKey, charset,signType);
//		} catch (AlipayApiException e) {
//			e.printStackTrace();
//		}
//		return flg;
//	}
//
//	/**
//	 * 验签方法(例如异步通知的时候,用户需要用到验签方法)
//	@param params 参数列表(包括待验签参数和签名值sign) key-参数名称 value-参数值
//	@param publicKey 验签公钥
//	@param charset 验签字符集
//	**/
//	public static boolean rsaCheckV2(Map<String, String> params, String publicKey, String charset,String signType){
//
//		boolean flg = false;
//		try {
//			flg =  AlipaySignature.rsaCheckV2(params, publicKey, charset,signType);
//		} catch (AlipayApiException e) {
//			e.printStackTrace();
//		}
//		return flg;
//	}
//
//	/**
//     * 除去数组中的空值和签名参数
//     * @param sArray 签名参数组
//     * @return 去掉空值与签名参数后的新签名参数组
//     */
//    public static Map<String, String> paraFilter(Map<String, String> sArray) {
//
//    	Map<String, String> result = new HashMap<String, String>();
//
//        if (sArray == null || sArray.size() <= 0) {
//            return result;
//        }
//
//        for (String key : sArray.keySet()) {
//            String value = sArray.get(key);
//            if (value == null || value.equals("") || key.equalsIgnoreCase("sign")) {
//                continue;
//            }
//            result.put(key, value);
//        }
//
//        return result;
//    }
//
//    /**
//     * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
//     * @param params 需要排序并参与字符拼接的参数组
//     * @return 拼接后字符串
//     */
//    public static String createLinkString(Map<String, String> params) {
//    	String prestr = "";
//        if(params != null && params.size() >0){
//        	List<String> keys = new ArrayList<String>(params.keySet());
//            Collections.sort(keys);
//            for (int i = 0; i < keys.size(); i++) {
//                String key = keys.get(i);
//                String value = params.get(key);
//
//                if (i == keys.size() - 1) {//拼接时,不包括最后一个&字符
//                    prestr = prestr + key + "=" + value;
//                } else {
//                    prestr = prestr + key + "=" + value + "&";
//                }
//            }
//            return prestr;
//        }else{
//        	return "";
//        }
//    }
//
//    /**
//	 * 返回创建的订单信息
//	 * @param aliPayOrderRequest
//	 * @return
//	 */
//    public static  Map<String,String> createOrderInfo(AliPayOrderRequest aliPayOrderRequest){
//    	//业务参数分装
//        Map<String,String> bizContentMap = new HashMap<String,String>();
//        if(StringUtils.isNotEmpty(aliPayOrderRequest.getBody())){
//        	 bizContentMap.put("body", aliPayOrderRequest.getBody());
//        }
//        if(aliPayOrderRequest.getPaySrcType()==OrderEnum.ORDER_PAY_SRC_TYPE_CARD_A.value() ){
//        	bizContentMap.put("subject", "任你停-购买会员卡"/*aliPayOrderRequest.getSubject()!=null?aliPayOrderRequest.getSubject():""*/);
//        }else if (aliPayOrderRequest.getPaySrcType()==OrderEnum.ORDER_PAY_SRC_TYPE_CARD_M.value()){
//        	bizContentMap.put("subject", "任你停-会员卡续费"/*aliPayOrderRequest.getSubject()!=null?aliPayOrderRequest.getSubject():""*/);
//        }else{
//			bizContentMap.put("subject", "任你停-停车支付"/*aliPayOrderRequest.getSubject()!=null?aliPayOrderRequest.getSubject():""*/);
//		}
//        bizContentMap.put("out_trade_no",aliPayOrderRequest.getPayOrderId());
//        bizContentMap.put("total_amount", AmountUtils.changeF2Y(aliPayOrderRequest.getOrderActFee()+""));
//        bizContentMap.put("seller_id", AlipayConfig.PARTNER);
//        bizContentMap.put("product_code", AlipayConfig.PRODUCT_CODE);
//        //临时字段,判断是否为新版PDA创建的支付单 zhaowg 2017-12-15
//		String attach = "";
//		if(aliPayOrderRequest.getIsNewPDACreate()!=null && aliPayOrderRequest.getIsNewPDACreate()){
//			attach = "isNewPDACreate";
//		}
//        bizContentMap.put("passback_params", attach);
//        return bizContentMap;createOrderInfo
//    }
//
//    /**
//	 * 返回创建的充值订单信息 <br/>
//	 * added by hxz 20170822 <br/>
//	 * @param aliPayOrderRequest
//	 * @return
//	 */
//    public static  Map<String,String> createAcctRechargeOrderInfo(AliPayOrderRequest aliPayOrderRequest){
//    	//业务参数分装
//        Map<String,String> bizContentMap = new HashMap<String,String>();
//        if(StringUtils.isNotEmpty(aliPayOrderRequest.getBody())){
//        	 bizContentMap.put("body", aliPayOrderRequest.getBody());
//        }
//        bizContentMap.put("subject", "手机端app充值"/*aliPayOrderRequest.getSubject()!=null?aliPayOrderRequest.getSubject():""*/);
//        bizContentMap.put("out_trade_no",aliPayOrderRequest.getPayOrderId());
//        bizContentMap.put("total_amount", AmountUtils.changeF2Y(aliPayOrderRequest.getOrderActFee()+""));
//        bizContentMap.put("seller_id", AlipayConfig.PARTNER);
//        bizContentMap.put("product_code", AlipayConfig.PRODUCT_CODE);
//        return bizContentMap;
//    }
//
//    /**
//	 * 获取退款参数
//	 * @param aliPayOrderRequest
//	 * @return
//	 * @throws Exception
//	 */
//	public static String getRefundMessage(AlipayTradeRefundQueryRequest alipayTradeRefundQueryRequest) throws Exception {
//		logger.info("【{}】开始获取退款请求参数AliPayUtil.getRefundMessage()方法,入参={}"+ JSONObject.toJSON(alipayTradeRefundQueryRequest).toString());
//		SimpleDateFormat formart = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
//		String timestamp = formart.format(new Date());
//		//公共参数
//        Map<String, String> map = new HashMap<String, String>();
//        map.put("app_id", AlipayConfig.APPID);
//        map.put("method", AlipayConfig.METHOD_REFUND);
//        map.put("format", AlipayConfig.FORMAT_JSON);
//        map.put("charset", AlipayConfig.CHARSET);
//        map.put("sign_type", AlipayConfig.SIGN_TYPE);
//        map.put("timestamp", timestamp);
//        map.put("version", AlipayConfig.VERSION);
//
//        //业务参数分装
//        Map<String,String> bizContentMap = new HashMap<String,String>();
//        bizContentMap.put("out_trade_no","");//订单支付时传入的商户订单号,不能和 trade_no同时为空
//        // bizContentMap.put("trade_no", value);//支付宝交易号,和商户订单号不能同时为空
//        bizContentMap.put("refund_amount", "");//需要退款的金额,该金额不能大于订单金额,单位为元,支持两位小数
//        bizContentMap.put("refund_reason", "");// 可选 	256 	退款的原因说明
//        bizContentMap.put("out_request_no ", "");//标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传
//        //转换成json
//        Object json =JSONArray.toJSON(bizContentMap);
//       //添加业务参数
//        map.put("biz_content", json+"");
//        String returnJson = AliPayUtil.createLinkString(map);
//        logger.info("签名前 串:"+returnJson);
//      //对未签名原始字符串进行签名
//        String rsaSign = AliPayUtil.createSigin(returnJson, AlipayConfig.APP_PRIVATE_KEY, AlipayConfig.CHARSET);
//        logger.info("签名 后:"+returnJson);
//
//        //最后对请求字符串的所有一级value(biz_content作为一个value)进行encode
//        Map<String, String> mapcode = new HashMap<String, String>();
//        mapcode.put("app_id", AlipayConfig.APPID);
//        mapcode.put("method", AlipayConfig.METHOD_REFUND);
//        mapcode.put("format", AlipayConfig.FORMAT_JSON);
//        mapcode.put("charset", AlipayConfig.CHARSET);
//        mapcode.put("sign_type", AlipayConfig.SIGN_TYPE);
//        mapcode.put("timestamp", URLEncoder.encode(timestamp,AlipayConfig.CHARSET));
//        mapcode.put("version", AlipayConfig.VERSION);
//        mapcode.put("biz_content", URLEncoder.encode(json+"",AlipayConfig.CHARSET));
//
//        String returnJso2 = AliPayUtil.createLinkString(mapcode);
//        returnJso2+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("发起退款参数"+returnJso2);
//		return  returnJso2;
//
//	}
//
//	public static void main(String[] args) throws Exception {
//
//		//Map<String,String> map = new HashMap<String,String>();
//		//map.put("a", "123");
//		//map.put("app_id", APPID);
//		//String sigin = AlipayJavaSDK.sigin(map, APP_PRIVATE_KEY, CHARSET);
//		//System.out.println(sigin);
//		AliPayOrderRequest aliPayOrderRequest = new AliPayOrderRequest();
//		aliPayOrderRequest.setBody("手机端发起支付");
//		aliPayOrderRequest.setSubject("车辆支付订单");
//		aliPayOrderRequest.setParkOrderId("1000112");
//		aliPayOrderRequest.setOrderActFee(BigDecimal.valueOf(Double.parseDouble("0.01")));
//		String json = AliPayUtil.getPayOutMessage(aliPayOrderRequest);
//		System.out.println("==json=="+json);
//
//
//	}
//
//	/**
//	 * 获取补缴请求参数.<br/>
//	 * @param aliPayOrderRequest
//	 * @return
//	 * @throws Exception
//	 */
//	public static String getPayBackMessage(AliPayOrderRequest aliPayOrderRequest) throws Exception {
//		logger.info("【{}】开始获取支付请求参数AliPayUtil.getPayOutMessage()方法,入参={}",aliPayOrderRequest.getBaseRequest().getRequestId(),JSONObject.toJSON(aliPayOrderRequest).toString());
//		SimpleDateFormat formart = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
//		String timestamp = formart.format(new Date());
//		//公共参数
//        Map<String, String> map = new HashMap<String, String>();
//        map.put("app_id", AlipayConfig.APPID);
//        map.put("method", AlipayConfig.METHOD);
//        map.put("format", AlipayConfig.FORMAT_JSON);
//        map.put("charset", AlipayConfig.CHARSET);
//        map.put("sign_type", AlipayConfig.SIGN_TYPE);
//        map.put("timestamp", timestamp);
//        map.put("version", AlipayConfig.VERSION);
//		/**微信-支付停车订单补缴-异步回调*/
//		logger.info("补缴订单:"+payNotifyUrl.getALIPAY_PAYBACK_NOTIFY_URL());
//		map.put("notify_url",  payNotifyUrl.getALIPAY_PAYBACK_NOTIFY_URL());
//        //业务参数分装
//        Map<String,String> bizContentMap = AliPayUtil.createOrderBackInfo(aliPayOrderRequest);
//
//        //转换成json
//        Object json ="";
//        if(bizContentMap != null && bizContentMap.size() > 0){
//            json = JSONArray.toJSON(bizContentMap);
//        }
//       //添加业务参数
//        map.put("biz_content", json+"");
//        String returnJson = AliPayUtil.createLinkString(map);
//        logger.info("签名前 串:"+returnJson);
//      //对未签名原始字符串进行签名
//        String rsaSign = AliPayUtil.createSigin(returnJson, AlipayConfig.APP_PRIVATE_KEY, AlipayConfig.CHARSET);
//
//
//       // returnJson+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("签名 后:"+returnJson);
//
//        //最后对请求字符串的所有一级value(biz_content作为一个value)进行encode
//        Map<String, String> mapcode = new HashMap<String, String>();
//        mapcode.put("app_id", AlipayConfig.APPID);
//        mapcode.put("method", AlipayConfig.METHOD);
//        mapcode.put("format", AlipayConfig.FORMAT_JSON);
//        mapcode.put("charset", AlipayConfig.CHARSET);
//        mapcode.put("sign_type", AlipayConfig.SIGN_TYPE);
//        mapcode.put("timestamp", URLEncoder.encode(timestamp,AlipayConfig.CHARSET));
//        mapcode.put("version", AlipayConfig.VERSION);
//
//		/**微信-支付停车订单-异步回调*/
//		logger.info("支付停车订单:"+payNotifyUrl.getALIPAY_PAYBACK_NOTIFY_URL());
//		mapcode.put("notify_url",  URLEncoder.encode(payNotifyUrl.getALIPAY_PAYBACK_NOTIFY_URL(),AlipayConfig.CHARSET));
//
//        mapcode.put("biz_content", URLEncoder.encode(json+"",AlipayConfig.CHARSET));
//
//        String returnJso2 = AliPayUtil.createLinkString(mapcode);
//       // Map<String,String> par = AliPayUtil.paraFilter(mapcode); //除去数组中的空值和签名参数
//        //拼接
//
//        returnJso2+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("【{}】编码后返回={}",aliPayOrderRequest.getBaseRequest().getRequestId(),returnJso2);
//
//        logger.info("【{}】结束获取支付请求参数AliPayUtil.getPayOutMessage()方法.",aliPayOrderRequest.getBaseRequest().getRequestId());
//
//		return  returnJso2;
//
//	}
//
//	 /**
//	 * 返回创建的订单信息
//	 * @param aliPayOrderRequest
//	 * @return
//	 */
//    public static  Map<String,String> createOrderBackInfo(AliPayOrderRequest aliPayOrderRequest){
//    	//业务参数分装
//        Map<String,String> bizContentMap = new HashMap<String,String>();
//        if(StringUtils.isNotEmpty(aliPayOrderRequest.getBody())){
//        	 bizContentMap.put("body", aliPayOrderRequest.getBody());
//        }
//        bizContentMap.put("subject", "任你停-欠费补缴"/*aliPayOrderRequest.getSubject()!=null?aliPayOrderRequest.getSubject():""*/);
//        bizContentMap.put("out_trade_no",aliPayOrderRequest.getPayOrderId());
//        bizContentMap.put("total_amount", AmountUtils.changeF2Y(aliPayOrderRequest.getOrderActFee()+""));
//        bizContentMap.put("seller_id", AlipayConfig.PARTNER);
//        bizContentMap.put("product_code", AlipayConfig.PRODUCT_CODE);
//        //临时字段,判断是否为新版PDA创建的支付单 zhaowg 2017-12-15
//		String attach = "";
//		if(aliPayOrderRequest.getIsNewPDACreate()!=null && aliPayOrderRequest.getIsNewPDACreate()){
//			attach = "isNewPDACreate";
//		}
//        bizContentMap.put("passback_params", attach);
//        return bizContentMap;
//    }
//
//
//	/**
//	 * 获取会员卡支付请求参数.<br/>
//	 * @param aliPayOrderRequest
//	 * @return
//	 * @throws Exception
//	 */
//	public static String getPayVipCardMessage(AliPayOrderRequest aliPayOrderRequest) throws Exception {
//		logger.info("【{}】开始获取支付请求参数AliPayUtil.getPayVipCardMessage()方法,入参={}",aliPayOrderRequest.getBaseRequest().getRequestId(),JSONObject.toJSON(aliPayOrderRequest).toString());
//		SimpleDateFormat formart = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
//		String timestamp = formart.format(new Date());
//		//公共参数
//        Map<String, String> map = new HashMap<String, String>();
//        map.put("app_id", AlipayConfig.APPID);
//        map.put("method", AlipayConfig.METHOD);
//        map.put("format", AlipayConfig.FORMAT_JSON);
//        map.put("charset", AlipayConfig.CHARSET);
//        map.put("sign_type", AlipayConfig.SIGN_TYPE);
//        map.put("timestamp", timestamp);
//        map.put("version", AlipayConfig.VERSION);
//		/**微信-会员卡-异步回调*/
//		logger.info("会员卡订单:"+payNotifyUrl.getAlipay_vipcard_notifu_url());
//		map.put("notify_url",  payNotifyUrl.getAlipay_vipcard_notifu_url());
//        //业务参数分装
//        Map<String,String> bizContentMap = AliPayUtil.createOrderVipCardInfo(aliPayOrderRequest);
//
//        //转换成json
//        Object json ="";
//        if(bizContentMap != null && bizContentMap.size() > 0){
//            json = JSONArray.toJSON(bizContentMap);
//        }
//       //添加业务参数
//        map.put("biz_content", json+"");
//        String returnJson = AliPayUtil.createLinkString(map);
//        logger.info("签名前 串:"+returnJson);
//      //对未签名原始字符串进行签名
//        String rsaSign = AliPayUtil.createSigin(returnJson, AlipayConfig.APP_PRIVATE_KEY, AlipayConfig.CHARSET);
//
//
//       // returnJson+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("签名 后:"+returnJson);
//
//        //最后对请求字符串的所有一级value(biz_content作为一个value)进行encode
//        Map<String, String> mapcode = new HashMap<String, String>();
//        mapcode.put("app_id", AlipayConfig.APPID);
//        mapcode.put("method", AlipayConfig.METHOD);
//        mapcode.put("format", AlipayConfig.FORMAT_JSON);
//        mapcode.put("charset", AlipayConfig.CHARSET);
//        mapcode.put("sign_type", AlipayConfig.SIGN_TYPE);
//        mapcode.put("timestamp", URLEncoder.encode(timestamp,AlipayConfig.CHARSET));
//        mapcode.put("version", AlipayConfig.VERSION);
//
//		/**微信-支付停车订单-异步回调*/
//		logger.info("支付停车订单:"+payNotifyUrl.getAlipay_vipcard_notifu_url());
//		mapcode.put("notify_url",  URLEncoder.encode(payNotifyUrl.getAlipay_vipcard_notifu_url(),AlipayConfig.CHARSET));
//
//        mapcode.put("biz_content", URLEncoder.encode(json+"",AlipayConfig.CHARSET));
//
//        String returnJso2 = AliPayUtil.createLinkString(mapcode);
//       // Map<String,String> par = AliPayUtil.paraFilter(mapcode); //除去数组中的空值和签名参数
//        //拼接
//
//        returnJso2+="&sign=" + URLEncoder.encode(rsaSign, "UTF-8");
//        logger.info("【{}】编码后返回={}",aliPayOrderRequest.getBaseRequest().getRequestId(),returnJso2);
//
//        logger.info("【{}】结束获取支付请求参数AliPayUtil.getPayOutMessage()方法.",aliPayOrderRequest.getBaseRequest().getRequestId());
//
//		return  returnJso2;
//
//	}
//
//	 /**
//		 * 返回创建的订单信息
//		 * @param aliPayOrderRequest
//		 * @return
//		 */
//	    public static  Map<String,String> createOrderVipCardInfo(AliPayOrderRequest aliPayOrderRequest){
//	    	//业务参数分装
//	        Map<String,String> bizContentMap = new HashMap<String,String>();
//	        if(StringUtils.isNotEmpty(aliPayOrderRequest.getBody())){
//	        	 bizContentMap.put("body", aliPayOrderRequest.getBody());
//	        }
//	        if(PayOrderEnum.PAY_RESOURCE_TYPE_VIP.getValue().equals(aliPayOrderRequest.getPaySrcType()+"")){
//	        	bizContentMap.put("subject", "任你停-购买会员卡");
//	        }else{
//	        	bizContentMap.put("subject", "任你停-会员卡续费");
//	        }
//	        bizContentMap.put("out_trade_no",aliPayOrderRequest.getPayOrderId());
//	        bizContentMap.put("total_amount", AmountUtils.changeF2Y(aliPayOrderRequest.getOrderActFee()+""));
//	        bizContentMap.put("seller_id", AlipayConfig.PARTNER);
//	        bizContentMap.put("product_code", AlipayConfig.PRODUCT_CODE);
//	        //临时字段,判断是否为新版PDA创建的支付单 zhaowg 2017-12-15
//			String attach = "";
//			if(aliPayOrderRequest.getIsNewPDACreate()!=null && aliPayOrderRequest.getIsNewPDACreate()){
//				attach = "isNewPDACreate";
//			}
//	        bizContentMap.put("passback_params", attach);
//	        return bizContentMap;
//	    }
//
//}