|
|
|
@ -78,25 +78,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
|
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getInteger(map, "payType") != null) { |
|
|
|
|
criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); |
|
|
|
|
} |
|
|
|
|
if (MapUtils.getInteger(map, "code") != null) { |
|
|
|
|
criteria.andIdentificationCodeEqualTo(MapUtils.getLong(map, "code")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "orderNo") != null) { |
|
|
|
|
criteria.andOrderNoLike("%" + MapUtils.getString(map, "orderNo") + "%"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "idCard") != null) { |
|
|
|
|
criteria.andIdCardLike("%" + MapUtils.getString(map, "idCard") + "%"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "userPhone") != null) { |
|
|
|
|
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); |
|
|
|
|
} |
|
|
|
@ -104,17 +93,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
if (MapUtils.getString(map, "rechargeContent") != null) { |
|
|
|
|
criteria.andRechargeContentLike("%" + MapUtils.getString(map, "rechargeContent") + "%"); |
|
|
|
|
} |
|
|
|
|
if (MapUtils.getString(map, "rechargeType") != null) { |
|
|
|
|
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map, "rechargeType")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "phone") != null) { |
|
|
|
|
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "rechargeModel") != null) { |
|
|
|
|
criteria.andRechargeModelEqualTo(Integer.valueOf(MapUtils.getString(map, "rechargeModel"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(map.get("payTimeS")) && StringUtils.isNotBlank(map.get("payTimeE"))) { |
|
|
|
|
criteria.andPayTimeBetween( |
|
|
|
@ -170,11 +153,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
public void updateOrderList(List<OutRechargeOrder> rechargeOrders) throws Exception { |
|
|
|
|
for (OutRechargeOrder list:rechargeOrders) { |
|
|
|
|
if (list.getStatus() == 3) { |
|
|
|
|
outRechargeOrderMapper.updateByPrimaryKey(list); |
|
|
|
|
} else if (list.getStatus() == 6) { |
|
|
|
|
rechargeOrderToRefund(list.getId()); |
|
|
|
|
} |
|
|
|
|
// if (list.getStatus() == 3) {
|
|
|
|
|
// outRechargeOrderMapper.updateByPrimaryKey(list);
|
|
|
|
|
// } else if (list.getStatus() == 6) {
|
|
|
|
|
// rechargeOrderToRefund(list.getId());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -183,25 +166,25 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
public void cancelOrder(Long orderId) { |
|
|
|
|
OutRechargeOrder order = findByOrderId(orderId); |
|
|
|
|
if (order != null && order.getStatus() == 1) { |
|
|
|
|
order.setStatus(4); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
|
|
|
|
|
order.setCancelTime(new Date()); |
|
|
|
|
|
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
|
|
if (rel != null) { |
|
|
|
|
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
rel.setUseTime(null); |
|
|
|
|
highDiscountUserRelService.updateDiscountUserRel(rel); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); |
|
|
|
|
code.setStatus(2); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateOrder(order); |
|
|
|
|
} |
|
|
|
|
// if (order != null && order.getStatus() == 1) {
|
|
|
|
|
// order.setStatus(4); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
|
|
|
|
|
// order.setCancelTime(new Date());
|
|
|
|
|
//
|
|
|
|
|
// if (order.getMemDiscountId() != null) {
|
|
|
|
|
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
|
|
|
|
|
// if (rel != null) {
|
|
|
|
|
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
// rel.setUseTime(null);
|
|
|
|
|
// highDiscountUserRelService.updateDiscountUserRel(rel);
|
|
|
|
|
//
|
|
|
|
|
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
|
|
|
|
|
// code.setStatus(2);
|
|
|
|
|
// highDiscountAgentCodeService.updateCode(code);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// updateOrder(order);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -210,7 +193,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
public void finishOrder(Long orderId) { |
|
|
|
|
OutRechargeOrder order = findByOrderId(orderId); |
|
|
|
|
if (order != null) { |
|
|
|
|
order.setStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
|
|
|
|
|
// order.setStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
|
|
|
|
|
order.setFinishTime(new Date()); |
|
|
|
|
updateOrder(order); |
|
|
|
|
} |
|
|
|
@ -242,7 +225,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Override |
|
|
|
|
public Long CountOrder() { |
|
|
|
|
OutRechargeOrderExample example = new OutRechargeOrderExample(); |
|
|
|
|
example.createCriteria().andStatusEqualTo(2); |
|
|
|
|
// example.createCriteria().andStatusEqualTo(2);
|
|
|
|
|
return outRechargeOrderMapper.countByExample(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -336,51 +319,51 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String goodsDesc = "充值话费"; |
|
|
|
|
String tranDesc = order.getRechargeContent() + "充值" + order.getPayPrice() +"元话费"; |
|
|
|
|
// String tranDesc = order.getRechargeContent() + "充值" + order.getPayPrice() +"元话费";
|
|
|
|
|
String instCode = "11101290"; |
|
|
|
|
String businessType = "hisen_consume"; |
|
|
|
|
|
|
|
|
|
// 工会卡支付
|
|
|
|
|
JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc); |
|
|
|
|
System.out.println("工会卡支付响应参数" + consumption.toJSONString()); |
|
|
|
|
// JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc);
|
|
|
|
|
// System.out.println("工会卡支付响应参数" + consumption.toJSONString());
|
|
|
|
|
|
|
|
|
|
Map<String,Object> dataMap = new HashMap<>(); |
|
|
|
|
dataMap.put("orderNo", order.getOrderNo()); |
|
|
|
|
dataMap.put("cardType", "ghk"); |
|
|
|
|
dataMap.put("cardNo", userCard.getCardNo()); |
|
|
|
|
dataMap.put("checkPassword", "N"); |
|
|
|
|
dataMap.put("tranAmount", order.getPayPrice()); |
|
|
|
|
// dataMap.put("tranAmount", order.getPayPrice());
|
|
|
|
|
dataMap.put("tranChannel", "HiSen"); |
|
|
|
|
dataMap.put("businessType", businessType); |
|
|
|
|
dataMap.put("instCode", instCode); |
|
|
|
|
dataMap.put("goodsDesc", goodsDesc); |
|
|
|
|
dataMap.put("tranDesc", tranDesc); |
|
|
|
|
// dataMap.put("tranDesc", tranDesc);
|
|
|
|
|
HighGasOrderPush payPush = new HighGasOrderPush(); |
|
|
|
|
payPush.setType(OrderPushType.type5.getType()); |
|
|
|
|
payPush.setOrderNo(order.getOrderNo()); |
|
|
|
|
payPush.setCreateTime(new Date()); |
|
|
|
|
payPush.setCode(consumption.getString("respCode")); |
|
|
|
|
payPush.setRequestContent(JSON.toJSONString(dataMap)); |
|
|
|
|
payPush.setReturnContent(consumption.toJSONString()); |
|
|
|
|
// payPush.setCode(consumption.getString("respCode"));
|
|
|
|
|
// payPush.setRequestContent(JSON.toJSONString(dataMap));
|
|
|
|
|
// payPush.setReturnContent(consumption.toJSONString());
|
|
|
|
|
highGasOrderPushMapper.insert(payPush); |
|
|
|
|
|
|
|
|
|
if(!consumption.getString("respCode").equals("0000")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); |
|
|
|
|
} |
|
|
|
|
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); |
|
|
|
|
if (!consumptionResult.getBoolean("success")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); |
|
|
|
|
} |
|
|
|
|
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
|
|
|
|
|
order.setPayRealPrice(order.getPayPrice()); // 实付金额
|
|
|
|
|
if (order.getRechargeType() == 1) { |
|
|
|
|
JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() ,order.getRechargeType()); |
|
|
|
|
if (object.getInteger("code") != 200) { |
|
|
|
|
order.setRechargeStatus(1); |
|
|
|
|
order.setAbnormalMsg(object.getString("message")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
order.setStatus(2); |
|
|
|
|
// if(!consumption.getString("respCode").equals("0000")) {
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage"));
|
|
|
|
|
// }
|
|
|
|
|
// JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data"));
|
|
|
|
|
// if (!consumptionResult.getBoolean("success")) {
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message"));
|
|
|
|
|
// }
|
|
|
|
|
// order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
|
|
|
|
|
// order.setPayRealPrice(order.getPayPrice()); // 实付金额
|
|
|
|
|
// if (order.getRechargeType() == 1) {
|
|
|
|
|
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() ,order.getRechargeType());
|
|
|
|
|
// if (object.getInteger("code") != 200) {
|
|
|
|
|
// order.setRechargeStatus(1);
|
|
|
|
|
// order.setAbnormalMsg(object.getString("message"));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// order.setStatus(2);
|
|
|
|
|
order.setPayType(2); |
|
|
|
|
order.setPayTime(new Date()); // 支付时间
|
|
|
|
|
updateOrder(order); |
|
|
|
@ -389,21 +372,21 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
public void goldPayOrder(Long userId, Long orderId) throws Exception { |
|
|
|
|
OutRechargeOrder order = findByOrderId(orderId); |
|
|
|
|
if(order == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); |
|
|
|
|
} |
|
|
|
|
// 查询用户
|
|
|
|
|
HighUser highUser = highUserService.findByUserId(userId); |
|
|
|
|
|
|
|
|
|
// 金币 1:100
|
|
|
|
|
Integer goldNum = new BigDecimal(order.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue(); |
|
|
|
|
highUserService.goldHandle(userId, goldNum, 2, 2, order.getId()); |
|
|
|
|
order.setPayRealPrice(order.getPayPrice()); // 实付金额
|
|
|
|
|
order.setStatus(2); |
|
|
|
|
order.setPayType(3); |
|
|
|
|
order.setPayTime(new Date()); // 支付时间
|
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
// OutRechargeOrder order = findByOrderId(orderId);
|
|
|
|
|
// if(order == null) {
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
|
|
|
|
|
// }
|
|
|
|
|
// // 查询用户
|
|
|
|
|
// HighUser highUser = highUserService.findByUserId(userId);
|
|
|
|
|
//
|
|
|
|
|
// // 金币 1:100
|
|
|
|
|
// Integer goldNum = new BigDecimal(order.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue();
|
|
|
|
|
// highUserService.goldHandle(userId, goldNum, 2, 2, order.getId());
|
|
|
|
|
// order.setPayRealPrice(order.getPayPrice()); // 实付金额
|
|
|
|
|
// order.setStatus(2);
|
|
|
|
|
// order.setPayType(3);
|
|
|
|
|
// order.setPayTime(new Date()); // 支付时间
|
|
|
|
|
// outRechargeOrderService.updateOrder(order);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -444,107 +427,107 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void rechargeOrderToRefund(Long orderId) throws Exception { |
|
|
|
|
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); |
|
|
|
|
|
|
|
|
|
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
|
|
|
|
|
if (order.getStatus() != 2) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 微信退款
|
|
|
|
|
if (order.getPayType() == 1) { |
|
|
|
|
Map<String,String> param = new HashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id" , "1614670195"); |
|
|
|
|
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"), 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); |
|
|
|
|
} else { |
|
|
|
|
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) { |
|
|
|
|
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")); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 金币退款
|
|
|
|
|
if (order.getPayType() == 3) { |
|
|
|
|
if (highUserService.findGoldRepeat(3 , order.getId())) { |
|
|
|
|
highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); |
|
|
|
|
}else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); |
|
|
|
|
} |
|
|
|
|
order.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo("HFR"+new Date().getTime() ); |
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 银联退款
|
|
|
|
|
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.setStatus(5); |
|
|
|
|
order.setRefundTime(new Date()); |
|
|
|
|
order.setOutRefundNo(refund.getString("oriwtorderid")); |
|
|
|
|
order.setRefundFee(order.getPayRealPrice()); |
|
|
|
|
outRechargeOrderService.updateOrder(order); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
|
|
if (rel != null) { |
|
|
|
|
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
rel.setUseTime(null); |
|
|
|
|
highDiscountUserRelService.updateDiscountUserRel(rel); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); |
|
|
|
|
code.setStatus(2); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
|
|
|
|
|
//
|
|
|
|
|
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
|
|
|
|
|
// if (order.getStatus() != 2) {
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 微信退款
|
|
|
|
|
// if (order.getPayType() == 1) {
|
|
|
|
|
// Map<String,String> param = new HashMap<>();
|
|
|
|
|
// param.put("appid", "wx637bd6f7314daa46");
|
|
|
|
|
// param.put("mch_id", "1289663601");
|
|
|
|
|
// param.put("sub_mch_id" , "1614670195");
|
|
|
|
|
// 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"), 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);
|
|
|
|
|
// } else {
|
|
|
|
|
// 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) {
|
|
|
|
|
// 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"));
|
|
|
|
|
// outRechargeOrderService.updateOrder(order);
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 金币退款
|
|
|
|
|
// if (order.getPayType() == 3) {
|
|
|
|
|
// if (highUserService.findGoldRepeat(3 , order.getId())) {
|
|
|
|
|
// highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId());
|
|
|
|
|
// }else {
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录");
|
|
|
|
|
// }
|
|
|
|
|
// order.setStatus(5);
|
|
|
|
|
// order.setRefundTime(new Date());
|
|
|
|
|
// order.setOutRefundNo("HFR"+new Date().getTime() );
|
|
|
|
|
// order.setRefundFee(order.getPayRealPrice());
|
|
|
|
|
// outRechargeOrderService.updateOrder(order);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 银联退款
|
|
|
|
|
// 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.setStatus(5);
|
|
|
|
|
// order.setRefundTime(new Date());
|
|
|
|
|
// order.setOutRefundNo(refund.getString("oriwtorderid"));
|
|
|
|
|
// order.setRefundFee(order.getPayRealPrice());
|
|
|
|
|
// outRechargeOrderService.updateOrder(order);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (order.getMemDiscountId() != null) {
|
|
|
|
|
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
|
|
|
|
|
// if (rel != null) {
|
|
|
|
|
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
// rel.setUseTime(null);
|
|
|
|
|
// highDiscountUserRelService.updateDiscountUserRel(rel);
|
|
|
|
|
//
|
|
|
|
|
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
|
|
|
|
|
// code.setStatus(2);
|
|
|
|
|
// highDiscountAgentCodeService.updateCode(code);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|