Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
优化 错误日志打印逻辑,返回失败的数据也打印到错误日志中
Browse files Browse the repository at this point in the history
  • Loading branch information
TKaxv-7S committed Jul 23, 2024
1 parent dfd5e3f commit 9b3f69a
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void doTask(String appletId, String tag, String name) {
try {
String s = taskQuery(appletId);
JSONObject jo = new JSONObject(s);
if (!jo.getBoolean("success")) {
if (!jo.optBoolean("success")) {
Log.i(tag + ".doTask.taskQuery", jo.optString("resultDesc"));
return;
}
Expand All @@ -75,15 +75,15 @@ public static void doTask(String appletId, String tag, String name) {
//领取奖品,任务待领奖
s = taskTrigger(taskId, "receive", appletId);
jo = new JSONObject(s);
if (!jo.getBoolean("success")) {
if (!jo.optBoolean("success")) {
Log.i(tag + ".doTask.receive", jo.optString("resultDesc"));
continue;
}
} else if ("NONE_SIGNUP".equals(status)) {
//没有报名的,先报名,再完成
s = taskTrigger(taskId, "signup", appletId);
jo = new JSONObject(s);
if (!jo.getBoolean("success")) {
if (!jo.optBoolean("success")) {
Log.i(tag + ".doTask.signup", jo.optString("resultDesc"));
continue;
}
Expand All @@ -92,7 +92,7 @@ public static void doTask(String appletId, String tag, String name) {
//已报名,待完成,去完成
s = taskTrigger(taskId, "send", appletId);
jo = new JSONObject(s);
if (!jo.getBoolean("success")) {
if (!jo.optBoolean("success")) {
Log.i(tag + ".doTask.send", jo.optString("resultDesc"));
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,29 @@ private static void queryTaskCenterPage() {
try {
String s = AntBookReadRpcCall.queryTaskCenterPage();
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONObject data = jo.getJSONObject("data");
String todayPlayDurationText = data.getJSONObject("benefitAggBlock").getString("todayPlayDurationText");
int PlayDuration = Integer.parseInt(StringUtil.getSubString(todayPlayDurationText, "今日听读时长", "分钟"));
if (PlayDuration < 450) {
jo = new JSONObject(AntBookReadRpcCall.queryHomePage());
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONArray bookList = jo.getJSONObject("data").getJSONArray("dynamicCardList").getJSONObject(0)
.getJSONObject("data").getJSONArray("bookList");
int bookListLength = bookList.length();
int postion = RandomUtil.nextInt(0, bookListLength - 1);
JSONObject book = bookList.getJSONObject(postion);
String bookId = book.getString("bookId");
jo = new JSONObject(AntBookReadRpcCall.queryReaderContent(bookId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
String nextChapterId = jo.getJSONObject("data").getString("nextChapterId");
String name = jo.getJSONObject("data").getJSONObject("readerHomePageVO").getString("name");
for (int i = 0; i < 17; i++) {
int energy = 0;
jo = new JSONObject(AntBookReadRpcCall.syncUserReadInfo(bookId, nextChapterId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
jo = new JSONObject(AntBookReadRpcCall.queryReaderForestEnergyInfo(bookId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
String tips = jo.getJSONObject("data").getString("tips");
if (tips.contains("已得")) {
energy = Integer.parseInt(StringUtil.getSubString(tips, "已得", "g"));
Expand Down Expand Up @@ -110,7 +110,7 @@ private static void queryTask() {
try {
String s = AntBookReadRpcCall.queryTaskCenterPage();
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONObject data = jo.getJSONObject("data");
JSONArray userTaskGroupList = data.getJSONObject("userTaskListModuleVO")
.getJSONArray("userTaskGroupList");
Expand Down Expand Up @@ -170,7 +170,7 @@ private static void collectTaskPrize(String taskId, String taskType, String name
try {
String s = AntBookReadRpcCall.collectTaskPrize(taskId, taskType);
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
int coinNum = jo.getJSONObject("data").getInt("coinNum");
Log.other("阅读任务📖[" + name + "]#" + coinNum);
}
Expand All @@ -184,7 +184,7 @@ private static void taskFinish(String taskId, String taskType) {
try {
String s = AntBookReadRpcCall.taskFinish(taskId, taskType);
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {

}
} catch (Throwable t) {
Expand All @@ -197,14 +197,14 @@ private static void queryTreasureBox() {
try {
String s = AntBookReadRpcCall.queryTreasureBox();
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONObject treasureBoxVo = jo.getJSONObject("data").getJSONObject("treasureBoxVo");
if (treasureBoxVo.has("countdown"))
return;
String status = treasureBoxVo.getString("status");
if ("CAN_OPEN".equals(status)) {
jo = new JSONObject(AntBookReadRpcCall.openTreasureBox());
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
int coinNum = jo.getJSONObject("data").getInt("coinNum");
Log.other("阅读任务📖[打开宝箱]#" + coinNum);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void receiveTaskAward() {
if (TaskStatus.FINISHED.name().equals(taskStatus)) {
JSONObject joAward = new JSONObject(
AntDodoRpcCall.receiveTaskAward(sceneCode, taskType));
if (joAward.getBoolean("success"))
if (joAward.optBoolean("success"))
Log.forest("任务奖励🎖️[" + taskTitle + "]#" + awardCount + "个");
else
Log.record("领取失败," + s);
Expand All @@ -205,7 +205,7 @@ private void receiveTaskAward() {
if ("SEND_FRIEND_CARD".equals(taskType)) {
JSONObject joFinishTask = new JSONObject(
AntDodoRpcCall.finishTask(sceneCode, taskType));
if (joFinishTask.getBoolean("success")) {
if (joFinishTask.optBoolean("success")) {
Log.forest("物种任务🧾️[" + taskTitle + "]");
continue th;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ private void answerQuestion() {
case TODO:
s = DadaDailyRpcCall.home("100");
jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONObject question = jo.getJSONObject("question");
Log.i("题目:" + question, "");
long questionId = question.getLong("questionId");
Expand Down Expand Up @@ -867,7 +867,7 @@ private void answerQuestion() {

s = DadaDailyRpcCall.submit("100", answer, questionId);
JSONObject joDailySubmit = new JSONObject(s);
if (joDailySubmit.getBoolean("success")) {
if (joDailySubmit.optBoolean("success")) {
Log.record("提交完成");
dadaDailySet = new HashSet<>();
JSONObject extInfo = joDailySubmit.getJSONObject("extInfo");
Expand Down Expand Up @@ -1002,10 +1002,10 @@ private void doFarmDailyTask() {
String contentId = videoUrl.substring(videoUrl.indexOf("&contentId=") + 1,
videoUrl.indexOf("&refer"));
jo = new JSONObject(AntFarmRpcCall.videoDeliverModule(contentId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
Thread.sleep(15100);
jo = new JSONObject(AntFarmRpcCall.videoTrigger(contentId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g");
} else {
Log.record(jo.getString("resultMsg"));
Expand Down Expand Up @@ -1435,7 +1435,7 @@ private void parseSyncAnimalStatusResponse(String resp) {
if (manurePot.getInt("manurePotNum") >= 100) {
JSONObject joManurePot = new JSONObject(
AntFarmRpcCall.collectManurePot(manurePot.getString("manurePotNO")));
if (joManurePot.getBoolean("success")) {
if (joManurePot.optBoolean("success")) {
int collectManurePotNum = joManurePot.getInt("collectManurePotNum");
Log.farm("打扫鸡屎🧹[" + collectManurePotNum + "g]");
}
Expand Down Expand Up @@ -1849,7 +1849,7 @@ private void chouchoule() {
try {
String s = AntFarmRpcCall.chouchouleListFarmTask();
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONArray farmTaskList = jo.getJSONArray("farmTaskList");
for (int i = 0; i < farmTaskList.length(); i++) {
jo = farmTaskList.getJSONObject(i);
Expand Down Expand Up @@ -1884,14 +1884,14 @@ private void chouchoule() {
for (int i = 0; i < 3; i++) {
String s = AntFarmRpcCall.enterDrawMachine();
JSONObject jo = new JSONObject(s);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONObject userInfo = jo.getJSONObject("userInfo");
int leftDrawTimes = userInfo.optInt("leftDrawTimes", 0);
if (leftDrawTimes > 0) {
for (int ii = 0; ii < leftDrawTimes; ii++) {
jo = new JSONObject(AntFarmRpcCall.DrawPrize());
TimeUtil.sleep(1000);
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
String title = jo.getString("title");
int prizeNum = jo.optInt("prizeNum", 0);
Log.farm("庄园小鸡🎁[领取:抽抽乐" + title + "*" + prizeNum + "]");
Expand Down Expand Up @@ -2090,7 +2090,7 @@ private boolean hireAnimalAction(String userId) {
private void drawGameCenterAward() {
try {
JSONObject jo = new JSONObject(AntFarmRpcCall.queryGameList());
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
JSONObject gameDrawAwardActivity = jo.getJSONObject("gameDrawAwardActivity");
int canUseTimes = gameDrawAwardActivity.getInt("canUseTimes");
while (canUseTimes > 0) {
Expand Down Expand Up @@ -2175,7 +2175,7 @@ private void listOrnaments() {
String saveResult = AntFarmRpcCall.saveOrnaments(animalId, farmId, ornamentsToSave);
JSONObject saveResultJson = new JSONObject(saveResult);
// 判断保存是否成功并输出日志
if (saveResultJson.getBoolean("success")) {
if (saveResultJson.optBoolean("success")) {
// 获取保存的整套服装名称
String[] ornamentIds = ornamentsToSave.split(",");
String wholeSetName = ""; // 整套服装名称
Expand Down Expand Up @@ -2207,7 +2207,7 @@ private void listOrnaments() {
private void letsGetChickenFeedTogether() {
try {
JSONObject jo = new JSONObject(AntFarmRpcCall.letsGetChickenFeedTogether());
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
String bizTraceId = jo.getString("bizTraceId");
JSONArray p2pCanInvitePersonDetailList = jo.getJSONArray("p2pCanInvitePersonDetailList");

Expand Down Expand Up @@ -2246,7 +2246,7 @@ private void letsGetChickenFeedTogether() {
}
if (getFeedSet.contains(userId)) {
jo = new JSONObject(AntFarmRpcCall.giftOfFeed(bizTraceId, userId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
Log.record("一起拿小鸡饲料🥡 [送饲料:" + UserIdMap.getMaskName(userId) + "]");
invitesToSend--; // 每成功发送一次邀请,减少一次邀请次数
} else {
Expand All @@ -2264,7 +2264,7 @@ private void letsGetChickenFeedTogether() {
String userId = userIdList.get(randomIndex);

jo = new JSONObject(AntFarmRpcCall.giftOfFeed(bizTraceId, userId));
if (jo.getBoolean("success")) {
if (jo.optBoolean("success")) {
Log.record("一起拿小鸡饲料🥡 [送饲料:" + UserIdMap.getMaskName(userId) + "]");
} else {
Log.record("邀请失败:" + jo);
Expand Down
Loading

0 comments on commit 9b3f69a

Please sign in to comment.