Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
5e13c07c
Commit
5e13c07c
authored
Apr 03, 2023
by
songyinghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 销售线索消息通知逻辑
parent
1f61fb82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
47 deletions
+72
-47
PotentialCustomerNotifyContext.java
...jo/bo/content/context/PotentialCustomerNotifyContext.java
+15
-2
PotentialCustomerNotifyBuilder.java
...rvice/content/adaptor/PotentialCustomerNotifyBuilder.java
+55
-44
PotentialCustomerServiceImpl.java
...ce/service/content/impl/PotentialCustomerServiceImpl.java
+1
-0
InteractRecordTest.java
haoban-manage3-service/src/test/java/InteractRecordTest.java
+1
-1
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/pojo/bo/content/context/PotentialCustomerNotifyContext.java
View file @
5e13c07c
package
com
.
gic
.
haoban
.
manage
.
service
.
pojo
.
bo
.
content
.
context
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.haoban.manage.api.dto.StaffClerkRelationDTO
;
import
com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO
;
...
...
@@ -61,9 +62,10 @@ public class PotentialCustomerNotifyContext {
/**
* 构建小程序消息通知
*
* @return
*/
public
List
<
NoticeMessageBO
>
buildNoticeMessage
()
{
public
List
<
NoticeMessageBO
>
build
HaoBan
NoticeMessage
()
{
if
(
CollectionUtils
.
isEmpty
(
this
.
customerStaticsBos
))
{
return
Collections
.
emptyList
();
}
...
...
@@ -88,9 +90,20 @@ public class PotentialCustomerNotifyContext {
noticeMessageBO
.
setDescription
(
String
.
format
(
"新增%s个客户的销售线索,请及时跟进"
,
customerStaticsMap
.
get
(
item
.
getClerkId
())));
noticeMessageBO
.
setEnterpriseId
(
this
.
enterpriseId
);
noticeMessageBO
.
setRelationId
(
item
.
getClerkId
());
noticeMessageBO
.
setMessageContent
(
""
);
noticeMessageBO
.
setMessageContent
(
this
.
buildExtendParams
(
item
.
getStoreId
())
);
return
noticeMessageBO
;
})
.
collect
(
Collectors
.
toList
());
}
/**
* 构建跳转参数
* @param storeId
* @return
*/
public
String
buildExtendParams
(
String
storeId
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"storeId"
,
storeId
);
return
jsonObject
.
toJSONString
();
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/adaptor/PotentialCustomerNotifyBuilder.java
View file @
5e13c07c
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
content
.
adaptor
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.haoban.manage.api.dto.StaffClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO
;
...
...
@@ -30,6 +31,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -110,7 +112,7 @@ public class PotentialCustomerNotifyBuilder {
* @param context
*/
public
void
sendHaoBanNotifyMessage
(
PotentialCustomerNotifyContext
context
)
{
List
<
NoticeMessageBO
>
noticeMessageBos
=
context
.
buildNoticeMessage
();
List
<
NoticeMessageBO
>
noticeMessageBos
=
context
.
build
HaoBan
NoticeMessage
();
if
(
CollectionUtils
.
isEmpty
(
noticeMessageBos
))
{
log
.
info
(
"好办消息为空"
);
return
;
...
...
@@ -120,66 +122,75 @@ public class PotentialCustomerNotifyBuilder {
/**
* 发送应用消息
* 批次中存在导购主门店数据的话 推送主门店数据
* 不存在主门店数据的话 随机推送一个有数据的门店
*
* @param context
*/
public
void
sendApplicationMessage
(
PotentialCustomerNotifyContext
context
)
{
if
(
CollectionUtils
.
isEmpty
(
context
.
getCustomerStaticsBos
())
||
CollectionUtils
.
isEmpty
(
context
.
getStaffClerkRelations
())
)
{
log
.
info
(
"发送应用消息
参数缺失 {}
"
);
if
(
CollectionUtils
.
isEmpty
(
context
.
getCustomerStaticsBos
()))
{
log
.
info
(
"发送应用消息
不存在导购纬度的统计
"
);
return
;
}
if
(
CollectionUtils
.
isEmpty
(
context
.
getStaffClerkRelations
()))
{
log
.
info
(
"发送应用消息 不存在导购绑定关系 clerkIds: {}"
,
JSON
.
toJSONString
(
context
.
getClerkIds
()));
return
;
}
Map
<
String
,
WxEnterpriseQwDTO
>
clerkEnterpriseCacheMap
=
new
HashMap
<>();
Map
<
String
,
PotentialCustomerStaticsBO
>
customerStaticsBOMap
=
context
.
getCustomerStaticsBos
()
.
stream
()
.
collect
(
Collectors
.
toMap
(
PotentialCustomerStaticsBO:
:
getClerkId
,
Function
.
identity
(),
(
v1
,
v2
)
->
v1
));
Map
<
String
,
TabHaobanClerkMainStoreRelated
>
clerkMainStoreMap
=
new
HashMap
<>();
Map
<
String
,
WxEnterpriseQwDTO
>
clerkEnterpriseMap
=
new
HashMap
<>();
for
(
StaffClerkRelationDTO
staffClerkRelation
:
context
.
getStaffClerkRelations
())
{
PotentialCustomerStaticsBO
customerStaticsBO
=
customerStaticsBOMap
.
get
(
staffClerkRelation
.
getClerkId
());
if
(
customerStaticsBO
==
null
||
customerStaticsBO
.
getNum
()
==
null
||
customerStaticsBO
.
getNum
()
==
0
)
{
log
.
info
(
"导购不存在新访问"
);
// 按staffId 聚合
Map
<
String
,
List
<
StaffClerkRelationDTO
>>
staffRelationMap
=
context
.
getStaffClerkRelations
()
.
stream
()
.
filter
(
item
->
{
PotentialCustomerStaticsBO
staticsBO
=
customerStaticsBOMap
.
get
(
item
.
getClerkId
());
return
staticsBO
!=
null
&&
staticsBO
.
getNum
()
!=
null
&&
staticsBO
.
getNum
()
>
0
;
})
.
collect
(
Collectors
.
groupingBy
(
StaffClerkRelationDTO:
:
getStaffId
));
for
(
Map
.
Entry
<
String
,
List
<
StaffClerkRelationDTO
>>
entry
:
staffRelationMap
.
entrySet
())
{
if
(
CollectionUtils
.
isEmpty
(
entry
.
getValue
()))
{
log
.
info
(
"成员不存在有数值的绑定关系 staffIf:{}"
,
entry
.
getKey
());
continue
;
}
String
staffId
=
staffClerkRelation
.
getStaffId
();
TabHaobanClerkMainStoreRelated
temp
=
clerkMainStoreMap
.
get
(
staffId
);
if
(
temp
==
null
)
{
TabHaobanClerkMainStoreRelated
tabHaobanClerkMainStoreRelated
=
clerkMainStoreRelatedService
.
selectByWxEnterpriseIdAndStoreId
(
staffId
,
staffClerkRelation
.
getWxEnterpriseId
());
if
(
tabHaobanClerkMainStoreRelated
==
null
)
{
tabHaobanClerkMainStoreRelated
=
new
TabHaobanClerkMainStoreRelated
();
}
clerkMainStoreMap
.
put
(
staffId
,
tabHaobanClerkMainStoreRelated
);
temp
=
clerkMainStoreMap
.
get
(
staffId
);
String
staffId
=
entry
.
getKey
();
String
wxEnterpriseId
=
entry
.
getValue
().
get
(
0
).
getWxEnterpriseId
();
TabHaobanClerkMainStoreRelated
tabHaobanClerkMainStoreRelated
=
clerkMainStoreRelatedService
.
selectByWxEnterpriseIdAndStoreId
(
staffId
,
wxEnterpriseId
);
if
(
tabHaobanClerkMainStoreRelated
==
null
)
{
log
.
info
(
"成员无主门店信息,不做处理 {}"
,
staffId
);
continue
;
}
if
(
temp
!=
null
)
{
if
(
StringUtils
.
isBlank
(
temp
.
getStoreId
()))
{
// 该成员无主门店
log
.
info
(
"成员无主门店 {}"
,
staffId
);
continue
;
}
if
(
StringUtils
.
isBlank
(
temp
.
getStoreId
()))
{
log
.
info
(
"成员不存在主门店 {}"
,
staffId
);
continue
;
}
// 需要发送应用消息
WxEnterpriseQwDTO
wxEnterpriseQwDTO
=
clerkEnterpriseMap
.
get
(
staffClerkRelation
.
getWxEnterpriseId
());
if
(
wxEnterpriseQwDTO
==
null
)
{
wxEnterpriseQwDTO
=
wxEnterpriseService
.
getQwInfo
(
staffClerkRelation
.
getWxEnterpriseId
());
clerkEnterpriseMap
.
put
(
staffClerkRelation
.
getWxEnterpriseId
(),
wxEnterpriseQwDTO
);
}
wxEnterpriseQwDTO
=
clerkEnterpriseMap
.
get
(
staffClerkRelation
.
getWxEnterpriseId
());
if
(
wxEnterpriseQwDTO
==
null
)
{
log
.
info
(
"企业信息不存在 {}"
,
staffClerkRelation
.
getWxEnterpriseId
());
return
;
}
QywxXcxSendMessageDTO
messageDTO
=
this
.
buildApplicationMessage
(
staffClerkRelation
,
wxEnterpriseQwDTO
,
customerStaticsBO
.
getNum
());
boolean
sendMessage
=
qywxSuiteApiService
.
sendMessage
(
wxEnterpriseQwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
messageDTO
);
log
.
info
(
"发送应用消息结果 {}"
,
sendMessage
);
Optional
<
StaffClerkRelationDTO
>
mainStoreClerkRelation
=
entry
.
getValue
()
.
stream
()
.
filter
(
item
->
StringUtils
.
equals
(
item
.
getStoreId
(),
tabHaobanClerkMainStoreRelated
.
getStoreId
()))
.
findFirst
();
StaffClerkRelationDTO
staffClerkRelation
=
entry
.
getValue
().
get
(
0
);
if
(
mainStoreClerkRelation
.
isPresent
())
{
staffClerkRelation
=
mainStoreClerkRelation
.
get
();
}
log
.
info
(
"发送应用消息的导购绑定关系 {}"
,
JSON
.
toJSONString
(
staffClerkRelation
));
// 需要发送应用消息
WxEnterpriseQwDTO
wxEnterpriseQwDTO
=
clerkEnterpriseCacheMap
.
get
(
staffClerkRelation
.
getWxEnterpriseId
());
if
(
wxEnterpriseQwDTO
==
null
)
{
wxEnterpriseQwDTO
=
wxEnterpriseService
.
getQwInfo
(
staffClerkRelation
.
getWxEnterpriseId
());
clerkEnterpriseCacheMap
.
put
(
staffClerkRelation
.
getWxEnterpriseId
(),
wxEnterpriseQwDTO
);
}
wxEnterpriseQwDTO
=
clerkEnterpriseCacheMap
.
get
(
staffClerkRelation
.
getWxEnterpriseId
());
if
(
wxEnterpriseQwDTO
==
null
)
{
log
.
info
(
"企业信息不存在 {}"
,
staffClerkRelation
.
getWxEnterpriseId
());
continue
;
}
QywxXcxSendMessageDTO
messageDTO
=
this
.
buildApplicationMessage
(
staffClerkRelation
,
wxEnterpriseQwDTO
,
customerStaticsBOMap
.
get
(
staffClerkRelation
.
getClerkId
()).
getNum
(),
context
.
buildExtendParams
(
staffClerkRelation
.
getStoreId
()));
boolean
sendMessage
=
qywxSuiteApiService
.
sendMessage
(
wxEnterpriseQwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
messageDTO
);
log
.
info
(
"发送销售线索应用消息结果 {}"
,
sendMessage
);
}
}
public
QywxXcxSendMessageDTO
buildApplicationMessage
(
StaffClerkRelationDTO
staffClerkRelation
,
WxEnterpriseQwDTO
wxEnterpriseQwDTO
,
int
count
)
{
public
QywxXcxSendMessageDTO
buildApplicationMessage
(
StaffClerkRelationDTO
staffClerkRelation
,
WxEnterpriseQwDTO
wxEnterpriseQwDTO
,
int
count
,
String
extendParams
)
{
StaffDTO
staffDTO
=
staffApiService
.
selectById
(
staffClerkRelation
.
getStaffId
());
String
wxUserId
=
staffDTO
.
getWxUserId
();
...
...
@@ -194,7 +205,7 @@ public class PotentialCustomerNotifyBuilder {
list
.
add
(
wxUserId
);
messageDTO
.
setAppid
(
config
.
getAppid
());
messageDTO
.
setUserIds
(
list
);
messageDTO
.
setPage
(
NoticeMessageUtil
.
buildMiniAppUrl
(
NoticeMessageTypeEnum
.
MATERIAL_REPORT_NOTIFY
,
""
));
messageDTO
.
setPage
(
NoticeMessageUtil
.
buildMiniAppUrl
(
NoticeMessageTypeEnum
.
MATERIAL_REPORT_NOTIFY
,
extendParams
));
messageDTO
.
setTitle
(
"销售线索通知"
);
messageDTO
.
setItems
(
Collections
.
singletonList
(
itemDTO
));
return
messageDTO
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/impl/PotentialCustomerServiceImpl.java
View file @
5e13c07c
...
...
@@ -227,6 +227,7 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
// 构建应用内消息
potentialCustomerNotifyBuilder
.
sendHaoBanNotifyMessage
(
context
);
// 如果该导购id是成员在主门店时的导购id 发送应用消息
// 如果本批数据中无成员主门店数据 则不发送
potentialCustomerNotifyBuilder
.
sendApplicationMessage
(
context
);
}
...
...
haoban-manage3-service/src/test/java/InteractRecordTest.java
View file @
5e13c07c
...
...
@@ -69,7 +69,7 @@ public class InteractRecordTest {
message
.
setMemberId
(
memberId
);
message
.
setUnionId
(
memberId
);
message
.
setStoreId
(
"ff8080818499a54801849ce85f9f003f"
);
message
.
setMaterialId
(
"123213
9123912
"
);
message
.
setMaterialId
(
"123213"
);
message
.
setChannelSource
(
TriggerCustomerChannelType
.
PYQ
.
getCode
());
message
.
setEventType
(
MaterialInteractRecordEventType
.
VISIT_PRODUCT
.
getCode
());
message
.
setGoodsId
(
"fbc508e395f846ef9005852c420e1c23"
);
...
...
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