diff --git a/README.md b/README.md index b38d511b3..5d193e90d 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ - [x] 芭芭农场 - [x] 保护地巡逻 - [x] 蚂蚁新村 -- [ ] 绿色营收 +- [x] 绿色经营 - [x] 高版本API存储问题 diff --git a/app/build.gradle b/app/build.gradle index d13e02642..23195becb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { minSdk 21 //noinspection ExpiredTargetSdkVersion targetSdk 29 - versionCode 63 - versionName "1.1.9" + versionCode 64 + versionName "1.2.0" } buildTypes { release { diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java b/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java index 573a940ee..c54d57a4f 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntOcean.java @@ -361,10 +361,7 @@ private static void queryMiscInfo() { if (homeTipsRefresh.optBoolean("fishCanBeCombined") || homeTipsRefresh.optBoolean("canBeRepaired")) { querySeaAreaDetailList(); } - //此处不确定,因为修复完成好像也会返回false - if (homeTipsRefresh.optBoolean("currentChapterFixed")) { - switchOceanChapter(); - } + switchOceanChapter(); } else { Log.i(TAG, jo.getString("resultDesc")); } diff --git a/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java b/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java index b41f7f9dc..e44a0cecc 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/AntStall.java @@ -132,6 +132,7 @@ private static void inviteOpen(String seatId) { jo = new JSONObject(s); if ("SUCCESS".equals(jo.getString("resultCode"))) { Log.farm("蚂蚁新村⛪邀请[" + FriendIdMap.getNameById(friendUserId) + "]开店成功"); + return; } } } @@ -666,7 +667,7 @@ private static void throwManure() { } JSONObject dynamic = new JSONObject(); dynamic.put("bizId", lossDynamic.getString("bizId")); - dynamic.put("bizType", lossDynamic.getInt("bizType")); + dynamic.put("bizType", lossDynamic.getString("bizType")); dynamicList.put(dynamic); if (dynamicList.length() == 5) { throwManure(dynamicList); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/GreenFinance.java b/app/src/main/java/pansong291/xposed/quickenergy/GreenFinance.java new file mode 100644 index 000000000..6fd214ca7 --- /dev/null +++ b/app/src/main/java/pansong291/xposed/quickenergy/GreenFinance.java @@ -0,0 +1,142 @@ +package pansong291.xposed.quickenergy; + +import org.json.JSONArray; +import org.json.JSONObject; +import pansong291.xposed.quickenergy.hook.GreenFinanceRpcCall; +import pansong291.xposed.quickenergy.util.Config; +import pansong291.xposed.quickenergy.util.Log; + +/** + * @author Constanline + * @since 2023/09/08 + */ +public class GreenFinance { + private static final String TAG = GreenFinance.class.getCanonicalName(); + + public static void start() { + if (!Config.greenFinance()) { + return; + } + new Thread() { + @Override + public void run() { + index(); + } + }.start(); + } + + private static void batchSelfCollect(JSONArray bsnIds) { + String s = GreenFinanceRpcCall.batchSelfCollect(bsnIds); + try { + JSONObject joSelfCollect = new JSONObject(s); + if (joSelfCollect.getBoolean("success")) { + int totalCollectPoint = joSelfCollect.getJSONObject("result").getInt("totalCollectPoint"); + Log.other("绿色经营📊收集获得" + totalCollectPoint); + } else { + Log.i(TAG + ".batchSelfCollect", s); + } + } catch (Throwable th) { + Log.i(TAG, "batchSelfCollect err:"); + Log.printStackTrace(TAG, th); + } + } + + private static void index() { + String s = GreenFinanceRpcCall.greenFinanceIndex(); + try { + JSONObject jo = new JSONObject(s); + if (jo.getBoolean("success")) { + JSONObject result = jo.getJSONObject("result"); + if (!result.getBoolean("greenFinanceSigned")) { + Log.other("绿色经营📊未开通"); + return; + } + JSONObject mcaGreenLeafResult = result.getJSONObject("mcaGreenLeafResult"); + JSONArray greenLeafList = mcaGreenLeafResult.getJSONArray("greenLeafList"); + String currentCode = ""; + JSONArray bsnIds = new JSONArray(); + for (int i = 0; i < greenLeafList.length(); i++) { + JSONObject greenLeaf = greenLeafList.getJSONObject(i); + String code = greenLeaf.getString("code"); + if (currentCode.equals(code) || bsnIds.length() == 0) { + bsnIds.put(greenLeaf.getString("bsnId")); + } else { + batchSelfCollect(bsnIds); + bsnIds = new JSONArray(); + } + } + if (bsnIds.length() > 0) { + batchSelfCollect(bsnIds); + } + } else { + Log.i(TAG, jo.getString("resultDesc")); + } + } catch (Throwable th) { + Log.i(TAG, "index err:"); + Log.printStackTrace(TAG, th); + } + + signIn("PLAY102632271"); + signIn("PLAY102932217"); + signIn("PLAY102232206"); + + String appletId = "AP13159535"; + doTask(appletId); + } + + private static void signIn(String sceneId) { + String s = GreenFinanceRpcCall.signInQuery(sceneId); + try { + JSONObject jo = new JSONObject(s); + if (jo.getBoolean("success")) { + JSONObject result = jo.getJSONObject("result"); + if (!result.getBoolean("isTodaySignin")) { + s = GreenFinanceRpcCall.signInTrigger(sceneId); + jo = new JSONObject(s); + if (jo.getBoolean("success")) { + Log.other("绿色经营📊签到成功"); + } else { + Log.i(TAG + ".signIn", s); + } + } + } else { + Log.i(TAG + ".signIn", s); + } + } catch (Throwable th) { + Log.i(TAG, "signIn err:"); + Log.printStackTrace(TAG, th); + } + } + + private static void doTask(String appletId) { + String s = GreenFinanceRpcCall.taskQuery(appletId); + try { + JSONObject jo = new JSONObject(s); + if (jo.getBoolean("success")) { + JSONObject result = jo.getJSONObject("result"); + JSONArray taskDetailList = result.getJSONArray("taskDetailList"); + for (int i = 0; i < taskDetailList.length(); i++) { + JSONObject taskDetail = taskDetailList.getJSONObject(i); + if ("USER_TRIGGER".equals(taskDetail.getString("sendCampTriggerType"))) { + if ("NONE_SIGNUP".equals(taskDetail.getString("taskProcessStatus"))) { + s = GreenFinanceRpcCall.taskTrigger(taskDetail.getString("taskId"), "signup", appletId); + jo = new JSONObject(s); + if (jo.getBoolean("success")) { + s = GreenFinanceRpcCall.taskTrigger(taskDetail.getString("taskId"), "send", appletId); + jo = new JSONObject(s); + if (jo.getBoolean("success")) { + Log.other("绿色经营📊任务完成"); + } + } + } + } + } + } else { + Log.i(TAG + ".doTask", s); + } + } catch (Throwable th) { + Log.i(TAG, "signIn err:"); + Log.printStackTrace(TAG, th); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/GreenFinanceRpcCall.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/GreenFinanceRpcCall.java new file mode 100644 index 000000000..1902219e7 --- /dev/null +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/GreenFinanceRpcCall.java @@ -0,0 +1,41 @@ +package pansong291.xposed.quickenergy.hook; + +import org.json.JSONArray; +import pansong291.xposed.quickenergy.util.FriendIdMap; + +public class GreenFinanceRpcCall { + + public static String greenFinanceIndex() { + return RpcUtil.request( + "com.alipay.mcaplatformunit.common.mobile.newservice.GreenFinancePageQueryService.indexV2", + "[{\"clientVersion\":\"VERSION2\",\"custType\":\"MERCHANT\"}]"); + } + + public static String batchSelfCollect(JSONArray bsnIds) { + return RpcUtil.request("com.alipay.mcaplatformunit.common.mobile.service.GreenFinancePointCollectService.batchSelfCollect", + "[{\"bsnIds\":" + bsnIds + ",\"clientVersion\":\"VERSION2\",\"custType\":\"MERCHANT\",\"uid\":\"" + + FriendIdMap.currentUid + "\"}]"); + } + + public static String signInQuery(String sceneId) { + return RpcUtil.request("com.alipay.loanpromoweb.promo.signin.query", + "[{\"cycleCount\":7,\"cycleType\":\"d\",\"extInfo\":{},\"needContinuous\":1,\"sceneId\":\"" + sceneId + "\"}]"); + } + + public static String signInTrigger(String sceneId) { + return RpcUtil.request("com.alipay.loanpromoweb.promo.signin.trigger", + "[{\"extInfo\":{},\"sceneId\":\"" + sceneId + "\"}]"); + } + + public static String taskQuery(String appletId) { + return RpcUtil.request("com.alipay.loanpromoweb.promo.task.taskQuery", + "[{\"appletId\":\"" + appletId + "\",\"completedBottom\":true}]"); + } + + public static String taskTrigger(String appletId, String stageCode, String taskCenId) { + return RpcUtil.request("com.alipay.loanpromoweb.promo.task.taskTrigger", + "[{\"appletId\":\"" + appletId + "\",\"stageCode\":\"" + stageCode + "\",\"taskCenId\":\"" + taskCenId + + "\"}]"); + } + +} diff --git a/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java b/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java index 9c168c8de..d91e57f93 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/hook/XposedHook.java @@ -102,6 +102,7 @@ public void run() { AntOcean.start(); AntOrchard.start(); AntStall.start(); + GreenFinance.start(); } } if (Config.collectEnergy() || Config.enableFarm()) { @@ -116,13 +117,13 @@ public void run() { }; } try { - AntForestToast.show("芝麻粒加载成功"); if (handler == null) { handler = new Handler(); if (Config.startAt7()) { Config.setAlarm7(AntForestToast.context); } } + AntForestToast.show("芝麻粒加载成功"); handler.removeCallbacks(runnable); AntForest.stop(); AntForestNotification.stop(service, false); diff --git a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java index 67fceef37..66d6a5eb5 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/ui/SettingsActivity.java @@ -45,7 +45,7 @@ public class SettingsActivity extends Activity { sw_enableOnGoing, sw_backupRuntime, sw_collectSesame, sw_zcjSignIn, sw_merchantKmdk, sw_acceptGift, sw_enableStall, sw_stallAutoClose, sw_stallAutoOpen, sw_stallAutoTask, sw_stallReceiveAward, sw_stallOpenType, sw_stallDonate, sw_chickenDiary, sw_collectGiftBox, sw_stallInviteRegister, - sw_stallThrowManure; + sw_stallThrowManure, sw_greenFinance; @Override protected void onCreate(Bundle savedInstanceState) { @@ -221,6 +221,7 @@ private void initSwitch() { sw_stallDonate = findViewById(R.id.sw_stallDonate); sw_stallInviteRegister = findViewById(R.id.sw_stallInviteRegister); sw_stallThrowManure = findViewById(R.id.sw_stallThrowManure); + sw_greenFinance = findViewById(R.id.sw_greenFinance); } @Override @@ -293,6 +294,7 @@ protected void onResume() { sw_stallDonate.setChecked(Config.stallDonate()); sw_stallInviteRegister.setChecked(Config.stallInviteRegister()); sw_stallThrowManure.setChecked(Config.stallThrowManure()); + sw_greenFinance.setChecked(Config.greenFinance()); } @SuppressLint("NonConstantResourceId") @@ -559,6 +561,10 @@ public void onClick(View v) { case R.id.sw_stallThrowManure: Config.setStallThrowManure(sw.isChecked()); break; + + case R.id.sw_greenFinance: + Config.setGreenFinance(sw.isChecked()); + break; } } else if (v instanceof Button) { Button btn = (Button) v; diff --git a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java index 67fadf116..537699069 100644 --- a/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java +++ b/app/src/main/java/pansong291/xposed/quickenergy/util/Config.java @@ -142,6 +142,7 @@ public CharSequence nickName() { public static final String jn_collectSesame = "collectSesame"; public static final String jn_zcjSignIn = "zcjSignIn"; public static final String jn_merchantKmdk = "merchantKmdk"; + public static final String jn_greenFinance = "greenFinance"; public static volatile boolean shouldReload; public static volatile boolean hasChanged; @@ -274,6 +275,7 @@ public CharSequence nickName() { private boolean collectSesame; private boolean zcjSignIn; private boolean merchantKmdk; + private boolean greenFinance; /* base */ private static volatile Config config; @@ -1267,6 +1269,15 @@ public static boolean merchantKmdk() { return getConfig().merchantKmdk; } + public static void setGreenFinance(boolean b) { + getConfig().greenFinance = b; + hasChanged = true; + } + + public static boolean greenFinance() { + return getConfig().greenFinance; + } + /* base */ private static synchronized Config getConfig() { if (config == null || shouldReload && config.immediateEffect) { @@ -1419,6 +1430,7 @@ public static Config defInit() { c.collectSesame = false; c.zcjSignIn = false; c.merchantKmdk = false; + c.greenFinance = false; return c; } @@ -1904,6 +1916,9 @@ public static Config json2Config(String json) { config.merchantKmdk = jo.optBoolean(jn_merchantKmdk, true); Log.i(TAG, jn_merchantKmdk + ":" + config.merchantKmdk); + + config.greenFinance = jo.optBoolean(jn_greenFinance, false); + Log.i(TAG, jn_greenFinance + ":" + config.greenFinance); } catch (Throwable t) { Log.printStackTrace(TAG, t); if (json != null) { @@ -2223,6 +2238,8 @@ public static String config2Json(Config config) { jo.put(jn_merchantKmdk, config.merchantKmdk); + jo.put(jn_greenFinance, config.greenFinance); + } catch (Throwable t) { Log.printStackTrace(TAG, t); } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 51d00c23f..961b90e8e 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1317,6 +1317,16 @@ android:minHeight="50dp" android:id="@+id/sw_merchantKmdk" /> + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index ba4c05570..0a2f69b95 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -145,5 +145,6 @@ 邀请好友开通新村 新村邀请摆摊列表 新村丢肥料 + 开启绿色经营 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1f870f30e..5e6037397 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,5 +149,6 @@ Stall invite register Stall invite shop list Stall throw manure + Green finance