江体小程序和zlb接口开发 #1

Merged
XiangZ merged 32 commits from feat/script_v1 into master 2026-05-10 09:06:35 +00:00
5 changed files with 32 additions and 13 deletions
Showing only changes of commit 8a302db65a - Show all commits

View File

@@ -62,6 +62,13 @@ public class ZlbCaptchaTrackDebugger {
return new ExecutionResult(generatedTrackList, debugResult.getConsolePreview(), debugResult.getDebugImagePath());
}
public static ExecutionResult execute(String imageBase64, List<String> coordinateText, String requestId) {
List<String> rawTrackList = coordinateText;
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList = ZlbCaptchaTrackUtil.generateBezierTrackList(rawTrackList);
DebugResult debugResult = debug(imageBase64, rawTrackList, generatedTrackList, requestId);
return new ExecutionResult(generatedTrackList, debugResult.getConsolePreview(), debugResult.getDebugImagePath());
}
public static void main(String[] args) {
if (args.length == 0) {
runLocalSample();

View File

@@ -40,6 +40,7 @@ public class ZlbUrlConstants {
public static final String siteStr = "{\"stadiumId\":\"49\",\"siteItemId\":1940,\"belongDate\":\"%s\",\"channelType\":6}";
public static final String siteQMStr = "{\"stadiumId\":\"185\",\"siteItemId\":194,\"belongDate\":\"%s\",\"channelType\":6}";
public static final String siteWqStr = "{\"stadiumId\":\"360112\",\"siteItemId\":1148,\"belongDate\":\"%s\",\"channelType\":6}";
public static final String refundStr = "{\"detailOrderId\":%s,\"detailOrderIds\":[%s],\"type\":2}";
public static final String cancelStr = "{\"orderId\":%s,\"type\":2}";

View File

@@ -79,7 +79,7 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
LambdaQueryWrapper<ZlbUserInfo> wrapper = Wrappers.lambdaQuery();
wrapper.eq(ZlbUserInfo::getIsBook, 0);
wrapper.eq(ZlbUserInfo::getName, "xiang");
Date date = DateUtils.addDate(new Date(), 0);
Date date = DateUtils.addDate(new Date(), 1);
String day = DateUtils.format(date, DateUtils.ENUM_FORMAT_YMD);
wrapper.eq(ZlbUserInfo::getWeek, DateUtils.getWeekDayTwo(day));
ZlbUserInfo zlbUserInfo = zlbUserInfoService.getOne(wrapper);
@@ -111,15 +111,15 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
LocalTime targetTime = LocalTime.parse("09:00:11.800");
Duration duration = Duration.between(currentTime, targetTime);
long milliseconds = duration.toMillis();
// executorService.schedule(() -> {
String response = null;
try {
response = client.postJson(ZlbUrlConstants.newOrderUrl, headers, newOrderJson);
} catch (Exception e) {
throw new RuntimeException(e);
}
buildOrder(name, response, placeName, siteTimeName);
// }, milliseconds, TimeUnit.MILLISECONDS);
executorService.schedule(() -> {
String response = null;
try {
response = client.postJson(ZlbUrlConstants.newOrderUrl, headers, newOrderJson);
} catch (Exception e) {
throw new RuntimeException(e);
}
buildOrder(name, response, placeName, siteTimeName);
}, milliseconds, TimeUnit.MILLISECONDS);
return taskResult;
}

View File

@@ -30,16 +30,19 @@ public class ZlbTaskConfig {
}
@GetMapping("/zlbSiteTask")
@Scheduled(cron = "30 30 16 * * ?")
public void zlbSiteTask() {
zlbSiteTask.run();
}
@GetMapping("/zlbSiteDayTask")
@Scheduled(cron = "0 00 17 * * ?")
public void zlbSiteDayTask() {
zlbSiteDayTask.run();
}
@GetMapping("/zlbOrderCreateTask")
@Scheduled(cron = "55 59 8 * * ?")
public void zlbOrderCreateTask() {
zlbOrderTask.run();
}

View File

@@ -32,7 +32,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -376,7 +377,7 @@ public class ZlbServiceImpl implements ZlbService {
@Override
public String buildNewOrder(String siteOrderDetailsStr, OkHttpUtil client) throws IOException {
LocalDateTime startTime = LocalDateTime.now();
Instant startTime = Instant.now().truncatedTo(ChronoUnit.MILLIS);
//获取图片验证码
String s = client.postJson(ZlbUrlConstants.captchaUrl, null, "{}");
@@ -403,11 +404,18 @@ public class ZlbServiceImpl implements ZlbService {
orderInfo.setId(id);
//获取验证码轨迹
List<ZlbOrderInfo.ZlbData.TrackList> trackListList = convert(trackList);
// ZlbCaptchaTrackDebugger.ExecutionResult execute = ZlbCaptchaTrackDebugger.execute(backgroundImage, trackList, "zlb-captcha-debugger");
// List<ZlbOrderInfo.ZlbData.TrackList> trackListList = execute.getTrackList();
ZlbOrderInfo.ZlbData data = new ZlbOrderInfo.ZlbData();
data.setBgImageWidth(zlbCaptchaResp.getCaptcha().getBackgroundImageWidth() / 2);
data.setBgImageHeight(zlbCaptchaResp.getCaptcha().getBackgroundImageHeight() / 2);
data.setStartTime(startTime.toString());
data.setStopTime(LocalDateTime.now().toString());
Integer t = trackListList.get(trackListList.size() - 1).getT();
data.setStopTime(startTime.plus(t, ChronoUnit.MILLIS).truncatedTo(ChronoUnit.MILLIS).toString());
data.setTrackList(trackListList);
orderInfo.setData(data);