|
|
@ -7,6 +7,7 @@ import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.common.utils.HttpsUtils; |
|
|
|
import com.hfkj.common.utils.HttpsUtils; |
|
|
|
import com.hfkj.config.CommonSysConst; |
|
|
|
import com.hfkj.config.CommonSysConst; |
|
|
|
import com.hfkj.entity.BsOrder; |
|
|
|
import com.hfkj.entity.BsOrder; |
|
|
|
|
|
|
|
import com.hfkj.entity.BsOrderChild; |
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
|
import com.hfkj.service.order.BsOrderService; |
|
|
|
import com.hfkj.service.order.BsOrderService; |
|
|
|
import com.hfkj.service.pay.huift.config.HuiftConfig; |
|
|
|
import com.hfkj.service.pay.huift.config.HuiftConfig; |
|
|
@ -36,16 +37,16 @@ public class TradeService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public JSONObject thirdPreOrder(OrderModel order) throws Exception { |
|
|
|
public JSONObject thirdPreOrder(OrderModel order , String shopCode , String signSecret) throws Exception { |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("shopCode", HuiftConfig.shopcode); |
|
|
|
param.put("shopCode", shopCode); |
|
|
|
param.put("outTradeNo", order.getOrderNo()); |
|
|
|
param.put("outTradeNo", order.getOrderNo()); |
|
|
|
param.put("transAmt", order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()); |
|
|
|
param.put("transAmt", order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()); |
|
|
|
param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/order/notify/huiftPay"); |
|
|
|
param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/order/notify/huiftPay"); |
|
|
|
// param.put("remark", ""); // 备注
|
|
|
|
// param.put("remark", ""); // 备注
|
|
|
|
// param.put("outAppId", "");
|
|
|
|
// param.put("outAppId", "");
|
|
|
|
param.put("outRedirectPath", CommonSysConst.getSysConfig().getDomainName()+"/cweb/#/order/order/orderList"); |
|
|
|
param.put("outRedirectPath", CommonSysConst.getSysConfig().getDomainName()+"/cweb/#/order/order/orderList"); |
|
|
|
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase()); |
|
|
|
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, signSecret).getBytes()).toLowerCase()); |
|
|
|
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPreOrder", JSONObject.toJSONString(param)); |
|
|
|
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPreOrder", JSONObject.toJSONString(param)); |
|
|
|
if (response.getString("status").equals("ok")) { |
|
|
|
if (response.getString("status").equals("ok")) { |
|
|
|
return response.getJSONObject("data"); |
|
|
|
return response.getJSONObject("data"); |
|
|
@ -59,11 +60,11 @@ public class TradeService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public JSONObject thirdPayResult(String preOrderNo) throws Exception { |
|
|
|
public JSONObject thirdPayResult(String preOrderNo , String shopCode , String signSecret) throws Exception { |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("shopCode", HuiftConfig.shopcode); |
|
|
|
param.put("shopCode", shopCode); |
|
|
|
param.put("preOrderNo", preOrderNo); |
|
|
|
param.put("preOrderNo", preOrderNo); |
|
|
|
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase()); |
|
|
|
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, signSecret).getBytes()).toLowerCase()); |
|
|
|
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayResult", JSONObject.toJSONString(param)); |
|
|
|
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayResult", JSONObject.toJSONString(param)); |
|
|
|
if (response.getString("status").equals("ok")) { |
|
|
|
if (response.getString("status").equals("ok")) { |
|
|
|
return response.getJSONObject("data"); |
|
|
|
return response.getJSONObject("data"); |
|
|
@ -82,6 +83,7 @@ public class TradeService { |
|
|
|
public JSONObject thirdPayRefund(String refundOrderNo, BigDecimal refundPrice, String orderNo) throws Exception { |
|
|
|
public JSONObject thirdPayRefund(String refundOrderNo, BigDecimal refundPrice, String orderNo) throws Exception { |
|
|
|
// 查询订单
|
|
|
|
// 查询订单
|
|
|
|
BsOrder order = orderService.getOrder(orderNo); |
|
|
|
BsOrder order = orderService.getOrder(orderNo); |
|
|
|
|
|
|
|
OrderModel orderModel = orderService.getDetail(orderNo); |
|
|
|
if (order == null) { |
|
|
|
if (order == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的的订单"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的的订单"); |
|
|
|
} |
|
|
|
} |
|
|
@ -93,11 +95,11 @@ public class TradeService { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
param.put("shopCode", HuiftConfig.shopcode); |
|
|
|
param.put("shopCode", orderModel.getOrderChildList().get(0).getSettleAccount()); |
|
|
|
param.put("preOrderNo", order.getPayChannelOrderNo()); |
|
|
|
param.put("preOrderNo", order.getPayChannelOrderNo()); |
|
|
|
param.put("outRefundNo", refundOrderNo); |
|
|
|
param.put("outRefundNo", refundOrderNo); |
|
|
|
param.put("refundAmt", refundPrice.multiply(new BigDecimal("100")).intValue()); |
|
|
|
param.put("refundAmt", refundPrice.multiply(new BigDecimal("100")).intValue()); |
|
|
|
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase()); |
|
|
|
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, orderModel.getOrderChildList().get(0).getSettleAccountKey()).getBytes()).toLowerCase()); |
|
|
|
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayRefund", JSONObject.toJSONString(param)); |
|
|
|
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayRefund", JSONObject.toJSONString(param)); |
|
|
|
if (response.getString("status").equals("ok")) { |
|
|
|
if (response.getString("status").equals("ok")) { |
|
|
|
return response.getJSONObject("data"); |
|
|
|
return response.getJSONObject("data"); |
|
|
|