|
|
@ -83,17 +83,23 @@ public class PeisService { |
|
|
|
.add("outTradeNo",outTradeNo) |
|
|
|
.add("outTradeNo",outTradeNo) |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxPay", formBody); |
|
|
|
String result = OkHttpHelper.post(XBDHelper.XBD_PEIS + "/wxUse/wxPay", formBody); |
|
|
|
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
|
|
|
|
|
|
log.info("[体检预约]缴费成功回调体检系统计费 recipeId={}, bankTransNo-{}, 计费状态-{}, 计费信息-{}", recipeId, bankTransNo, jsonResult.get("code"), jsonResult.get("message")); |
|
|
|
|
|
|
|
if(result==null){ |
|
|
|
if(result==null){ |
|
|
|
String pushMessage = "体检预约失败已申请退款,原因:体检系统计费失败,订单号:" + outTradeNo+"orderNo:"+ recipeId; |
|
|
|
log.info("[体检预约]体检服务无响应,开始退费"); |
|
|
|
|
|
|
|
String pushMessage = "体检预约失败已申请退款,原因:体检服务无响应,订单号:" + outTradeNo+"orderNo:"+ recipeId; |
|
|
|
peisAutoRefund(recipeId,merchantEnum,outTradeNo,totalFee,pushMessage,tradeDate,openid); |
|
|
|
peisAutoRefund(recipeId,merchantEnum,outTradeNo,totalFee,pushMessage,tradeDate,openid); |
|
|
|
} |
|
|
|
} |
|
|
|
if("200".equals(jsonResult.get("code"))){ |
|
|
|
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
|
|
|
|
|
|
log.info("[体检预约]缴费成功回调体检系统计费 recipeId={}, bankTransNo-{}, 计费状态-{}, 计费信息-{}", recipeId, bankTransNo, jsonResult.get("code"), jsonResult.get("message")); |
|
|
|
|
|
|
|
if("200".equals(jsonResult.get("code").toString())){ |
|
|
|
if(!peisDao.updatePeisStateOk(outTradeNo, bankTransNo)){ |
|
|
|
if(!peisDao.updatePeisStateOk(outTradeNo, bankTransNo)){ |
|
|
|
log.info("[体检预约]修改体检系统支付状态失败 outTradeNo={}, bankTransNo={}", outTradeNo, bankTransNo); |
|
|
|
log.info("[体检预约]修改体检系统支付状态失败 outTradeNo={}, bankTransNo={}", outTradeNo, bankTransNo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
log.info("[体检预约]回调体检系统计费状态码异常 recipeId={}, bankTransNo-{}, 计费状态-{}, 计费信息-{}", recipeId, bankTransNo, jsonResult.get("code"), jsonResult.get("message")); |
|
|
|
|
|
|
|
String pushMessage = "体检预约失败已申请退款,原因:体检系统计费失败,订单号:" + outTradeNo+"orderNo:"+ recipeId; |
|
|
|
|
|
|
|
peisAutoRefund(recipeId,merchantEnum,outTradeNo,totalFee,pushMessage,tradeDate,openid); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -110,37 +116,41 @@ public class PeisService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Result peisAutoRefund(String recipeId, MerchantEnum merchantEnum, String outTradeNo, BigDecimal totalFee, String pushInfo, Date tradeDate, String openid){ |
|
|
|
public Result peisAutoRefund(String recipeId, MerchantEnum merchantEnum, String outTradeNo, BigDecimal totalFee, String pushInfo, Date tradeDate, String openid){ |
|
|
|
PeisDao peisDao = new PeisDao(); |
|
|
|
PeisDao peisDao = new PeisDao(); |
|
|
|
|
|
|
|
if(peisDao.checkRefund(outTradeNo)){ |
|
|
|
|
|
|
|
log.info("{} [体检预约][该订单已经退费,请不要重复退费] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
|
|
|
|
return Result.error("该订单已经退费,请不要重复退费"); |
|
|
|
|
|
|
|
} |
|
|
|
String result = OkHttpHelper.get(XBDHelper.XBD_PEIS+"/wxUse/GetOrder",params -> { |
|
|
|
String result = OkHttpHelper.get(XBDHelper.XBD_PEIS+"/wxUse/GetOrder",params -> { |
|
|
|
params.put("orderNo",recipeId); |
|
|
|
params.put("orderNo",recipeId); |
|
|
|
}); |
|
|
|
}); |
|
|
|
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
|
|
|
|
|
|
if(result==null){ |
|
|
|
if(result==null){ |
|
|
|
log.info("{} [体检预约][退费错误,计费信息查询失败] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}",recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
log.info("{} [体检预约][退费错误,计费信息查询失败] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
return Result.error("退费错误,计费信息查询失败"); |
|
|
|
return Result.error("退费错误,计费信息查询失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
JSONObject jsonResult = JsonHelper.parseObject(result); |
|
|
|
String fee = jsonResult.getJSONObject("data").get("fee").toString(); |
|
|
|
String fee = jsonResult.getJSONObject("data").get("fee").toString(); |
|
|
|
boolean isWxPay = Boolean.parseBoolean(jsonResult.getJSONObject("data").get("isWxPay").toString()); |
|
|
|
boolean isWxPay = Boolean.parseBoolean(jsonResult.getJSONObject("data").get("isWxPay").toString()); |
|
|
|
boolean isCost = Boolean.parseBoolean(jsonResult.getJSONObject("data").get("isCost").toString()); |
|
|
|
boolean isCost = Boolean.parseBoolean(jsonResult.getJSONObject("data").get("isCost").toString()); |
|
|
|
if(totalFee.compareTo(BigDecimal.ZERO)==0||"0".equals(fee)){ |
|
|
|
if(totalFee.compareTo(BigDecimal.ZERO)==0||"0".equals(fee)){ |
|
|
|
log.info("{} [体检预约][退费错误,退费金额为0] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}",recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
log.info("{} [体检预约][退费错误,退费金额为0] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
return Result.error("退费错误,退费金额为0"); |
|
|
|
return Result.error("退费错误,退费金额为0"); |
|
|
|
} |
|
|
|
} |
|
|
|
if(totalFee.equals(new BigDecimal(String.valueOf(fee)))){ |
|
|
|
if(totalFee.compareTo(new BigDecimal(fee))!=0){ |
|
|
|
log.info("{} [体检预约][退费错误,退费金额跟订单金额不符] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}",recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
log.info("{} [体检预约][退费错误,退费金额跟订单金额不符] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
return Result.error("退费错误,退费金额跟订单金额不符"); |
|
|
|
return Result.error("退费错误,退费金额跟订单金额不符"); |
|
|
|
} |
|
|
|
} |
|
|
|
if(isWxPay){ |
|
|
|
// if(isWxPay){
|
|
|
|
log.info("{} [体检预约][退费错误,体检显示已计费,不允许退费] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}", recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
// log.info("{} [体检预约][退费错误,体检显示已计费,不允许退费] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}", recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee);
|
|
|
|
return Result.error("退费错误,体检显示已计费,不允许退费"); |
|
|
|
// return Result.error("退费错误,体检显示已计费,不允许退费");
|
|
|
|
} |
|
|
|
// }
|
|
|
|
if(isCost){ |
|
|
|
if(isCost){ |
|
|
|
log.info("{} [体检预约][退费错误,his显示已计费,不允许退费] recipeId-{}, outTradeNo={}, recipeId={}, totalFee={}", recipeId, merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
log.info("{} [体检预约][退费错误,his显示已计费,不允许退费] outTradeNo={}, recipeId={}, totalFee={}", merchantEnum.NAME, outTradeNo, recipeId, totalFee); |
|
|
|
return Result.error("退费错误,his显示已计费,不允许退费"); |
|
|
|
return Result.error("退费错误,his显示已计费,不允许退费"); |
|
|
|
} |
|
|
|
} |
|
|
|
String refundResult; |
|
|
|
String refundResult; |
|
|
|
Order orderRefund = PayService.refund(merchantEnum, outTradeNo, recipeId, totalFee, totalFee, pushInfo, tradeDate, openid, null, pushInfo); |
|
|
|
Order orderRefund = PayService.refund(merchantEnum, outTradeNo, recipeId, totalFee, totalFee, pushInfo, tradeDate, openid, null, pushInfo); |
|
|
|
if (!orderRefund.isSuccess()) { |
|
|
|
if (!orderRefund.isSuccess()) { |
|
|
|
log.info("{} [体检预约][退费错误] outTradeNo={}, recipeId={}, totalFee={},recipeId-{}", merchantEnum.NAME, outTradeNo, recipeId, totalFee,recipeId); |
|
|
|
log.info("{} [体检预约][退费错误] outTradeNo={}, totalFee={},recipeId-{}", merchantEnum.NAME, outTradeNo, totalFee,recipeId); |
|
|
|
refundResult = orderRefund.getRefundResult(); |
|
|
|
refundResult = orderRefund.getRefundResult(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|