|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.ctop.toutiao.modules.agent.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.toutiao.modules.agent.entity.TransactionDay;
|
|
|
import cn.com.ctop.toutiao.modules.agent.entity.TransactionDetails;
|
|
|
import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDayMapper;
|
|
@@ -8,7 +9,9 @@ import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDetailsMap
|
|
|
import cn.com.ctop.toutiao.modules.agent.mapper.CtopAgentAccountMapper;
|
|
|
import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import javafx.beans.binding.When;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.client.ClientProtocolException;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
@@ -268,9 +271,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
|
ca.add(Calendar.DATE, -1);
|
|
|
|
|
|
try {
|
|
|
-// List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
- List<String> accountIdList = new ArrayList<>();
|
|
|
- accountIdList.add("1744115510360071");
|
|
|
+ List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
+// List<String> accountIdList = new ArrayList<>();
|
|
|
+ //accountIdList.add("1744115510360071");
|
|
|
if (!accountIdList.isEmpty()) {
|
|
|
accountIdList.stream().forEach(str -> {
|
|
|
List<TransactionDay> transactionDetailsList = new ArrayList<>();
|
|
@@ -353,6 +356,57 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
|
|
|
|
|
|
|
return result;
|
|
|
+ } /**
|
|
|
+ * 同步账户日流水
|
|
|
+ *
|
|
|
+ * @author zzy
|
|
|
+ * @create: 2021-07-15
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void synchronousAccountTransactionDayNew(String startDate, String endDate,int page, int pageSize) {
|
|
|
+
|
|
|
+ List<TransactionDay> list = new ArrayList<>();
|
|
|
+ List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
+
|
|
|
+// List<String> accountIdList = new ArrayList<>();
|
|
|
+// accountIdList.add("1735775204994062");
|
|
|
+// accountIdList.add("1744114166675533");
|
|
|
+// accountIdList.add("1744114166069261");
|
|
|
+
|
|
|
+ for (String accountId : accountIdList) {
|
|
|
+ log.info("同步头条账户流水信息{}:开始时间{},结束时间{},第{}页" ,accountId,startDate,endDate,page);
|
|
|
+ JSONObject jsonObject = queryAccountTransactionDay(accountId, 1, 1000, startDate, endDate);
|
|
|
+ JSONObject data = null;
|
|
|
+ int code = 1;
|
|
|
+ if (jsonObject != null) {
|
|
|
+ data = (JSONObject) jsonObject.get("data");
|
|
|
+ code = (int) jsonObject.get("code");
|
|
|
+ } else {
|
|
|
+ log.info("返回数据jsonObject为null:");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (code != 0) {
|
|
|
+ log.info("返回数据:" + jsonObject.toJSONString() + ":" + accountId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (data != null) {
|
|
|
+ List<Object> dataList = (List<Object>) data.get("list");
|
|
|
+ if (dataList != null && !dataList.isEmpty()) {
|
|
|
+ dataList.stream().forEach(ob -> {
|
|
|
+ TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
|
|
|
+ list.add(transactionDay);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ctopAccountTransactionDayMapper.replaceAccountTransactionDay(list);
|
|
|
+
|
|
|
+ page++;
|
|
|
+ int totalPage = jsonObject.getJSONObject("data").getJSONObject("page_info").getInteger("total_page");
|
|
|
+ if (page <= totalPage) {
|
|
|
+ synchronousAccountTransactionDayNew(startDate, endDate, page, 1000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|