package com.example.sso.dao; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.example.sso.util.V5utils; public class Sum { public static Integer main1(String ID) { JSONObject jsonObject = new JSONObject(); jsonObject.put("app_id", "65815f117de49256b1e67e75"); jsonObject.put("entry_id", "658fce1d771e971c5816e475"); jsonObject.put("limit", 10000); JSONArray fields = new JSONArray(); fields.add("sj_id"); fields.add("invite_level"); fields.add("invite_money"); JSONObject filter = new JSONObject(); filter.put("rel", "and"); JSONArray cond = new JSONArray(); JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("field", "sj_id"); jsonObject1.put("method", "eq"); JSONArray value = new JSONArray(); value.add(ID); jsonObject1.put("value",value); JSONObject jsonObject2 = new JSONObject(); jsonObject2.put("field", "invite_level"); jsonObject2.put("method", "eq"); JSONArray value1 = new JSONArray(); value1.add("1"); jsonObject2.put("value",value1); cond.add(jsonObject2); cond.add(jsonObject1); filter.put("cond",cond); jsonObject.put("fields",fields); jsonObject.put("filter",filter); String jsonString = jsonObject.toJSONString(); String list = V5utils.list(jsonString); JSONObject jsonObject3 = JSON.parseObject(list); JSONArray jsonArray1 = jsonObject3.getJSONArray("data"); int sum = 0; for (Object o: jsonArray1){ JSONObject test = (JSONObject) o; Integer money = test.getInteger("invite_money"); sum += money; } return sum; } public static Integer main2(String ID) { JSONObject jsonObject = new JSONObject(); jsonObject.put("app_id", "65815f117de49256b1e67e75"); jsonObject.put("entry_id", "658fce1d771e971c5816e475"); jsonObject.put("limit", 10000); JSONArray fields = new JSONArray(); fields.add("sj_id"); fields.add("invite_level"); fields.add("invite_money"); JSONObject filter = new JSONObject(); filter.put("rel", "and"); JSONArray cond = new JSONArray(); JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("field", "sj_id"); jsonObject1.put("method", "eq"); JSONArray value = new JSONArray(); value.add(ID); jsonObject1.put("value",value); JSONObject jsonObject2 = new JSONObject(); jsonObject2.put("field", "invite_level"); jsonObject2.put("method", "eq"); JSONArray value1 = new JSONArray(); value1.add("2"); jsonObject2.put("value",value1); cond.add(jsonObject2); cond.add(jsonObject1); filter.put("cond",cond); jsonObject.put("fields",fields); jsonObject.put("filter",filter); String jsonString = jsonObject.toJSONString(); String list = V5utils.list(jsonString); JSONObject jsonObject3 = JSON.parseObject(list); JSONArray jsonArray1 = jsonObject3.getJSONArray("data"); int sum = 0; for (Object o: jsonArray1){ JSONObject test = (JSONObject) o; Integer money = test.getInteger("invite_money"); sum += money; } return sum; } }