Blame view

parking-module-pay/src/main/java/com/zteits/pay/weixinpublic/WeiXinPublicPayUtil.java 5.6 KB
55f68655   王彪总   新项目
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
  //package com.zteits.pay.weixinpublic;
  //
  //import java.util.HashMap;
  //import java.util.Map;
  //
  //import org.apache.commons.lang3.StringUtils;
  //import com.alibaba.fastjson.JSONObject;
  //
  //import com.clouds.common.utils.WxConfigUtil;
  //import com.zteits.clouds.api.apibase.bean.BizResult;
  //import com.zteits.clouds.api.apibase.constants.ErrorType;
  //import com.zteits.clouds.api.dto.pay.TdBPayOrderDTO;
  //import com.zteits.clouds.api.dto.pay.TdBWxConfigDTO;
  //import com.zteits.pay.weixin.util.PaymentUtil;
  //import com.zteits.pay.weixinpublic.util.PaymentApi;
  //import com.zteits.pay.weixinpublic.util.TradeType;
  //
  //import org.eclipse.jetty.util.StringUtil;
  //import org.slf4j.Logger;
  //import org.slf4j.LoggerFactory;
  //
  ///**
  // * 微信公众号统一下单工具类.<br/>
  // *
  // * Copyright: Copyright (c) 2017  zteits
  // *
  // * @ClassName: WeiXinPublicPayUtil.java
  // * @Description:
  // * @version: v1.0.0
  // * @author: wangfs
  // * @date: 2017年9月4日   下午7:01:55
  // * Modification History:
  // * Date             Author          Version            Description
  // * ---------------------------------------------------------*
  // * 2017年9月4日      wangfs           v1.0.0               创建
  // */
  //
  //public class WeiXinPublicPayUtil {
  //
  //    private static final Logger logger = LoggerFactory.getLogger(WeiXinPublicPayUtil.class);
  //
  //    /**
  //     * 统一下单接口.<br/>
  //     *
  //     * @param payOrderDTO
  //     * @param openId
  //     * @param body TODO
  //     * @return
  //     */
  //    public static BizResult<String> unifiedOrder(TdBPayOrderDTO payOrderDTO, String openId, TdBWxConfigDTO configDTO,
  //        String notifyUrl, String body) {
  //        BizResult<String> bizResult = new BizResult<>();
  //        Map<String, String> params = new HashMap<String, String>();
  //
  //        //封装参数
  //        params.put("appid", configDTO.getAppid());
  //        params.put("mch_id", configDTO.getMchid() + "");
  //        if(StringUtil.isNotBlank(body)) {
  //        	params.put("body", body);
  //        }else {
  //        	params.put("body", "任你停公众号订单支付");
  //        }
  //        params.put("out_trade_no", payOrderDTO.getPayOrderId());
  //        //支付金额
  //        params.put("total_fee", payOrderDTO.getOrderActFee() != null ? payOrderDTO.getOrderActFee().toString() : "0");
  //
  //        params.put("spbill_create_ip", "127.0.0.1");
  //        params.put("trade_type", TradeType.JSAPI.name());
  //        params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
  //        params.put("notify_url", notifyUrl);
  //        params.put("openid", openId);
  //        //临时字段,判断是否为新版PDA创建的支付单 zhaowg 2017-12-15
  //  		String attach = "";
  //  		if(payOrderDTO.getIsNewPDACreate()!=null && payOrderDTO.getIsNewPDACreate()){
  //  			attach = "isNewPDACreate";
  //  		}
  //  		params.put("attach", attach);
  //        
  //        //是否支持信用卡支付
  //        if (configDTO.getIsPayNocredit() == 1) {
  //            //不支持信用卡
  //            params.put("limit_pay", "no_credit");
  //        }
  //        //
  //        String sign = PaymentUtil.createSign(params, WxConfigUtil.decode(configDTO.getPayApiSecret()));
  //        params.put("sign", sign);
  //        logger.info("调用微信支付统一下单接口请求入参为:param=" + JSONObject.toJSONString(params));
  //        String xmlResult = PaymentApi.pushOrder(params);
  //        logger.info("调用微信支付统一下单接口返回结果为:xmlResult=" + xmlResult);
  //        Map<String, String> result = PaymentUtil.xmlToMap(xmlResult);
  //        String return_code = result.get("return_code");
  //        String return_msg = result.get("return_msg");
  //        if (StringUtils.isBlank(return_code) || !"SUCCESS".equals(return_code)) {
  //            bizResult.setData("return_code=" + return_code + "; return_msg=" + return_msg);
  //            bizResult.setErrCode(ErrorType.BIZ_ERROR);
  //            bizResult.setErrMsg("调用微信支付异常,请稍后重试!");
  //            return bizResult;
  //        }
  //        String result_code = result.get("result_code");
  //        if (StringUtils.isBlank(result_code) || !"SUCCESS".equals(result_code)) {
  //            bizResult.setData("result_code=" + result_code + "; return_msg=" + return_msg);
  //            bizResult.setErrCode(ErrorType.BIZ_ERROR);
  //            bizResult.setErrMsg("调用微信支付异常,请稍后重试!");
  //            return bizResult;
  //        }
  //        // 以下字段在return_code 和result_code都为SUCCESS的时候有返回
  //        String prepay_id = result.get("prepay_id");
  //        Map<String, String> packageParams = new HashMap<String, String>();
  //        packageParams.put("appId", configDTO.getAppid());
  //        packageParams.put("timeStamp", System.currentTimeMillis() / 1000 + "");
  //        packageParams.put("nonceStr", System.currentTimeMillis() + "");
  //        packageParams.put("package", "prepay_id=" + prepay_id);
  //        packageParams.put("signType", "MD5");
  //        logger.info("生成签名钱的字符串为: param=" + packageParams.toString());
  //        String packageSign = PaymentUtil.createSign(packageParams, WxConfigUtil.decode(configDTO.getPayApiSecret()));
  //        logger.info("获取到的密钥为: paternerKey=" + WxConfigUtil.decode(configDTO.getPayApiSecret()));
  //        packageParams.put("paySign", packageSign);
  //        //生成js 支付调用串
  //        String paySign = JSONObject.toJSON(packageParams).toString();
  //        logger.info("生成H5 调用支付串为:paySign=" + paySign);
  //        bizResult.setErrCode(ErrorType.BIZ_SUCCESS);
  //        bizResult.setData(paySign);
  //        return bizResult;
  //    }
  //
  //}