Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-data-cloud
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
base_platform_enterprise
gic-data-cloud
Commits
ea3d86f2
Commit
ea3d86f2
authored
Aug 04, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
观云台小程序
parent
00b4adfb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
28 deletions
+96
-28
BaseSalesController.java
...ava/com/gic/cloud/web/controller/BaseSalesController.java
+26
-3
StoreSearchUtils.java
...n/java/com/gic/cloud/web/controller/StoreSearchUtils.java
+70
-25
No files found.
gic-data-cloud-wxapp/src/main/java/com/gic/cloud/web/controller/BaseSalesController.java
View file @
ea3d86f2
...
...
@@ -47,8 +47,16 @@ public class BaseSalesController {
List
<
String
>
onLine
=
this
.
storeSearchUtils
.
onLineStoreSearch
(
userId
,
enterpriseId
,
searchJSON
);
List
<
Integer
>
childrenStoreGroupIdList
=
this
.
storeSearchUtils
.
getChildrenStoreGroupIdList
(
parentId
);
List
<
Long
>
mbrAreaIdList
=
this
.
dataAuthUtils
.
getMbrAreaId
(
userId
,
enterpriseId
);
Integer
maxLevel
=
0
;
/******线下渠道需要点击下钻,该值只会在线下时才会使用********/
if
(
level
==
null
){
level
=
this
.
storeSearchUtils
.
getLevel
(
userId
,
enterpriseId
,
searchJSON
).
getLevel
();
LevelVo
levelVo
=
this
.
storeSearchUtils
.
getLevel
(
userId
,
enterpriseId
,
searchJSON
);
level
=
levelVo
.
getLevel
();
maxLevel
=
levelVo
.
getMaxLevel
();
}
/****首页进入基础页面时,如果渠道为空,根据当前条件判断渠道,channel==null表示多渠道***/
if
(
channel
==
null
){
channel
=
this
.
storeSearchUtils
.
getChannel
(
userId
,
enterpriseId
,
searchJSON
);
}
BaseSalesParamsDTO
dto
=
new
BaseSalesParamsDTO
();
dto
.
setChannel
(
channel
);
...
...
@@ -67,7 +75,7 @@ public class BaseSalesController {
dto
.
setPageSize
(
pageSize
);
ServiceResponse
<
Page
<
BaseSalesDTO
>>
response
=
this
.
baseSalesApiService
.
pageBaseSales
(
dto
);
BaseSalesVo
vo
=
new
BaseSalesVo
();
vo
.
setPage
(
this
.
parseData
(
response
.
getResult
(),
channel
,
enterpriseId
,
level
));
vo
.
setPage
(
this
.
parseData
(
response
.
getResult
(),
channel
,
enterpriseId
,
level
,
maxLevel
));
dto
.
setCountType
(
2
);
//合计
ServiceResponse
<
Page
<
BaseSalesDTO
>>
response1
=
this
.
baseSalesApiService
.
pageBaseSales
(
dto
);
if
(
response1
.
isSuccess
()
&&
response1
.
getResult
()
!=
null
&&
CollectionUtils
.
isNotEmpty
(
response1
.
getResult
().
getResult
())){
...
...
@@ -93,21 +101,30 @@ public class BaseSalesController {
return
RestResponse
.
success
(
vo
);
}
public
Page
<
BaseSalesDTO
>
parseData
(
Page
<
BaseSalesDTO
>
page
,
Integer
channel
,
Integer
enterpriseId
,
Integer
level
){
public
Page
<
BaseSalesDTO
>
parseData
(
Page
<
BaseSalesDTO
>
page
,
Integer
channel
,
Integer
enterpriseId
,
Integer
level
,
Integer
maxLevel
){
if
(
page
!=
null
&&
CollectionUtils
.
isNotEmpty
(
page
.
getResult
())){
if
(
channel
==
null
){
//全渠道
page
.
getResult
().
stream
().
forEach
(
baseSalesDTO
->
{
baseSalesDTO
.
setLevel
(
level
-
1
);
if
(
StoreChannelEnum
.
OFFLINE
.
getChannel
()
==
Integer
.
valueOf
(
baseSalesDTO
.
getId
())){
baseSalesDTO
.
setName
(
StoreChannelEnum
.
OFFLINE
.
getMessage
());
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
OFFLINE
.
getChannel
());
baseSalesDTO
.
setHasChildren
(
1
);
}
if
(
StoreChannelEnum
.
GICMALL
.
getChannel
()
==
Integer
.
valueOf
(
baseSalesDTO
.
getId
())){
baseSalesDTO
.
setName
(
StoreChannelEnum
.
GICMALL
.
getMessage
());
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
GICMALL
.
getChannel
());
baseSalesDTO
.
setHasChildren
(
1
);
}
if
(
StoreChannelEnum
.
WMMALL
.
getChannel
()
==
Integer
.
valueOf
(
baseSalesDTO
.
getId
())){
baseSalesDTO
.
setName
(
StoreChannelEnum
.
WMMALL
.
getMessage
());
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
WMMALL
.
getChannel
());
baseSalesDTO
.
setHasChildren
(
1
);
}
if
(
StoreChannelEnum
.
TIANMAO
.
getChannel
()
==
Integer
.
valueOf
(
baseSalesDTO
.
getId
())){
baseSalesDTO
.
setName
(
StoreChannelEnum
.
TIANMAO
.
getMessage
());
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
TIANMAO
.
getChannel
());
baseSalesDTO
.
setHasChildren
(
1
);
}
});
}
...
...
@@ -115,9 +132,11 @@ public class BaseSalesController {
List
<
ShopDTO
>
result
=
shopApiService
.
getAllShopByEnterpriseIdAndName
(
enterpriseId
,
null
,
ShopTypeEnum
.
MALL_SHOP
.
getCode
()).
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
result
)){
page
.
getResult
().
stream
().
forEach
(
baseSalesDTO
->
{
baseSalesDTO
.
setLevel
(
level
-
1
);
for
(
ShopDTO
shopDTO
:
result
){
if
(
baseSalesDTO
.
getId
().
equals
(
shopDTO
.
getId
())){
baseSalesDTO
.
setName
(
shopDTO
.
getName
());
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
OFFLINE
.
getChannel
());
}
}
});
...
...
@@ -127,9 +146,11 @@ public class BaseSalesController {
List
<
WmStoreDTO
>
result1
=
wmStoreApiService
.
listWmStore
(
enterpriseId
,
null
).
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
result1
)){
page
.
getResult
().
stream
().
forEach
(
baseSalesDTO
->
{
baseSalesDTO
.
setLevel
(
level
-
1
);
for
(
WmStoreDTO
dto
:
result1
){
if
(
baseSalesDTO
.
getId
().
equals
(
dto
.
getWmMallStoreId
()+
""
)){
baseSalesDTO
.
setName
(
dto
.
getWmMainAccount
());
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
OFFLINE
.
getChannel
());
}
}
});
...
...
@@ -138,6 +159,8 @@ public class BaseSalesController {
if
(
channel
==
StoreChannelEnum
.
OFFLINE
.
getChannel
()){
page
.
getResult
().
stream
().
forEach
(
baseSalesDTO
->
{
baseSalesDTO
.
setLevel
(
level
);
baseSalesDTO
.
setChannel
(
StoreChannelEnum
.
OFFLINE
.
getChannel
());
baseSalesDTO
.
setHasChildren
(
level
<
maxLevel
?
1
:
0
);
});
}
}
...
...
gic-data-cloud-wxapp/src/main/java/com/gic/cloud/web/controller/StoreSearchUtils.java
View file @
ea3d86f2
...
...
@@ -15,6 +15,7 @@ import com.gic.cloud.web.auth.StoreAuth;
import
com.gic.cloud.web.constant.StoreChannelEnum
;
import
com.gic.cloud.web.qo.StoreSearchQo
;
import
com.gic.cloud.web.vo.LevelVo
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.store.dto.StoreDTO
;
import
com.gic.store.dto.StoreGroupDTO
;
import
com.gic.store.dto.StoreSearchDTO
;
...
...
@@ -32,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
@Component
...
...
@@ -51,17 +53,19 @@ public class StoreSearchUtils {
private
StoreGroupApiService
storeGroupApiService
;
public
List
<
Integer
>
storeSearch
(
Integer
userId
,
Integer
enterpriseId
,
String
searchJson
){
String
key
=
"1:"
+
enterpriseId
+
":"
+
userId
+
":"
+
(
StringUtils
.
isNotBlank
(
searchJson
)
?
searchJson
.
hashCode
()
:
"searchJSON"
.
hashCode
());
StoreAuth
storeAuth
=
this
.
dataAuthUtils
.
getStoreAuth
(
userId
,
enterpriseId
);
if
(!
storeAuth
.
isHasAuth
()){
ArrayList
<
Integer
>
list
=
new
ArrayList
<>();
list
.
add
(
0
);
return
list
;
}
List
<
Integer
>
resultList
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
searchJson
)){
JSONObject
json
=
JSON
.
parseObject
(
searchJson
);
StoreSearchQo
storeSearchQo
=
json
.
getObject
(
StoreChannelEnum
.
OFFLINE
.
getChannel
().
toString
(),
StoreSearchQo
.
class
);
if
(
storeSearchQo
.
getAll
()
==
1
){
re
turn
storeAuth
.
getStoreInfoIdList
();
re
sultList
=
storeAuth
.
getStoreInfoIdList
();
}
else
{
StoreSearchDTO
storeSearchDTO
=
new
StoreSearchDTO
();
storeSearchDTO
.
setEnterpriseId
(
enterpriseId
);
...
...
@@ -91,30 +95,35 @@ public class StoreSearchUtils {
List
<
StoreDTO
>
storeDTOList
=
pageServiceResponse
.
getResult
().
getResult
();
List
<
Integer
>
storeInfoIdList
=
storeDTOList
.
stream
().
map
(
storeDTO
->
storeDTO
.
getStoreInfoId
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
storeAuth
.
getStoreInfoIdList
())){
re
turn
storeInfoIdList
.
stream
().
filter
(
s
->
{
for
(
Integer
storeInfoId
:
storeAuth
.
getStoreInfoIdList
())
{
if
(
s
.
intValue
()
==
storeInfoId
.
intValue
())
{
re
sultList
=
storeInfoIdList
.
stream
().
filter
(
s
->
{
for
(
Integer
storeInfoId
:
storeAuth
.
getStoreInfoIdList
())
{
if
(
s
.
intValue
()
==
storeInfoId
.
intValue
())
{
return
true
;
}
}
return
false
;
}).
collect
(
Collectors
.
toList
());
}
else
{
return
storeInfoIdList
;
}
}
}
}
else
{
resultList
=
storeAuth
.
getStoreInfoIdList
();
}
if
(
CollectionUtils
.
isNotEmpty
(
resultList
)){
RedisUtil
.
setCache
(
key
,
1
,
10
l
,
TimeUnit
.
MINUTES
);
}
else
{
resultList
.
add
(
0
);
}
return
storeAuth
.
getStoreInfoIdList
()
;
return
resultList
;
}
public
List
<
String
>
onLineStoreSearch
(
Integer
userId
,
Integer
enterpriseId
,
String
searchJson
){
OnLineAuth
onlineStoreAuth
=
this
.
dataAuthUtils
.
getOnlineStore
(
userId
,
enterpriseId
);
List
<
String
>
list
=
new
ArrayList
<>();
if
(
onlineStoreAuth
.
isHasAuth
()){
this
.
getOnlineStoreIds
(
searchJson
,
onlineStoreAuth
,
list
,
StoreChannelEnum
.
GICMALL
.
getChannel
());
this
.
getOnlineStoreIds
(
searchJson
,
onlineStoreAuth
,
list
,
StoreChannelEnum
.
WMMALL
.
getChannel
());
this
.
getOnlineStoreIds
(
searchJson
,
onlineStoreAuth
,
list
,
StoreChannelEnum
.
TIANMAO
.
getChannel
());
this
.
getOnlineStoreIds
(
searchJson
,
onlineStoreAuth
,
list
,
StoreChannelEnum
.
GICMALL
.
getChannel
()
,
userId
,
enterpriseId
);
this
.
getOnlineStoreIds
(
searchJson
,
onlineStoreAuth
,
list
,
StoreChannelEnum
.
WMMALL
.
getChannel
()
,
userId
,
enterpriseId
);
this
.
getOnlineStoreIds
(
searchJson
,
onlineStoreAuth
,
list
,
StoreChannelEnum
.
TIANMAO
.
getChannel
()
,
userId
,
enterpriseId
);
}
else
{
list
.
add
(
"noauth"
);
}
...
...
@@ -147,17 +156,47 @@ public class StoreSearchUtils {
}
});
int
start
=
0
;
while
(
true
){
if
(
levelMap
.
get
(
start
)
!=
null
&&
levelMap
.
get
(
start
).
intValue
()
>
1
){
vo
.
setLevel
(
start
);
break
;
if
(!
levelMap
.
isEmpty
()){
while
(
true
){
if
(
levelMap
.
get
(
start
)
!=
null
&&
levelMap
.
get
(
start
).
intValue
()
>
1
){
vo
.
setLevel
(
start
);
break
;
}
start
++;
}
start
++
;
vo
.
setMaxLevel
(
levelMap
.
size
()
-
1
)
;
}
vo
.
setMaxLevel
(
levelMap
.
size
()
-
1
);
return
vo
;
}
public
Integer
getChannel
(
Integer
userId
,
Integer
enterpriseId
,
String
searchJson
){
String
offlineKey
=
"1:"
+
enterpriseId
+
":"
+
userId
+
":"
+
(
StringUtils
.
isNotBlank
(
searchJson
)
?
searchJson
.
hashCode
()
:
"searchJSON"
.
hashCode
());
String
gicMallKey
=
"2:"
+
enterpriseId
+
":"
+
userId
+
":"
+
(
StringUtils
.
isNotBlank
(
searchJson
)
?
searchJson
.
hashCode
()
:
"searchJSON"
.
hashCode
());
String
wmKey
=
"3:"
+
enterpriseId
+
":"
+
userId
+
":"
+
(
StringUtils
.
isNotBlank
(
searchJson
)
?
searchJson
.
hashCode
()
:
"searchJSON"
.
hashCode
());
String
tmKey
=
"4:"
+
enterpriseId
+
":"
+
userId
+
":"
+
(
StringUtils
.
isNotBlank
(
searchJson
)
?
searchJson
.
hashCode
()
:
"searchJSON"
.
hashCode
());
int
offline
=
RedisUtil
.
getCache
(
offlineKey
)
==
null
?
0
:
1
;
int
gicMall
=
RedisUtil
.
getCache
(
gicMallKey
)
==
null
?
0
:
1
;
int
wm
=
RedisUtil
.
getCache
(
wmKey
)
==
null
?
0
:
1
;
int
tm
=
RedisUtil
.
getCache
(
tmKey
)
==
null
?
0
:
1
;
if
((
offline
+
gicMall
+
wm
+
tm
)
>
1
){
//多渠道
return
null
;
}
else
if
((
offline
+
gicMall
+
wm
+
tm
)
==
1
){
if
(
offline
==
1
){
return
offline
;
}
if
(
gicMall
==
1
){
return
gicMall
;
}
if
(
wm
==
1
){
return
wm
;
}
if
(
tm
==
1
){
return
tm
;
}
}
return
null
;
}
public
List
<
Integer
>
getChildrenStoreGroupIdList
(
Integer
storeGroupId
){
if
(
storeGroupId
!=
null
){
List
<
StoreGroupDTO
>
result
=
this
.
storeGroupApiService
.
listStoreGroupAndChildren
(
storeGroupId
).
getResult
();
...
...
@@ -168,24 +207,30 @@ public class StoreSearchUtils {
return
new
ArrayList
<>();
}
private
void
getOnlineStoreIds
(
String
searchJson
,
OnLineAuth
onlineStoreAuth
,
List
<
String
>
list
,
Integer
channel
){
private
void
getOnlineStoreIds
(
String
searchJson
,
OnLineAuth
onlineStoreAuth
,
List
<
String
>
list
,
Integer
channel
,
Integer
userId
,
Integer
enterpriseId
){
String
key
=
channel
+
":"
+
enterpriseId
+
":"
+
userId
+
":"
+
(
StringUtils
.
isNotBlank
(
searchJson
)
?
searchJson
.
hashCode
()
:
"searchJSON"
.
hashCode
());
if
(
StringUtils
.
isNotBlank
(
searchJson
)){
StoreSearchQo
searchQo
=
JSON
.
parseObject
(
searchJson
).
getObject
(
channel
.
toString
(),
StoreSearchQo
.
class
);
log
.
info
(
"getOnlineStoreIds:{},{}"
,
searchJson
,
JSON
.
toJSONString
(
searchQo
));
if
(
searchQo
!=
null
){
if
(
searchQo
.
getAll
()
==
1
){
onlineStoreAuth
.
getList
().
stream
().
filter
(
s
->
{
if
(
s
.
getChannel
()
==
channel
){
list
.
addAll
(
s
.
getStoreIdList
());
}
return
false
;
});
}
else
{
if
(
searchQo
.
getAll
()
!=
1
){
if
(
StringUtils
.
isNotBlank
(
searchQo
.
getStoreGroupIds
())){
RedisUtil
.
setCache
(
key
,
1
,
10
l
,
TimeUnit
.
MINUTES
);
list
.
addAll
(
Arrays
.
asList
(
searchQo
.
getStoreGroupIds
().
split
(
","
)));
}
}
}
}
else
{
onlineStoreAuth
.
getList
().
stream
().
forEach
(
s
->
{
System
.
out
.
println
(
JSON
.
toJSONString
(
s
));
if
(
s
.
getChannel
().
intValue
()
==
channel
.
intValue
()){
if
(
CollectionUtils
.
isNotEmpty
(
s
.
getStoreIdList
())){
RedisUtil
.
setCache
(
key
,
1
,
10
l
,
TimeUnit
.
MINUTES
);
list
.
addAll
(
s
.
getStoreIdList
());
}
}
});
}
}
}
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