mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-22 23:22:32 +08:00
102 lines
4.1 KiB
Java
102 lines
4.1 KiB
Java
import com.alibaba.fastjson.JSON;
|
||
import com.jsowell.pile.dto.QueryOrderSplitRecordDTO;
|
||
import org.springframework.http.*;
|
||
import org.springframework.web.client.RestTemplate;
|
||
|
||
import java.util.Arrays;
|
||
import java.util.List;
|
||
|
||
public class MemberBindingCarNoHttpTest {
|
||
|
||
public static void main(String[] args) {
|
||
|
||
// 1️⃣ 接口地址(和 curl 完全一致)
|
||
String url = "https://apitest.jsowellcloud.com/order/commission/retryMerchantSplit";
|
||
|
||
// 2️⃣ 登录态 token(去掉 Bearer 前缀,setBearerAuth 会自动添加)
|
||
String token = "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImEyNmNhZmNiLTk5YzQtNDZkNi05M2EyLTg2NGYyOGVmYmFkYSJ9.Hv5-CztUtq04POwcUeBwvPLr2CzAnXcvnAZzNTH0zFo8ZxsP1ZoeqK7Pnohg4a-cdwvlpGFrXLDQ_gkr5psyBw";
|
||
|
||
|
||
|
||
String endTime = "2025-11-28";
|
||
String startTime = "2025-11-28";
|
||
|
||
List<Integer> merchantIds = Arrays.asList(
|
||
444, 281, 399, 355, 86, 162, 252, 341, 267, 327,
|
||
312, 400, 384, 282, 297, 370, 87, 356, 41, 313,
|
||
222, 255, 343, 447, 177, 25, 329, 147, 268, 283,
|
||
298, 101, 314, 385, 401, 132, 193, 118, 166, 209,
|
||
56, 357, 223, 416, 269, 88, 449, 330, 284, 402,
|
||
102, 475, 149, 299, 237, 375, 210, 345, 72, 270,
|
||
167, 134, 179, 26, 386, 316, 417, 89, 331, 451,
|
||
195, 358, 103, 44, 376, 211, 432, 150, 119, 459,
|
||
58, 259, 285, 301, 180, 73, 238, 477, 387, 28,
|
||
452, 403, 226, 196, 272, 136, 332, 104, 45, 435,
|
||
151, 460, 418, 377, 59, 302, 212, 319, 359, 349,
|
||
273, 453, 388, 404, 170, 239, 29, 121, 227, 419,
|
||
261, 106, 436, 138, 183, 76, 287, 198, 60, 462,
|
||
47, 304, 389, 378, 481, 274, 351, 334, 214, 122,
|
||
420, 321, 30, 405, 154, 228, 437, 172, 288, 352,
|
||
108, 184, 263, 139, 322, 363, 275, 97, 199, 31,
|
||
78, 421, 155, 391, 307, 123, 229, 353, 215, 173,
|
||
380, 408, 185, 241, 364, 336, 276, 466, 140, 63,
|
||
110, 422, 392, 32, 354, 230, 409, 309, 124, 324,
|
||
186, 201, 51, 393, 141, 277, 337, 382, 33, 292,
|
||
64, 366, 442, 310, 187, 489, 244, 468, 158, 410,
|
||
232, 111, 425, 202, 125, 338, 81, 443, 188, 160,
|
||
221, 34, 469, 143, 397, 427, 233, 294, 66, 54,
|
||
126, 471, 367, 161, 189, 144, 113, 429, 295, 190,
|
||
145, 114, 246, 127, 474, 82, 236, 368, 70, 146,
|
||
369, 278, 115, 130, 248, 279, 131, 83, 280, 84,
|
||
251, 116, 85, 35, 36, 3, 37, 9,
|
||
17, 18, 19, 21, 22, 23, 24
|
||
);
|
||
|
||
|
||
|
||
|
||
|
||
RestTemplate restTemplate = new RestTemplate();
|
||
|
||
HttpHeaders headers = new HttpHeaders();
|
||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||
headers.setAccept(MediaType.parseMediaTypes("*/*"));
|
||
headers.setBearerAuth(token); // 等价于 Authorization: Bearer xxx
|
||
|
||
int success = 0;
|
||
int fail = 0;
|
||
|
||
for (Integer merchantId : merchantIds) {
|
||
|
||
QueryOrderSplitRecordDTO dto = new QueryOrderSplitRecordDTO();
|
||
dto.setMerchantId(String.valueOf(merchantId));
|
||
dto.setStartTime(startTime);
|
||
dto.setEndTime(endTime);
|
||
|
||
HttpEntity<String> request =
|
||
new HttpEntity<>(JSON.toJSONString(dto), headers);
|
||
|
||
try {
|
||
ResponseEntity<String> response =
|
||
restTemplate.postForEntity(url, request, String.class);
|
||
|
||
System.out.println("成功处理 merchantId=" + merchantId
|
||
+ " response=" + response.getBody());
|
||
success++;
|
||
|
||
// 👇 可选:防止接口被限流
|
||
Thread.sleep(100);
|
||
|
||
} catch (Exception e) {
|
||
fail++;
|
||
System.err.println("处理失败 merchantId=" + merchantId);
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
System.out.println("====== 批量处理完成 ======");
|
||
System.out.println("成功:" + success);
|
||
System.out.println("失败:" + fail);
|
||
}
|
||
}
|