|
@@ -1,8 +1,9 @@
|
|
package cn.com.ctop.toutiao.modules.agent.service.impl;
|
|
package cn.com.ctop.toutiao.modules.agent.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
|
|
|
|
+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.entity.TransactionDetails;
|
|
|
|
+import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDayMapper;
|
|
import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDetailsMapper;
|
|
import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDetailsMapper;
|
|
import cn.com.ctop.toutiao.modules.agent.mapper.CtopAgentAccountMapper;
|
|
import cn.com.ctop.toutiao.modules.agent.mapper.CtopAgentAccountMapper;
|
|
import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
|
|
import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
|
|
@@ -42,17 +43,21 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
private final String OPEN_API_URL_PREFIX = "https://ad.oceanengine.com/open_api/2/";
|
|
private final String OPEN_API_URL_PREFIX = "https://ad.oceanengine.com/open_api/2/";
|
|
private final String ACCOUNT_LIST_URL = "agent/advertiser/select/";
|
|
private final String ACCOUNT_LIST_URL = "agent/advertiser/select/";
|
|
private final String ACCOUNT_TRANSACTION_DETAILS_URL = "advertiser/fund/transaction/get/";
|
|
private final String ACCOUNT_TRANSACTION_DETAILS_URL = "advertiser/fund/transaction/get/";
|
|
|
|
+ private final String ACCOUNT_TRANSACTION_DAY_URL = "advertiser/fund/daily_stat/";
|
|
private final String ADVERTISER_ID = "73970348172";
|
|
private final String ADVERTISER_ID = "73970348172";
|
|
private final String RECHARGE = "RECHARGE";
|
|
private final String RECHARGE = "RECHARGE";
|
|
private final String TRANSFER = "TRANSFER";
|
|
private final String TRANSFER = "TRANSFER";
|
|
- @Resource
|
|
|
|
- CtopOauthTokenMapper ctopOauthTokenMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
CtopAgentAccountMapper ctopAgentAccountMapper;
|
|
CtopAgentAccountMapper ctopAgentAccountMapper;
|
|
@Resource
|
|
@Resource
|
|
CtopAccountTransactionDetailsMapper ctopAccountTransactionDetailsMapper;
|
|
CtopAccountTransactionDetailsMapper ctopAccountTransactionDetailsMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CtopAccountTransactionDayMapper ctopAccountTransactionDayMapper;
|
|
|
|
+
|
|
|
|
+ private String accountList = "1651537304110087;1640370875427848;73970348172";
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 同步代理商下账号
|
|
* 同步代理商下账号
|
|
*
|
|
*
|
|
@@ -67,43 +72,50 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
List<String> dataList = new ArrayList();
|
|
List<String> dataList = new ArrayList();
|
|
Result result = new Result();
|
|
Result result = new Result();
|
|
try {
|
|
try {
|
|
- //分页查询第一页数据
|
|
|
|
- JSONObject agentAccountList = selectAgentAdvertiser(1, 2000);
|
|
|
|
- JSONObject data = (JSONObject) agentAccountList.get("data");
|
|
|
|
- //dataList.addAll((List) data.get("list"));
|
|
|
|
- if (data.size() > 0) {
|
|
|
|
- JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
|
- int total_page = (int) page_info.get("total_page");
|
|
|
|
- //查询其他页数据
|
|
|
|
- for (int i = 0; i < total_page; i++) {
|
|
|
|
- JSONObject agenttList = selectAgentAdvertiser(i + 1, 2000);
|
|
|
|
- JSONObject agentData = (JSONObject) agenttList.get("data");
|
|
|
|
- List<Long> list = (List<Long>) agentData.get("list");
|
|
|
|
- list.stream().forEach(str -> {
|
|
|
|
- dataList.add(str.toString());
|
|
|
|
- });
|
|
|
|
|
|
+ if (accountList != null) {
|
|
|
|
+ String[] split = accountList.split(";");
|
|
|
|
+ for (String account : split) {
|
|
|
|
+ //分页查询第一页数据
|
|
|
|
+ JSONObject agentAccountList = selectAgentAdvertiser(1, 2000, account);
|
|
|
|
+ JSONObject data = (JSONObject) agentAccountList.get("data");
|
|
|
|
+ //dataList.addAll((List) data.get("list"));
|
|
|
|
+ if (data.size() > 0) {
|
|
|
|
+ JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
|
+ int total_page = (int) page_info.get("total_page");
|
|
|
|
+ //查询其他页数据
|
|
|
|
+ for (int i = 0; i < total_page; i++) {
|
|
|
|
+ JSONObject agenttList = selectAgentAdvertiser(i + 1, 2000, account);
|
|
|
|
+ JSONObject agentData = (JSONObject) agenttList.get("data");
|
|
|
|
+ List<Long> list = (List<Long>) agentData.get("list");
|
|
|
|
+ list.stream().forEach(str -> {
|
|
|
|
+ dataList.add(str.toString());
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ log.info("拉取" + account + "下账户数量:{}", dataList.size());
|
|
|
|
+ //查询数据库已存在id
|
|
|
|
+ List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
|
+ if (!accountIdList.isEmpty()) {
|
|
|
|
+ //筛选巨量引擎剔除的用户
|
|
|
|
+ List<String> removeList = accountIdList.stream().filter(item -> !dataList.contains(item)).collect(toList());
|
|
|
|
+ //筛选巨量引擎新增的用户
|
|
|
|
+ List<String> addList = dataList.stream().filter(item -> !accountIdList.contains(item)).collect(toList());
|
|
|
|
+ //修改剔除的用户状态
|
|
|
|
+ if (!removeList.isEmpty()) {
|
|
|
|
+ ctopAgentAccountMapper.updateAccountState(removeList, 1);
|
|
|
|
+ }
|
|
|
|
+ //保存新增的用户
|
|
|
|
+ if (!addList.isEmpty()) {
|
|
|
|
+ ctopAgentAccountMapper.insertAccountData(addList, ADVERTISER_ID, df.format(new Date()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ ctopAgentAccountMapper.insertAccountData(dataList, ADVERTISER_ID, df.format(new Date()));
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- //查询数据库已存在id
|
|
|
|
- List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
|
- if (!accountIdList.isEmpty()) {
|
|
|
|
- //筛选巨量引擎剔除的用户
|
|
|
|
- List<String> removeList = accountIdList.stream().filter(item -> !dataList.contains(item)).collect(toList());
|
|
|
|
- //筛选巨量引擎新增的用户
|
|
|
|
- List<String> addList = dataList.stream().filter(item -> !accountIdList.contains(item)).collect(toList());
|
|
|
|
- //修改剔除的用户状态
|
|
|
|
- if (!removeList.isEmpty()) {
|
|
|
|
- ctopAgentAccountMapper.updateAccountState(removeList, 1);
|
|
|
|
- }
|
|
|
|
- //保存新增的用户
|
|
|
|
- if (!addList.isEmpty()) {
|
|
|
|
- ctopAgentAccountMapper.insertAccountData(addList, ADVERTISER_ID, df.format(new Date()));
|
|
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- ctopAgentAccountMapper.insertAccountData(dataList, ADVERTISER_ID, df.format(new Date()));
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
result.setMessage("success");
|
|
result.setMessage("success");
|
|
return result;
|
|
return result;
|
|
@@ -121,8 +133,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
* @create: 2021-07-15
|
|
* @create: 2021-07-15
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result synchronousAccountTransactionDetails() {
|
|
|
|
|
|
+ public Result synchronousAccountTransactionDetails(String startDate, String endDate) {
|
|
log.info("开始同步账号交易流水");
|
|
log.info("开始同步账号交易流水");
|
|
|
|
+ Result result = new Result();
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
List<TransactionDetails> transactionDetailsList = new ArrayList<>();
|
|
List<TransactionDetails> transactionDetailsList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
@@ -132,70 +145,88 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
accountIdList.stream().forEach(str -> {
|
|
accountIdList.stream().forEach(str -> {
|
|
if (!str.isEmpty()) {
|
|
if (!str.isEmpty()) {
|
|
//查询账号下充值的交易流水
|
|
//查询账号下充值的交易流水
|
|
- JSONObject jsonObject = queryAccountTransactionDetails(str, RECHARGE, 1, 1000);
|
|
|
|
|
|
+ JSONObject jsonObject = queryAccountTransactionDetails(str, RECHARGE, 1, 1000, startDate, endDate);
|
|
|
|
+ int code = (int) jsonObject.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ result.setMessage((String) jsonObject.get("message"));
|
|
|
|
+ log.info((String) jsonObject.get("message"));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
JSONObject data = (JSONObject) jsonObject.get("data");
|
|
JSONObject data = (JSONObject) jsonObject.get("data");
|
|
- List<Object> dataList = (List<Object>) data.get("list");
|
|
|
|
- if (!dataList.isEmpty()) {
|
|
|
|
- //充值类存在记录
|
|
|
|
- //保存第一页数据
|
|
|
|
- dataList.stream().forEach(ob -> {
|
|
|
|
- TransactionDetails transactionDetails = JSONObject.toJavaObject((JSON) ob, TransactionDetails.class);
|
|
|
|
- //订单号不存在
|
|
|
|
- if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetails.getTransaction_seq())) {
|
|
|
|
- transactionDetailsList.add(transactionDetails);
|
|
|
|
- }
|
|
|
|
|
|
+ if (data != null) {
|
|
|
|
+ List<Object> dataList = (List<Object>) data.get("list");
|
|
|
|
+ if (dataList != null && !dataList.isEmpty()) {
|
|
|
|
+ //充值类存在记录
|
|
|
|
+ //保存第一页数据
|
|
|
|
+ dataList.stream().forEach(ob -> {
|
|
|
|
+ TransactionDetails transactionDetails = JSONObject.toJavaObject((JSON) ob, TransactionDetails.class);
|
|
|
|
+ //订单号不存在
|
|
|
|
+ if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetails.getTransaction_seq())) {
|
|
|
|
+ transactionDetailsList.add(transactionDetails);
|
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
|
- JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
|
- int total_page = (int) page_info.get("total_page");
|
|
|
|
- //查询其他页数据
|
|
|
|
- if (total_page > 1) {
|
|
|
|
- for (int i = 2; i <= total_page; i++) {
|
|
|
|
- JSONObject jo = queryAccountTransactionDetails(str, RECHARGE, i, 1000);
|
|
|
|
- JSONObject accountData = (JSONObject) jo.get("data");
|
|
|
|
- List<Object> rechargeList = (List<Object>) accountData.get("list");
|
|
|
|
- rechargeList.stream().forEach(transactionDetails -> {
|
|
|
|
- TransactionDetails transactionDetailsOther = JSONObject.toJavaObject((JSON) transactionDetails, TransactionDetails.class);
|
|
|
|
- //订单号不存在
|
|
|
|
- if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetailsOther.getTransaction_seq())) {
|
|
|
|
- transactionDetailsList.add(transactionDetailsOther);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
|
+ int total_page = (int) page_info.get("total_page");
|
|
|
|
+ //查询其他页数据
|
|
|
|
+ if (total_page > 1) {
|
|
|
|
+ for (int i = 2; i <= total_page; i++) {
|
|
|
|
+ JSONObject jo = queryAccountTransactionDetails(str, RECHARGE, i, 1000, startDate, endDate);
|
|
|
|
+ JSONObject accountData = (JSONObject) jo.get("data");
|
|
|
|
+ List<Object> rechargeList = (List<Object>) accountData.get("list");
|
|
|
|
+ rechargeList.stream().forEach(transactionDetails -> {
|
|
|
|
+ TransactionDetails transactionDetailsOther = JSONObject.toJavaObject((JSON) transactionDetails, TransactionDetails.class);
|
|
|
|
+ //订单号不存在
|
|
|
|
+ if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetailsOther.getTransaction_seq())) {
|
|
|
|
+ transactionDetailsList.add(transactionDetailsOther);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//查询账号下转账的交易流水
|
|
//查询账号下转账的交易流水
|
|
- JSONObject transferJsonObject = queryAccountTransactionDetails(str, TRANSFER, 1, 1000);
|
|
|
|
|
|
+ JSONObject transferJsonObject = queryAccountTransactionDetails(str, TRANSFER, 1, 1000, startDate, endDate);
|
|
JSONObject transferData = (JSONObject) transferJsonObject.get("data");
|
|
JSONObject transferData = (JSONObject) transferJsonObject.get("data");
|
|
- List<Object> transferDataList = (List<Object>) transferData.get("list");
|
|
|
|
- if (!transferDataList.isEmpty()) {
|
|
|
|
- //转账类存在记录
|
|
|
|
- //保存第一页数据
|
|
|
|
- transferDataList.stream().forEach(ob -> {
|
|
|
|
- TransactionDetails transactionDetails = JSONObject.toJavaObject((JSON) ob, TransactionDetails.class);
|
|
|
|
- //订单号不存在
|
|
|
|
- if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetails.getTransaction_seq())) {
|
|
|
|
- transactionDetailsList.add(transactionDetails);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- JSONObject transferPageInfo = (JSONObject) transferData.get("page_info");
|
|
|
|
- int transferTotalPage = (int) transferPageInfo.get("total_page");
|
|
|
|
- //查询其他页数据
|
|
|
|
- if (transferTotalPage > 1) {
|
|
|
|
- for (int i = 2; i <= transferTotalPage; i++) {
|
|
|
|
- JSONObject jo = queryAccountTransactionDetails(str, TRANSFER, i, 1000);
|
|
|
|
- JSONObject accountData = (JSONObject) jo.get("data");
|
|
|
|
- List<Object> rechargeList = (List<Object>) accountData.get("list");
|
|
|
|
- rechargeList.stream().forEach(transactionDetails -> {
|
|
|
|
- TransactionDetails transactionDetailsOther = JSONObject.toJavaObject((JSON) transactionDetails, TransactionDetails.class);
|
|
|
|
- //订单号不存在
|
|
|
|
- if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetailsOther.getTransaction_seq())) {
|
|
|
|
- transactionDetailsList.add(transactionDetailsOther);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ int code1 = (int) jsonObject.get("code");
|
|
|
|
+ if (code1 != 0) {
|
|
|
|
+ result.setMessage((String) jsonObject.get("message"));
|
|
|
|
+ log.info((String) jsonObject.get("message"));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (transferData != null) {
|
|
|
|
+ List<Object> transferDataList = (List<Object>) transferData.get("list");
|
|
|
|
+ if (!transferDataList.isEmpty()) {
|
|
|
|
+ //转账类存在记录
|
|
|
|
+ //保存第一页数据
|
|
|
|
+ transferDataList.stream().forEach(ob -> {
|
|
|
|
+ TransactionDetails transactionDetails = JSONObject.toJavaObject((JSON) ob, TransactionDetails.class);
|
|
|
|
+ //订单号不存在
|
|
|
|
+ if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetails.getTransaction_seq())) {
|
|
|
|
+ transactionDetailsList.add(transactionDetails);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ JSONObject transferPageInfo = (JSONObject) transferData.get("page_info");
|
|
|
|
+ int transferTotalPage = (int) transferPageInfo.get("total_page");
|
|
|
|
+ //查询其他页数据
|
|
|
|
+ if (transferTotalPage > 1) {
|
|
|
|
+ for (int i = 2; i <= transferTotalPage; i++) {
|
|
|
|
+ JSONObject jo = queryAccountTransactionDetails(str, TRANSFER, i, 1000, startDate, endDate);
|
|
|
|
+ JSONObject accountData = (JSONObject) jo.get("data");
|
|
|
|
+ List<Object> rechargeList = (List<Object>) accountData.get("list");
|
|
|
|
+ rechargeList.stream().forEach(transactionDetails -> {
|
|
|
|
+ TransactionDetails transactionDetailsOther = JSONObject.toJavaObject((JSON) transactionDetails, TransactionDetails.class);
|
|
|
|
+ //订单号不存在
|
|
|
|
+ if (transactionSeqList.isEmpty() || !transactionSeqList.contains(transactionDetailsOther.getTransaction_seq())) {
|
|
|
|
+ transactionDetailsList.add(transactionDetailsOther);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -204,17 +235,111 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
ctopAccountTransactionDetailsMapper.saveAccountTransactionDetails(transactionDetailsList, df.format(new Date()));
|
|
ctopAccountTransactionDetailsMapper.saveAccountTransactionDetails(transactionDetailsList, df.format(new Date()));
|
|
log.info("新增交易记录:{}条", transactionDetailsList.size());
|
|
log.info("新增交易记录:{}条", transactionDetailsList.size());
|
|
}
|
|
}
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setMessage("success");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("error");
|
|
log.info("同步失败:{}", e.toString());
|
|
log.info("同步失败:{}", e.toString());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询账号流水
|
|
|
|
|
|
+ * 同步账户日流水
|
|
|
|
+ *
|
|
|
|
+ * @author zzy
|
|
|
|
+ * @create: 2021-07-15
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Result synchronousAccountTransactionDay(String startDate, String endDate) {
|
|
|
|
+ log.info("开始同步账号日流水");
|
|
|
|
+ Result result = new Result();
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
|
|
+ Calendar ca = Calendar.getInstance();
|
|
|
|
+ ca.setTime(new Date());
|
|
|
|
+ ca.add(Calendar.DATE, -1);
|
|
|
|
+ List<TransactionDay> transactionDetailsList = new ArrayList<>();
|
|
|
|
+ try {
|
|
|
|
+ List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
|
|
|
|
+ if (!accountIdList.isEmpty()) {
|
|
|
|
+ accountIdList.stream().forEach(str -> {
|
|
|
|
+ if (!str.isEmpty()) {
|
|
|
|
+ //查询账号下充值的交易流水
|
|
|
|
+ JSONObject jsonObject = queryAccountTransactionDay(str, 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:");
|
|
|
|
+ }
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ result.setMessage((String) jsonObject.get("message"));
|
|
|
|
+ log.info("返回数据:" + jsonObject.toJSONString() + ":" + str);
|
|
|
|
+ }
|
|
|
|
+ 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<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
|
|
|
|
+ //订单号不存在
|
|
|
|
+ if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
|
|
|
|
+ transactionDetailsList.add(transactionDay);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ JSONObject page_info = (JSONObject) data.get("page_info");
|
|
|
|
+ int total_page = (int) page_info.get("total_page");
|
|
|
|
+ //查询其他页数据
|
|
|
|
+ if (total_page > 1) {
|
|
|
|
+ for (int i = 2; i <= total_page; i++) {
|
|
|
|
+ JSONObject jo = queryAccountTransactionDay(str, i, 1000, startDate, endDate);
|
|
|
|
+ JSONObject accountData = (JSONObject) jo.get("data");
|
|
|
|
+ List<Object> rechargeList = (List<Object>) accountData.get("list");
|
|
|
|
+ rechargeList.stream().forEach(obj -> {
|
|
|
|
+ TransactionDay transactionDay = JSONObject.toJavaObject((JSON) obj, TransactionDay.class);
|
|
|
|
+ List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
|
|
|
|
+
|
|
|
|
+ //订单号不存在
|
|
|
|
+ if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
|
|
|
|
+ transactionDetailsList.add(transactionDay);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //保存数据
|
|
|
|
+ if (!transactionDetailsList.isEmpty()) {
|
|
|
|
+ ctopAccountTransactionDayMapper.saveAccountTransactionDay(transactionDetailsList, df.format(new Date()));
|
|
|
|
+ log.info("新增日流水记录:{}条", transactionDetailsList.size());
|
|
|
|
+ }
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setMessage("success");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("error");
|
|
|
|
+ log.info("同步失败:{}", e.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询账号流水明细
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* @author zzy
|
|
* @author zzy
|
|
@@ -222,7 +347,31 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
* @create: 2021-07-14
|
|
* @create: 2021-07-14
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public JSONObject queryAccountTransactionDetails(String AccountId, String transaction_type, int pageNum, int pageSize) {
|
|
|
|
|
|
+ public JSONObject queryAccountTransactionDetails(String AccountId, String transaction_type, int pageNum, int pageSize, String startDate, String endDate) {
|
|
|
|
+ // 请求参数
|
|
|
|
+ Map data = new HashMap() {
|
|
|
|
+ {
|
|
|
|
+ put("advertiser_id", AccountId);
|
|
|
|
+ put("start_date", startDate);
|
|
|
|
+ put("end_date", endDate);
|
|
|
|
+ put("transaction_type", transaction_type);
|
|
|
|
+ put("page", pageNum);
|
|
|
|
+ put("page_size", pageSize);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ return sendHttpRequest(data, ACCOUNT_TRANSACTION_DETAILS_URL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询账号日流水
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ * @author zzy
|
|
|
|
+ * @Param AccountId 账户id pageNum 当前页 pageSize 每页显示数量
|
|
|
|
+ * @create: 2021-07-14
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject queryAccountTransactionDay(String AccountId, int pageNum, int pageSize, String startDate, String endDate) {
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
|
Calendar ca = Calendar.getInstance();
|
|
Calendar ca = Calendar.getInstance();
|
|
ca.setTime(new Date());
|
|
ca.setTime(new Date());
|
|
@@ -231,14 +380,15 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
Map data = new HashMap() {
|
|
Map data = new HashMap() {
|
|
{
|
|
{
|
|
put("advertiser_id", AccountId);
|
|
put("advertiser_id", AccountId);
|
|
- put("start_date", df.format(ca.getTime()));
|
|
|
|
- put("end_date", df.format(ca.getTime()));
|
|
|
|
- put("transaction_type", transaction_type);
|
|
|
|
|
|
+ put("start_date", startDate);
|
|
|
|
+ put("end_date", endDate);
|
|
put("page", pageNum);
|
|
put("page", pageNum);
|
|
put("page_size", pageSize);
|
|
put("page_size", pageSize);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- return sendHttpRequest(data, ACCOUNT_TRANSACTION_DETAILS_URL);
|
|
|
|
|
|
+ return sendHttpRequest(data, ACCOUNT_TRANSACTION_DAY_URL);
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -250,7 +400,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public String getToken() {
|
|
public String getToken() {
|
|
- CtopOauthToken ctopOauthToken = ctopOauthTokenMapper.selectByAccountId(Long.parseLong(ADVERTISER_ID));
|
|
|
|
|
|
+ CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(Long.parseLong(ADVERTISER_ID));
|
|
if (ctopOauthToken != null) {
|
|
if (ctopOauthToken != null) {
|
|
return ctopOauthToken.getAccessToken();
|
|
return ctopOauthToken.getAccessToken();
|
|
} else {
|
|
} else {
|
|
@@ -268,11 +418,11 @@ public class AgentManagementServiceImpl implements AgentManagementService {
|
|
* @create: 2021-07-14
|
|
* @create: 2021-07-14
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public JSONObject selectAgentAdvertiser(int pageNum, int pageSize) {
|
|
|
|
|
|
+ public JSONObject selectAgentAdvertiser(int pageNum, int pageSize, String account) {
|
|
// 请求参数
|
|
// 请求参数
|
|
Map data = new HashMap() {
|
|
Map data = new HashMap() {
|
|
{
|
|
{
|
|
- put("advertiser_id", ADVERTISER_ID);
|
|
|
|
|
|
+ put("advertiser_id", account);
|
|
put("page", pageNum);
|
|
put("page", pageNum);
|
|
put("page_size", pageSize);
|
|
put("page_size", pageSize);
|
|
}
|
|
}
|