|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.bweb.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.bweb.config.SysConst; |
|
|
|
|
import com.bweb.model.ExportOutRechargeOrder; |
|
|
|
|
import com.bweb.model.ExportOutRechargeOrderCount; |
|
|
|
@ -14,6 +15,7 @@ import com.hai.common.pay.util.XmlUtil; |
|
|
|
|
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.entity.OutRechargeOrder; |
|
|
|
|
import com.hai.model.*; |
|
|
|
|
import com.hai.service.OutRechargeOrderService; |
|
|
|
@ -124,6 +126,7 @@ public class OutRechargeOrderController { |
|
|
|
|
@RequestParam(name = "rechargeModel", required = false) String rechargeModel, |
|
|
|
|
@RequestParam(name = "rechargeContent", required = false) String rechargeContent, |
|
|
|
|
@RequestParam(name = "userPhone", required = false) String userPhone, |
|
|
|
|
@RequestParam(name = "payType", required = false) Integer payType, |
|
|
|
|
@RequestParam(name = "payTimeS", required = false) Long payTimeS, |
|
|
|
|
@RequestParam(name = "payTimeE", required = false) Long payTimeE, |
|
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
@ -150,7 +153,10 @@ public class OutRechargeOrderController { |
|
|
|
|
if (StringUtils.isNotBlank(userPhone)) { |
|
|
|
|
map.put("userPhone", userPhone); |
|
|
|
|
} |
|
|
|
|
if (payType != null) { |
|
|
|
|
map.put("payType" , payType.toString()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (payTimeS != null) { |
|
|
|
|
map.put("payTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeS)); |
|
|
|
|
} |
|
|
|
@ -189,6 +195,7 @@ public class OutRechargeOrderController { |
|
|
|
|
@RequestParam(name = "rechargeModel", required = false) String rechargeModel, |
|
|
|
|
@RequestParam(name = "rechargeContent", required = false) String rechargeContent, |
|
|
|
|
@RequestParam(name = "userPhone", required = false) String userPhone, |
|
|
|
|
@RequestParam(name = "payType", required = false) Integer payType, |
|
|
|
|
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
|
|
|
|
@RequestParam(name = "createTimeE", required = false) Long createTimeE, |
|
|
|
|
@RequestParam(name = "payTimeS", required = false) Long payTimeS, |
|
|
|
@ -201,6 +208,7 @@ public class OutRechargeOrderController { |
|
|
|
|
map.put("rechargeModel", rechargeModel); |
|
|
|
|
map.put("rechargeContent", rechargeContent); |
|
|
|
|
map.put("userPhone", userPhone); |
|
|
|
|
map.put("payType", payType); |
|
|
|
|
map.put("createTimeS", createTimeS); |
|
|
|
|
map.put("createTimeE", createTimeE); |
|
|
|
|
map.put("payTimeS", payTimeS); |
|
|
|
@ -236,32 +244,53 @@ public class OutRechargeOrderController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,String> param = new HashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); |
|
|
|
|
param.put("nonce_str", WxUtils.makeNonStr()); |
|
|
|
|
param.put("transaction_id", order.getPaySerialNo()); |
|
|
|
|
param.put("out_refund_no", "HFR"+new Date().getTime()); |
|
|
|
|
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("sign_type", "HMAC-SHA256"); |
|
|
|
|
|
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
param.put("sign", signStr); |
|
|
|
|
|
|
|
|
|
String resultXmL = doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); |
|
|
|
|
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); |
|
|
|
|
if(orderRefundModel.getResult_code().equals("SUCCESS")) { |
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo(orderRefundModel.getOut_refund_no()); |
|
|
|
|
order.setRefundId(orderRefundModel.getRefund_id()); |
|
|
|
|
order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
return ResponseMsgUtil.success("退款成功"); |
|
|
|
|
if (order.getPayType() == 2) { |
|
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); |
|
|
|
|
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); |
|
|
|
|
|
|
|
|
|
if (dataObject.getBoolean("success")) { |
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo("HFR"+new Date().getTime() ); |
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
order.setRefundId(dataObject.getString("orderId")); |
|
|
|
|
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 { |
|
|
|
|
Map<String,String> param = new HashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1609882817"); |
|
|
|
|
param.put("nonce_str", WxUtils.makeNonStr()); |
|
|
|
|
param.put("transaction_id", order.getPaySerialNo()); |
|
|
|
|
param.put("out_refund_no", "HFR"+new Date().getTime()); |
|
|
|
|
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("sign_type", "HMAC-SHA256"); |
|
|
|
|
|
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
param.put("sign", signStr); |
|
|
|
|
|
|
|
|
|
String resultXmL = doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); |
|
|
|
|
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); |
|
|
|
|
if(orderRefundModel.getResult_code().equals("SUCCESS")) { |
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo(orderRefundModel.getOut_refund_no()); |
|
|
|
|
order.setRefundId(orderRefundModel.getRefund_id()); |
|
|
|
|
order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
return ResponseMsgUtil.success("退款成功"); |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success("退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success("退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOrderController --> getUserOrderList() error!", e); |
|
|
|
|