|
|
@@ -1,9 +1,12 @@
|
|
|
package com.ytpm.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ytpm.agent.model.YtApp;
|
|
|
+import com.ytpm.agent.model.YtPlatformUserApp;
|
|
|
import com.ytpm.agent.param.AuditCheckParam;
|
|
|
import com.ytpm.agent.param.AuditUserParam;
|
|
|
import com.ytpm.agent.view.AgentUserInfo;
|
|
|
@@ -13,30 +16,32 @@ import com.ytpm.app.param.YtAppUserListParam;
|
|
|
import com.ytpm.app.view.AppUserStaticsView;
|
|
|
import com.ytpm.app.view.YtAppUserListView;
|
|
|
import com.ytpm.app.view.YtUserEcpmListView;
|
|
|
+import com.ytpm.dao.AgentAppMapper;
|
|
|
import com.ytpm.dao.AgentStaticsMapper;
|
|
|
import com.ytpm.dao.AppMapper;
|
|
|
import com.ytpm.dao.MessageMapper;
|
|
|
import com.ytpm.dao.RiskMapper;
|
|
|
import com.ytpm.feign.AppFeign;
|
|
|
+import com.ytpm.general.PageMeta;
|
|
|
import com.ytpm.general.RepMessage;
|
|
|
import com.ytpm.general.Result;
|
|
|
import com.ytpm.general.ResultTable;
|
|
|
+import com.ytpm.general.StatusCode;
|
|
|
import com.ytpm.middle.model.YtPlatformMessage;
|
|
|
import com.ytpm.middle.view.MessageRecordVO;
|
|
|
import com.ytpm.middle.view.MessageVO;
|
|
|
import com.ytpm.risk.view.RiskTemplateView;
|
|
|
import com.ytpm.service.YtAppUserService;
|
|
|
+import com.ytpm.utils.FeignClientInvoker;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* App用户业务逻辑
|
|
|
@@ -44,6 +49,8 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FeignClientInvoker feignInvoker;
|
|
|
@Resource
|
|
|
private AppMapper appMapper;
|
|
|
@Resource
|
|
|
@@ -51,9 +58,9 @@ public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
@Resource
|
|
|
private AgentStaticsMapper staticsMapper;
|
|
|
@Resource
|
|
|
- private AppFeign appFeign;
|
|
|
- @Resource
|
|
|
private MessageMapper messageMapper;
|
|
|
+ @Resource
|
|
|
+ private AgentAppMapper agentAppMapper;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -63,45 +70,35 @@ public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultTable<YtAppUserListView> selectAppUserList(YtAppUserListParam param, AgentUserInfo userInfo) {
|
|
|
- //查询当前用户的所有应用
|
|
|
- List<YtApp> ytApps = appMapper.queryAll(userInfo.getUserId());
|
|
|
- if(StrUtil.isBlank(param.getAppIds())){
|
|
|
- if(CollUtil.isEmpty(ytApps)) {
|
|
|
- return ResultTable.resultTableOk(new PageInfo<>(Collections.emptyList()));
|
|
|
- }
|
|
|
- String appIds = ytApps.stream().map(YtApp::getAppId).collect(Collectors.joining(","));
|
|
|
- param.setAppIds(appIds);
|
|
|
- }
|
|
|
- Map<String, YtApp> appMap = ytApps.stream().collect(Collectors.toMap(YtApp::getAppId, o->o));
|
|
|
- ResultTable<YtAppUserListView> resultTable = appFeign.queryAll(param);
|
|
|
- setUserExtInfo(resultTable,appMap);
|
|
|
- return resultTable;
|
|
|
+ //数据量大已改为appId必传
|
|
|
+ YtApp ytApp = appMapper.selectPrimary(param.getAppIds());
|
|
|
+ YtPlatformUserApp app = agentAppMapper.selectByPrimaryKey(ytApp.getSuperiorId());
|
|
|
+ Object o = feignInvoker.invoke(app.getServiceName(), "queryAll", param);
|
|
|
+ String string = JSON.toJSONString(o);
|
|
|
+ JSONObject object = JSON.parseObject(string);
|
|
|
+ List<YtAppUserListView> views = JSONArray.parseArray(object.getString("data"), YtAppUserListView.class);
|
|
|
+ PageMeta pageMeta = JSON.parseObject(object.getString("pageMeta"), PageMeta.class);
|
|
|
+ setUserExtInfo(views,ytApp);
|
|
|
+ return new ResultTable(StatusCode.OK,RepMessage.QUERY_SUCCESS,views,pageMeta);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置用户扩展信息
|
|
|
*/
|
|
|
- private void setUserExtInfo(ResultTable<YtAppUserListView> resultTable, Map<String, YtApp> appMap) {
|
|
|
- List<YtAppUserListView> data = resultTable.getData();
|
|
|
+ private void setUserExtInfo(List<YtAppUserListView> data, YtApp ytApp) {
|
|
|
for (YtAppUserListView datum : data) {
|
|
|
List<YtDyzLoginRecord> recordList = datum.getLoginRecordList();
|
|
|
- YtApp ytApp = appMap.get(datum.getAppId());
|
|
|
- if(Objects.nonNull(ytApp)) {
|
|
|
- datum.setAppId(ytApp.getAppId());
|
|
|
- datum.setAppName(ytApp.getAppName());
|
|
|
- datum.setAppType(ytApp.getAppType());
|
|
|
- datum.setChannelId(ytApp.getChannelId());
|
|
|
- datum.setVersionCode(ytApp.getVersionCode());
|
|
|
- datum.setDitchId(ytApp.getDitchId());
|
|
|
- datum.setDitchName(ytApp.getDitchName());
|
|
|
- }
|
|
|
- if(CollUtil.isNotEmpty(recordList)){
|
|
|
- datum.setDeviceRepeatCount((int) recordList.stream().map(YtDyzLoginRecord::getDeviceModel).distinct().count());
|
|
|
- datum.setIpRepeatCount((int)recordList.stream().map(YtDyzLoginRecord::getIpAddr).distinct().count());
|
|
|
- datum.setCommunicationOperator(recordList.get(0).getOperator());
|
|
|
- }
|
|
|
+ datum.setAppId(ytApp.getAppId());
|
|
|
+ datum.setAppName(ytApp.getAppName());
|
|
|
+ datum.setAppType(ytApp.getAppType());
|
|
|
+ datum.setChannelId(ytApp.getChannelId());
|
|
|
+ datum.setVersionCode(ytApp.getVersionCode());
|
|
|
+ datum.setDitchId(ytApp.getDitchId());
|
|
|
+ datum.setDitchName(ytApp.getDitchName());
|
|
|
+ datum.setDeviceRepeatCount((int) recordList.stream().map(YtDyzLoginRecord::getDeviceModel).distinct().count());
|
|
|
+ datum.setIpRepeatCount((int)recordList.stream().map(YtDyzLoginRecord::getIpAddr).distinct().count());
|
|
|
+ datum.setCommunicationOperator(recordList.get(0).getOperator());
|
|
|
}
|
|
|
- resultTable.setData(data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -136,10 +133,14 @@ public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
* 查询用户的ecpm
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResultTable<YtUserEcpmListView> ecpmList(String userId,Integer adsourceType) {
|
|
|
- ResultTable<YtDyzAdRecord> table = appFeign.adRecords(userId,adsourceType);
|
|
|
- List<YtDyzAdRecord> data = table.getData();
|
|
|
- return ResultTable.resultTableOk(new PageInfo<>(data));
|
|
|
+ public ResultTable<YtUserEcpmListView> ecpmList(String appId,String userId,Integer adsourceType) {
|
|
|
+ YtApp ytApp = appMapper.selectPrimary(appId);
|
|
|
+ YtPlatformUserApp app = agentAppMapper.selectByPrimaryKey(ytApp.getSuperiorId());
|
|
|
+ Object o = feignInvoker.invoke(app.getServiceName(), "adRecords", userId,adsourceType);
|
|
|
+ JSONObject object = JSONObject.parseObject(JSON.toJSONString(o));
|
|
|
+ List<YtDyzAdRecord> records = JSONArray.parseArray(object.getString("data"), YtDyzAdRecord.class);
|
|
|
+ PageMeta pageMeta = JSON.parseObject(object.getString("pageMeta"), PageMeta.class);
|
|
|
+ return new ResultTable(StatusCode.OK,RepMessage.QUERY_SUCCESS,records,pageMeta);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -147,15 +148,11 @@ public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result<BigDecimal> getRevenueByTime(YtAppUserListParam param, String userId) {
|
|
|
- if(StrUtil.isBlank(param.getAppIds())){
|
|
|
- List<YtApp> ytApps = appMapper.queryAll(userId);
|
|
|
- if(CollUtil.isEmpty(ytApps)) {
|
|
|
- return Result.resultObjOk(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- String appIds = ytApps.stream().map(YtApp::getAppId).collect(Collectors.joining(","));
|
|
|
- param.setAppIds(appIds);
|
|
|
- }
|
|
|
- return Result.resultObjOk(appFeign.getRevenueByTime(param));
|
|
|
+ //数据量大改为必定选择一个app
|
|
|
+ YtApp ytApp = appMapper.selectPrimary(param.getAppIds());
|
|
|
+ YtPlatformUserApp app = agentAppMapper.selectByPrimaryKey(ytApp.getSuperiorId());
|
|
|
+ Object o = feignInvoker.invoke(app.getServiceName(), "getRevenueByTime",param);
|
|
|
+ return Result.resultObjOk(new BigDecimal(JSON.toJSONString(o)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -192,6 +189,7 @@ public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
|
|
|
/**
|
|
|
* 批量审核
|
|
|
+ * 数据量大必须选择一个app
|
|
|
*/
|
|
|
@Override
|
|
|
public Result<String> batchAudit(AuditUserParam auditParam) {
|
|
|
@@ -202,7 +200,9 @@ public class YtAppUserServiceImpl implements YtAppUserService {
|
|
|
if(Objects.isNull(ecpmLimit) || Objects.isNull(revenueLimit)){
|
|
|
return Result.resultErr(RepMessage.OBJECT_NOT_EXIST);
|
|
|
}
|
|
|
- appFeign.batchAudit(new AuditCheckParam(ecpmLimit,revenueLimit,auditParam));
|
|
|
+ YtApp ytApp = appMapper.selectPrimary(auditParam.getAppId());
|
|
|
+ YtPlatformUserApp app = agentAppMapper.selectByPrimaryKey(ytApp.getSuperiorId());
|
|
|
+ feignInvoker.invoke(app.getServiceName(), "batchAudit", new AuditCheckParam(ecpmLimit,revenueLimit,auditParam));
|
|
|
return Result.resultOk(RepMessage.CONFIRM_SUCCESS);
|
|
|
}
|
|
|
|