|
|
|
@ -16,6 +16,7 @@ import com.hai.common.pay.util.sdk.WXPayConstants; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.common.utils.WxUtils; |
|
|
|
|
import com.hai.config.HuiLianTongUnionCardConfig; |
|
|
|
|
import com.hai.config.UnionPayConfig; |
|
|
|
|
import com.hai.entity.HighRefundAudit; |
|
|
|
|
import com.hai.entity.OutRechargeOrder; |
|
|
|
|
import com.hai.model.*; |
|
|
|
@ -260,33 +261,8 @@ public class OutRechargeOrderController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getPayType() == 2) { |
|
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); |
|
|
|
|
|
|
|
|
|
if (jsonObject == null) { |
|
|
|
|
log.error("orderToPay error!", "请求超时"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); |
|
|
|
|
|
|
|
|
|
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { |
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo("HFR"+new Date().getTime() ); |
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
order.setRefundId(dataObject.getString("orderId")); |
|
|
|
|
|
|
|
|
|
highRefundAudit.setStatus(1); |
|
|
|
|
highRefundAuditService.updateRefundAudit(highRefundAudit); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
return ResponseMsgUtil.success("退款成功"); |
|
|
|
|
} else { |
|
|
|
|
log.error("orderToPay error!", dataObject.getString("message")); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
// 微信退款
|
|
|
|
|
if (order.getPayType() == 1) { |
|
|
|
|
Map<String,String> param = new HashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
@ -312,13 +288,57 @@ public class OutRechargeOrderController { |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
highRefundAudit.setStatus(1); |
|
|
|
|
highRefundAuditService.updateRefundAudit(highRefundAudit); |
|
|
|
|
return ResponseMsgUtil.success("退款成功"); |
|
|
|
|
} else { |
|
|
|
|
log.error("orderToPay error!", "退款失败"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 工会卡退款
|
|
|
|
|
if (order.getPayType() == 2) { |
|
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); |
|
|
|
|
|
|
|
|
|
if (jsonObject == null) { |
|
|
|
|
log.error("orderToPay error!", "请求超时"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); |
|
|
|
|
|
|
|
|
|
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { |
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo("HFR"+new Date().getTime() ); |
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
order.setRefundId(dataObject.getString("orderId")); |
|
|
|
|
|
|
|
|
|
highRefundAudit.setStatus(1); |
|
|
|
|
highRefundAuditService.updateRefundAudit(highRefundAudit); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
log.error("orderToPay error!", dataObject.getString("message")); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 银联退款
|
|
|
|
|
if (order.getPayType() == 4) { |
|
|
|
|
// 订单退款
|
|
|
|
|
JSONObject refund = UnionPayConfig.zwrefund(order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); |
|
|
|
|
if (!refund.getString("resultcode").equals("W6")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo(refund.getString("oriwtorderid")); |
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
highRefundAudit.setStatus(1); |
|
|
|
|
highRefundAuditService.updateRefundAudit(highRefundAudit); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success("退款成功"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOrderController --> getUserOrderList() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|