diff --git a/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java b/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java index d177e55..95d83ba 100644 --- a/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java +++ b/update-service/src/main/java/com/xuqm/update/service/StoreSubmissionService.java @@ -482,30 +482,34 @@ public class StoreSubmissionService { // Log full root response so we can verify exact field names from production log.info("MI poll full response for version={}: {}", v.getId(), root); JsonNode pkg = root.path("packageInfo"); - // Xiaomi /devupload/dev/query response: - // packageInfo.appStatus: 1=待审核, 2=审核中, 3=已发布/上线, 4=已下线, 5=拒绝 - // root.updateVersion (bool): true=用户可更新(已上线), false=不可更新(审核中或拒绝) + // Xiaomi /devupload/dev/query returns status of the currently-published app, + // NOT the pending submission. appStatus=3 means the old version is online — + // it does NOT mean the newly-submitted version was accepted. + // + // Reliable fields: + // root.updateVersion (bool): true = new version update available to users + // (i.e. the newly submitted version is APPROVED/published) + // false = users cannot update (new version still under review OR rejected) + // packageInfo.appStatus: 5 = this version was explicitly rejected/驳回 // packageInfo.synchroResult: 1=上线成功, 0=拒绝/失败 int appStatus = pkg.path("appStatus").asInt(pkg.path("status").asInt(-1)); - boolean updateVersion = root.path("updateVersion").asBoolean(true); + // updateVersion=false means the submitted version is not yet live (either under review or rejected) + // We need a DIFFERENT signal to distinguish rejected from still-under-review + boolean updateVersion = root.path("updateVersion").asBoolean(false); log.info("MI poll appStatus={} updateVersion={} for version={}", appStatus, updateVersion, v.getId()); - yield switch (appStatus) { - case 3 -> updateVersion - ? AppVersionEntity.StoreReviewState.APPROVED - : AppVersionEntity.StoreReviewState.UNDER_REVIEW; // published but new version rejected - case 5 -> AppVersionEntity.StoreReviewState.REJECTED; - case 1, 2 -> AppVersionEntity.StoreReviewState.UNDER_REVIEW; - default -> { - // appStatus field absent — fall back to synchroResult and updateVersion - int synchroResult = pkg.path("synchroResult").asInt(-1); - log.info("MI poll synchroResult={} for version={}", synchroResult, v.getId()); - // synchroResult: 1=已上线(通过), 0=拒绝/失败 - yield synchroResult == 1 ? AppVersionEntity.StoreReviewState.APPROVED - : synchroResult == 0 ? AppVersionEntity.StoreReviewState.REJECTED - : updateVersion ? AppVersionEntity.StoreReviewState.APPROVED - : AppVersionEntity.StoreReviewState.UNDER_REVIEW; - } - }; + // appStatus=5 is an explicit rejection signal + if (appStatus == 5) { + yield AppVersionEntity.StoreReviewState.REJECTED; + } + // updateVersion=true means the submitted version is now live/approved + if (updateVersion) { + yield AppVersionEntity.StoreReviewState.APPROVED; + } + // Fall back: synchroResult distinguishes rejected(0) from still-pending(-1) + int synchroResult = pkg.path("synchroResult").asInt(-1); + log.info("MI poll synchroResult={} for version={}", synchroResult, v.getId()); + yield synchroResult == 0 ? AppVersionEntity.StoreReviewState.REJECTED + : AppVersionEntity.StoreReviewState.UNDER_REVIEW; } default -> null; // APP_STORE, GOOGLE_PLAY: no vendor query API };