|
|
@ -587,6 +587,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
public void rechargeOrderToRefund(Long orderId) throws Exception { |
|
|
|
public void rechargeOrderToRefund(Long orderId) throws Exception { |
|
|
|
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); |
|
|
|
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("发起退款------------------------------------------------------------------------------" + orderId); |
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
if (order.getPayStatus() != 102) { |
|
|
|
if (order.getPayStatus() != 102) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
@ -597,88 +598,84 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 1:支付宝 2:微信 3:汇联通工会卡 4:银联 5:银联分期
|
|
|
|
// 退还积分
|
|
|
|
if (order.getPayType() == null) { |
|
|
|
if (order.getIntegralNum().compareTo(new BigDecimal(0)) > 0) { |
|
|
|
// 退还积分
|
|
|
|
highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId()); |
|
|
|
if (order.getIntegralNum() != null) { |
|
|
|
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId()); |
|
|
|
order.setPayStatus(105); |
|
|
|
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
order.setRechargeStatus(203); |
|
|
|
order.setPayStatus(105); |
|
|
|
order.setRefundTime(new Date()); |
|
|
|
order.setRechargeStatus(203); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
// 微信退款
|
|
|
|
// 微信退款
|
|
|
|
if (order.getPayType() == 2) { |
|
|
|
if (order.getPayType() == 2) { |
|
|
|
Map<String, String> param = new HashMap<>(); |
|
|
|
Map<String, String> param = new HashMap<>(); |
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
param.put("sub_mch_id", "1614670195"); |
|
|
|
param.put("sub_mch_id", "1614670195"); |
|
|
|
param.put("nonce_str", WxUtils.makeNonStr()); |
|
|
|
param.put("nonce_str", WxUtils.makeNonStr()); |
|
|
|
param.put("transaction_id", order.getPaySerialNo()); |
|
|
|
param.put("transaction_id", order.getPaySerialNo()); |
|
|
|
param.put("out_refund_no", "HFR" + new Date().getTime()); |
|
|
|
param.put("out_refund_no", "HFR" + new Date().getTime()); |
|
|
|
param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); |
|
|
|
param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); |
|
|
|
param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); |
|
|
|
param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); |
|
|
|
param.put("sign_type", "HMAC-SHA256"); |
|
|
|
param.put("sign_type", "HMAC-SHA256"); |
|
|
|
|
|
|
|
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); |
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); |
|
|
|
param.put("sign", signStr); |
|
|
|
param.put("sign", signStr); |
|
|
|
|
|
|
|
|
|
|
|
String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); |
|
|
|
String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); |
|
|
|
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); |
|
|
|
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); |
|
|
|
if (orderRefundModel.getResult_code().equals("SUCCESS")) { |
|
|
|
if (orderRefundModel.getResult_code().equals("SUCCESS")) { |
|
|
|
order.setPayStatus(105); |
|
|
|
order.setPayStatus(105); |
|
|
|
order.setRechargeStatus(203); |
|
|
|
order.setRechargeStatus(203); |
|
|
|
order.setRefundTime(new Date()); |
|
|
|
order.setRefundTime(new Date()); |
|
|
|
order.setOutRefundNo(orderRefundModel.getOut_refund_no()); |
|
|
|
order.setOutRefundNo(orderRefundModel.getOut_refund_no()); |
|
|
|
order.setRefundId(orderRefundModel.getRefund_id()); |
|
|
|
order.setRefundId(orderRefundModel.getRefund_id()); |
|
|
|
order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); |
|
|
|
order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:" + orderRefundModel.getErr_code() + ",错误描述" + orderRefundModel.getErr_code_des()); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:" + orderRefundModel.getErr_code() + ",错误描述" + orderRefundModel.getErr_code_des()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 工会卡退款
|
|
|
|
// 工会卡退款
|
|
|
|
if (order.getPayType() == 3) { |
|
|
|
if (order.getPayType() == 3) { |
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); |
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); |
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject == null) { |
|
|
|
|
|
|
|
jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { |
|
|
|
|
|
|
|
order.setPayStatus(105); |
|
|
|
|
|
|
|
order.setRechargeStatus(203); |
|
|
|
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
|
|
|
order.setOutRefundNo("HFR" + new Date().getTime()); |
|
|
|
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
|
|
|
order.setRefundId(dataObject.getString("orderId")); |
|
|
|
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
if (jsonObject == null) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); |
|
|
|
jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 银联退款
|
|
|
|
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); |
|
|
|
if (order.getPayType() == 4) { |
|
|
|
|
|
|
|
// 订单退款
|
|
|
|
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { |
|
|
|
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, 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.setPayStatus(105); |
|
|
|
order.setPayStatus(105); |
|
|
|
order.setRechargeStatus(203); |
|
|
|
order.setRechargeStatus(203); |
|
|
|
order.setRefundTime(new Date()); |
|
|
|
order.setRefundTime(new Date()); |
|
|
|
order.setOutRefundNo(refund.getString("oriwtorderid")); |
|
|
|
order.setOutRefundNo("HFR" + new Date().getTime()); |
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
|
|
|
order.setRefundId(dataObject.getString("orderId")); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 银联退款
|
|
|
|
|
|
|
|
if (order.getPayType() == 4) { |
|
|
|
|
|
|
|
// 订单退款
|
|
|
|
|
|
|
|
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, 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.setPayStatus(105); |
|
|
|
|
|
|
|
order.setRechargeStatus(203); |
|
|
|
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
|
|
|
order.setOutRefundNo(refund.getString("oriwtorderid")); |
|
|
|
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -755,21 +752,46 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
outRechargeChildOrderService.updateOrder(childOrder); |
|
|
|
outRechargeChildOrderService.updateOrder(childOrder); |
|
|
|
type = childOrder.getRechargePlatform(); |
|
|
|
type = childOrder.getRechargePlatform(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 查询充值子订单
|
|
|
|
|
|
|
|
Map<String, Object> childOrderMap103 = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childOrderMap.put("parent_order_id", outRechargeOrder.getId()); |
|
|
|
|
|
|
|
childOrderMap.put("status", 103); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OutRechargeChildOrder> childOrderList103 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap103); |
|
|
|
|
|
|
|
if (childOrderList103.size() > 0) { |
|
|
|
|
|
|
|
type = childOrderList103.get(0).getRechargePlatform(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == 2) { |
|
|
|
|
|
|
|
type = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
type++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
|
|
|
|
|
|
|
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); |
|
|
|
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); |
|
|
|
|
|
|
|
|
|
|
|
String[] rechargePlatform = outRechargePrice.getRechargePlatform().split("-"); |
|
|
|
String string = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] rechargePlatform = string.split("-"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.length() == 1) { |
|
|
|
|
|
|
|
type = Integer.parseInt(string); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String s : rechargePlatform) { |
|
|
|
for (String s : rechargePlatform) { |
|
|
|
// 尖椒充值
|
|
|
|
// 尖椒充值
|
|
|
|
if (s.equals("1") && (type == 2 || type == 0)) { |
|
|
|
if (s.equals("1") && type == 1) { |
|
|
|
object.put("out_order_id", orderNo); |
|
|
|
object.put("out_order_id", orderNo); |
|
|
|
object.put("amount", outRechargePrice.getRechargePrice()); |
|
|
|
object.put("amount", outRechargePrice.getRechargePrice()); |
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
if (outRechargePrice.getRechargeType() == 1) { |
|
|
|
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); |
|
|
|
|
|
|
|
System.out.println("outRechargeOrder-----------------------------------------------------------------------------------------------------------------------------------------------------" + outRechargePrice.getRechargeType()); |
|
|
|
|
|
|
|
if (outRechargeOrder.getRechargeType() == 1) { |
|
|
|
object.put("is_fast", 1); |
|
|
|
object.put("is_fast", 1); |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); |
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); |
|
|
@ -782,11 +804,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
rechargePlatformType = 1; |
|
|
|
rechargePlatformType = 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (s.equals("2") && (type == 1 || type == 0)) { |
|
|
|
// 龙阅充值
|
|
|
|
|
|
|
|
if (s.equals("2") && type == 2) { |
|
|
|
object.put("out_trade_num", orderNo); |
|
|
|
object.put("out_trade_num", orderNo); |
|
|
|
object.put("product_id", outRechargePrice.getGoodsId()); |
|
|
|
object.put("product_id", outRechargePrice.getGoodsId()); |
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
object.put("mobile", outRechargeOrder.getRechargeContent()); |
|
|
|
|
|
|
|
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); |
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); |
|
|
|
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); |
|
|
|
|
|
|
|
System.out.println("龙阅请求回调地址---------------------" + CommonSysConst.getSysConfig().getLyNotifyUrl()); |
|
|
|
object.put("return_content", returnObject); |
|
|
|
object.put("return_content", returnObject); |
|
|
|
if (returnObject != null && returnObject.getLong("errno") == 0) { |
|
|
|
if (returnObject != null && returnObject.getLong("errno") == 0) { |
|
|
|
childOrder.setStatus(102); |
|
|
|
childOrder.setStatus(102); |
|
|
|