|
|
|
@ -39,7 +39,7 @@ public class RedServiceImpl implements RedService { |
|
|
|
private String BASE_URLProd ; |
|
|
|
private static final String BASE_URLDev = "http://gf977328.natappfree.cc"; |
|
|
|
private static final String PATH = "/api/coupon/IssueRechargeRedPacket"; |
|
|
|
|
|
|
|
private static final String CONSUME_PATH = "/api/coupon/updateCostRedPacket"; |
|
|
|
private static final HttpClient CLIENT = HttpClient.newHttpClient(); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -108,7 +108,27 @@ public class RedServiceImpl implements RedService { |
|
|
|
return "{\"success\":false,\"msg\":\"网络异常\"}"; |
|
|
|
} |
|
|
|
} |
|
|
|
@Override |
|
|
|
public String sendConsumeJwcode(Integer jwcode, Integer price) { |
|
|
|
try { |
|
|
|
String body = JSON.toJSONString(java.util.Map.of("jwcode", jwcode,"discount",price)); |
|
|
|
HttpRequest request = HttpRequest.newBuilder() |
|
|
|
.uri(URI.create(BASE_URLProd + CONSUME_PATH)) //URL记得换 |
|
|
|
.header("Content-Type", "application/json") |
|
|
|
.POST(HttpRequest.BodyPublishers.ofString(body)) |
|
|
|
.build(); |
|
|
|
|
|
|
|
HttpResponse<String> resp = CLIENT.send(request, HttpResponse.BodyHandlers.ofString()); |
|
|
|
|
|
|
|
if (resp.statusCode() != 200) { |
|
|
|
log.warn("红包接口异常,status:{},body:{}", resp.statusCode(), resp.body()); |
|
|
|
} |
|
|
|
return resp.body(); |
|
|
|
} catch (IOException | InterruptedException e) { |
|
|
|
log.error("调用红包接口失败,jwcode:{}", jwcode, e); |
|
|
|
return "{\"success\":false,\"msg\":\"网络异常\"}"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// --- 校验方法 --- |
|
|
|
private void validateParams(Integer jwcode, Integer type, BigDecimal delta) { |
|
|
|
|