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
1863fc31
Commit
1863fc31
authored
Mar 30, 2023
by
songyinghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 销售线索通知
parent
22f111f6
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
558 additions
and
14 deletions
+558
-14
NoticeMessageCategoryTypeEnum.java
...aoban/manage/api/enums/NoticeMessageCategoryTypeEnum.java
+1
-0
NoticeMessageTypeEnum.java
...om/gic/haoban/manage/api/enums/NoticeMessageTypeEnum.java
+2
-0
QywxGroupMsgTaskApiService.java
.../api/service/content/task/QywxGroupMsgTaskApiService.java
+7
-0
TabHaobanStaffClerkRelationMapper.java
...service/dao/mapper/TabHaobanStaffClerkRelationMapper.java
+2
-1
TabHaobanInteractRecordMapper.java
...ice/dao/mapper/content/TabHaobanInteractRecordMapper.java
+8
-0
PotentialCustomerStaticsBO.java
...e/service/pojo/bo/content/PotentialCustomerStaticsBO.java
+25
-0
PotentialCustomerNotifyContext.java
...jo/bo/content/context/PotentialCustomerNotifyContext.java
+110
-0
InteractRecordQO.java
...oban/manage/service/pojo/qo/content/InteractRecordQO.java
+8
-1
StaffClerkRelationService.java
...ban/manage/service/service/StaffClerkRelationService.java
+1
-1
InteractRecordService.java
...manage/service/service/content/InteractRecordService.java
+11
-0
PotentialCustomerService.java
...age/service/service/content/PotentialCustomerService.java
+7
-0
PotentialCustomerNotifyBuilder.java
...rvice/content/adaptor/PotentialCustomerNotifyBuilder.java
+194
-0
InteractRecordServiceImpl.java
...rvice/service/content/impl/InteractRecordServiceImpl.java
+12
-0
PotentialCustomerServiceImpl.java
...ce/service/content/impl/PotentialCustomerServiceImpl.java
+48
-1
InteractRecordMessageService.java
...service/content/message/InteractRecordMessageService.java
+0
-1
StaffClerkRelationServiceImpl.java
...e/service/service/impl/StaffClerkRelationServiceImpl.java
+2
-3
QywxGroupMsgTaskApiServiceImpl.java
...out/impl/content/task/QywxGroupMsgTaskApiServiceImpl.java
+72
-2
TabHaobanStaffClerkRelationMapper.xml
...in/resources/mapper/TabHaobanStaffClerkRelationMapper.xml
+5
-3
TabHaobanInteractRecordMapper.xml
...esources/mapper/content/TabHaobanInteractRecordMapper.xml
+23
-0
InteractRecordTest.java
haoban-manage3-service/src/test/java/InteractRecordTest.java
+14
-0
PotentialCustomerVO.java
.../manage/web/vo/content/potential/PotentialCustomerVO.java
+6
-1
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/enums/NoticeMessageCategoryTypeEnum.java
View file @
1863fc31
...
...
@@ -11,6 +11,7 @@ public enum NoticeMessageCategoryTypeEnum {
TASK
(
1
,
"任务相关"
),
ACTIVITY
(
2
,
"活动相关"
),
MATERIAL
(
4
,
"素材相关"
),
POTENTIAL_CUSTOMER
(
5
,
"销售线索"
),
OTHER
(
3
,
"其它"
),;
private
int
type
;
private
String
name
;
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/enums/NoticeMessageTypeEnum.java
View file @
1863fc31
...
...
@@ -61,6 +61,8 @@ public enum NoticeMessageTypeEnum {
MATERIAL_NEW_NOTIFY
(
6001
,
"素材上新通知"
,
NoticeMessageCategoryTypeEnum
.
MATERIAL
.
getType
(),
"material_new_notify"
,
"/pages/route/index?pageType="
,
"hbapp_material_center"
),
MATERIAL_WEEK_REPORT
(
6002
,
"素材周报通知"
,
NoticeMessageCategoryTypeEnum
.
MATERIAL
.
getType
(),
"material_week_notify"
,
"/pages/route/index?pageType="
,
"hbapp_material_report"
),
POTENTIAL_CUSTOMER_NOTIFY
(
6003
,
"销售线索通知"
,
NoticeMessageCategoryTypeEnum
.
POTENTIAL_CUSTOMER
.
getType
(),
"potential_customer_notify"
,
"/pages/route/index?pageType="
,
"hbapp_sales_clue_center"
);
;
/**
* 消息类型
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/content/task/QywxGroupMsgTaskApiService.java
View file @
1863fc31
...
...
@@ -52,4 +52,11 @@ public interface QywxGroupMsgTaskApiService {
* @return
*/
ServiceResponse
<
Void
>
doHandlerMaterialOneStaffReportMQ
(
String
params
);
/**
* 销售线索 通知job
* @param params
* @return
*/
ServiceResponse
<
Void
>
potentialCustomerJob
(
String
params
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/TabHaobanStaffClerkRelationMapper.java
View file @
1863fc31
...
...
@@ -120,5 +120,5 @@ public interface TabHaobanStaffClerkRelationMapper {
List
<
StaffClerkRelationDTO
>
listByStoreIds
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"storeIds"
)
List
<
String
>
storeIds
);
List
<
St
affClerkRelationDTO
>
listAllRelationDto
sByEnterpriseId
(
@Param
(
"enterpriseId"
)
String
enterpriseId
);
List
<
St
ring
>
listAllClerkId
sByEnterpriseId
(
@Param
(
"enterpriseId"
)
String
enterpriseId
);
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/content/TabHaobanInteractRecordMapper.java
View file @
1863fc31
...
...
@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.dao.mapper.content;
import
com.gic.haoban.manage.service.entity.content.TabHaobanInteractRecord
;
import
com.gic.haoban.manage.service.entity.content.TabHaobanPotentialCustomer
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO
;
import
com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -97,5 +98,12 @@ public interface TabHaobanInteractRecordMapper {
*/
List
<
TabHaobanInteractRecord
>
queryInteractRecordList
(
InteractRecordQO
interactRecordQO
);
/**
* 统计互动记录总数
* @param interactRecordQO
* @return
*/
List
<
PotentialCustomerStaticsBO
>
staticsClerkInteractRecordNew
(
InteractRecordQO
interactRecordQO
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/pojo/bo/content/PotentialCustomerStaticsBO.java
0 → 100644
View file @
1863fc31
package
com
.
gic
.
haoban
.
manage
.
service
.
pojo
.
bo
.
content
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Author MUSI
* @Date 2023/3/30 11:12 AM
* @Description
* @Version
**/
@Data
public
class
PotentialCustomerStaticsBO
implements
Serializable
{
/**
* 导购id
*/
private
String
clerkId
;
/**
* 数量
*/
private
Integer
num
;
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/pojo/bo/content/context/PotentialCustomerNotifyContext.java
0 → 100644
View file @
1863fc31
package
com
.
gic
.
haoban
.
manage
.
service
.
pojo
.
bo
.
content
.
context
;
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
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
static
com
.
gic
.
haoban
.
manage
.
api
.
enums
.
NoticeMessageTypeEnum
.
MATERIAL_WEEK_REPORT
;
import
static
com
.
gic
.
haoban
.
manage
.
api
.
enums
.
NoticeMessageTypeEnum
.
POTENTIAL_CUSTOMER_NOTIFY
;
/**
* @Author MUSI
* @Date 2023/3/30 10:55 AM
* @Description
* @Version
**/
@Slf4j
@Data
@Builder
public
class
PotentialCustomerNotifyContext
{
/**
* 开始时间
*/
private
Date
startTime
;
/**
* 结束时间
*/
private
Date
endTime
;
/**
* 企业id
*/
private
String
enterpriseId
;
/**
* 企业下的导购id
*/
private
List
<
String
>
clerkIds
;
/**
* 导购关联关系
*/
private
List
<
StaffClerkRelationDTO
>
staffClerkRelations
;
List
<
PotentialCustomerStaticsBO
>
customerStaticsBos
;
public
static
NoticeMessageBO
buildMessage
(
String
clerkId
,
int
count
)
{
NoticeMessageBO
noticeMessageBO
=
new
NoticeMessageBO
();
// noticeMessageBO.setCategoryType(POTENTIAL_CUSTOMER_NOTIFY.getCategory());
// noticeMessageBO.setMessageType(POTENTIAL_CUSTOMER_NOTIFY.getType());
// noticeMessageBO.setClerkId(clerkId);
// noticeMessageBO.setStoreId("");
// noticeMessageBO.setTitle("销售线索通知");
// noticeMessageBO.setTemplateCode(POTENTIAL_CUSTOMER_NOTIFY.getTemplateCode());
// noticeMessageBO.setDescription(String.format("新增%s个客户的销售线索,请及时跟进", count));
// noticeMessageBO.setEnterpriseId(this.enterpriseId);
// noticeMessageBO.setRelationId(this.clerkId);
// noticeMessageBO.setMessageContent();
return
noticeMessageBO
;
}
public
List
<
NoticeMessageBO
>
buildNoticeMessage
()
{
if
(
CollectionUtils
.
isEmpty
(
this
.
customerStaticsBos
))
{
return
Collections
.
emptyList
();
}
if
(
CollectionUtils
.
isEmpty
(
this
.
staffClerkRelations
))
{
return
Collections
.
emptyList
();
}
Map
<
String
,
Integer
>
customerStaticsMap
=
this
.
customerStaticsBos
.
stream
()
.
collect
(
Collectors
.
toMap
(
PotentialCustomerStaticsBO:
:
getClerkId
,
item
->
Optional
.
ofNullable
(
item
.
getNum
()).
orElse
(
0
),
(
v1
,
v2
)
->
v1
));
return
this
.
staffClerkRelations
.
stream
()
.
filter
(
item
->
customerStaticsMap
.
get
(
item
.
getClerkId
())
>
0
)
.
map
(
item
->
{
NoticeMessageBO
noticeMessageBO
=
new
NoticeMessageBO
();
noticeMessageBO
.
setCategoryType
(
POTENTIAL_CUSTOMER_NOTIFY
.
getCategory
());
noticeMessageBO
.
setMessageType
(
POTENTIAL_CUSTOMER_NOTIFY
.
getType
());
noticeMessageBO
.
setClerkId
(
item
.
getClerkId
());
noticeMessageBO
.
setStoreId
(
StringUtils
.
isNotBlank
(
item
.
getStoreId
())
?
item
.
getStoreId
()
:
"-1"
);
noticeMessageBO
.
setTitle
(
"销售线索通知"
);
noticeMessageBO
.
setTemplateCode
(
POTENTIAL_CUSTOMER_NOTIFY
.
getTemplateCode
());
noticeMessageBO
.
setDescription
(
String
.
format
(
"新增%s个客户的销售线索,请及时跟进"
,
customerStaticsMap
.
get
(
item
.
getClerkId
())));
noticeMessageBO
.
setEnterpriseId
(
this
.
enterpriseId
);
noticeMessageBO
.
setRelationId
(
item
.
getClerkId
());
noticeMessageBO
.
setMessageContent
(
""
);
return
noticeMessageBO
;
})
.
collect
(
Collectors
.
toList
());
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/pojo/qo/content/InteractRecordQO.java
View file @
1863fc31
...
...
@@ -14,6 +14,8 @@ import java.util.Date;
@Data
public
class
InteractRecordQO
extends
BasePageInfo
{
private
String
enterpriseId
;
/**
* 导购id
*/
...
...
@@ -30,8 +32,13 @@ public class InteractRecordQO extends BasePageInfo {
private
String
unionId
;
/**
* 开始时间
* 开始时间
-创建时间
*/
private
Date
startTime
;
/**
* 结束时间-创建时间
*/
private
Date
endTime
;
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/StaffClerkRelationService.java
View file @
1863fc31
...
...
@@ -176,5 +176,5 @@ public interface StaffClerkRelationService {
* @param enterpriseId
* @return
*/
List
<
St
affClerkRelationDTO
>
listAllRelationDto
sByEnterpriseId
(
String
enterpriseId
);
List
<
St
ring
>
listAllClerkId
sByEnterpriseId
(
String
enterpriseId
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/InteractRecordService.java
View file @
1863fc31
...
...
@@ -2,8 +2,11 @@ package com.gic.haoban.manage.service.service.content;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.manage.service.pojo.bo.content.InteractRecordBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO
;
import
com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO
;
import
java.util.List
;
/**
* 互动记录明细(TabHaobanInteractRecord)表服务接口
*
...
...
@@ -40,4 +43,12 @@ public interface InteractRecordService {
* @return
*/
Long
saveOrUpdateInteractRecord
(
InteractRecordBO
interactRecordBO
);
/**
* 统计导购的互动记录总数
* @param interactRecordQO
* @return
*/
List
<
PotentialCustomerStaticsBO
>
staticsClerkNewInteractRecord
(
InteractRecordQO
interactRecordQO
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/PotentialCustomerService.java
View file @
1863fc31
...
...
@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.content;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext
;
import
com.gic.haoban.manage.service.pojo.qo.content.PotentialCustomerQO
;
/**
...
...
@@ -48,4 +49,10 @@ public interface PotentialCustomerService {
* @return
*/
Long
saveOrUpdatePotentialCustomer
(
PotentialCustomerBO
potentialCustomerBO
);
/**
* 销售线索通知
* @param context
*/
void
sendPotentialCustomerNotice
(
PotentialCustomerNotifyContext
context
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/adaptor/PotentialCustomerNotifyBuilder.java
0 → 100644
View file @
1863fc31
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
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated
;
import
com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext
;
import
com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.service.notify.NoticeMessageService
;
import
com.gic.wechat.api.dto.qywx.ItemDTO
;
import
com.gic.wechat.api.dto.qywx.QywxNewsArticleMessageDTO
;
import
com.gic.wechat.api.dto.qywx.QywxNewsSendMessageDTO
;
import
com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* @Author MUSI
* @Date 2023/3/30 10:58 AM
* @Description
* @Version
**/
@Slf4j
@Component
public
class
PotentialCustomerNotifyBuilder
{
@Autowired
StaffClerkRelationService
staffClerkRelationService
;
@Autowired
private
ClerkMainStoreRelatedService
clerkMainStoreRelatedService
;
@Autowired
private
NoticeMessageService
noticeMessageService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
@Autowired
private
Config
config
;
@Autowired
private
StaffApiService
staffApiService
;
/**
* 获取企业下所有导购id
*
* @param context
*/
public
void
buildEnterpriseClerkIds
(
PotentialCustomerNotifyContext
context
)
{
if
(
StringUtils
.
isBlank
(
context
.
getEnterpriseId
()))
{
return
;
}
List
<
String
>
clerkIds
=
staffClerkRelationService
.
listAllClerkIdsByEnterpriseId
(
context
.
getEnterpriseId
());
if
(
CollectionUtils
.
isEmpty
(
clerkIds
))
{
return
;
}
context
.
setClerkIds
(
clerkIds
);
}
/**
* 获取导购的绑定关系
*
* @param context
*/
public
void
buildClerkRelations
(
PotentialCustomerNotifyContext
context
)
{
List
<
String
>
clerkIds
=
context
.
getCustomerStaticsBos
()
.
stream
()
.
map
(
PotentialCustomerStaticsBO:
:
getClerkId
)
.
collect
(
Collectors
.
toList
());
context
.
setClerkIds
(
clerkIds
);
List
<
StaffClerkRelationDTO
>
staffClerkRelations
=
staffClerkRelationService
.
listByClerkIds
(
context
.
getClerkIds
());
context
.
setStaffClerkRelations
(
staffClerkRelations
);
}
/**
* 过滤区经
*
* @param context
*/
public
void
filterAreaManage
(
PotentialCustomerNotifyContext
context
)
{
List
<
StaffClerkRelationDTO
>
clerkRelations
=
context
.
getStaffClerkRelations
()
.
stream
()
.
filter
(
item
->
!
Objects
.
equals
(
2
,
item
.
getClerkType
()))
.
collect
(
Collectors
.
toList
());
context
.
setStaffClerkRelations
(
clerkRelations
);
}
/**
* 发送好办小程序消息
*
* @param context
*/
public
void
sendHaoBanNotifyMessage
(
PotentialCustomerNotifyContext
context
)
{
List
<
NoticeMessageBO
>
noticeMessageBos
=
context
.
buildNoticeMessage
();
if
(
CollectionUtils
.
isEmpty
(
noticeMessageBos
))
{
return
;
}
noticeMessageService
.
addNoticeMessageBatch
(
noticeMessageBos
);
}
/**
* 发送应用消息
*
* @param context
*/
public
void
sendApplicationMessage
(
PotentialCustomerNotifyContext
context
)
{
if
(
CollectionUtils
.
isEmpty
(
context
.
getCustomerStaticsBos
())
||
CollectionUtils
.
isEmpty
(
context
.
getStaffClerkRelations
()))
{
return
;
}
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
())
{
String
staffId
=
staffClerkRelation
.
getStaffId
();
TabHaobanClerkMainStoreRelated
temp
=
clerkMainStoreMap
.
get
(
staffId
);
if
(
temp
!=
null
)
{
if
(
StringUtils
.
isBlank
(
temp
.
getStoreId
()))
{
// 该成员无主门店
continue
;
}
if
(
StringUtils
.
isBlank
(
temp
.
getStoreId
()))
{
log
.
info
(
"成员不存在主门店 {}"
,
staffId
);
continue
;
}
PotentialCustomerStaticsBO
customerStaticsBO
=
customerStaticsBOMap
.
get
(
staffClerkRelation
.
getClerkId
());
if
(
customerStaticsBO
==
null
||
customerStaticsBO
.
getNum
()
==
null
||
customerStaticsBO
.
getNum
()
==
0
)
{
return
;
}
// 需要发送应用消息
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
)
{
return
;
}
QywxXcxSendMessageDTO
messageDTO
=
this
.
buildApplicationMessage
(
staffClerkRelation
,
wxEnterpriseQwDTO
,
customerStaticsBO
.
getNum
());
qywxSuiteApiService
.
sendMessage
(
wxEnterpriseQwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
messageDTO
);
continue
;
}
TabHaobanClerkMainStoreRelated
tabHaobanClerkMainStoreRelated
=
clerkMainStoreRelatedService
.
selectByWxEnterpriseIdAndStoreId
(
staffId
,
staffClerkRelation
.
getWxEnterpriseId
());
if
(
tabHaobanClerkMainStoreRelated
==
null
)
{
tabHaobanClerkMainStoreRelated
=
new
TabHaobanClerkMainStoreRelated
();
}
clerkMainStoreMap
.
put
(
staffId
,
tabHaobanClerkMainStoreRelated
);
}
}
public
QywxXcxSendMessageDTO
buildApplicationMessage
(
StaffClerkRelationDTO
staffClerkRelation
,
WxEnterpriseQwDTO
wxEnterpriseQwDTO
,
int
count
)
{
StaffDTO
staffDTO
=
staffApiService
.
selectById
(
staffClerkRelation
.
getStaffId
());
String
wxUserId
=
staffDTO
.
getWxUserId
();
if
(
wxEnterpriseQwDTO
.
needOpenUserId3th
())
{
wxUserId
=
staffDTO
.
getWxOpenUseId
();
}
QywxXcxSendMessageDTO
messageDTO
=
new
QywxXcxSendMessageDTO
();
ItemDTO
itemDTO
=
new
ItemDTO
();
itemDTO
.
setKey
(
"事件"
);
itemDTO
.
setValue
(
String
.
format
(
"新增%s个客户的销售线索,请及时跟进"
,
count
));
ArrayList
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
wxUserId
);
messageDTO
.
setAppid
(
config
.
getAppid
());
messageDTO
.
setUserIds
(
list
);
messageDTO
.
setPage
(
"/pageurl?"
);
messageDTO
.
setTitle
(
"销售线索通知"
);
messageDTO
.
setItems
(
Collections
.
singletonList
(
itemDTO
));
return
messageDTO
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/impl/InteractRecordServiceImpl.java
View file @
1863fc31
...
...
@@ -7,6 +7,7 @@ import com.gic.commons.util.UniqueIdUtils;
import
com.gic.haoban.manage.service.dao.mapper.content.TabHaobanInteractRecordMapper
;
import
com.gic.haoban.manage.service.entity.content.TabHaobanInteractRecord
;
import
com.gic.haoban.manage.service.pojo.bo.content.InteractRecordBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO
;
import
com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO
;
import
com.gic.haoban.manage.service.service.content.InteractRecordService
;
import
com.gic.haoban.manage.service.service.content.adaptor.InteractRecordBuilder
;
...
...
@@ -140,4 +141,15 @@ public class InteractRecordServiceImpl implements InteractRecordService {
}
return
temp
.
getId
();
}
/**
* 统计导购的互动记录总数
*
* @param interactRecordQO
* @return
*/
@Override
public
List
<
PotentialCustomerStaticsBO
>
staticsClerkNewInteractRecord
(
InteractRecordQO
interactRecordQO
)
{
return
this
.
tabHaobanInteractRecordMapper
.
staticsClerkInteractRecordNew
(
interactRecordQO
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/impl/PotentialCustomerServiceImpl.java
View file @
1863fc31
...
...
@@ -5,18 +5,30 @@ import com.gic.commons.util.UniqueIdUtils;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.manage.service.dao.mapper.content.TabHaobanPotentialCustomerMapper
;
import
com.gic.haoban.manage.service.entity.content.TabHaobanPotentialCustomer
;
import
com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO
;
import
com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext
;
import
com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO
;
import
com.gic.haoban.manage.service.pojo.qo.content.PotentialCustomerQO
;
import
com.gic.haoban.manage.service.service.content.InteractRecordService
;
import
com.gic.haoban.manage.service.service.content.PotentialCustomerService
;
import
com.gic.haoban.manage.service.service.content.adaptor.PotentialCustomerNotifyBuilder
;
import
com.gic.haoban.manage.service.service.notify.NoticeMessageService
;
import
com.github.pagehelper.PageHelper
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 销售线索(TabHaobanPotentialCustomer)表服务实现类
...
...
@@ -30,6 +42,12 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
@Resource
private
TabHaobanPotentialCustomerMapper
potentialCustomerMapper
;
@Autowired
private
PotentialCustomerNotifyBuilder
potentialCustomerNotifyBuilder
;
@Autowired
private
InteractRecordService
interactRecordService
;
@Autowired
private
NoticeMessageService
noticeMessageService
;
/**
...
...
@@ -123,9 +141,38 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
if
(
temp
.
getId
()
==
null
)
{
temp
.
setId
(
UniqueIdUtils
.
uniqueLong
());
potentialCustomerMapper
.
insert
(
temp
);
}
else
{
}
else
{
potentialCustomerMapper
.
update
(
temp
);
}
return
temp
.
getId
();
}
/**
* 销售线索通知
*
* @param context
*/
@Override
public
void
sendPotentialCustomerNotice
(
PotentialCustomerNotifyContext
context
)
{
// 根据企业id + 时间 循环查询时间段内的有新互动记录的导购id 去重
InteractRecordQO
searchQo
=
new
InteractRecordQO
();
searchQo
.
setEnterpriseId
(
context
.
getEnterpriseId
());
searchQo
.
setStartTime
(
context
.
getStartTime
());
searchQo
.
setEndTime
(
context
.
getEndTime
());
List
<
PotentialCustomerStaticsBO
>
customerStaticsBos
=
interactRecordService
.
staticsClerkNewInteractRecord
(
searchQo
);
if
(
CollectionUtils
.
isEmpty
(
customerStaticsBos
))
{
return
;
}
context
.
setCustomerStaticsBos
(
customerStaticsBos
);
// 获取导购与成员关联关联关系
potentialCustomerNotifyBuilder
.
buildClerkRelations
(
context
);
// 获取成员的主门店
// 区经 忽略
potentialCustomerNotifyBuilder
.
filterAreaManage
(
context
);
// 构建应用内消息
potentialCustomerNotifyBuilder
.
sendHaoBanNotifyMessage
(
context
);
// 如果该导购id是成员在主门店时的导购id 发送应用消息
potentialCustomerNotifyBuilder
.
sendApplicationMessage
(
context
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/message/InteractRecordMessageService.java
View file @
1863fc31
...
...
@@ -112,7 +112,6 @@ public class InteractRecordMessageService {
potentialCustomerBO
.
setDurationTime
(
interactRecordBO
.
getDurationTime
());
potentialCustomerBO
.
setTimes
(
interactRecordBO
.
getTimes
());
potentialCustomerService
.
saveOrUpdatePotentialCustomer
(
potentialCustomerBO
);
// 累计 该导购 + 时间段内 未读数量
}
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/StaffClerkRelationServiceImpl.java
View file @
1863fc31
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.service.ClerkService
;
...
...
@@ -421,7 +420,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
* @return
*/
@Override
public
List
<
St
affClerkRelationDTO
>
listAllRelationDto
sByEnterpriseId
(
String
enterpriseId
)
{
return
this
.
mapper
.
listAll
RelationDto
sByEnterpriseId
(
enterpriseId
);
public
List
<
St
ring
>
listAllClerkId
sByEnterpriseId
(
String
enterpriseId
)
{
return
this
.
mapper
.
listAll
ClerkId
sByEnterpriseId
(
enterpriseId
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/content/task/QywxGroupMsgTaskApiServiceImpl.java
View file @
1863fc31
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
.
content
.
task
;
import
cn.hutool.core.date.DateTime
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.DateUtil
;
...
...
@@ -10,18 +11,22 @@ import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import
com.gic.haoban.manage.api.enums.content.TriggerCustomerChannelType
;
import
com.gic.haoban.manage.api.service.content.task.QywxGroupMsgTaskApiService
;
import
com.gic.haoban.manage.service.pojo.bo.content.GroupMessageInfoBo
;
import
com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.service.content.GroupMessageService
;
import
com.gic.haoban.manage.service.service.content.MaterialReportService
;
import
com.gic.haoban.manage.service.service.content.PotentialCustomerService
;
import
com.gic.haoban.manage.service.task.RouterConstant
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.formula.functions.Now
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -43,6 +48,8 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
private
StaffService
staffService
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
@Autowired
private
PotentialCustomerService
potentialCustomerService
;
@Override
public
ServiceResponse
<
Void
>
groupMsgTaskJob
(
String
params
)
{
...
...
@@ -115,6 +122,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
/**
* 发送企业周报/月报素材
*
* @param reportType
* @return
*/
...
...
@@ -153,9 +161,9 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
/**
* 处理单成员素材使用周报/月报
*
* @see RouterConstant#DEAL_ONE_STAFF_MATERIAL_REPORT
* @param params
* @return
* @see RouterConstant#DEAL_ONE_STAFF_MATERIAL_REPORT
*/
@Override
public
ServiceResponse
<
Void
>
doHandlerMaterialOneStaffReportMQ
(
String
params
)
{
...
...
@@ -171,6 +179,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
/**
* 发送成员使用素材消息MQ
*
* @param materialReportDTO
* @return
*/
...
...
@@ -179,9 +188,70 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
GICMQClientUtil
.
getClientInstance
()
.
sendMessage
(
RouterConstant
.
DEAL_ONE_STAFF_MATERIAL_REPORT
,
JSON
.
toJSONString
(
materialReportDTO
));
return
true
;
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
warn
(
"发送成员使用素材周报/月报MQ异常, 参数: {}"
,
JSON
.
toJSONString
(
materialReportDTO
),
ex
);
}
return
false
;
}
/**
* 销售线索 通知job
*
* @param params
* @return 每半小时通知一次,提醒时间段:当天 8:00~23:00
* 当天23:00~第二天8:00产生的线索动态,第二天 8:00 提醒
* 区经不发应用、小程序消息
* 导购、店长 应用只发主门店数据的应用消息
*/
@Override
public
ServiceResponse
<
Void
>
potentialCustomerJob
(
String
params
)
{
Date
now
=
new
Date
();
int
currentHour
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
hour
(
now
,
true
);
if
(
currentHour
>=
23
||
currentHour
<
8
)
{
log
.
info
(
"当前时间处于消息禁发时间, 忽略{}"
,
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
now
,
"yyyy-MM-dd HH:mm:ss"
));
return
ServiceResponse
.
success
();
}
List
<
String
>
enterpriseIds
=
groupMessageService
.
hasMaterialRightEnterprise
();
if
(
CollectionUtils
.
isEmpty
(
enterpriseIds
))
{
return
ServiceResponse
.
success
();
}
Date
startTime
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
offsetMinute
(
now
,
-
30
).
toJdkDate
();
// 如果是8点那次的执行 需要获取 23 ~ 8点的数据
if
(
checkIsTodayFirst
(
now
))
{
log
.
info
(
"本次执行为当天第一次执行 {}"
,
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
now
,
"yyyy-MM-dd HH:mm:ss"
));
Date
yesterday
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
yesterday
().
toJdkDate
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
clear
();
calendar
.
setTime
(
yesterday
);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
23
);
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
startTime
=
calendar
.
getTime
();
}
for
(
String
enterpriseId
:
enterpriseIds
)
{
PotentialCustomerNotifyContext
context
=
PotentialCustomerNotifyContext
.
builder
()
.
enterpriseId
(
enterpriseId
)
.
startTime
(
startTime
)
.
endTime
(
now
)
.
build
();
potentialCustomerService
.
sendPotentialCustomerNotice
(
context
);
}
return
ServiceResponse
.
success
();
}
/**
* 判断是否是当天第一次
* 执行时间处于 8:00 ~ 8:30
*
* @param now
* @return
*/
int
hour_sec
=
30
*
60
+
1
;
private
boolean
checkIsTodayFirst
(
Date
now
)
{
DateTime
temp
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
offsetSecond
(
now
,
-(
hour_sec
+
1
));
return
cn
.
hutool
.
core
.
date
.
DateUtil
.
hour
(
temp
,
true
)
<
8
;
}
}
haoban-manage3-service/src/main/resources/mapper/TabHaobanStaffClerkRelationMapper.xml
View file @
1863fc31
...
...
@@ -447,9 +447,10 @@
</if>
</select>
<select
id=
"listAllRelationDtosByEnterpriseId"
resultType=
"com.gic.haoban.manage.api.dto.StaffClerkRelationDTO"
>
<include
refid=
"leftJoinStaffSQL"
/>
where a.enterprise_id = #{wxEnterpriseId} and a.status_flag=1 and b.status_flag = 1
<select
id=
"listAllClerkIdsByEnterpriseId"
resultType=
"java.lang.String"
>
select a.clerk_id clerkId
from tab_haoban_staff_clerk_relation a inner join tab_haoban_staff b on b.staff_id = a.staff_id
where a.enterprise_id = #{enterpriseId} and a.status_flag=1 and b.status_flag = 1
</select>
</mapper>
\ No newline at end of file
haoban-manage3-service/src/main/resources/mapper/content/TabHaobanInteractRecordMapper.xml
View file @
1863fc31
...
...
@@ -268,9 +268,32 @@
<if
test=
"startTime != null"
>
and create_time >= #{startTime}
</if>
<if
test=
"endTime != null"
>
and create_time
<![CDATA[ <= ]]>
#{endTime}
</if>
</where>
order by id desc
</select>
<select
id=
"staticsClerkInteractRecordNew"
resultType=
"com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO"
>
select clerk_id clerkId, count(1) num
from tab_haoban_interact_record
where delete_flag = 0
<if
test=
"clerkId != null and clerkId != ''"
>
and clerk_id = #{clerkId}
</if>
<if
test=
"enterpriseId != null and enterpriseId != ''"
>
and enterprise_id = #{enterpriseId}
</if>
<if
test=
"startTime != null"
>
and create_time >= #{startTime}
</if>
<if
test=
"endTime != null"
>
and create_time
<![CDATA[ <= ]]>
#{endTime}
</if>
group by clerk_id
order by null
</select>
</mapper>
haoban-manage3-service/src/test/java/InteractRecordTest.java
View file @
1863fc31
import
cn.hutool.crypto.digest.MD5
;
import
com.gic.haoban.manage.api.dto.chat.ChatOwnerTotalDTO
;
import
com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO
;
import
com.gic.haoban.manage.api.enums.content.MaterialInteractRecordEventType
;
import
com.gic.haoban.manage.api.enums.content.TriggerCustomerChannelType
;
import
com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanOwnerLogMapper
;
import
com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessageBO
;
import
com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO
;
import
com.gic.haoban.manage.service.service.content.InteractRecordService
;
...
...
@@ -13,6 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
/**
...
...
@@ -69,4 +73,14 @@ public class InteractRecordTest {
System
.
out
.
println
(
MD5
.
create
().
digestHex
(
"song"
));
}
}
@Autowired
GroupChatPlanOwnerLogMapper
groupChatPlanOwnerLogMapper
;
@Test
public
void
caseWhenTest
(){
GroupChatPlanSearchQDTO
search
=
new
GroupChatPlanSearchQDTO
();
search
.
setWxEnterpriseId
(
"f5f8c78e395e4ca1a493707316096097"
);
List
<
ChatOwnerTotalDTO
>
chatOwnerTotalDTOS
=
groupChatPlanOwnerLogMapper
.
listOwnerLogPageForWxaTotal
(
search
);
}
}
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/vo/content/potential/PotentialCustomerVO.java
View file @
1863fc31
...
...
@@ -25,11 +25,16 @@ public class PotentialCustomerVO implements Serializable {
private
Long
potentialCustomerId
;
/**
* 会员
昵
称
* 会员
名
称
*/
private
String
memberName
;
/**
* 会员昵称
*/
private
String
memberNickName
;
/**
* 会员头像
*/
private
String
memberImageUrl
;
...
...
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