|
|
|
@ -253,28 +253,38 @@ public class RedServiceImpl implements RedService { |
|
|
|
} |
|
|
|
// 解析返回 JSON |
|
|
|
JsonNode root = objectMapper.readTree(resp.body()); |
|
|
|
JsonNode dataNode = root.get("data"); |
|
|
|
int code = root.path("code").asInt(); |
|
|
|
if (code==0){ |
|
|
|
//旧订单 |
|
|
|
return "old"; |
|
|
|
} |
|
|
|
boolean flag = root.path("data").path("flag").asBoolean(); |
|
|
|
int num = root.path("data").path("num").asInt(); // 获取 num |
|
|
|
if (code == 400) { |
|
|
|
|
|
|
|
// 400 状态码表示参数错误 |
|
|
|
log.warn("该订单无法处理,status:{},body:{}", |
|
|
|
resp.statusCode(), resp.body()); |
|
|
|
throw new RuntimeException("该订单无法自动处理,请联系工作人员"); |
|
|
|
throw new RuntimeException("该订单无法自动处理,请联系管理员"); |
|
|
|
} |
|
|
|
|
|
|
|
boolean flag = root.path("data").path("flag").asBoolean(); |
|
|
|
int num = root.path("data").path("num").asInt(); // 获取 num |
|
|
|
|
|
|
|
// 业务判断 |
|
|
|
if (code == 200 && flag) { |
|
|
|
return "success"; |
|
|
|
} else { // flag 为 false |
|
|
|
|
|
|
|
throw new RedCheckException( |
|
|
|
"红包校验失败,orderId=" + linkId, num); |
|
|
|
if (code == 200 ) { |
|
|
|
if (dataNode.asInt() == 1) { |
|
|
|
throw new RuntimeException("该订单不符合退款条件,请手动处理!"); |
|
|
|
} |
|
|
|
if (dataNode.asInt() == 0){ |
|
|
|
return "old"; |
|
|
|
} |
|
|
|
if (flag) { |
|
|
|
return "success"; |
|
|
|
} else { |
|
|
|
throw new RedCheckException( |
|
|
|
"红包校验失败,orderId=" + linkId, num); |
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new RuntimeException("系统异常,请联系管理员"); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (IOException | InterruptedException e) { |
|
|
|
log.error("调用红包接口失败,orderId:{}", linkId, e); |
|
|
|
throw new RuntimeException("调用红包接口异常", e); |
|
|
|
|