|
@@ -66,19 +66,21 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT first_level.channel_shortname, first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ String sql = String.format(
|
|
|
+ "SELECT first_level.channel_shortname, first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
"left join loghubods.out_channel_mid_split_total fission " +
|
|
|
- "on first_level.channel_shortname = fission.channel_shortname and first_level.subchannel = fission.subchannel and first_level.dt = fission.dt " +
|
|
|
- "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
- "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '分投放渠道客户分账号去重';", dt);
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.subchannel = fission.subchannel " +
|
|
|
+ "and first_level.dt = fission.dt and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '分投放渠道客户分账号去重';", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformGzhAccount> accountList = getAllGzhAccount();
|
|
|
Map<String, ContentPlatformGzhAccount> accountMap = accountList.stream()
|
|
|
.collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, account -> account));
|
|
|
List<String> ghIds = accountList.stream().map(ContentPlatformGzhAccount::getGhId).collect(Collectors.toList());
|
|
|
- List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
+ List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
@@ -102,7 +104,7 @@ public class ContentPlatformDatastatJob {
|
|
|
item.setFansIncreaseCount(wxAccountDatastatVO.getFansIncreaseCount());
|
|
|
}
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
@@ -125,12 +127,16 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ String sql = String.format(
|
|
|
+ "SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv, price.arpu " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
"left join loghubods.out_channel_mid_split_total fission " +
|
|
|
"on first_level.channel_shortname = fission.channel_shortname and first_level.dt = fission.dt " +
|
|
|
"and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
- "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
+ "left join loghubods.wecom_cooperation_dynamic_unit_price price " +
|
|
|
+ "on first_level.channel_shortname = price.channel_shortname and first_level.dt = price.dt " +
|
|
|
+ "and first_level.type = price.type and first_level.tag = price.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '公众号即时回复' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformAccount> accountList = getAllAccount();
|
|
@@ -139,7 +145,8 @@ public class ContentPlatformDatastatJob {
|
|
|
List<ContentPlatformGzhAccount> gzhAccountList = getAllGzhAccount();
|
|
|
Map<Long, List<ContentPlatformGzhAccount>> gzhAccountMap = gzhAccountList.stream()
|
|
|
.collect(Collectors.groupingBy(ContentPlatformGzhAccount::getCreateAccountId));
|
|
|
- List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
+ List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
@@ -151,6 +158,7 @@ public class ContentPlatformDatastatJob {
|
|
|
String channel = record.getString(0);
|
|
|
Integer firstLevelCount = Integer.valueOf((String) record.get(1));
|
|
|
Integer fissionCount = parseInteger(record.get(2));
|
|
|
+ Double arpu = parseDouble(record.get(3));
|
|
|
item.setDateStr(dt);
|
|
|
item.setChannel(channel);
|
|
|
item.setFirstLevelCount(firstLevelCount);
|
|
@@ -168,10 +176,15 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
item.setFansIncreaseCount(fansIncreaseCount);
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
- BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
+ BigDecimal unitPrice = num.multiply(new BigDecimal(arpu)).multiply(BigDecimal.valueOf(account.getPrice()))
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setUnitPrice(unitPrice.doubleValue());
|
|
|
+ BigDecimal settlementAmount = unitPrice.multiply(new BigDecimal(firstLevelCount));
|
|
|
+ item.setSettlementAmount(settlementAmount.doubleValue());
|
|
|
}
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveList.add(item);
|
|
@@ -196,19 +209,21 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ String sql = String.format(
|
|
|
+ "SELECT first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
"left join loghubods.out_channel_mid_split_total fission " +
|
|
|
"on first_level.subchannel = fission.subchannel and first_level.dt = fission.dt " +
|
|
|
"and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
- "WHERE first_level.dt = %s and first_level.type = '服务号代运营' and first_level.tag = '分投放渠道客户分账号去重' ;", dt);
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '服务号代运营' and first_level.tag = '分投放渠道客户分账号去重' ;", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformGzhAccount> accountList = getAllGzhAccount();
|
|
|
Map<String, ContentPlatformGzhAccount> accountMap = accountList.stream()
|
|
|
.collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, account -> account));
|
|
|
List<String> ghIds = accountList.stream().map(ContentPlatformGzhAccount::getGhId).collect(Collectors.toList());
|
|
|
- List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
+ List<String> accountExternalIds = accountList.stream().map(ContentPlatformGzhAccount::getExternalId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
@@ -232,7 +247,7 @@ public class ContentPlatformDatastatJob {
|
|
|
item.setFansIncreaseCount(wxAccountDatastatVO.getFansIncreaseCount());
|
|
|
}
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
@@ -255,12 +270,16 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
// 公众号自动回复数据统计
|
|
|
- String sql = String.format("SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ String sql = String.format(
|
|
|
+ "SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv, price.arpu " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
"left join loghubods.out_channel_mid_split_total fission " +
|
|
|
"on first_level.channel_shortname = fission.channel_shortname and first_level.dt = fission.dt " +
|
|
|
"and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
- "WHERE first_level.dt = %s and first_level.type = '服务号代运营' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
+ "left join loghubods.wecom_cooperation_dynamic_unit_price price " +
|
|
|
+ "on first_level.channel_shortname = price.channel_shortname and first_level.dt = price.dt " +
|
|
|
+ "and first_level.type = price.type and first_level.tag = price.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '服务号代运营' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
// 所有公众号
|
|
|
List<ContentPlatformAccount> accountList = getAllAccount();
|
|
@@ -269,7 +288,8 @@ public class ContentPlatformDatastatJob {
|
|
|
List<ContentPlatformGzhAccount> gzhAccountList = getAllGzhAccount();
|
|
|
Map<Long, List<ContentPlatformGzhAccount>> gzhAccountMap = gzhAccountList.stream()
|
|
|
.collect(Collectors.groupingBy(ContentPlatformGzhAccount::getCreateAccountId));
|
|
|
- List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId).collect(Collectors.toList());
|
|
|
+ List<String> accountExternalIds = gzhAccountList.stream().map(ContentPlatformGzhAccount::getExternalId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
String dateStr = dt.substring(0, 4) + "-" + dt.substring(4, 6) + "-" + dt.substring(6, 8);
|
|
|
List<WxAccountDatastatVO> wxAccountDatastatVOList = aigcApiService.getWxAccountDatastat(dateStr, accountExternalIds);
|
|
|
Map<String, WxAccountDatastatVO> wxAccountDatastatMap = wxAccountDatastatVOList.stream()
|
|
@@ -281,6 +301,7 @@ public class ContentPlatformDatastatJob {
|
|
|
String channel = record.getString(0);
|
|
|
Integer firstLevelCount = Integer.valueOf((String) record.get(1));
|
|
|
Integer fissionCount = parseInteger(record.get(2));
|
|
|
+ Double arpu = parseDouble(record.get(3));
|
|
|
item.setDateStr(dt);
|
|
|
item.setChannel(channel);
|
|
|
item.setFirstLevelCount(firstLevelCount);
|
|
@@ -298,10 +319,15 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
item.setFansIncreaseCount(fansIncreaseCount);
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
- BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
+ BigDecimal unitPrice = num.multiply(new BigDecimal(arpu)).multiply(BigDecimal.valueOf(account.getPrice()))
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setUnitPrice(unitPrice.doubleValue());
|
|
|
+ BigDecimal settlementAmount = unitPrice.multiply(new BigDecimal(firstLevelCount));
|
|
|
+ item.setSettlementAmount(settlementAmount.doubleValue());
|
|
|
}
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveList.add(item);
|
|
@@ -355,7 +381,8 @@ public class ContentPlatformDatastatJob {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
List<ContentPlatformQwDataStat> existList = getQwDatastatCount(dt);
|
|
|
- List<String> existRootSourceIds = existList.stream().map(ContentPlatformQwDataStat::getRootSourceId).collect(Collectors.toList());
|
|
|
+ List<String> existRootSourceIds = existList.stream().map(ContentPlatformQwDataStat::getRootSourceId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
Map<String, Long> rootSourceIdMap = qwPlanList.stream()
|
|
|
.collect(Collectors.toMap(ContentPlatformQwPlan::getRootSourceId, ContentPlatformQwPlan::getId));
|
|
|
List<Long> planIds = qwPlanList.stream().map(ContentPlatformQwPlan::getId).collect(Collectors.toList());
|
|
@@ -449,19 +476,27 @@ public class ContentPlatformDatastatJob {
|
|
|
dt = param;
|
|
|
}
|
|
|
Map<String, ContentPlatformQwDataStatTotal> saveMap = new HashMap<>();
|
|
|
- String outSql = String.format("SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ String outSql = String.format(
|
|
|
+ "SELECT first_level.channel_shortname, first_level.first_uv, fission.split_uv, price.arpu " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
"left join loghubods.out_channel_mid_split_total fission " +
|
|
|
"on first_level.channel_shortname = fission.channel_shortname and first_level.dt = fission.dt " +
|
|
|
"and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
- "WHERE first_level.dt = %s and first_level.type = '企微外部' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
+ "left join loghubods.wecom_cooperation_dynamic_unit_price price " +
|
|
|
+ "on first_level.channel_shortname = price.channel_shortname and first_level.dt = price.dt " +
|
|
|
+ "and first_level.type = price.type and first_level.tag = price.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '企微外部' and first_level.tag = '投放渠道内去重' ;", dt);
|
|
|
List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
|
|
|
+ List<ContentPlatformAccount> accountList = getAllAccount();
|
|
|
+ Map<String, ContentPlatformAccount> accountMap = accountList.stream()
|
|
|
+ .collect(Collectors.toMap(ContentPlatformAccount::getChannel, account -> account));
|
|
|
Long now = System.currentTimeMillis();
|
|
|
if (CollectionUtils.isNotEmpty(outDataList)) {
|
|
|
for (Record record : outDataList) {
|
|
|
String channel = (String) record.get(0);
|
|
|
int firstLevelCount = Integer.parseInt((String) record.get(1));
|
|
|
Integer fissionCount = parseInteger(record.get(2));
|
|
|
+ Double arpu = parseDouble(record.get(3));
|
|
|
if (firstLevelCount == 0) {
|
|
|
continue;
|
|
|
}
|
|
@@ -471,11 +506,21 @@ public class ContentPlatformDatastatJob {
|
|
|
if (item.getFirstLevelCount() == null) {
|
|
|
item.setFirstLevelCount(0);
|
|
|
}
|
|
|
+ ContentPlatformAccount account = accountMap.get(channel);
|
|
|
+ if (Objects.isNull(account)) {
|
|
|
+ account = new ContentPlatformAccount();
|
|
|
+ account.setPrice(1d);
|
|
|
+ }
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
- BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
+ BigDecimal unitPrice = num.multiply(new BigDecimal(arpu)).multiply(BigDecimal.valueOf(account.getPrice()))
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setUnitPrice(unitPrice.doubleValue());
|
|
|
+ BigDecimal settlementAmount = unitPrice.multiply(new BigDecimal(firstLevelCount));
|
|
|
+ item.setSettlementAmount(settlementAmount.doubleValue());
|
|
|
}
|
|
|
item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
|
|
|
item.setCreateTimestamp(now);
|
|
@@ -529,7 +574,6 @@ public class ContentPlatformDatastatJob {
|
|
|
continue;
|
|
|
}
|
|
|
if (saveMap.containsKey(channel) && !out2Channels.contains(channel)) {
|
|
|
-
|
|
|
saveMap.remove(channel);
|
|
|
}
|
|
|
ContentPlatformQwDataStatReplyTotal item = saveMap.getOrDefault(channel, new ContentPlatformQwDataStatReplyTotal());
|
|
@@ -546,10 +590,12 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
List<ContentPlatformQwDataStatReplyTotal> saveList = new ArrayList<>(saveMap.values());
|
|
|
if (CollectionUtils.isNotEmpty(saveList)) {
|
|
|
- List<String> channels = saveList.stream().map(ContentPlatformQwDataStatReplyTotal::getChannel).distinct().collect(Collectors.toList());
|
|
|
+ List<String> channels = saveList.stream().map(ContentPlatformQwDataStatReplyTotal::getChannel).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
List<ContentPlatformQwDataStatReplyTotal> channelScoreList = dataStatMapperExt.getQwTotalDatastatReplyScoreList(dt, channels);
|
|
|
Map<String, Double> channelScoreMap = channelScoreList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformQwDataStatReplyTotal::getChannel, ContentPlatformQwDataStatReplyTotal::getScore, (a, b) -> a));
|
|
|
+ .collect(Collectors.toMap(ContentPlatformQwDataStatReplyTotal::getChannel,
|
|
|
+ ContentPlatformQwDataStatReplyTotal::getScore, (a, b) -> a));
|
|
|
for (ContentPlatformQwDataStatReplyTotal item : saveList) {
|
|
|
item.setScore(channelScoreMap.get(item.getChannel()));
|
|
|
}
|
|
@@ -566,12 +612,16 @@ public class ContentPlatformDatastatJob {
|
|
|
dt = param;
|
|
|
}
|
|
|
List<ContentPlatformQwDataStatSubChannel> saveList = new ArrayList<>();
|
|
|
- String outSql = String.format("SELECT first_level.channel_shortname, first_level.subchannel, first_level.first_uv, fission.split_uv " +
|
|
|
- "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
+ String outSql = String.format(
|
|
|
+ "SELECT first_level.channel_shortname, first_level.subchannel, first_level.first_uv, fission.split_uv, price.arpu " +
|
|
|
+ "FROM loghubods.out_channel_mid_first_total first_level " +
|
|
|
"left join loghubods.out_channel_mid_split_total fission " +
|
|
|
- "on first_level.channel_shortname = fission.channel_shortname and first_level.subchannel = fission.subchannel and first_level.dt = fission.dt " +
|
|
|
- "and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
- "WHERE first_level.dt = %s and first_level.type = '企微外部' and first_level.tag = '分投放渠道客户分账号去重' ;", dt);
|
|
|
+ "on first_level.channel_shortname = fission.channel_shortname and first_level.subchannel = fission.subchannel " +
|
|
|
+ "and first_level.dt = fission.dt and first_level.type = fission.type and first_level.tag = fission.tag " +
|
|
|
+ "left join loghubods.wecom_cooperation_dynamic_unit_price price " +
|
|
|
+ "on first_level.channel_shortname = price.channel_shortname and first_level.subchannel = price.subchannel " +
|
|
|
+ "and first_level.dt = price.dt and first_level.type = price.type and first_level.tag = price.tag " +
|
|
|
+ "WHERE first_level.dt = %s and first_level.type = '企微外部' and first_level.tag = '分投放渠道客户分账号去重' ;", dt);
|
|
|
List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
|
|
|
List<ContentPlatformAccount> accountList = getAllAccount();
|
|
|
Map<String, ContentPlatformAccount> accountMap = accountList.stream()
|
|
@@ -587,6 +637,7 @@ public class ContentPlatformDatastatJob {
|
|
|
String subChannel = (String) record.get(1);
|
|
|
int firstLevelCount = Integer.parseInt((String) record.get(2));
|
|
|
Integer fissionCount = parseInteger(record.get(3));
|
|
|
+ Double arpu = parseDouble(record.get(4));
|
|
|
if (firstLevelCount == 0) {
|
|
|
continue;
|
|
|
}
|
|
@@ -597,23 +648,26 @@ public class ContentPlatformDatastatJob {
|
|
|
continue;
|
|
|
}
|
|
|
List<ContentPlatformQwPlan> qwPlans = qwPlanMap.getOrDefault(account.getId(), new ArrayList<>());
|
|
|
- List<String> subChannelList = qwPlans.stream().map(ContentPlatformQwPlan::getSubChannel).distinct().collect(Collectors.toList());
|
|
|
+ List<String> subChannelList = qwPlans.stream().map(ContentPlatformQwPlan::getSubChannel).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(qwPlans) || !subChannelList.contains(subChannel)) {
|
|
|
noSubChannelRecordList.add(record);
|
|
|
continue;
|
|
|
}
|
|
|
item.setCreateAccountId(account.getId());
|
|
|
item.setSubChannel(subChannel);
|
|
|
- if (item.getFirstLevelCount() == null) {
|
|
|
- item.setFirstLevelCount(0);
|
|
|
- }
|
|
|
+ item.setFirstLevelCount(firstLevelCount);
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
- BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
+ BigDecimal unitPrice = num.multiply(new BigDecimal(arpu)).multiply(BigDecimal.valueOf(account.getPrice()))
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setUnitPrice(unitPrice.doubleValue());
|
|
|
+ BigDecimal settlementAmount = unitPrice.multiply(new BigDecimal(firstLevelCount));
|
|
|
+ item.setSettlementAmount(settlementAmount.doubleValue());
|
|
|
}
|
|
|
- item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveList.add(item);
|
|
|
}
|
|
@@ -621,6 +675,7 @@ public class ContentPlatformDatastatJob {
|
|
|
String channel = (String) record.get(0);
|
|
|
int firstLevelCount = Integer.parseInt((String) record.get(2));
|
|
|
Integer fissionCount = parseInteger(record.get(3));
|
|
|
+ Double arpu = parseDouble(record.get(4));
|
|
|
ContentPlatformQwDataStatSubChannel item = new ContentPlatformQwDataStatSubChannel();
|
|
|
item.setDateStr(dt);
|
|
|
ContentPlatformAccount account = accountMap.get(channel);
|
|
@@ -629,15 +684,17 @@ public class ContentPlatformDatastatJob {
|
|
|
}
|
|
|
item.setCreateAccountId(account.getId());
|
|
|
item.setSubChannel("未知");
|
|
|
- if (item.getFirstLevelCount() == null) {
|
|
|
- item.setFirstLevelCount(0);
|
|
|
- }
|
|
|
- item.setFirstLevelCount(item.getFirstLevelCount() + firstLevelCount);
|
|
|
+ item.setFirstLevelCount(firstLevelCount);
|
|
|
|
|
|
- if (Objects.nonNull(fissionCount) && fissionCount > 0 && firstLevelCount > 0) {
|
|
|
- BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() * 10 / firstLevelCount);
|
|
|
- BigDecimal rounded = num.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ if (fissionCount > 0 && firstLevelCount > 0) {
|
|
|
+ BigDecimal num = BigDecimal.valueOf(fissionCount.doubleValue() / firstLevelCount);
|
|
|
+ BigDecimal rounded = num.multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP);
|
|
|
item.setScore(rounded.doubleValue());
|
|
|
+ BigDecimal unitPrice = num.multiply(new BigDecimal(arpu)).multiply(BigDecimal.valueOf(account.getPrice()))
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ item.setUnitPrice(unitPrice.doubleValue());
|
|
|
+ BigDecimal settlementAmount = unitPrice.multiply(new BigDecimal(firstLevelCount));
|
|
|
+ item.setSettlementAmount(settlementAmount.doubleValue());
|
|
|
}
|
|
|
item.setCreateTimestamp(now);
|
|
|
saveList.add(item);
|
|
@@ -655,12 +712,12 @@ public class ContentPlatformDatastatJob {
|
|
|
example.createCriteria().andSubChannelIsNotNull();
|
|
|
return qwPlanMapper.selectByExample(example);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private Integer parseInteger(Object value) {
|
|
|
try {
|
|
|
return Integer.parseInt((String) value);
|
|
|
} catch (NumberFormatException e) {
|
|
|
- return null;
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -668,7 +725,7 @@ public class ContentPlatformDatastatJob {
|
|
|
try {
|
|
|
return Double.parseDouble((String) value);
|
|
|
} catch (NumberFormatException e) {
|
|
|
- return null;
|
|
|
+ return 0.0;
|
|
|
}
|
|
|
}
|
|
|
|