|
|
@ -8,6 +8,8 @@ import com.hai.common.utils.HttpsUtils; |
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
import com.hai.entity.HighOrder; |
|
|
|
import com.hai.entity.HighOrder; |
|
|
|
import com.hai.entity.HighOrderRefund; |
|
|
|
import com.hai.entity.HighOrderRefund; |
|
|
|
|
|
|
|
import com.hai.enum_type.OrderStatusEnum; |
|
|
|
|
|
|
|
import com.hai.order.type.OrderPayType; |
|
|
|
import com.hai.pay.channel.huift.config.HuiftConfig; |
|
|
|
import com.hai.pay.channel.huift.config.HuiftConfig; |
|
|
|
import com.hai.service.HighOrderService; |
|
|
|
import com.hai.service.HighOrderService; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
@ -72,19 +74,32 @@ public class TradeService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 交易退款 |
|
|
|
* 交易退款 |
|
|
|
* @param orderRefund |
|
|
|
* @param refundOrderNo 退款订单号 |
|
|
|
|
|
|
|
* @param refundPrice 退款金额 |
|
|
|
|
|
|
|
* @param orderNo 订单号 |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public JSONObject thirdPayRefund(HighOrderRefund orderRefund) throws Exception { |
|
|
|
public JSONObject thirdPayRefund(String refundOrderNo, BigDecimal refundPrice, String orderNo) throws Exception { |
|
|
|
// 查询订单
|
|
|
|
// 查询订单
|
|
|
|
HighOrder order = orderService.getOrderById(orderRefund.getId()); |
|
|
|
HighOrder order = orderService.getOrderByOrderNo(orderNo); |
|
|
|
|
|
|
|
if (order == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的的订单"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!order.getOrderStatus().equals(OrderStatusEnum.type2.getType()) |
|
|
|
|
|
|
|
&& !order.getOrderStatus().equals(OrderStatusEnum.type3.getType()) |
|
|
|
|
|
|
|
&& !order.getOrderStatus().equals(OrderStatusEnum.type7.getType())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单当前状态无法退款"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!order.getPayType().equals(OrderPayType.PAY_TYPE10.getNumber())) { |
|
|
|
|
|
|
|
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", HuiftConfig.shopcode); |
|
|
|
param.put("preOrderNo", order.getPayChannelOrderNo()); |
|
|
|
param.put("preOrderNo", order.getPayChannelOrderNo()); |
|
|
|
param.put("outRefundNo", orderRefund.getRefundOrderNo()); |
|
|
|
param.put("outRefundNo", refundOrderNo); |
|
|
|
param.put("refundAmt", orderRefund.getRefundPrice().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, HuiftConfig.signSecret).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")) { |
|
|
|