|
|
@ -5,8 +5,12 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.hai.common.pay.util.sdk.WXPayConstants; |
|
|
|
import com.hai.common.pay.util.sdk.WXPayConstants; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.common.utils.MD5Util; |
|
|
|
import com.hai.common.utils.MD5Util; |
|
|
|
|
|
|
|
import com.hai.dao.HighPayRecordMapper; |
|
|
|
|
|
|
|
import com.hai.entity.HighPayRecord; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
@ -14,8 +18,12 @@ import java.util.*; |
|
|
|
* 银联支付 |
|
|
|
* 银联支付 |
|
|
|
* @author hurui |
|
|
|
* @author hurui |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Component |
|
|
|
public class UnionPayConfig { |
|
|
|
public class UnionPayConfig { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighPayRecordMapper highPayRecordMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 【注意】请勿随意调用,会更新签名秘钥。会导致接口签名错误 |
|
|
|
* 【注意】请勿随意调用,会更新签名秘钥。会导致接口签名错误 |
|
|
|
* 更新并获取签名密钥 |
|
|
|
* 更新并获取签名密钥 |
|
|
@ -39,7 +47,7 @@ public class UnionPayConfig { |
|
|
|
* @return 响应信息 |
|
|
|
* @return 响应信息 |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static JSONObject upPreOrder(String orderNo, BigDecimal payPrice, String orderDesc) throws Exception { |
|
|
|
public JSONObject upPreOrder(String orderNo, BigDecimal payPrice, String orderDesc,String notifyurl) throws Exception { |
|
|
|
Map<String,Object> paramMap = new HashMap<>(); |
|
|
|
Map<String,Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("channelid", CommonSysConst.getSysConfig().getUnionPayChannelid()); |
|
|
|
paramMap.put("channelid", CommonSysConst.getSysConfig().getUnionPayChannelid()); |
|
|
|
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); |
|
|
|
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); |
|
|
@ -49,8 +57,31 @@ public class UnionPayConfig { |
|
|
|
paramMap.put("tradetype", "APP"); |
|
|
|
paramMap.put("tradetype", "APP"); |
|
|
|
paramMap.put("tradeamt", payPrice.multiply(new BigDecimal("100")).intValue()); |
|
|
|
paramMap.put("tradeamt", payPrice.multiply(new BigDecimal("100")).intValue()); |
|
|
|
paramMap.put("body", orderDesc); |
|
|
|
paramMap.put("body", orderDesc); |
|
|
|
paramMap.put("notifyurl", CommonSysConst.getSysConfig().getUnionPayNotifyUrl()); |
|
|
|
paramMap.put("notifyurl", notifyurl); |
|
|
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
String requestParam = generateRequestParam(paramMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录请求参数
|
|
|
|
|
|
|
|
HighPayRecord payRecord = new HighPayRecord(); |
|
|
|
|
|
|
|
payRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
payRecord.setResType(1); |
|
|
|
|
|
|
|
payRecord.setPayType(3); |
|
|
|
|
|
|
|
payRecord.setPayMoney(payPrice); |
|
|
|
|
|
|
|
payRecord.setBodyInfo(requestParam); |
|
|
|
|
|
|
|
highPayRecordMapper.insert(payRecord); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject responseParam = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), requestParam, new HashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录响应参数
|
|
|
|
|
|
|
|
payRecord = new HighPayRecord(); |
|
|
|
|
|
|
|
payRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
payRecord.setResType(3); |
|
|
|
|
|
|
|
payRecord.setPayType(3); |
|
|
|
|
|
|
|
payRecord.setPayMoney(payPrice); |
|
|
|
|
|
|
|
payRecord.setBodyInfo(responseParam.toString()); |
|
|
|
|
|
|
|
highPayRecordMapper.insert(payRecord); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return responseParam; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -66,10 +97,10 @@ public class UnionPayConfig { |
|
|
|
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); |
|
|
|
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); |
|
|
|
paramMap.put("tradetrace", paySerialNo); |
|
|
|
paramMap.put("tradetrace", paySerialNo); |
|
|
|
paramMap.put("opt", "tradeQuery"); |
|
|
|
paramMap.put("opt", "tradeQuery"); |
|
|
|
paramMap.put("tradetype", "samecardQuery"); |
|
|
|
|
|
|
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); |
|
|
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 交易退货 |
|
|
|
* 交易退货 |
|
|
|
* @param orderNo 订单号 |
|
|
|
* @param orderNo 订单号 |
|
|
@ -84,12 +115,30 @@ public class UnionPayConfig { |
|
|
|
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); |
|
|
|
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); |
|
|
|
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); |
|
|
|
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); |
|
|
|
paramMap.put("tradetrace", orderNo); |
|
|
|
paramMap.put("tradetrace", orderNo); |
|
|
|
paramMap.put("oritradetrace", paySerialNo); |
|
|
|
paramMap.put("oriwtorderid", paySerialNo); |
|
|
|
paramMap.put("tradeamt", refundPrice); |
|
|
|
paramMap.put("tradeamt", refundPrice); |
|
|
|
paramMap.put("opt", "zwrefund"); |
|
|
|
paramMap.put("opt", "zwrefund"); |
|
|
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); |
|
|
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 交易撤销 |
|
|
|
|
|
|
|
* @param orderNo 订单号 |
|
|
|
|
|
|
|
* @param paySerialNo 第三方订单号 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static JSONObject cancel(String orderNo,String paySerialNo) throws Exception { |
|
|
|
|
|
|
|
Map<String,Object> paramMap = new HashMap<>(); |
|
|
|
|
|
|
|
paramMap.put("channelid", CommonSysConst.getSysConfig().getUnionPayChannelid()); |
|
|
|
|
|
|
|
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); |
|
|
|
|
|
|
|
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); |
|
|
|
|
|
|
|
paramMap.put("tradetrace", orderNo); |
|
|
|
|
|
|
|
paramMap.put("oriwtorderid", paySerialNo); |
|
|
|
|
|
|
|
paramMap.put("opt", "cancel"); |
|
|
|
|
|
|
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 参数排序 |
|
|
|
* 参数排序 |
|
|
|
* @param param |
|
|
|
* @param param |
|
|
|