Skip to content

Commit

Permalink
修复部分bug,添加绿色经营。
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Sep 8, 2023
1 parent d78284d commit b2621ee
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- [x] 芭芭农场
- [x] 保护地巡逻
- [x] 蚂蚁新村
- [ ] 绿色营收
- [x] 绿色经营
- [x] 高版本API存储问题


Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
142 changes: 142 additions & 0 deletions app/src/main/java/pansong291/xposed/quickenergy/GreenFinance.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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
+ "\"}]");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void run() {
AntOcean.start();
AntOrchard.start();
AntStall.start();
GreenFinance.start();
}
}
if (Config.collectEnergy() || Config.enableFarm()) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/pansong291/xposed/quickenergy/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1419,6 +1430,7 @@ public static Config defInit() {
c.collectSesame = false;
c.zcjSignIn = false;
c.merchantKmdk = false;
c.greenFinance = false;
return c;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,16 @@
android:minHeight="50dp"
android:id="@+id/sw_merchantKmdk" />

<Switch
android:paddingStart="@dimen/setting_item_padding"
android:paddingEnd="@dimen/setting_item_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/green_finance"
android:onClick="onClick"
android:minHeight="50dp"
android:id="@+id/sw_greenFinance" />

</LinearLayout>

</FrameLayout>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@
<string name="stall_invite_register">邀请好友开通新村</string>
<string name="stall_invite_shop_list">新村邀请摆摊列表</string>
<string name="stall_throw_manure">新村丢肥料</string>
<string name="green_finance">开启绿色经营</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@
<string name="stall_invite_register">Stall invite register</string>
<string name="stall_invite_shop_list">Stall invite shop list</string>
<string name="stall_throw_manure">Stall throw manure</string>
<string name="green_finance">Green finance</string>

</resources>

0 comments on commit b2621ee

Please sign in to comment.