Commit 8e879fbe by 阮思源

修改下获取作品应用统计

parent 65890204
......@@ -796,6 +796,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
wechatGroupDtoP.setType("PRODUCT");
wechatGroupDtoP.setQrcodeId(qrcodeId);
Map<Long, GroupMoneyDto> productSaleMap = tradeConsr.getQrGroupSaleMoney(wechatGroupDtoP);
Map<Long, BigDecimal> productIncomeMap = settlementConsr.getAdviserIncomeByCondition(valProductIds, "PRODUCT", partyId, qrcodeId, bookGroupId);
SpeWechatGroupDto speWechatGroupDto=new SpeWechatGroupDto();
speWechatGroupDto.setBookGroupId(bookGroupId);
speWechatGroupDto.setPartyId(partyId);
......@@ -807,10 +808,11 @@ public class BookGroupBizImpl implements BookGroupBiz {
speWechatGroupDto.setProductIdMap(map);
Map<Long, GroupMoneyDto> forBuyCountMap = tradeConsr.getSpeQrGroupSaleMoney(speWechatGroupDto);
Map<Long, Double> proSaleMap = new HashMap<>();
Map<Long, Double> proIncomeMap = new HashMap<>();
if (productSaleMap.values() != null && !productSaleMap.values().isEmpty()) {
dealSale(videoProductIds, videoPProductMapIds, productSaleMap, proSaleMap);
dealSale(audioProductIds, audioPProductMapIds, productSaleMap, proSaleMap);
dealSale(liveProductIds, livePProductMapIds, productSaleMap, proSaleMap);
dealSale(videoProductIds, videoPProductMapIds, productSaleMap, proSaleMap, productIncomeMap, proIncomeMap);
dealSale(audioProductIds, audioPProductMapIds, productSaleMap, proSaleMap, productIncomeMap, proIncomeMap);
dealSale(liveProductIds, livePProductMapIds, productSaleMap, proSaleMap, productIncomeMap, proIncomeMap);
for (AppStatisticsDTO appStatisticsDTO : appStatisticsDTOS) {
Long id = appStatisticsDTO.getServeId();
String type = appStatisticsDTO.getServeType();
......@@ -820,14 +822,14 @@ public class BookGroupBizImpl implements BookGroupBiz {
if (groupMoneyDto != null && groupMoneyDto.getSaleCount() != null) {
toAddCount = groupMoneyDto.getSaleCount().intValue();
}
addProductSale(id, productDtoMap, proSaleMap, toAddCount, appStatisticsDTO);
addProductSale(id, productDtoMap, proSaleMap, proIncomeMap, toAddCount, appStatisticsDTO);
}
}
}
}
}
private void addProductSale(Long id, Map<Long, ProductDto> productDtoMap, Map<Long, Double> proSaleMap, Integer toAddCount, AppStatisticsDTO appStatisticsDTO) {
private void addProductSale(Long id, Map<Long, ProductDto> productDtoMap, Map<Long, Double> proSaleMap, Map<Long, Double> proIncomeMap, Integer toAddCount, AppStatisticsDTO appStatisticsDTO) {
ProductDto productDto = productDtoMap.get(id);
String[] videoTypes = {"VIDEO_COURSE", "VIDEO_SCHEDULE"};
String[] audioTypes = {"AUDIOAPP", "AUDIO_RESOURCE", "AUDIO_SCHEDULE", "AUDIO_COURSE"};
......@@ -840,6 +842,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
|| Arrays.asList(audioTypes).contains(typeCode)
|| Arrays.asList(liveTypes).contains(typeCode))) {
Double toAdd = proSaleMap.get(id);
Double incomeToAdd = proIncomeMap.get(id);
if (toAdd != null) {
Double oldSale = appStatisticsDTO.getSaleAmount();
if (oldSale == null) {
......@@ -847,6 +850,13 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
appStatisticsDTO.setSaleAmount(oldSale + toAdd);
}
if (incomeToAdd != null) {
Double oldIncome = appStatisticsDTO.getIncomeAmount();
if (oldIncome == null) {
oldIncome = 0D;
}
appStatisticsDTO.setIncomeAmount(oldIncome + incomeToAdd);
}
if (toAddCount != null) {
Integer oldBuy = appStatisticsDTO.getBuyCount();
if (oldBuy == null) {
......@@ -865,13 +875,14 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
}
private void dealSale(List<Long> ids, Map<Long,List<Long>> productMapIds, Map<Long,GroupMoneyDto> productSaleMap, Map<Long,Double> saleMap) {
private void dealSale(List<Long> ids, Map<Long,List<Long>> productMapIds, Map<Long,GroupMoneyDto> productSaleMap, Map<Long,Double> saleMap, Map<Long, BigDecimal> productIncomeMap, Map<Long, Double> incomeMap) {
if (!ListUtils.isEmpty(ids)) {
for (Long id : ids) {
List<Long> productIds = productMapIds.get(id);
if (!ListUtils.isEmpty(productIds)) {
Double saleMoney = 0D;
Long saleCount = 0L;
Double incomeMoney = 0D;
for (Long productId : productIds) {
GroupMoneyDto groupMoneyDto = productSaleMap.get(productId);
if (groupMoneyDto != null) {
......@@ -882,8 +893,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
saleCount = saleCount + groupMoneyDto.getSaleCount();
}
}
if (productIncomeMap != null && productIncomeMap.get(productId) != null) {
incomeMoney = incomeMoney + productIncomeMap.get(productId).doubleValue();
}
}
saleMap.put(id, saleMoney);
incomeMap.put(id, incomeMoney);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment