|
|
@ -13,6 +13,7 @@ import com.shop.cereshop.business.pay.xs.utils.CommonUtils; |
|
|
|
import com.shop.cereshop.business.pay.xs.utils.HttpUtils; |
|
|
|
import com.shop.cereshop.business.service.order.CereShopOrderService; |
|
|
|
import com.shop.cereshop.commons.config.XspayConfig; |
|
|
|
import com.shop.cereshop.commons.constant.CoReturnFormat; |
|
|
|
import com.shop.cereshop.commons.constant.WxPayEnum; |
|
|
|
import com.shop.cereshop.commons.constant.XsPayEnum; |
|
|
|
import com.shop.cereshop.commons.exception.CoBusinessException; |
|
|
@ -46,7 +47,7 @@ public class XsPayServiceImpl implements XsPayService { |
|
|
|
//构建请求参数 |
|
|
|
Map<String, String> headMap = CommonUtils.buildHeadMap(REFUND_SER_CODE); |
|
|
|
|
|
|
|
Map<String, Object> contentMap = build06ContentMap(outTradeNo, transactionId, refund, |
|
|
|
Map<String, Object> contentMap = build06ContentMap(outRefundNo, outTradeNo, transactionId, refund, |
|
|
|
XspayConfig.BUSINESS_RETURN_NOTICE_URL); |
|
|
|
//head+content做md5并根据加签方式加密 |
|
|
|
String msg = CommonUtils.getRequestMsg(headMap, contentMap); |
|
|
@ -88,7 +89,7 @@ public class XsPayServiceImpl implements XsPayService { |
|
|
|
} |
|
|
|
} catch (CoBusinessException e) { |
|
|
|
if(StringUtils.equals(e.getCode(), "0005")){ |
|
|
|
throw new CoBusinessException("10000","支付系统正在处理,请支付5分钟后再申请退款"); |
|
|
|
throw new CoBusinessException(CoReturnFormat.APPLY_REFUND_FAILED_LATER,"支付系统正在处理,请支付5分钟后再申请退款"); |
|
|
|
}else { |
|
|
|
throw e; |
|
|
|
} |
|
|
@ -111,7 +112,7 @@ public class XsPayServiceImpl implements XsPayService { |
|
|
|
//构建请求参数 |
|
|
|
Map<String, String> headMap = CommonUtils.buildHeadMap(REFUND_SER_CODE); |
|
|
|
|
|
|
|
Map<String, Object> contentMap = build06ContentMap(outTradeNo, transactionId, refund, XspayConfig.APP_NOTICE_URL); |
|
|
|
Map<String, Object> contentMap = build06ContentMap(outRefundNo, outTradeNo, transactionId, refund, XspayConfig.APP_NOTICE_URL); |
|
|
|
//head+content做md5并根据加签方式加密 |
|
|
|
String msg = CommonUtils.getRequestMsg(headMap, contentMap); |
|
|
|
log.info("【" + REFUND_SER_CODE + "】接口-请求报文:msg="+msg); |
|
|
@ -132,21 +133,30 @@ public class XsPayServiceImpl implements XsPayService { |
|
|
|
JSONObject content = jsonObject.getJSONObject("content"); |
|
|
|
String status = content.getString("status"); |
|
|
|
//2成功 3失败 |
|
|
|
if(StringUtils.equals(status, "0")) { |
|
|
|
String merOrderId = content.getString("merOrderId"); |
|
|
|
String[] split = merOrderId.split("-"); |
|
|
|
if (!EmptyUtils.isEmpty(split)) { |
|
|
|
String orderFormId = split[0]; |
|
|
|
if (!EmptyUtils.isEmpty(orderFormId)) { |
|
|
|
String dealId = content.getString("refundOrderNo"); |
|
|
|
//处理支付成功后的其他逻辑 |
|
|
|
cereShopOrderService.handleRefundWxLog(orderFormId, dealId, merOrderId); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.equals(status, "1")) { |
|
|
|
Map<String, String> result = new HashMap<>(); |
|
|
|
result.put("return_msg", WxPayEnum.REFUND_SUCCESS.getCode()); |
|
|
|
result.put("return_code", WxPayEnum.REFUND_OK.getCode()); |
|
|
|
return result; |
|
|
|
// if(StringUtils.equals(status, "0")) { |
|
|
|
// String merOrderId = content.getString("merOrderId"); |
|
|
|
// String[] split = merOrderId.split("-"); |
|
|
|
// if (!EmptyUtils.isEmpty(split)) { |
|
|
|
// String orderFormId = split[0]; |
|
|
|
// if (!EmptyUtils.isEmpty(orderFormId)) { |
|
|
|
// String dealId = content.getString("refundOrderNo"); |
|
|
|
// //处理支付成功后的其他逻辑 |
|
|
|
// cereShopOrderService.handleRefundWxLog(orderFormId, dealId, merOrderId); |
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
} catch (CoBusinessException e) { |
|
|
|
throw e; |
|
|
|
if(StringUtils.equals(e.getCode(), "0005")){ |
|
|
|
throw new CoBusinessException(CoReturnFormat.APPLY_REFUND_FAILED_LATER,"支付系统正在处理,请支付5分钟后再申请退款"); |
|
|
|
}else { |
|
|
|
throw e; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
//支付方式为B2C、B2B、H5,成功响应时respMsg为html页面代码 |
|
|
|
if(respMsg.contains("toNativePayIndexForm")){ |
|
|
@ -227,10 +237,10 @@ public class XsPayServiceImpl implements XsPayService { |
|
|
|
* 构建content请求参数 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private static Map<String,Object> build06ContentMap(String orderFormid, String dealId, BigDecimal money, String noticeUrl){ |
|
|
|
private static Map<String,Object> build06ContentMap(String merOrderId, String orderFormid, String dealId, BigDecimal money, String noticeUrl){ |
|
|
|
Map<String, Object> contentMap = new LinkedHashMap<>(); |
|
|
|
log.info("orderFormid:" + orderFormid); |
|
|
|
contentMap.put("merOrderId", System.currentTimeMillis()+""); |
|
|
|
contentMap.put("merOrderId", merOrderId); |
|
|
|
//oldMerOrderId 对应 101004、101005接口中merOrderId |
|
|
|
contentMap.put("oldMerOrderId", orderFormid); |
|
|
|
//oldDealId 对应 101004、101005接口响应参数中dealId |
|
|
|