Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
bca0f885
Commit
bca0f885
authored
Mar 11, 2021
by
郑勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: [1004412] ERP码下权益、收益数据优化及相关问题处理
parent
d6792782
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
277 additions
and
63 deletions
+277
-63
BookAdviserBizImpl.java
...ava/com/pcloud/book/book/biz/impl/BookAdviserBizImpl.java
+238
-63
QrCodeVO.java
...-book/src/main/java/com/pcloud/book/book/vo/QrCodeVO.java
+5
-0
TradeConsr.java
.../main/java/com/pcloud/book/consumer/trade/TradeConsr.java
+34
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/impl/BookAdviserBizImpl.java
View file @
bca0f885
...
...
@@ -19,23 +19,8 @@ import com.pcloud.book.book.biz.BookLabelBiz;
import
com.pcloud.book.book.biz.BookQrcodeWxworkBiz
;
import
com.pcloud.book.book.constant.BookConstant
;
import
com.pcloud.book.book.dao.BookAdviserDao
;
import
com.pcloud.book.book.dto.AdviserBookInfoDTO
;
import
com.pcloud.book.book.dto.AdviserManageDto
;
import
com.pcloud.book.book.dto.AviserBookInfoParam
;
import
com.pcloud.book.book.dto.BookAdviserDto
;
import
com.pcloud.book.book.dto.BookCountAndAdviserIdDTO
;
import
com.pcloud.book.book.dto.BookCountByAdvisersDto
;
import
com.pcloud.book.book.dto.BookCountDto
;
import
com.pcloud.book.book.dto.BookDataStatisticsDTO
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.book.dto.BookQrcodeStatisticsDTO
;
import
com.pcloud.book.book.dto.BookResourceStatisticsDTO
;
import
com.pcloud.book.book.dto.BookRightsSettingDTO
;
import
com.pcloud.book.book.dto.BookVarietyStatsDto
;
import
com.pcloud.book.book.dto.BookVarietyStatsRequestDto
;
import
com.pcloud.book.book.dto.ERPPublishNumDTO
;
import
com.pcloud.book.book.dto.ErpBookInfoDTO
;
import
com.pcloud.book.book.dto.QrcodeStatisticsDTO
;
import
com.pcloud.book.book.dto.*
;
import
com.pcloud.book.book.dto.AppBookRequestDTO
;
import
com.pcloud.book.book.entity.Book
;
import
com.pcloud.book.book.entity.BookAdviser
;
import
com.pcloud.book.book.enums.BookQrcodeType
;
...
...
@@ -81,6 +66,10 @@ import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import
com.pcloud.book.rightsSetting.constants.RightsSettingConstant
;
import
com.pcloud.book.rightsSetting.dao.RightsSettingDAO
;
import
com.pcloud.book.rightsSetting.dto.RightsSettingDto
;
import
com.pcloud.book.rightsSetting.dto.RightsSettingQueryDTO
;
import
com.pcloud.book.rightsSetting.entity.RightsSetting
;
import
com.pcloud.book.rightsSetting.entity.RightsSettingNow
;
import
com.pcloud.book.rightsSetting.entity.RightsSettingTitle
;
import
com.pcloud.book.util.common.ThreadPoolUtils
;
import
com.pcloud.channelcenter.base.exceptions.ChannelBizException
;
import
com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO
;
...
...
@@ -89,6 +78,7 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import
com.pcloud.common.constant.CacheConstant
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.ProductTypeConstant
;
import
com.pcloud.common.core.constant.RedisKeyConstant
;
import
com.pcloud.common.core.constant.SceneCode
;
import
com.pcloud.common.core.constant.SendType
;
import
com.pcloud.common.core.constant.SystemCode
;
...
...
@@ -114,6 +104,7 @@ import com.pcloud.wechatgroup.group.dto.GroupUserCountDTO;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -1091,7 +1082,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
throw
new
BookBizException
(
BookBizException
.
ERROR
,
"参数为空"
);
}
//type 代表的是过滤二维码。如果是0,展示所有的二维码。如果是1(展示没有资源的码。但是要过滤小睿教育的书的非公众号二维码)
//获取rays码的权益书。一本书的权益书都一样
Integer
rightsettingCounts
=
getRightsettingCounts
(
bookId
,
adviserId
,
channelId
);
List
<
Long
>
xiaoRuiEducation
=
channelConsr
.
isXiaoRuiEducation
(
Lists
.
newArrayList
(
bookId
));
//BookAdviserDto bookAdviserDto = bookAdviserDao.getBase(bookId, channelId, adviserId);
//现在一本书下面可以配多个跳小睿的码
...
...
@@ -1109,6 +1101,11 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
Map
<
Long
,
BookGroupServeCountDTO
>
robotMap
=
CollUtil
.
isEmpty
(
robotList
)
?
new
HashMap
<>()
:
bookGroupServeDao
.
mapGroupQrcodeServeCount
(
robotList
);
//(**不包括群二维码)小睿二维码下资源数量
Map
<
Long
,
BookGroupServeCountDTO
>
xiaoruiMap
=
CollUtil
.
isEmpty
(
xiaoruiList
)
?
new
HashMap
<>()
:
bookGroupServeDao
.
mapXiaoRuiGroupQrcodeServeCount
(
xiaoruiList
);
//计算码的销售额
List
<
Long
>
bookGroupIds
=
CollUtil
.
isEmpty
(
bookGroupDTOList
)
?
new
ArrayList
<>()
:
bookGroupDTOList
.
stream
().
filter
(
a
->
null
!=
a
.
getId
()).
map
(
a
->
a
.
getId
()).
distinct
().
collect
(
Collectors
.
toList
());
Map
<
Long
,
BigDecimal
>
groupListSaleInfoMap
=
tradeConsr
.
getGroupListSaleInfo
(
bookGroupIds
);
List
<
QrCodeVO
>
qrCodeVOS
=
new
ArrayList
<>();
QrCodeVO
qrCodeVO
;
for
(
BookGroupDTO
bookGroupDTO
:
bookGroupDTOList
)
{
...
...
@@ -1119,6 +1116,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrCodeVO
.
setRightsCount
(
0
);
qrCodeVO
.
setSceneId
(
bookGroupDTO
.
getId
());
qrCodeVO
.
setJoinGroupType
(
bookGroupDTO
.
getJoinGroupType
());
qrCodeVO
.
setRightsCount
(
0
);
qrCodeVO
.
setSaleMoney
(
new
BigDecimal
(
0
));
if
(
JoinGroupTypeEnum
.
GROUP_QRCODE
.
getCode
().
equals
(
bookGroupDTO
.
getJoinGroupType
())){
if
(
CollUtil
.
isNotEmpty
(
groupQrCodeMap
)
&&
groupQrCodeMap
.
containsKey
(
bookGroupDTO
.
getId
())){
BookGroupServeCountDTO
bookGroupServeCountDTO
=
groupQrCodeMap
.
get
(
bookGroupDTO
.
getId
());
...
...
@@ -1138,6 +1137,14 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
}
}
//小睿的码才有权益
if
(
JoinGroupTypeEnum
.
XIAORUI
.
getCode
().
equals
(
bookGroupDTO
.
getJoinGroupType
())){
qrCodeVO
.
setRightsCount
(
rightsettingCounts
);
}
//设置销售额
if
(
CollUtil
.
isNotEmpty
(
groupListSaleInfoMap
)
&&
groupListSaleInfoMap
.
containsKey
(
bookGroupDTO
.
getId
())){
qrCodeVO
.
setSaleMoney
(
groupListSaleInfoMap
.
get
(
bookGroupDTO
.
getId
()));
}
qrCodeVO
.
setCodeType
(
"group"
);
qrCodeVO
.
setXiaoRuiEducation
(
false
);
if
(
CollUtil
.
isNotEmpty
(
xiaoRuiEducation
)
&&
xiaoRuiEducation
.
contains
(
bookId
)){
...
...
@@ -1198,6 +1205,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
List
<
Long
>
sceneIds
=
qrcodeSceneDtos
.
stream
().
map
(
x
->
x
.
getSceneId
()).
collect
(
Collectors
.
toList
());
// 企业微信群资源数
Map
<
Long
,
BookGroupServeCountDTO
>
bookQrcodeWxworkMap
=
bookQrcodeWxworkBiz
.
mapWxWorkServeCount4SceneIds
(
sceneIds
,
BookQrcodeType
.
OFFICIAL_ACCOUNTS
.
getCode
());
//计算码的销售额
Map
<
Long
,
BigDecimal
>
sceneListSaleInfoMap
=
tradeConsr
.
getSceneListSaleInfo
(
sceneIds
);
for
(
QrcodeSceneDto
e
:
qrcodeSceneDtos
)
{
QrCodeVO
qrCodeVO1
=
new
QrCodeVO
();
qrCodeVO1
.
setQrCodeName
(
e
.
getSceneName
());
...
...
@@ -1211,6 +1220,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
qrCodeVO1
.
setXiaoRuiEducation
(
true
);
}
qrCodeVO1
.
setSceneId
(
e
.
getSceneId
());
qrCodeVO1
.
setSaleMoney
(
new
BigDecimal
(
0
));
if
(
CollUtil
.
isNotEmpty
(
sceneListSaleInfoMap
)
&&
sceneListSaleInfoMap
.
containsKey
(
e
.
getSceneId
())){
qrCodeVO1
.
setSaleMoney
(
sceneListSaleInfoMap
.
get
(
e
.
getSceneId
()));
}
qrCodeVOS
.
add
(
qrCodeVO1
);
}
}
...
...
@@ -1237,6 +1250,33 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return
new
PageBeanNew
<>(
currentPage
,
numPerPage
,
qrCodeVOS
.
size
(),
record
);
}
private
Integer
getRightsettingCounts
(
Long
bookId
,
Long
adviserId
,
Long
channelId
)
{
Long
rightsSettingId
=
bookGroupBiz
.
getRightsSettingId4Book
(
adviserId
,
channelId
,
bookId
);
int
i
=
0
;
if
(
null
!=
rightsSettingId
){
RightsSettingQueryDTO
rightsSettingQueryDTO
=
new
RightsSettingQueryDTO
();
rightsSettingQueryDTO
.
setAdviserId
(
adviserId
);
rightsSettingQueryDTO
.
setBookId
(
bookId
);
rightsSettingQueryDTO
.
setChannelId
(
channelId
);
rightsSettingQueryDTO
.
setRightsSettingTypes
(
Lists
.
newArrayList
(
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
));
rightsSettingQueryDTO
.
setRightsSettingId
(
rightsSettingId
);
RightsSetting
rightsSetting
=
rightsSettingBiz
.
getRightsSettingItemsByTypeListNew
(
rightsSettingQueryDTO
);
if
(
null
!=
rightsSetting
&&
null
!=
rightsSetting
.
getRightsSettingNow
()){
RightsSettingNow
rightsSettingNow
=
rightsSetting
.
getRightsSettingNow
();
if
(
CollUtil
.
isNotEmpty
(
rightsSettingNow
.
getRightsSettingTitles
())){
for
(
RightsSettingTitle
rightsSettingTitle
:
rightsSettingNow
.
getRightsSettingTitles
())
{
if
(
CollUtil
.
isEmpty
(
rightsSettingTitle
.
getRightsSettingItemList
())){
continue
;
}
i
+=
rightsSettingTitle
.
getRightsSettingItemList
().
size
();
}
}
}
}
return
i
;
}
@Override
public
Map
<
String
,
BookResourceStatisticsDTO
>
mapResourceTotalCount
(
List
<
Long
>
adviserIds
,
List
<
Long
>
bookIds
,
List
<
Long
>
channelIds
){
Map
<
String
,
BookResourceStatisticsDTO
>
mapBookResourceStatistics
=
new
HashMap
<>();
...
...
@@ -1342,6 +1382,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
bookResourceStatisticsDTO
.
setServeCount
(
bookResourceStatisticsDTO
.
getServeCount
()
+
qrcodeMessageDTO
.
getServeCount
());
bookResourceStatisticsDTO
.
setQrcodeCount
(
bookResourceStatisticsDTO
.
getQrcodeCount
()
+
qrcodeMessageDTO
.
getQrcodeCount
());
bookResourceStatisticsDTO
.
setModernBookServeCount
(
bookResourceStatisticsDTO
.
getServeCount
()
+
qrcodeMessageDTO
.
getServeCount
());
bookResourceStatisticsDTO
.
setModernBookQrcodeCount
(
bookResourceStatisticsDTO
.
getQrcodeCount
()
+
qrcodeMessageDTO
.
getQrcodeCount
());
}
if
(
bookGroupServeCountDTO
!=
null
){
if
(
StringUtil
.
isEmpty
(
bookResourceStatisticsDTO
.
getBookChannelAdviserId
())){
...
...
@@ -1390,6 +1432,21 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
@Override
public
Map
<
Long
,
BookAdviserDto
>
getOneMainBooks
(
List
<
Long
>
bookIds4Agent
)
{
return
bookAdviserDao
.
getOneMainBooks
(
bookIds4Agent
);
}
@Override
public
Integer
getBookCountByAgentAndTime
(
Long
agentId
,
String
startTime
,
String
endTime
)
{
List
<
Long
>
adviserIds
=
adviserConsr
.
getByAgentId
(
agentId
);
Integer
bookCount
=
0
;
if
(!
ListUtils
.
isEmpty
(
adviserIds
))
{
bookCount
=
bookAdviserDao
.
getBookCountByTime
(
adviserIds
,
startTime
,
endTime
);
}
return
bookCount
;
}
@Override
public
Map
<
String
,
BookDataStatisticsDTO
>
mapBookDataStatistics
(
List
<
Long
>
adviserIds
,
List
<
Long
>
bookIds
,
List
<
Long
>
channelIds
)
{
if
(
CollectionUtils
.
isEmpty
(
adviserIds
)
||
CollectionUtils
.
isEmpty
(
bookIds
)
||
CollectionUtils
.
isEmpty
(
channelIds
)){
throw
new
ChannelBizException
(
ChannelBizException
.
FILED_NULL
,
"adviserIds、bookIds、channelIds 参数为空!"
);
...
...
@@ -1437,7 +1494,6 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
catch
(
InterruptedException
|
ExecutionException
|
TimeoutException
e
)
{
LOGGER
.
error
(
"获取社群码扫码次数/人数错误: {}=="
,
e
);
}
for
(
BookGroupDTO
bookGroupDTO
:
bookGroupList
)
{
GroupUserCountDTO
groupUserCountDTO
=
scanCountByGroup
.
get
(
bookGroupDTO
.
getId
());
bookDataStatisticsDTO
=
new
BookDataStatisticsDTO
();
...
...
@@ -1457,6 +1513,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
resultMap
.
put
(
bookDataStatisticsDTO
.
getBookChannelAdviserId
(),
bookDataStatisticsDTO
);
}
}
// 综合
for
(
BrowseCacheRecordDto
browseCacheRecordDto
:
bookScanAndUv
.
values
())
{
String
bookChannelAdviserId
=
browseCacheRecordDto
.
getJournalId
()
+
"_"
+
browseCacheRecordDto
.
getChannelId
()
+
"_"
+
browseCacheRecordDto
.
getAdviserId
();
...
...
@@ -1502,16 +1559,6 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
@Override
public
Integer
getBookCountByAgentAndTime
(
Long
agentId
,
String
startTime
,
String
endTime
)
{
List
<
Long
>
adviserIds
=
adviserConsr
.
getByAgentId
(
agentId
);
Integer
bookCount
=
0
;
if
(!
ListUtils
.
isEmpty
(
adviserIds
))
{
bookCount
=
bookAdviserDao
.
getBookCountByTime
(
adviserIds
,
startTime
,
endTime
);
}
return
bookCount
;
}
@Override
public
Map
<
String
,
BookQrcodeStatisticsDTO
>
mapBookQrcodeStatistics
(
List
<
Long
>
adviserIds
,
List
<
Long
>
bookIds
,
List
<
Long
>
channelIds
)
{
Map
<
String
,
BookQrcodeStatisticsDTO
>
resultMap
=
new
HashMap
<>();
BookQrcodeStatisticsDTO
bookQrcodeStatisticsDTO
;
...
...
@@ -1676,7 +1723,6 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return
new
PageBeanNew
(
currentPage
,
numPerPage
,
qrcodeSceneDtoList
.
size
(),
qrcodeSceneDtoList
.
stream
().
skip
(
currentPage
*
numPerPage
).
limit
(
numPerPage
).
collect
(
Collectors
.
toList
()));
}
@Override
public
Map
<
String
,
Object
>
getRayBookCountAndRate
(
Boolean
showRate
)
{
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
...
...
@@ -1697,6 +1743,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return
map
;
}
@Override
public
Integer
getIsRui
(
Long
adviserId
,
Long
bookId
,
Long
channelId
)
{
return
bookAdviserDao
.
getIsRui
(
adviserId
,
bookId
,
channelId
);
...
...
@@ -1746,11 +1793,6 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
@Override
public
BookAdviserDto
getBookByBookIdAdviserId
(
Long
bookId
,
Long
adviserId
){
return
bookAdviserDao
.
getBookByBookIdAdviserId
(
bookId
,
adviserId
);
}
@Override
public
Map
<
Long
,
BookVarietyStatsDto
>
getAdviserBookVarietyStats
(
List
<
BookVarietyStatsRequestDto
>
requestDtos
)
{
Map
<
Long
,
BookVarietyStatsDto
>
result
=
new
HashMap
<>();
if
(
CollUtil
.
isEmpty
(
requestDtos
))
{
...
...
@@ -1778,33 +1820,22 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
dtos
.
add
(
statsDTO
);
}
});
// 分析引擎获取非社群书统计结果
List
<
BookBrowseAndScanStatsDTO
>
browseAndScanStats
=
browseRecordConsr
.
getBookBrowseAndScanStats
(
dtos
);
List
<
BookBrowseAndScanStatsDTO
>
browseAndScanStats
=
new
ArrayList
<>();
CompletableFuture
<
List
<
BookBrowseAndScanStatsDTO
>>
browseAndScanStatsFuture
=
CompletableFuture
.
supplyAsync
(()
->
browseRecordConsr
.
getBookBrowseAndScanStats
(
dtos
));
// 微信群获取社群书统计结果
List
<
GroupScanUserStatsDTO
>
bookGroupScanStats
=
wechatGroupConsr
.
getBookGroupScanStats
(
adviserIds
);
List
<
GroupScanUserStatsDTO
>
bookGroupScanStats
=
new
ArrayList
<>();
CompletableFuture
<
List
<
GroupScanUserStatsDTO
>>
bookGroupScanStatsFuture
=
CompletableFuture
.
supplyAsync
(()
->
wechatGroupConsr
.
getBookGroupScanStats
(
adviserIds
));
// 查询印册量
List
<
ERPPublishNumDTO
>
finalPublishNumDto
=
new
ArrayList
<>();
List
<
ERPPublishNumDTO
>
dataFromDB
=
bookAdviserDao
.
getErpPublishNumQueryParams
(
adviserIds
);
CompletableFuture
<
List
<
ERPPublishNumDTO
>>
dataFromErpFuture
=
null
;
if
(
CollUtil
.
isNotEmpty
(
dataFromDB
))
{
List
<
ERPPublishNumDTO
>
dataFromErp
=
erpConsr
.
getBookExpectPublishNum
(
dataFromDB
);
// 根据ERP填充数据
finalPublishNumDto
=
dataFromErp
.
stream
().
map
(
// 匹配 adviserId channelId bookId
erpData
->
dataFromDB
.
stream
().
filter
(
dbData
->
Objects
.
equals
(
dbData
.
getAdviserId
(),
erpData
.
getAdviserId
())
&&
Objects
.
equals
(
dbData
.
getBookId
(),
erpData
.
getBookId
())
&&
Objects
.
equals
(
dbData
.
getChannelId
(),
erpData
.
getChannelId
())
).
findFirst
().
map
(
// 填充印册量
dbData
->
{
dbData
.
setExpectPublishNum
(
erpData
.
getExpectPublishNum
());
return
dbData
;
}
).
orElse
(
null
)
).
collect
(
Collectors
.
toList
());
dataFromErpFuture
=
CompletableFuture
.
supplyAsync
(()
->
erpConsr
.
getBookExpectPublishNum
(
dataFromDB
));
}
// 组装数据
...
...
@@ -1826,17 +1857,22 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
setVarietyLastQuarter
((
int
)
collect
.
stream
().
filter
(
x
->
getAgentQuarterDigital
(
x
.
getCreatedDate
())
==
getAgentLastQuarterDigital
(
new
Date
())).
map
(
BookAdviserDto:
:
getBookId
).
distinct
().
count
());
}
if
(
CollUtil
.
isNotEmpty
(
browseAndScanStats
)){
try
{
browseAndScanStats
=
browseAndScanStatsFuture
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
LOGGER
.
error
(
"分析引擎获取非社群书统计结果 失败,err:{}"
,
e
.
getMessage
(),
e
);
}
if
(
CollUtil
.
isNotEmpty
(
browseAndScanStats
))
{
List
<
BookBrowseAndScanStatsDTO
>
scanStatsDTOS
=
browseAndScanStats
.
stream
().
filter
(
x
->
map
.
get
(
agentId
).
contains
(
x
.
getAdviserId
())).
collect
(
Collectors
.
toList
());
if
(
CollUtil
.
isNotEmpty
(
scanStatsDTOS
))
{
// 累计扫码量
varietyStatsDto
.
setScanTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookScanTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookScanTotal
).
sum
());
varietyStatsDto
.
setScanTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookScanTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookScanTotal
).
sum
());
// 累计扫码人数
varietyStatsDto
.
setScanUserTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookScanUserTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookScanUserTotal
).
sum
());
varietyStatsDto
.
setScanUserTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookScanUserTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookScanUserTotal
).
sum
());
// 累计浏览量
varietyStatsDto
.
setBrowseTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookBrowseTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookBrowseTotal
).
sum
());
varietyStatsDto
.
setBrowseTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookBrowseTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookBrowseTotal
).
sum
());
// 累计浏览人数
varietyStatsDto
.
setBrowseUserTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookBrowseUserTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookBrowseUserTotal
).
sum
());
varietyStatsDto
.
setBrowseUserTotal
(
scanStatsDTOS
.
stream
().
filter
(
x
->
Objects
.
nonNull
(
x
.
getBookBrowseUserTotal
())).
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookBrowseUserTotal
).
sum
());
// 筛选本季度数据
...
...
@@ -1844,7 +1880,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
x
->
Objects
.
nonNull
(
x
.
getBookScanTotal
())
&&
StrUtil
.
isNotBlank
(
x
.
getDateStr
())
&&
getAgentQuarterDigital
(
DateUtil
.
parse
(
x
.
getDateStr
(),
"yyyyMM"
).
toJdkDate
())
==
getAgentQuarterDigital
(
new
Date
())
).
collect
(
Collectors
.
toList
());
if
(
CollUtil
.
isNotEmpty
(
thisQuarterCollect
)){
if
(
CollUtil
.
isNotEmpty
(
thisQuarterCollect
))
{
// 本季度扫码量
varietyStatsDto
.
setScanThisQuarter
(
thisQuarterCollect
.
stream
().
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookScanTotal
).
sum
());
// 本季度扫码人数
...
...
@@ -1861,7 +1897,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
x
->
Objects
.
nonNull
(
x
.
getBookScanTotal
())
&&
StrUtil
.
isNotBlank
(
x
.
getDateStr
())
&&
getAgentQuarterDigital
(
DateUtil
.
parse
(
x
.
getDateStr
(),
"yyyyMM"
).
toJdkDate
())
==
getAgentLastQuarterDigital
(
new
Date
())
).
collect
(
Collectors
.
toList
());
if
(
CollUtil
.
isNotEmpty
(
lastQuarterCollect
)){
if
(
CollUtil
.
isNotEmpty
(
lastQuarterCollect
))
{
// 上季度扫码量
varietyStatsDto
.
setScanLastQuarter
(
lastQuarterCollect
.
stream
().
mapToInt
(
BookBrowseAndScanStatsDTO:
:
getBookScanTotal
).
sum
());
// 上季度扫码人数
...
...
@@ -1874,6 +1910,11 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
}
try
{
bookGroupScanStats
=
bookGroupScanStatsFuture
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
LOGGER
.
error
(
"微信群获取社群书统计结果 失败,err:{}"
,
e
.
getMessage
(),
e
);
}
if
(
CollUtil
.
isNotEmpty
(
bookGroupScanStats
))
{
List
<
GroupScanUserStatsDTO
>
statsDTOS
=
bookGroupScanStats
.
stream
().
filter
(
x
->
map
.
get
(
agentId
).
contains
(
x
.
getAdviserId
())).
collect
(
Collectors
.
toList
());
if
(
CollUtil
.
isNotEmpty
(
statsDTOS
))
{
...
...
@@ -1933,7 +1974,31 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
}
if
(
CollUtil
.
isNotEmpty
(
dataFromDB
)
&&
Objects
.
nonNull
(
dataFromErpFuture
))
{
List
<
ERPPublishNumDTO
>
dataFromErp
=
new
ArrayList
<>();
try
{
dataFromErp
=
dataFromErpFuture
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
LOGGER
.
error
(
"获取ERP图书统计信息失败,err:{}"
,
e
.
getMessage
(),
e
);
}
if
(
CollUtil
.
isNotEmpty
(
dataFromErp
))
{
// 根据ERP填充数据
finalPublishNumDto
=
dataFromErp
.
stream
().
map
(
// 匹配 adviserId channelId bookId
erpData
->
dataFromDB
.
stream
().
filter
(
dbData
->
Objects
.
equals
(
dbData
.
getAdviserId
(),
erpData
.
getAdviserId
())
&&
Objects
.
equals
(
dbData
.
getBookId
(),
erpData
.
getBookId
())
&&
Objects
.
equals
(
dbData
.
getChannelId
(),
erpData
.
getChannelId
())
).
findFirst
().
map
(
// 填充印册量
dbData
->
{
dbData
.
setExpectPublishNum
(
erpData
.
getExpectPublishNum
());
return
dbData
;
}
).
orElse
(
null
)
).
collect
(
Collectors
.
toList
());
}
}
// 统计印册量
if
(
CollUtil
.
isNotEmpty
(
finalPublishNumDto
))
{
...
...
@@ -1962,6 +2027,17 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
public
PageBeanNew
<
AgentBookStatsDetailVO
>
getAgentBookStatsDetail
(
Long
agentId
,
String
name
,
Date
startDate
,
Date
endDate
,
Integer
isRay
,
Integer
currentPage
,
Integer
numPerPage
)
{
String
cacheKey
=
String
.
format
(
"%s_AGENT_BOOK_STATS_DETAIL_%s:%s:%s:%s:%s:%s:%s"
,
CacheConstant
.
BOOK
,
agentId
,
name
,
startDate
,
endDate
,
isRay
,
currentPage
,
numPerPage
);
synchronized
(
this
){
// 测试环境 2s内点击3次 清除缓存
Long
incr
=
JedisClusterUtils
.
incr
(
"CLICK_COUNT:"
+
cacheKey
);
if
(
incr
==
1
){
JedisClusterUtils
.
expire
(
"CLICK_COUNT:"
+
cacheKey
,
2
);
}
else
if
(
incr
>
2
){
JedisClusterUtils
.
del
(
"CLICK_COUNT:"
+
cacheKey
);
JedisClusterUtils
.
del
(
cacheKey
);
}
}
String
cache
=
JedisClusterUtils
.
get
(
cacheKey
);
if
(
StrUtil
.
isNotBlank
(
cache
)){
PageBeanNew
<
AgentBookStatsDetailVO
>
pageBeanNew
=
JSONObject
.
parseObject
(
cache
,
new
TypeReference
<
PageBeanNew
<
AgentBookStatsDetailVO
>>()
{});
...
...
@@ -2270,6 +2346,12 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
@Override
public
BookAdviserDto
getBookByBookIdAdviserId
(
Long
bookId
,
Long
adviserId
){
return
bookAdviserDao
.
getBookByBookIdAdviserId
(
bookId
,
adviserId
);
}
@Override
public
List
<
BookServeDTO
>
getAnswerServesByBook
(
Long
bookId
,
Long
adviserId
,
Long
channelId
)
{
List
<
BookServeDTO
>
answerList
=
new
ArrayList
<>();
List
<
BookServeDTO
>
bookServeVOS
=
bookGroupBiz
.
getBookAndBookGroupServeIds
(
adviserId
,
bookId
,
channelId
);
...
...
@@ -2373,6 +2455,31 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return
bookAdviserDao
.
getLatestAdviserBookByIsbn
(
isbn
);
}
@Override
public
List
<
BookAdviser
>
getRightBook
(
List
appIds
)
{
if
(
CollUtil
.
isEmpty
(
appIds
))
return
new
ArrayList
<>();
return
bookAdviserDao
.
getRightBook
(
appIds
);
}
@Override
public
void
selectAppBookExport
(
List
<
AppBookRequestDTO
>
appBookRequestDTOS
)
{
//erp查询立项书
//查询AppId
//查询公众号下配置应用的书
//查询社群码下配置应用的书
//查询权益下配置应用的书
//查询RAYS体验社下的编辑ID
return
;
}
private
void
setBookInfo4Erp
(
List
<
ErpAdviserBookVO
>
bookVOS
)
{
List
<
Long
>
adviserIds
=
bookVOS
.
stream
().
filter
(
s
->
s
.
getAdviserId
()
!=
null
).
map
(
ErpAdviserBookVO:
:
getAdviserId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
Long
>
channelIds
=
bookVOS
.
stream
().
filter
(
s
->
s
.
getChannelId
()
!=
null
).
map
(
ErpAdviserBookVO:
:
getChannelId
).
distinct
().
collect
(
Collectors
.
toList
());
...
...
@@ -2423,7 +2530,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
if
(
CollUtil
.
isEmpty
(
bookServesListDTOS
))
return
new
BookServeInfo
();
Long
maxId
=
bookServesListDTOS
.
stream
().
filter
(
Objects:
:
nonNull
).
map
(
BookServesListDTO:
:
getBookAdviserId
).
max
(
Long:
:
compareTo
).
orElse
(
0L
);
String
key
=
UUID
.
randomUUID
().
toString
();
JedisClusterUtils
.
set
(
key
,
String
.
valueOf
(
maxId
)
,
2
*
60
*
60
);
JedisClusterUtils
.
set
(
key
,
String
.
valueOf
(
maxId
));
BookServeInfo
bookServeInfo
=
new
BookServeInfo
();
bookServeInfo
.
setCursor
(
key
);
...
...
@@ -2584,4 +2691,72 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
return
list
;
}
@Override
@ParamLog
(
"根据agentId获取书籍id"
)
public
void
getBookIdsByAgentId
(
Long
agentId
)
{
if
(
null
==
agentId
)
{
return
;
}
List
<
Long
>
adviserIds
=
adviserConsr
.
getByAgentId
(
agentId
);
if
(
ListUtils
.
isEmpty
(
adviserIds
))
{
return
;
}
String
key
=
CacheConstant
.
BOOK
+
"BOOKIDS4AGENT:"
+
agentId
;
//为空的话从数据库查询并缓存5分钟
if
(
StringUtil
.
isEmpty
(
JedisClusterUtils
.
get
(
key
)))
{
List
<
ERPPublishNumDTO
>
erpPublishNumQueryParams
=
bookAdviserDao
.
getErpPublishNumQueryParams
(
adviserIds
);
if
(
ListUtils
.
isEmpty
(
erpPublishNumQueryParams
))
{
return
;
}
Integer
expireTime
=
60
*
5
;
JedisClusterUtils
.
setJsonList
(
key
,
erpPublishNumQueryParams
,
expireTime
);
}
}
@Override
public
List
<
Long
>
getBooksByAgentToken
(
Long
agentId
,
int
index
)
{
if
(
null
==
agentId
)
{
return
new
ArrayList
<>();
}
List
<
Long
>
result
=
new
ArrayList
<>();
String
key
=
CacheConstant
.
BOOK
+
"BOOKIDS4AGENT:"
+
agentId
;
if
(
StringUtil
.
isEmpty
(
JedisClusterUtils
.
get
(
key
)))
{
List
<
Long
>
adviserIds
=
adviserConsr
.
getByAgentId
(
agentId
);
List
<
ERPPublishNumDTO
>
erpPublishNumQueryParams
=
bookAdviserDao
.
getErpPublishNumQueryParams
(
adviserIds
);
if
(
ListUtils
.
isEmpty
(
erpPublishNumQueryParams
))
{
return
new
ArrayList
<>();
}
Integer
expireTime
=
60
*
5
;
JedisClusterUtils
.
setJsonList
(
key
,
erpPublishNumQueryParams
,
expireTime
);
}
else
{
List
<
ERPPublishNumDTO
>
bookList
=
JedisClusterUtils
.
getJsonList
(
key
,
ERPPublishNumDTO
.
class
);
List
<
ERPPublishNumDTO
>
booksByIndex
=
getBooksByIndex
(
index
,
bookList
);
for
(
ERPPublishNumDTO
erpPublishNumDTO
:
booksByIndex
)
{
result
.
add
(
erpPublishNumDTO
.
getBookId
());
}
}
return
result
;
}
private
static
List
<
ERPPublishNumDTO
>
getBooksByIndex
(
int
index
,
List
<
ERPPublishNumDTO
>
source
){
if
(
source
==
null
){
return
new
ArrayList
<>();
}
List
<
ERPPublishNumDTO
>
result
=
new
ArrayList
<>();
if
((
index
-
1
)*
500
>
source
.
size
()){
return
result
;
}
else
{
for
(
int
i
=
index
*
500
;
i
<(
index
+
1
)*
500
;
i
++){
if
(
source
.
size
()>=
i
)
{
result
.
add
(
source
.
get
(
i
));
}
else
{
break
;
}
}
}
return
result
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/book/vo/QrCodeVO.java
View file @
bca0f885
package
com
.
pcloud
.
book
.
book
.
vo
;
import
java.math.BigDecimal
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -27,4 +29,7 @@ public class QrCodeVO {
@ApiModelProperty
(
"公众号码id"
)
private
Long
sceneId
;
@ApiModelProperty
(
"销售额"
)
private
BigDecimal
saleMoney
;
}
pcloud-service-book/src/main/java/com/pcloud/book/consumer/trade/TradeConsr.java
View file @
bca0f885
...
...
@@ -278,4 +278,38 @@ public class TradeConsr {
}
return
new
ArrayList
<>();
}
/**
* 获取rays码销售额
* @param bookGroupIds
* @return
*/
public
Map
<
Long
,
BigDecimal
>
getGroupListSaleInfo
(
List
<
Long
>
bookGroupIds
)
{
if
(
CollUtil
.
isEmpty
(
bookGroupIds
))
{
return
new
HashMap
<>();
}
try
{
return
ResponseHandleUtil
.
parseMap
(
orderFormService
.
getGroupListSaleInfo
(
bookGroupIds
),
Long
.
class
,
BigDecimal
.
class
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"查询rays码销售额失败.[getGroupListSaleInfo]:{}"
,
e
.
getMessage
(),
e
);
}
return
new
HashMap
<>();
}
/**
* 获取二维码销售额
* @param sceneIds
* @return
*/
public
Map
<
Long
,
BigDecimal
>
getSceneListSaleInfo
(
List
<
Long
>
sceneIds
)
{
if
(
CollUtil
.
isEmpty
(
sceneIds
))
{
return
new
HashMap
<>();
}
try
{
return
ResponseHandleUtil
.
parseMap
(
orderFormService
.
getSceneListSaleInfo
(
sceneIds
),
Long
.
class
,
BigDecimal
.
class
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"查询二维码销售额失败.[getSceneListSaleInfo]:{}"
,
e
.
getMessage
(),
e
);
}
return
new
HashMap
<>();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment