Browse Source

20260128DC免费金豆

milestone-20260128-DC金豆金币接口
sunjiabei 4 weeks ago
parent
commit
f0e1494aa0
  1. 42
      src/main/java/com/example/demo/serviceImpl/bean/BeanRechargeServiceImpl.java
  2. 2
      src/main/resources/application-dev.yml
  3. 3
      src/main/resources/application-prod.yml

42
src/main/java/com/example/demo/serviceImpl/bean/BeanRechargeServiceImpl.java

@ -22,6 +22,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
@ -128,6 +130,8 @@ public class BeanRechargeServiceImpl implements BeanRechargeService {
}
}
@Value("${toujiaoApp.url}")
private String toujiaoAppUrl;
@Override
public Result addBeanDC(BeanRecharge recharge) {
@ -169,6 +173,44 @@ public class BeanRechargeServiceImpl implements BeanRechargeService {
} catch (Exception e) {
return Result.error("加密失败");
}
try {
// 构建完整的请求URL
String fullUrl = toujiaoAppUrl + "/api/user/toujiaoAppLogin";
// 创建请求头设置Content-Type为application/x-www-form-urlencoded
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// 创建请求体使用MultiValueMap存储参数
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("jwcode", jwcode);
// 构建请求实体
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
// 发送POST请求
ResponseEntity<String> response = restTemplate.postForEntity(
fullUrl,
requestEntity,
String.class
);
System.out.println("请求URL:" + fullUrl);
System.out.println("请求参数:" + params);
System.out.println("响应状态码:" + response.getStatusCodeValue());
System.out.println("响应内容:" + response.getBody());
if (!response.getStatusCode().is2xxSuccessful()) {
return Result.error("远程接口调用失败,状态码:" + response.getStatusCodeValue() + ",响应:" + response.getBody());
}
} catch (RestClientException e) {
e.printStackTrace();
return Result.error("请求发送失败:" + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
return Result.error("系统异常:" + e.getMessage());
}
String content = recharge.getRemark(); // 备注作为content参数
String orderNo = UUID.randomUUID().toString().replace("-", ""); // 生成唯一订单号去除横线

2
src/main/resources/application-dev.yml

@ -92,6 +92,8 @@ file:
upload:
url: http://39.101.133.168:8828/hljw/api/aws/upload
toujiaoApp:
url: http://39.101.133.168:8828/hljw
feishu:
webhook:
url: https://open.feishu.cn/open-apis/bot/v2/hook/455ccf9c-a8b1-46b4-b4d8-9f528620595d

3
src/main/resources/application-prod.yml

@ -98,6 +98,9 @@ feishu:
webhook:
url: https://open.feishu.cn/open-apis/bot/v2/hook/1a515b19-b64f-46b7-9486-35842b9539fe
toujiaoApp:
url: https://api.homilychart.com/hljw
bean:
recharge:
url: http://api.homilychart.com/hljwgo/api/wallet/recharge

Loading…
Cancel
Save