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
82221e5b
Commit
82221e5b
authored
Mar 24, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送欢迎语
parent
a3b8d8a2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
528 additions
and
347 deletions
+528
-347
HaobanCommonMQApiService.java
...c/haoban/manage/api/service/HaobanCommonMQApiService.java
+2
-0
WelcomeSendService.java
...gic/haoban/manage/service/service/WelcomeSendService.java
+21
-0
WelcomeSendServiceImpl.java
...n/manage/service/service/impl/WelcomeSendServiceImpl.java
+454
-0
WelcomeServiceImpl.java
...aoban/manage/service/service/impl/WelcomeServiceImpl.java
+0
-2
HaobanCommonMQApiServiceImpl.java
...ervice/service/out/impl/HaobanCommonMQApiServiceImpl.java
+24
-16
MemberUnionidRelatedApiServiceImpl.java
.../service/out/impl/MemberUnionidRelatedApiServiceImpl.java
+27
-329
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/HaobanCommonMQApiService.java
View file @
82221e5b
...
@@ -17,5 +17,7 @@ public interface HaobanCommonMQApiService {
...
@@ -17,5 +17,7 @@ public interface HaobanCommonMQApiService {
public
void
putCommonDelayMessage
(
CommonMQDTO
dto
,
int
delay
);
public
void
putCommonDelayMessage
(
CommonMQDTO
dto
,
int
delay
);
public
void
commonHandler
(
String
message
);
public
void
commonHandler
(
String
message
);
public
void
welcomeMQ
(
String
params
)
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/WelcomeSendService.java
0 → 100644
View file @
82221e5b
package
com
.
gic
.
haoban
.
manage
.
service
.
service
;
import
com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO
;
public
interface
WelcomeSendService
{
/**
* @Description: 发送欢迎语
*/
public
void
sendWelcome
(
String
params
);
/**
* @Title: sendWelcome
* @Description: 发送欢迎语
* @throws
*/
public
void
sendWelcome
(
String
corpid
,
String
externalUserId
,
String
welcomeCode
,
String
wxUserId
,
String
state
);
public
String
getHmClerk
(
HmQrcodeDTO
hmDTO
,
String
wxEnterpriseId
,
String
staffId
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/WelcomeSendServiceImpl.java
0 → 100644
View file @
82221e5b
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.dubbo.entity.ProviderLocalTag
;
import
com.gic.enterprise.api.dto.QRcodeDTO
;
import
com.gic.enterprise.api.service.ImageService
;
import
com.gic.haoban.manage.api.constants.Manage3Constants
;
import
com.gic.haoban.manage.api.dto.QwFrientNoticeDTO
;
import
com.gic.haoban.manage.api.dto.QywxErrorLogDTO
;
import
com.gic.haoban.manage.api.dto.StaffClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO
;
import
com.gic.haoban.manage.api.enums.WelcomeMediaTypeEnum
;
import
com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType
;
import
com.gic.haoban.manage.api.service.hm.HmClerkRelationApiService
;
import
com.gic.haoban.manage.api.service.hm.HmQrcodeApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.dao.mapper.StaffMapper
;
import
com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaff
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabMiniprogramSetting
;
import
com.gic.haoban.manage.service.pojo.bo.hm.KeyDataLinkBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeMediaBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO
;
import
com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService
;
import
com.gic.haoban.manage.service.service.KeyDataService
;
import
com.gic.haoban.manage.service.service.MiniprogramSettingService
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
com.gic.haoban.manage.service.service.WelcomeSendService
;
import
com.gic.haoban.manage.service.service.WelcomeService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.util.CommonUtil
;
import
com.gic.haoban.manage.service.util.EmojiFilterUtil
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxExternalMessageBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxFileExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxImageExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxLinkExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxMiniprogramExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxVideoExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxWelcomeMsgDTO
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.crypto.SecureUtil
;
@Service
public
class
WelcomeSendServiceImpl
implements
WelcomeSendService
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
WelcomeSendServiceImpl
.
class
);
@Autowired
private
QywxUserApiService
qywxUserApiService
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
@Autowired
private
ClerkService
clerkService
;
@Autowired
private
ClerkMainStoreRelatedService
clerkMainStoreRelatedService
;
@Autowired
private
Config
config
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
StaffClerkRelationService
staffClerkRelationService
;
@Autowired
private
MiniprogramSettingService
miniprogramSettingService
;
@Autowired
private
WelcomeService
welcomeService
;
@Autowired
private
ImageService
imageService
;
@Autowired
private
HmQrcodeApiService
hmQrcodeApiService
;
@Autowired
private
KeyDataService
keyDataService
;
@Autowired
private
HmClerkRelationApiService
hmClerkRelationApiService
;
@Autowired
private
StaffMapper
staffMapper
;
private
static
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
();
@Override
public
void
sendWelcome
(
String
params
)
{
log
.
info
(
"发送欢迎语={}"
,
params
);
QwFrientNoticeDTO
dto
=
JSON
.
parseObject
(
params
,
QwFrientNoticeDTO
.
class
);
this
.
sendWelcome
(
dto
.
getCorpid
(),
dto
.
getExternalUserid
(),
dto
.
getWelcomeCode
(),
dto
.
getWxUserId
(),
dto
.
getState
());
}
/**
* 发送欢迎语
*
* @param dto
* @param wxEnterpriseDTO
* @param enterpriseId
* @param staffId
* {"data":{"welcomeCode":"J0GjdrsF-nZNac3Xc6V2K2p8OokQZcY4g0jxljdHc7A","wxUserId":"016903","suiteid":"selfSuiteId","corpid":"wxbde984c3488b837e","externalUserid":"wmSe9FEAAAy39F1NI6Z-THUUd9mkqOIw","changeType":"add_external_contact"},"type":1,"mqTraceId":"278473818-1-1679557069.126"}
*/
@Override
public
void
sendWelcome
(
String
corpid
,
String
externalUserId
,
String
welcomeCode
,
String
wxUserId
,
String
state
)
{
if
(
StringUtils
.
isEmpty
(
welcomeCode
))
{
log
.
error
(
"welcomeCode为空,externalUserId={}"
,
externalUserId
);
return
;
}
TabHaobanWxEnterprise
wxEnterprise
=
this
.
wxEnterpriseService
.
getEnterpriseBycorpId
(
corpid
);
if
(
wxEnterprise
==
null
)
{
log
.
info
(
"企业不存在,corpid={}"
,
corpid
);
return
;
}
String
wxEnterpriseId
=
wxEnterprise
.
getWxEnterpriseId
();
WxEnterpriseQwDTO
qwDTO
=
this
.
wxEnterpriseService
.
getQwInfo
(
wxEnterpriseId
);
if
(
qwDTO
==
null
)
{
log
.
info
(
"企业不存在,wxEnterpriseId={}"
,
wxEnterpriseId
);
return
;
}
TabHaobanStaff
staff
=
this
.
staffMapper
.
selectByUserIdAndEnterpriseId
(
wxUserId
,
wxEnterpriseId
);
if
(
null
==
staff
)
{
log
.
info
(
"成员不存在,wxUserid={}"
,
wxUserId
);
return
;
}
String
staffId
=
staff
.
getStaffId
();
log
.
info
(
"发送欢迎语,state={}"
,
state
);
String
relationKey
=
SecureUtil
.
md5
(
staffId
+
externalUserId
);
WelcomeDetailBO
welcomeBO
=
null
;
if
(
StringUtils
.
isNotBlank
(
state
)
&&
(
state
.
startsWith
(
Manage3Constants
.
HM
)
||
state
.
startsWith
(
Manage3Constants
.
DT
)))
{
WelcomeReferBO
welcomeReferBo
=
getWelcomeReferBo
(
state
);
welcomeBO
=
welcomeService
.
getMatchWelcomeWithReferId
(
staffId
,
wxEnterpriseId
,
welcomeReferBo
);
}
else
{
welcomeBO
=
welcomeService
.
getMatchWelcome
(
staffId
,
wxEnterpriseId
);
}
if
(
Objects
.
isNull
(
welcomeBO
))
{
log
.
info
(
"欢迎语未配置wxEnterpriseId:{}"
,
wxEnterpriseId
);
return
;
}
// 内容
log
.
info
(
"欢迎语发送={}"
,
JSON
.
toJSONString
(
welcomeBO
));
String
content
=
welcomeBO
.
getWelcomeContent
();
if
(
content
.
contains
(
"<微信昵称>"
))
{
String
nickName
=
this
.
getExternalUserName
(
qwDTO
,
externalUserId
);
content
=
content
.
replaceAll
(
"<微信昵称>"
,
nickName
);
}
QywxWelcomeMsgDTO
qywxWelcomeMsgDTO
=
new
QywxWelcomeMsgDTO
();
// 欢迎语内容
qywxWelcomeMsgDTO
.
setText
(
content
);
// 欢迎语类型
List
<
QywxExternalMessageBaseDTO
>
attachments
=
new
ArrayList
<>();
// 开始设置欢迎语附件
List
<
WelcomeMediaBO
>
mediaList
=
welcomeBO
.
getWelcomeMediaList
();
mediaList
.
forEach
(
one
->
{
Integer
mediaType
=
one
.
getMediaType
();
if
(
WelcomeMediaTypeEnum
.
IMAGE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddImage
(
attachments
,
one
,
corpid
);
}
if
(
WelcomeMediaTypeEnum
.
VIDEO
.
getCode
().
equals
(
mediaType
))
{
attachmentAddVideo
(
attachments
,
one
,
corpid
);
}
if
(
WelcomeMediaTypeEnum
.
FILE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddFile
(
attachments
,
one
,
corpid
);
}
if
(
WelcomeMediaTypeEnum
.
LINK
.
getCode
().
equals
(
mediaType
))
{
attachmentAddLink
(
attachments
,
one
);
}
if
(
WelcomeMediaTypeEnum
.
PROGRAM
.
getCode
().
equals
(
mediaType
))
{
attachmentAddProgram
(
attachments
,
one
,
wxEnterpriseId
);
}
if
(
WelcomeMediaTypeEnum
.
PARAM_PROGRAM
.
getCode
().
equals
(
mediaType
)
||
WelcomeMediaTypeEnum
.
PARAM_QRCODE
.
getCode
().
equals
(
mediaType
))
{
String
clerkId
=
this
.
getClerkId
(
wxEnterpriseId
,
staffId
,
state
);
String
enterpriseId
=
null
;
if
(
null
!=
clerkId
)
{
ClerkDTO
clerk
=
this
.
clerkService
.
getclerkById
(
clerkId
);
if
(
null
!=
clerk
)
{
enterpriseId
=
clerk
.
getEnterpriseId
();
}
}
if
(
WelcomeMediaTypeEnum
.
PARAM_QRCODE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddParamQrCode
(
attachments
,
enterpriseId
,
clerkId
,
corpid
,
relationKey
);
}
if
(
WelcomeMediaTypeEnum
.
PARAM_PROGRAM
.
getCode
().
equals
(
mediaType
))
{
attachmentAddParamProgram
(
attachments
,
enterpriseId
,
wxEnterpriseId
,
relationKey
);
}
}
});
if
(
CollectionUtils
.
isNotEmpty
(
attachments
))
{
qywxWelcomeMsgDTO
.
setAttachments
(
attachments
);
}
qywxWelcomeMsgDTO
.
setWelcomeCode
(
welcomeCode
);
String
result
=
this
.
qywxUserApiService
.
sendWelcomeMsgByExternal
(
corpid
,
config
.
getWxSuiteid
(),
qywxWelcomeMsgDTO
);
log
.
info
(
"发送欢迎语 params:{},返回={}"
,
JSON
.
toJSONString
(
qywxWelcomeMsgDTO
),
result
);
if
(
StringUtils
.
isNotBlank
(
result
))
{
JSONObject
json
=
JSON
.
parseObject
(
result
);
int
errcode
=
json
.
getIntValue
(
"errcode"
);
if
(
0
!=
errcode
)
{
try
{
QywxErrorLogDTO
errLog
=
new
QywxErrorLogDTO
();
errLog
.
setWxEnterpriseId
(
wxEnterpriseId
);
errLog
.
setExternalUserId
(
externalUserId
);
errLog
.
setTraceId
(
ProviderLocalTag
.
tag
.
get
().
traceId
);
errLog
.
setQywxErrorType
(
1
);
errLog
.
setScenario
(
"欢迎语"
);
errLog
.
setErrorContent
(
result
);
clientInstance
.
sendMessage
(
Manage3Constants
.
QYWX_ERROR_MSG
,
JSON
.
toJSONString
(
errLog
));
}
catch
(
Exception
e
)
{
log
.
error
(
"发送消息失败:{}"
,
e
.
getMessage
(),
e
);
}
}
}
}
/**
* 获取链接或者活码id
*/
private
WelcomeReferBO
getWelcomeReferBo
(
String
state
)
{
WelcomeReferBO
welcomeReferBo
=
new
WelcomeReferBO
();
String
id
=
state
.
substring
(
2
);
if
(
state
.
contains
(
Manage3Constants
.
HM
))
{
welcomeReferBo
.
setType
(
HmWelcomeReferType
.
HM
.
getCode
());
welcomeReferBo
.
setReferId
(
id
);
}
else
if
(
state
.
contains
(
Manage3Constants
.
DT
))
{
KeyDataLinkBO
dataForHmLink
=
keyDataService
.
getDataForHmLink
(
id
);
if
(
dataForHmLink
!=
null
)
{
welcomeReferBo
.
setType
(
HmWelcomeReferType
.
LINK
.
getCode
());
welcomeReferBo
.
setReferId
(
Convert
.
toStr
(
dataForHmLink
.
getLinkId
()));
}
}
return
welcomeReferBo
;
}
private
void
attachmentAddImage
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
String
mediaUrl
=
media
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
log
.
info
(
"欢迎语发送图片返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
qywxImageExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxImageExternalBaseDTO
);
}
}
private
void
attachmentAddVideo
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
String
mediaUrl
=
media
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
VIDEO
.
getCode
());
log
.
info
(
"欢迎语发送视频返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxVideoExternalBaseDTO
qywxVideoExternalBaseDTO
=
new
QywxVideoExternalBaseDTO
();
qywxVideoExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxVideoExternalBaseDTO
);
}
}
private
void
attachmentAddFile
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
String
mediaUrl
=
media
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
FILE
.
getCode
());
log
.
info
(
"欢迎语发送文件返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxFileExternalBaseDTO
qywxFileExternalBaseDTO
=
new
QywxFileExternalBaseDTO
();
qywxFileExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxFileExternalBaseDTO
);
}
}
private
void
attachmentAddLink
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
)
{
String
mediaTitle
=
media
.
getMediaTitle
();
String
mediaUrl
=
media
.
getMediaUrl
();
QywxLinkExternalBaseDTO
qywxLinkExternalBaseDTO
=
new
QywxLinkExternalBaseDTO
();
qywxLinkExternalBaseDTO
.
setTitle
(
mediaTitle
);
qywxLinkExternalBaseDTO
.
setUrl
(
mediaUrl
);
attachments
.
add
(
qywxLinkExternalBaseDTO
);
}
private
void
attachmentAddProgram
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
wxEnterpriseId
)
{
log
.
info
(
"发送小程序:wxEnterpriseId:{}"
,
wxEnterpriseId
);
String
miniprogramSettingId
=
media
.
getMiniprogramSettingId
();
TabMiniprogramSetting
miniprogramSetting
=
miniprogramSettingService
.
getById
(
miniprogramSettingId
);
if
(
Objects
.
isNull
(
miniprogramSetting
)
||
miniprogramSetting
.
getStatusFlag
()
==
0
)
{
log
.
info
(
"小程序不存在或已被删除, miniprogramSettingId:{}"
,
miniprogramSettingId
);
return
;
}
QywxMiniprogramExternalBaseDTO
messageBaseDTO
=
new
QywxMiniprogramExternalBaseDTO
();
messageBaseDTO
.
setAppid
(
miniprogramSetting
.
getAppId
());
messageBaseDTO
.
setPicMediaId
(
miniprogramSetting
.
getMediaId
());
messageBaseDTO
.
setTitle
(
miniprogramSetting
.
getTitle
());
messageBaseDTO
.
setPage
(
media
.
getMiniProgramPage
());
attachments
.
add
(
messageBaseDTO
);
}
private
void
attachmentAddParamProgram
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
String
enterpriseId
,
String
wxEnterpriseId
,
String
relationKey
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
)
||
StringUtils
.
isEmpty
(
relationKey
))
{
log
.
info
(
"带参二维码无法发送"
);
return
;
}
log
.
info
(
"发送带参小程序:wxEnterpriseId:{}"
,
wxEnterpriseId
);
// 发送小程序
TabMiniprogramSetting
miniprogramSetting
=
miniprogramSettingService
.
getMiniprogramSetting
(
wxEnterpriseId
,
enterpriseId
);
if
(
null
==
miniprogramSetting
)
{
log
.
info
(
"需要配置小程序配置:wxEnterpriseId:{},enterpriseId:{}"
,
wxEnterpriseId
,
enterpriseId
);
return
;
}
QywxMiniprogramExternalBaseDTO
messageBaseDTO
=
new
QywxMiniprogramExternalBaseDTO
();
messageBaseDTO
.
setAppid
(
miniprogramSetting
.
getAppId
());
messageBaseDTO
.
setPicMediaId
(
miniprogramSetting
.
getMediaId
());
messageBaseDTO
.
setTitle
(
miniprogramSetting
.
getTitle
());
messageBaseDTO
.
setPage
(
config
.
getMemberOpenPage
()
+
relationKey
);
attachments
.
add
(
messageBaseDTO
);
}
private
void
attachmentAddParamQrCode
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
String
enterpriseId
,
String
clerkId
,
String
corpid
,
String
relationKey
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
)
||
StringUtils
.
isEmpty
(
clerkId
))
{
log
.
info
(
"带参小程序无法发送"
);
return
;
}
// 带参数的公众号二维码
String
sceneStr
=
"QWHY_"
+
relationKey
+
"_"
+
clerkId
;
// 30天失效
QRcodeDTO
qRcodePic
=
imageService
.
getQRcodePic
(
enterpriseId
,
sceneStr
,
2592000
);
log
.
info
(
"参数的公众号二维码返回:{}"
,
JSON
.
toJSONString
(
qRcodePic
));
if
(
qRcodePic
!=
null
)
{
String
downloadUrl
=
qRcodePic
.
getPicUploadResDTO
().
downloadUrl
;
String
[]
arr
=
downloadUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
downloadUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
log
.
info
(
"欢迎语发送带参数的公众号企微二维码返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
qywxImageExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxImageExternalBaseDTO
);
}
}
}
private
String
getExternalUserName
(
WxEnterpriseQwDTO
qwDTO
,
String
externalUserId
)
{
log
.
info
(
"查询好友详情,externalUserId={}"
,
externalUserId
);
String
userInfo
=
qywxUserApiService
.
getExternalUseridInfo
(
qwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
externalUserId
);
String
name
=
""
;
if
(
StringUtils
.
isBlank
(
userInfo
))
{
log
.
info
(
"好友不存在"
);
return
name
;
}
if
(
"1"
.
equals
(
userInfo
))
{
log
.
info
(
"限制次数"
);
return
name
;
}
if
(
StringUtils
.
isNotBlank
(
userInfo
))
{
JSONObject
userJson
=
JSON
.
parseObject
(
userInfo
);
String
external_contact
=
userJson
.
getString
(
"external_contact"
);
JSONObject
jt
=
null
;
if
(
StringUtils
.
isNotBlank
(
external_contact
))
{
jt
=
JSON
.
parseObject
(
external_contact
);
name
=
EmojiFilterUtil
.
filterEmojiLast
(
jt
.
getString
(
"name"
),
true
);
}
}
return
name
;
}
private
String
getClerkId
(
String
wxEnterpriseId
,
String
staffId
,
String
state
)
{
String
hyClerkId
=
null
;
Long
hmId
=
null
;
if
(
StringUtils
.
isNotBlank
(
state
)
&&
(
state
.
startsWith
(
Manage3Constants
.
HM
)
||
state
.
startsWith
(
Manage3Constants
.
DT
)))
{
String
id
=
state
.
substring
(
2
);
if
(
state
.
startsWith
(
Manage3Constants
.
HM
))
{
hmId
=
Convert
.
toLong
(
id
);
}
else
if
(
state
.
startsWith
(
Manage3Constants
.
DT
))
{
KeyDataLinkBO
linkData
=
keyDataService
.
getDataForHmLink
(
id
);
if
(
null
!=
linkData
)
{
hmId
=
linkData
.
getHmId
();
}
}
if
(
null
!=
hmId
)
{
HmQrcodeDTO
hmDTO
=
hmQrcodeApiService
.
getSimpleById
(
hmId
);
if
(
hmDTO
!=
null
)
{
hyClerkId
=
this
.
getHmClerk
(
hmDTO
,
wxEnterpriseId
,
staffId
);
log
.
info
(
"获取到活码导购={},hmId={}"
,
hyClerkId
,
hmId
);
}
}
}
if
(
StringUtils
.
isEmpty
(
hyClerkId
))
{
TabHaobanClerkMainStoreRelated
mainStoreRelated
=
clerkMainStoreRelatedService
.
getMainStoreByStaffId
(
staffId
,
wxEnterpriseId
);
if
(
mainStoreRelated
!=
null
)
{
StaffClerkRelationDTO
staffClerkRelationDTO
=
staffClerkRelationService
.
getOneBindByStoreId
(
staffId
,
mainStoreRelated
.
getStoreId
());
if
(
null
!=
staffClerkRelationDTO
)
{
hyClerkId
=
staffClerkRelationDTO
.
getClerkId
();
log
.
info
(
"获取成员关联导购={}"
,
hyClerkId
);
}
}
}
return
hyClerkId
;
}
@Override
public
String
getHmClerk
(
HmQrcodeDTO
hmDTO
,
String
wxEnterpriseId
,
String
staffId
)
{
Long
hmId
=
hmDTO
.
getHmId
();
if
(
hmDTO
.
getHmType
()
==
1
)
{
return
hmDTO
.
getClerkId
();
}
else
if
(
hmDTO
.
getHmType
()
==
2
)
{
// 有主门店导购绑定主导购,没有主门店导购绑定第一个导购,其余随机
HmClerkRelationDTO
hmClerkRelationDTO
=
null
;
TabHaobanClerkMainStoreRelated
mainStoreRelated
=
clerkMainStoreRelatedService
.
getMainStoreByStaffId
(
staffId
,
wxEnterpriseId
);
if
(
mainStoreRelated
!=
null
)
{
StaffClerkRelationDTO
relationDTO
=
staffClerkRelationService
.
getOneBindByStoreId
(
staffId
,
mainStoreRelated
.
getStoreId
());
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getHmClerkByHmIdAndClerkId
(
hmId
,
relationDTO
.
getClerkId
());
if
(
hmClerkRelationDTO
==
null
)
{
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getOneHmClerkByHmIdAndStaffId
(
hmId
,
staffId
);
if
(
hmClerkRelationDTO
==
null
)
{
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getOneHmClerkByHmId
(
hmId
);
}
}
}
else
{
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getOneHmClerkByHmId
(
hmId
);
}
return
hmClerkRelationDTO
.
getClerkId
();
}
return
null
;
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/WelcomeServiceImpl.java
View file @
82221e5b
...
@@ -3,7 +3,6 @@ package com.gic.haoban.manage.service.service.impl;
...
@@ -3,7 +3,6 @@ package com.gic.haoban.manage.service.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.UniqueIdUtils
;
import
com.gic.commons.util.UniqueIdUtils
;
import
com.gic.enterprise.api.service.LinkService
;
import
com.gic.haoban.common.utils.StringUtil
;
import
com.gic.haoban.common.utils.StringUtil
;
import
com.gic.haoban.manage.api.dto.welcome.dto.WelcomeRemoveCheckDTO
;
import
com.gic.haoban.manage.api.dto.welcome.dto.WelcomeRemoveCheckDTO
;
import
com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeQDTO
;
import
com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeQDTO
;
...
@@ -40,7 +39,6 @@ import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeSuitDepartmentBO;
...
@@ -40,7 +39,6 @@ import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeSuitDepartmentBO;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeSuitStaffBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeSuitStaffBO
;
import
com.gic.haoban.manage.service.pojo.qo.WelcomeInfoQO
;
import
com.gic.haoban.manage.service.pojo.qo.WelcomeInfoQO
;
import
com.gic.haoban.manage.service.pojo.qo.WelcomeRelationQO
;
import
com.gic.haoban.manage.service.pojo.qo.WelcomeRelationQO
;
import
com.gic.haoban.manage.service.service.KeyDataService
;
import
com.gic.haoban.manage.service.service.WelcomeService
;
import
com.gic.haoban.manage.service.service.WelcomeService
;
import
com.gic.haoban.manage.service.service.WelcomeSuitRangService
;
import
com.gic.haoban.manage.service.service.WelcomeSuitRangService
;
import
com.gic.haoban.manage.service.service.hm.HmLinkService
;
import
com.gic.haoban.manage.service.service.hm.HmLinkService
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/HaobanCommonMQApiServiceImpl.java
View file @
82221e5b
...
@@ -14,6 +14,7 @@ import com.gic.commons.util.GICMQClientUtil;
...
@@ -14,6 +14,7 @@ import com.gic.commons.util.GICMQClientUtil;
import
com.gic.haoban.manage.api.dto.CommonMQDTO
;
import
com.gic.haoban.manage.api.dto.CommonMQDTO
;
import
com.gic.haoban.manage.api.service.HaobanCommonMQApiService
;
import
com.gic.haoban.manage.api.service.HaobanCommonMQApiService
;
import
com.gic.haoban.manage.service.service.StaffDepartmentRelatedService
;
import
com.gic.haoban.manage.service.service.StaffDepartmentRelatedService
;
import
com.gic.haoban.manage.service.service.WelcomeSendService
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.quartz.api.dto.QuartzTaskDTO
;
import
com.gic.quartz.api.dto.QuartzTaskDTO
;
import
com.gic.quartz.api.service.QuartzService
;
import
com.gic.quartz.api.service.QuartzService
;
...
@@ -24,16 +25,18 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
...
@@ -24,16 +25,18 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
private
final
Logger
log
=
LogManager
.
getLogger
(
HaobanCommonMQApiService
.
class
);
private
final
Logger
log
=
LogManager
.
getLogger
(
HaobanCommonMQApiService
.
class
);
private
static
GicMQClient
mqClient
=
GICMQClientUtil
.
getClientInstance
();
private
static
GicMQClient
mqClient
=
GICMQClientUtil
.
getClientInstance
();
@Autowired
private
QuartzService
quartzService
;
@Autowired
@Autowired
private
QuartzService
quartzService
;
private
StaffDepartmentRelatedService
staffDepartmentRelatedService
;
@Autowired
@Autowired
private
StaffDepartmentRelatedService
staffDepartmentRelatedService
;
private
WelcomeSendService
welcomeSendService
;
@Override
@Override
public
void
putCommonMessage
(
CommonMQDTO
dto
)
{
public
void
putCommonMessage
(
CommonMQDTO
dto
)
{
String
message
=
JSONObject
.
toJSONString
(
dto
);
String
message
=
JSONObject
.
toJSONString
(
dto
);
log
.
info
(
"加入好办通用队列params={}"
,
message
);
log
.
info
(
"加入好办通用队列params={}"
,
message
);
try
{
try
{
mqClient
.
sendCommonMessage
(
"haobanCommonRouter"
,
message
,
mqClient
.
sendCommonMessage
(
"haobanCommonRouter"
,
message
,
"com.gic.haoban.manage.api.service.HaobanCommonMQApiService"
,
"commonHandler"
);
"com.gic.haoban.manage.api.service.HaobanCommonMQApiService"
,
"commonHandler"
);
...
@@ -42,11 +45,11 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
...
@@ -42,11 +45,11 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
@Override
@Override
public
void
putCommonDelayMessage
(
CommonMQDTO
dto
,
int
delay
)
{
public
void
putCommonDelayMessage
(
CommonMQDTO
dto
,
int
delay
)
{
String
message
=
JSONObject
.
toJSONString
(
dto
);
String
message
=
JSONObject
.
toJSONString
(
dto
);
log
.
info
(
"加入好办延时通用队列params={}"
,
message
);
log
.
info
(
"加入好办延时通用队列params={}"
,
message
);
try
{
try
{
mqClient
.
sendMessage
(
"haobanDelayMQ"
,
message
,
delay
);
mqClient
.
sendMessage
(
"haobanDelayMQ"
,
message
,
delay
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -57,30 +60,30 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
...
@@ -57,30 +60,30 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
@Override
@Override
public
void
commonHandler
(
String
message
)
{
public
void
commonHandler
(
String
message
)
{
log
.
info
(
"接收好办通用队列params={}"
,
message
);
log
.
info
(
"接收好办通用队列params={}"
,
message
);
CommonMQDTO
dto
=
JSON
.
parseObject
(
message
,
CommonMQDTO
.
class
);
CommonMQDTO
dto
=
JSON
.
parseObject
(
message
,
CommonMQDTO
.
class
);
// 好办停用,删除定时
// 好办停用,删除定时
Map
<
String
,
String
>
map
=
(
Map
<
String
,
String
>)
dto
.
getParams
()
;
Map
<
String
,
String
>
map
=
(
Map
<
String
,
String
>)
dto
.
getParams
()
;
switch
(
dto
.
getType
())
{
switch
(
dto
.
getType
())
{
case
1
:
case
1
:
String
enterpriseId
=
map
.
get
(
"enterpriseId"
)
;
String
enterpriseId
=
map
.
get
(
"enterpriseId"
);
this
.
deleteQuartz
(
enterpriseId
);
this
.
deleteQuartz
(
enterpriseId
);
break
;
break
;
case
2
:
case
2
:
String
staffId
=
map
.
get
(
"staffId"
)
;
String
staffId
=
map
.
get
(
"staffId"
);
if
(
StringUtils
.
isNotBlank
(
staffId
))
{
if
(
StringUtils
.
isNotBlank
(
staffId
))
{
this
.
staffDepartmentRelatedService
.
repairStaffDepart
(
staffId
);
this
.
staffDepartmentRelatedService
.
repairStaffDepart
(
staffId
);
}
}
default
:
default
:
break
;
break
;
}
}
}
}
private
void
deleteQuartz
(
String
enterpriseId
)
{
private
void
deleteQuartz
(
String
enterpriseId
)
{
if
(
StringUtils
.
isBlank
(
enterpriseId
))
{
if
(
StringUtils
.
isBlank
(
enterpriseId
))
{
return
;
return
;
}
}
log
.
info
(
"删除好办定时eid={}"
,
enterpriseId
);
log
.
info
(
"删除好办定时eid={}"
,
enterpriseId
);
// 日报
// 日报
QuartzTaskDTO
task
=
new
QuartzTaskDTO
();
QuartzTaskDTO
task
=
new
QuartzTaskDTO
();
task
.
setTaskService
(
"com.gic.haoban.app.daily.api.service.DailyReportTaskApiService"
);
task
.
setTaskService
(
"com.gic.haoban.app.daily.api.service.DailyReportTaskApiService"
);
...
@@ -88,4 +91,9 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
...
@@ -88,4 +91,9 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
task
.
setReferId
(
enterpriseId
);
task
.
setReferId
(
enterpriseId
);
this
.
quartzService
.
delQuartzTask
(
task
);
this
.
quartzService
.
delQuartzTask
(
task
);
}
}
@Override
public
void
welcomeMQ
(
String
params
)
{
this
.
welcomeSendService
.
sendWelcome
(
params
);
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MemberUnionidRelatedApiServiceImpl.java
View file @
82221e5b
...
@@ -7,10 +7,8 @@ import java.util.HashMap;
...
@@ -7,10 +7,8 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -19,7 +17,6 @@ import org.apache.logging.log4j.LogManager;
...
@@ -19,7 +17,6 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.redisson.api.RAtomicLong
;
import
org.redisson.api.RAtomicLong
;
import
org.redisson.api.RRateLimiter
;
import
org.redisson.api.RRateLimiter
;
import
org.redisson.api.RSet
;
import
org.redisson.api.RateIntervalUnit
;
import
org.redisson.api.RateIntervalUnit
;
import
org.redisson.api.RateType
;
import
org.redisson.api.RateType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -34,10 +31,7 @@ import com.gic.clerk.api.dto.ClerkDTO;
...
@@ -34,10 +31,7 @@ import com.gic.clerk.api.dto.ClerkDTO;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.dubbo.entity.ProviderLocalTag
;
import
com.gic.enterprise.api.dto.QRcodeDTO
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.service.ImageService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.app.customer.dto.ChildDTO
;
import
com.gic.haoban.app.customer.dto.ChildDTO
;
import
com.gic.haoban.app.customer.dto.CustomerDTO
;
import
com.gic.haoban.app.customer.dto.CustomerDTO
;
...
@@ -57,20 +51,15 @@ import com.gic.haoban.manage.api.dto.MemberStoreDTO;
...
@@ -57,20 +51,15 @@ import com.gic.haoban.manage.api.dto.MemberStoreDTO;
import
com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO
;
import
com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO
;
import
com.gic.haoban.manage.api.dto.MemberUnionidWechatAccountQDTO
;
import
com.gic.haoban.manage.api.dto.MemberUnionidWechatAccountQDTO
;
import
com.gic.haoban.manage.api.dto.QwFrientNoticeDTO
;
import
com.gic.haoban.manage.api.dto.QwFrientNoticeDTO
;
import
com.gic.haoban.manage.api.dto.QywxErrorLogDTO
;
import
com.gic.haoban.manage.api.dto.SecretSettingDTO
;
import
com.gic.haoban.manage.api.dto.SecretSettingDTO
;
import
com.gic.haoban.manage.api.dto.StaffClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.StaffClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO
;
import
com.gic.haoban.manage.api.dto.qdto.hm.WxUserAddLogQDTO
;
import
com.gic.haoban.manage.api.dto.qdto.hm.WxUserAddLogQDTO
;
import
com.gic.haoban.manage.api.enums.SecretTypeEnum
;
import
com.gic.haoban.manage.api.enums.SecretTypeEnum
;
import
com.gic.haoban.manage.api.enums.WelcomeMediaTypeEnum
;
import
com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType
;
import
com.gic.haoban.manage.api.service.CheckQywxSettingApiService
;
import
com.gic.haoban.manage.api.service.CheckQywxSettingApiService
;
import
com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService
;
import
com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService
;
import
com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService
;
import
com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService
;
import
com.gic.haoban.manage.api.service.hm.HmClerkRelationApiService
;
import
com.gic.haoban.manage.api.service.hm.HmQrcodeApiService
;
import
com.gic.haoban.manage.api.service.hm.HmQrcodeApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.dao.mapper.StaffMapper
;
import
com.gic.haoban.manage.service.dao.mapper.StaffMapper
;
...
@@ -82,32 +71,26 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
...
@@ -82,32 +71,26 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import
com.gic.haoban.manage.service.entity.TabHaobanWxApplication
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxApplication
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated
;
import
com.gic.haoban.manage.service.entity.TabMiniprogramSetting
;
import
com.gic.haoban.manage.service.exception.WxApiLimitException
;
import
com.gic.haoban.manage.service.exception.WxApiLimitException
;
import
com.gic.haoban.manage.service.pojo.DealQywxExternalUserPojo
;
import
com.gic.haoban.manage.service.pojo.DealQywxExternalUserPojo
;
import
com.gic.haoban.manage.service.pojo.ExternalUserPojo
;
import
com.gic.haoban.manage.service.pojo.ExternalUserPojo
;
import
com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo
;
import
com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo
;
import
com.gic.haoban.manage.service.pojo.bo.hm.HmLinkBO
;
import
com.gic.haoban.manage.service.pojo.bo.hm.HmLinkBO
;
import
com.gic.haoban.manage.service.pojo.bo.hm.KeyDataLinkBO
;
import
com.gic.haoban.manage.service.pojo.bo.hm.KeyDataLinkBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeMediaBO
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO
;
import
com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService
;
import
com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService
;
import
com.gic.haoban.manage.service.service.ExternalClerkRelatedService
;
import
com.gic.haoban.manage.service.service.ExternalClerkRelatedService
;
import
com.gic.haoban.manage.service.service.KeyDataService
;
import
com.gic.haoban.manage.service.service.KeyDataService
;
import
com.gic.haoban.manage.service.service.MemberUnionRelatedService
;
import
com.gic.haoban.manage.service.service.MemberUnionRelatedService
;
import
com.gic.haoban.manage.service.service.MiniprogramSettingService
;
import
com.gic.haoban.manage.service.service.QywxSendService
;
import
com.gic.haoban.manage.service.service.QywxSendService
;
import
com.gic.haoban.manage.service.service.SecretSettingService
;
import
com.gic.haoban.manage.service.service.SecretSettingService
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.WelcomeService
;
import
com.gic.haoban.manage.service.service.WelcomeSe
ndSe
rvice
;
import
com.gic.haoban.manage.service.service.WxEnterpriseRelatedService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseRelatedService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.service.chat.GroupChatService
;
import
com.gic.haoban.manage.service.service.chat.GroupChatService
;
import
com.gic.haoban.manage.service.service.hm.HmLinkService
;
import
com.gic.haoban.manage.service.service.hm.HmLinkService
;
import
com.gic.haoban.manage.service.service.hm.WxUserAddLogService
;
import
com.gic.haoban.manage.service.service.hm.WxUserAddLogService
;
import
com.gic.haoban.manage.service.util.CommonUtil
;
import
com.gic.haoban.manage.service.util.EmojiFilterUtil
;
import
com.gic.haoban.manage.service.util.EmojiFilterUtil
;
import
com.gic.member.api.dto.MemberDTO
;
import
com.gic.member.api.dto.MemberDTO
;
import
com.gic.member.api.dto.MemberSimpleDetailDTO
;
import
com.gic.member.api.dto.MemberSimpleDetailDTO
;
...
@@ -123,14 +106,6 @@ import com.gic.member.tag.api.service.MemberTagOpenApiService;
...
@@ -123,14 +106,6 @@ import com.gic.member.tag.api.service.MemberTagOpenApiService;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.UnionidToExternalUseridDTO
;
import
com.gic.wechat.api.dto.qywx.UnionidToExternalUseridDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxExternalMessageBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxFileExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxImageExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxLinkExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxMiniprogramExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxVideoExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxWelcomeMsgDTO
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
...
@@ -177,10 +152,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -177,10 +152,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
@Autowired
private
ExternalClerkRelatedService
externalClerkRelatedService
;
private
ExternalClerkRelatedService
externalClerkRelatedService
;
@Autowired
@Autowired
private
MiniprogramSettingService
miniprogramSettingService
;
@Autowired
private
WelcomeService
welcomeService
;
@Autowired
private
CheckQywxSettingApiService
checkQywxSettingApiService
;
private
CheckQywxSettingApiService
checkQywxSettingApiService
;
@Autowired
@Autowired
private
CustomerApiService
customerApiService
;
private
CustomerApiService
customerApiService
;
...
@@ -195,8 +166,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -195,8 +166,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
@Autowired
private
MemberStoreService
memberStoreService
;
private
MemberStoreService
memberStoreService
;
@Autowired
@Autowired
private
ImageService
imageService
;
@Autowired
private
HmQrcodeApiService
hmQrcodeApiService
;
private
HmQrcodeApiService
hmQrcodeApiService
;
@Autowired
@Autowired
private
WxUserAddLogService
wxUserAddLogService
;
private
WxUserAddLogService
wxUserAddLogService
;
...
@@ -209,8 +178,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -209,8 +178,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
@Autowired
private
MemberService
memberService
;
private
MemberService
memberService
;
@Autowired
@Autowired
private
HmClerkRelationApiService
hmClerkRelationApiService
;
@Autowired
private
StaffMapper
staffMapper
;
private
StaffMapper
staffMapper
;
@Autowired
@Autowired
private
MemberEntranceApiService
memberEntranceApiService
;
private
MemberEntranceApiService
memberEntranceApiService
;
...
@@ -218,9 +185,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -218,9 +185,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private
QywxSendService
qywxSendService
;
private
QywxSendService
qywxSendService
;
@Autowired
@Autowired
private
GroupChatService
groupChatService
;
private
GroupChatService
groupChatService
;
@Autowired
private
static
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
()
;
private
WelcomeSendService
welcomeSendService
;
GicMQClient
instance
=
GICMQClientUtil
.
getClientInstance
();
@Override
@Override
public
void
dealQywxExternalUser
(
String
params
)
{
public
void
dealQywxExternalUser
(
String
params
)
{
...
@@ -385,19 +352,34 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -385,19 +352,34 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
DealQywxExternalUserPojo
dealQywxExternalUserPojo
=
new
DealQywxExternalUserPojo
();
DealQywxExternalUserPojo
dealQywxExternalUserPojo
=
new
DealQywxExternalUserPojo
();
dealQywxExternalUserPojo
.
setType
(
DealQywxExternalUserPojo
.
DealType
.
add
.
getType
());
dealQywxExternalUserPojo
.
setType
(
DealQywxExternalUserPojo
.
DealType
.
add
.
getType
());
dealQywxExternalUserPojo
.
setData
(
dto
);
dealQywxExternalUserPojo
.
setData
(
dto
);
this
.
sendWelcome
(
dto
);
GicMQClient
instance
=
GICMQClientUtil
.
getClientInstance
();
String
mqName
=
"dealQywxExternalUserMq"
;
String
mqName
=
"dealQywxExternalUserMq"
;
if
(
this
.
mqCheck
(
dto
))
{
if
(
this
.
mqCheck
(
dto
))
{
mqName
=
"dealQywxExternalUserMq2"
;
mqName
=
"dealQywxExternalUserMq2"
;
}
}
try
{
try
{
instance
.
sendMessage
(
mqName
,
JSONObject
.
toJSONString
(
dealQywxExternalUserPojo
));
instance
.
sendMessage
(
mqName
,
JSONObject
.
toJSONString
(
dealQywxExternalUserPojo
)
,
60
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"异步处理异常:{}"
,
e
);
log
.
info
(
"异步处理异常:{}"
,
e
);
}
}
return
null
;
return
null
;
}
}
private
void
sendWelcome
(
QwFrientNoticeDTO
dto
)
{
String
suiteid
=
dto
.
getSuiteid
();
if
(
SELF_APP
.
equals
(
suiteid
))
{
return
;
}
if
(
StringUtils
.
isEmpty
(
dto
.
getWelcomeCode
()))
{
return
;
}
try
{
instance
.
sendMessage
(
"qywxWelcomeSendMQ"
,
JSONObject
.
toJSONString
(
dto
));
}
catch
(
Exception
e
)
{
log
.
info
(
"异步处理异常:{}"
,
e
);
}
}
// 加好友量大的迁移到mq2
// 加好友量大的迁移到mq2
private
boolean
mqCheck
(
QwFrientNoticeDTO
dto
)
{
private
boolean
mqCheck
(
QwFrientNoticeDTO
dto
)
{
int
maxCount
=
800
;
int
maxCount
=
800
;
...
@@ -538,7 +520,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -538,7 +520,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
return
;
return
;
}
}
memberLabelId
=
this
.
getMemberLabel
(
state
,
hmDTO
.
getMemberLabelId
(),
wxEnterpriseId
,
linkId
)
;
memberLabelId
=
this
.
getMemberLabel
(
state
,
hmDTO
.
getMemberLabelId
(),
wxEnterpriseId
,
linkId
)
;
hyClerkId
=
this
.
getHmClerk
(
hmDTO
,
wxEnterpriseId
,
staffId
)
;
hyClerkId
=
this
.
welcomeSendService
.
getHmClerk
(
hmDTO
,
wxEnterpriseId
,
staffId
)
;
if
(
StringUtils
.
isBlank
(
hyClerkId
))
{
if
(
StringUtils
.
isBlank
(
hyClerkId
))
{
log
.
info
(
"【新增外部联系人】hm未获取到导购,staffId={}"
,
staffId
);
log
.
info
(
"【新增外部联系人】hm未获取到导购,staffId={}"
,
staffId
);
return
;
return
;
...
@@ -549,7 +531,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -549,7 +531,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
TabHaobanClerkMainStoreRelated
mainStoreRelated
=
clerkMainStoreRelatedService
.
getMainStoreByStaffId
(
staffId
,
wxEnterpriseId
);
TabHaobanClerkMainStoreRelated
mainStoreRelated
=
clerkMainStoreRelatedService
.
getMainStoreByStaffId
(
staffId
,
wxEnterpriseId
);
if
(
mainStoreRelated
==
null
)
{
if
(
mainStoreRelated
==
null
)
{
log
.
info
(
"【新增外部联系人】主门店为空:staffId={}"
,
staffId
);
log
.
info
(
"【新增外部联系人】主门店为空:staffId={}"
,
staffId
);
this
.
sendWelcome
(
dto
,
qwDTO
,
null
,
staffId
,
null
,
null
);
//
this.sendWelcome(dto, qwDTO, null, staffId, null , null);
return
;
return
;
}
}
staffClerkRelationDTO
=
staffClerkRelationService
.
getOneBindByStoreId
(
staffId
,
mainStoreRelated
.
getStoreId
());
staffClerkRelationDTO
=
staffClerkRelationService
.
getOneBindByStoreId
(
staffId
,
mainStoreRelated
.
getStoreId
());
...
@@ -604,32 +586,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -604,32 +586,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
}
}
}
// 获取hm关联的导购
private
String
getHmClerk
(
HmQrcodeDTO
hmDTO
,
String
wxEnterpriseId
,
String
staffId
)
{
Long
hmId
=
hmDTO
.
getHmId
()
;
if
(
hmDTO
.
getHmType
()
==
1
)
{
return
hmDTO
.
getClerkId
()
;
}
else
if
(
hmDTO
.
getHmType
()
==
2
)
{
//有主门店导购绑定主导购,没有主门店导购绑定第一个导购,其余随机
HmClerkRelationDTO
hmClerkRelationDTO
=
null
;
TabHaobanClerkMainStoreRelated
mainStoreRelated
=
clerkMainStoreRelatedService
.
getMainStoreByStaffId
(
staffId
,
wxEnterpriseId
);
if
(
mainStoreRelated
!=
null
)
{
StaffClerkRelationDTO
relationDTO
=
staffClerkRelationService
.
getOneBindByStoreId
(
staffId
,
mainStoreRelated
.
getStoreId
());
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getHmClerkByHmIdAndClerkId
(
hmId
,
relationDTO
.
getClerkId
());
if
(
hmClerkRelationDTO
==
null
)
{
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getOneHmClerkByHmIdAndStaffId
(
hmId
,
staffId
);
if
(
hmClerkRelationDTO
==
null
)
{
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getOneHmClerkByHmId
(
hmId
);
}
}
}
else
{
hmClerkRelationDTO
=
hmClerkRelationApiService
.
getOneHmClerkByHmId
(
hmId
);
}
return
hmClerkRelationDTO
.
getClerkId
()
;
}
return
null
;
}
// 获取hm配置的会员标签
// 获取hm配置的会员标签
private
String
getMemberLabel
(
String
state
,
String
hmMemberLableId
,
String
wxEnterpriseId
,
Long
linkId
)
{
private
String
getMemberLabel
(
String
state
,
String
hmMemberLableId
,
String
wxEnterpriseId
,
Long
linkId
)
{
if
(
state
.
startsWith
(
Manage3Constants
.
HM
))
{
if
(
state
.
startsWith
(
Manage3Constants
.
HM
))
{
...
@@ -714,7 +670,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -714,7 +670,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
}
String
storeId
=
staffClerkRelationDTO
.
getStoreId
();
String
storeId
=
staffClerkRelationDTO
.
getStoreId
();
this
.
saveExternalClerk
(
memberId
,
staffId
,
dto
,
staffClerkRelationDTO
,
1
);
this
.
saveExternalClerk
(
memberId
,
staffId
,
dto
,
staffClerkRelationDTO
,
1
);
this
.
sendWelcome
(
dto
,
qwDTO
,
enterpriseId
,
staffId
,
clerkId
,
memberId
);
//
this.sendWelcome(dto, qwDTO, enterpriseId, staffId, clerkId,memberId);
//同步好友标签
//同步好友标签
this
.
pushTagSync
(
memberId
,
wxEnterpriseId
,
enterpriseId
);
this
.
pushTagSync
(
memberId
,
wxEnterpriseId
,
enterpriseId
);
//回调给会员,更新是否为企微好友
//回调给会员,更新是否为企微好友
...
@@ -853,266 +809,11 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -853,266 +809,11 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
*/
*/
private
void
addFriendByWelcome
(
MemberUnionidRelatedDTO
dto
,
StaffClerkRelationDTO
staffClerkRelationDTO
,
WxEnterpriseQwDTO
qwDTO
)
{
private
void
addFriendByWelcome
(
MemberUnionidRelatedDTO
dto
,
StaffClerkRelationDTO
staffClerkRelationDTO
,
WxEnterpriseQwDTO
qwDTO
)
{
String
staffId
=
staffClerkRelationDTO
.
getStaffId
();
String
staffId
=
staffClerkRelationDTO
.
getStaffId
();
String
clerkId
=
staffClerkRelationDTO
.
getClerkId
();
String
enterpriseId
=
staffClerkRelationDTO
.
getEnterpriseId
();
//发送欢迎语
//发送欢迎语
sendWelcome
(
dto
,
qwDTO
,
enterpriseId
,
staffId
,
clerkId
,
null
);
//
sendWelcome(dto, qwDTO, enterpriseId, staffId, clerkId,null);
//保存好友关系
//保存好友关系
this
.
saveExternalClerk
(
null
,
staffId
,
dto
,
staffClerkRelationDTO
,
4
);
this
.
saveExternalClerk
(
null
,
staffId
,
dto
,
staffClerkRelationDTO
,
4
);
}
}
/**
* 发送欢迎语
*
* @param dto
* @param wxEnterpriseDTO
* @param enterpriseId
* @param staffId
*/
private
void
sendWelcome
(
MemberUnionidRelatedDTO
dto
,
WxEnterpriseQwDTO
wxEnterpriseDTO
,
String
enterpriseId
,
String
staffId
,
String
clerkId
,
String
memberId
)
{
log
.
info
(
"发送欢迎语:dto:{},staffId:{}"
,
JSONObject
.
toJSONString
(
dto
),
staffId
);
String
welcomeCode
=
dto
.
getWelcomeCode
();
String
state
=
dto
.
getState
();
String
wxEnterpriseId
=
wxEnterpriseDTO
.
getWxEnterpriseId
();
QywxErrorLogDTO
errLog
=
new
QywxErrorLogDTO
();
errLog
.
setWxEnterpriseId
(
wxEnterpriseId
);
errLog
.
setMemberId
(
memberId
);
errLog
.
setExternalUserId
(
dto
.
getExternalUserid
());
errLog
.
setTraceId
(
ProviderLocalTag
.
tag
.
get
().
traceId
);
errLog
.
setQywxErrorType
(
1
);
if
(
StringUtils
.
isBlank
(
welcomeCode
))
{
log
.
error
(
"welcomeCode为空,请检查是否使用企微的欢迎语:{}"
,
wxEnterpriseId
);
try
{
errLog
.
setScenario
(
"欢迎语"
);
errLog
.
setErrorContent
(
"welcomeCode空,GIC不处理,使用企微发送欢迎语"
);
clientInstance
.
sendMessage
(
Manage3Constants
.
QYWX_ERROR_MSG
,
JSON
.
toJSONString
(
errLog
));
}
catch
(
Exception
e
)
{
log
.
error
(
"发送消息失败:{}"
,
e
.
getMessage
(),
e
);
}
return
;
}
String
relationKey
=
SecureUtil
.
md5
(
staffId
+
dto
.
getExternalUserid
());
WelcomeDetailBO
welcomeDetailBO
=
null
;
if
(
StringUtils
.
isNotBlank
(
state
)
&&
(
state
.
startsWith
(
Manage3Constants
.
HM
)
||
state
.
startsWith
(
Manage3Constants
.
DT
)))
{
log
.
info
(
"特殊欢迎语 state:{}"
,
state
);
WelcomeReferBO
welcomeReferBo
=
getWelcomeReferBo
(
state
);
welcomeDetailBO
=
welcomeService
.
getMatchWelcomeWithReferId
(
staffId
,
wxEnterpriseId
,
welcomeReferBo
);
}
else
{
welcomeDetailBO
=
welcomeService
.
getMatchWelcome
(
staffId
,
wxEnterpriseId
);
}
if
(
Objects
.
isNull
(
welcomeDetailBO
))
{
log
.
info
(
"欢迎语未配置:wxEnterpriseId:{}"
,
wxEnterpriseId
);
return
;
}
//内容
String
content
=
welcomeDetailBO
.
getWelcomeContent
().
replaceAll
(
"<微信昵称>"
,
Matcher
.
quoteReplacement
(
dto
.
getExternalName
()));
QywxWelcomeMsgDTO
qywxWelcomeMsgDTO
=
new
QywxWelcomeMsgDTO
();
// 欢迎语内容
qywxWelcomeMsgDTO
.
setText
(
content
);
//欢迎语类型
List
<
QywxExternalMessageBaseDTO
>
attachments
=
new
ArrayList
<>();
// 开始设置欢迎语附件
List
<
WelcomeMediaBO
>
mediaList
=
welcomeDetailBO
.
getWelcomeMediaList
();
log
.
info
(
"欢迎语发送附件list:{}"
,
JSON
.
toJSONString
(
mediaList
));
mediaList
.
forEach
(
one
->
{
Integer
mediaType
=
one
.
getMediaType
();
if
(
WelcomeMediaTypeEnum
.
IMAGE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddImage
(
attachments
,
one
,
wxEnterpriseDTO
.
getThirdCorpid
());
}
if
(
WelcomeMediaTypeEnum
.
VIDEO
.
getCode
().
equals
(
mediaType
))
{
attachmentAddVideo
(
attachments
,
one
,
wxEnterpriseDTO
.
getThirdCorpid
());
}
if
(
WelcomeMediaTypeEnum
.
FILE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddFile
(
attachments
,
one
,
wxEnterpriseDTO
.
getThirdCorpid
());
}
if
(
WelcomeMediaTypeEnum
.
LINK
.
getCode
().
equals
(
mediaType
))
{
attachmentAddLink
(
attachments
,
one
);
}
if
(
WelcomeMediaTypeEnum
.
PROGRAM
.
getCode
().
equals
(
mediaType
))
{
attachmentAddProgram
(
attachments
,
one
,
wxEnterpriseId
);
}
if
(
WelcomeMediaTypeEnum
.
PARAM_PROGRAM
.
getCode
().
equals
(
mediaType
))
{
attachmentAddParamProgram
(
attachments
,
enterpriseId
,
wxEnterpriseId
,
relationKey
);
}
if
(
WelcomeMediaTypeEnum
.
PARAM_QRCODE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddParamQrCode
(
attachments
,
enterpriseId
,
clerkId
,
wxEnterpriseDTO
.
getThirdCorpid
(),
relationKey
);
}
});
if
(
CollectionUtils
.
isNotEmpty
(
attachments
))
{
qywxWelcomeMsgDTO
.
setAttachments
(
attachments
);
}
qywxWelcomeMsgDTO
.
setWelcomeCode
(
welcomeCode
);
String
result
=
null
;
if
(
dto
.
getSuiteid
().
equals
(
SELF_APP
))
{
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
dto
.
getWxEnterpriseId
(),
SecretTypeEnum
.
CUSTOMIZED_APP
.
getVal
());
result
=
qywxUserApiService
.
sendSelfWelcomeMsgByExternal
(
dto
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
qywxWelcomeMsgDTO
);
}
else
{
result
=
qywxUserApiService
.
sendWelcomeMsgByExternal
(
dto
.
getCorpid
(),
config
.
getWxSuiteid
(),
qywxWelcomeMsgDTO
);
}
log
.
info
(
"发送欢迎语 params:{},返回={}"
,
JSON
.
toJSONString
(
qywxWelcomeMsgDTO
),
result
);
if
(
StringUtils
.
isNotBlank
(
result
))
{
JSONObject
json
=
JSON
.
parseObject
(
result
)
;
int
errcode
=
json
.
getIntValue
(
"errcode"
)
;
if
(
0
!=
errcode
)
{
try
{
errLog
.
setScenario
(
"欢迎语"
);
errLog
.
setErrorContent
(
result
);
clientInstance
.
sendMessage
(
Manage3Constants
.
QYWX_ERROR_MSG
,
JSON
.
toJSONString
(
errLog
));
}
catch
(
Exception
e
)
{
log
.
error
(
"发送消息失败:{}"
,
e
.
getMessage
(),
e
);
}
}
}
}
/**
* 获取链接或者活码id
*
* @param state
* @return
*/
private
WelcomeReferBO
getWelcomeReferBo
(
String
state
)
{
WelcomeReferBO
welcomeReferBo
=
new
WelcomeReferBO
();
String
id
=
state
.
substring
(
2
);
if
(
state
.
contains
(
Manage3Constants
.
HM
))
{
welcomeReferBo
.
setType
(
HmWelcomeReferType
.
HM
.
getCode
());
welcomeReferBo
.
setReferId
(
id
);
}
else
if
(
state
.
contains
(
Manage3Constants
.
DT
))
{
KeyDataLinkBO
dataForHmLink
=
keyDataService
.
getDataForHmLink
(
id
);
if
(
dataForHmLink
!=
null
)
{
welcomeReferBo
.
setType
(
HmWelcomeReferType
.
LINK
.
getCode
());
welcomeReferBo
.
setReferId
(
Convert
.
toStr
(
dataForHmLink
.
getLinkId
()));
}
}
return
welcomeReferBo
;
}
private
void
attachmentAddImage
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
String
mediaUrl
=
media
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
log
.
info
(
"欢迎语发送图片返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
qywxImageExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxImageExternalBaseDTO
);
}
}
private
void
attachmentAddVideo
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
String
mediaUrl
=
media
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
VIDEO
.
getCode
());
log
.
info
(
"欢迎语发送视频返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxVideoExternalBaseDTO
qywxVideoExternalBaseDTO
=
new
QywxVideoExternalBaseDTO
();
qywxVideoExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxVideoExternalBaseDTO
);
}
}
private
void
attachmentAddFile
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
String
mediaUrl
=
media
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
FILE
.
getCode
());
log
.
info
(
"欢迎语发送文件返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxFileExternalBaseDTO
qywxFileExternalBaseDTO
=
new
QywxFileExternalBaseDTO
();
qywxFileExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxFileExternalBaseDTO
);
}
}
private
void
attachmentAddLink
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
)
{
String
mediaTitle
=
media
.
getMediaTitle
();
String
mediaUrl
=
media
.
getMediaUrl
();
QywxLinkExternalBaseDTO
qywxLinkExternalBaseDTO
=
new
QywxLinkExternalBaseDTO
();
qywxLinkExternalBaseDTO
.
setTitle
(
mediaTitle
);
qywxLinkExternalBaseDTO
.
setUrl
(
mediaUrl
);
attachments
.
add
(
qywxLinkExternalBaseDTO
);
}
private
void
attachmentAddProgram
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
wxEnterpriseId
)
{
log
.
info
(
"发送小程序:wxEnterpriseId:{}"
,
wxEnterpriseId
);
String
miniprogramSettingId
=
media
.
getMiniprogramSettingId
();
TabMiniprogramSetting
miniprogramSetting
=
miniprogramSettingService
.
getById
(
miniprogramSettingId
);
if
(
Objects
.
isNull
(
miniprogramSetting
)
||
miniprogramSetting
.
getStatusFlag
()
==
0
)
{
log
.
info
(
"小程序不存在或已被删除, miniprogramSettingId:{}"
,
miniprogramSettingId
);
return
;
}
QywxMiniprogramExternalBaseDTO
messageBaseDTO
=
new
QywxMiniprogramExternalBaseDTO
();
messageBaseDTO
.
setAppid
(
miniprogramSetting
.
getAppId
());
messageBaseDTO
.
setPicMediaId
(
miniprogramSetting
.
getMediaId
());
messageBaseDTO
.
setTitle
(
miniprogramSetting
.
getTitle
());
messageBaseDTO
.
setPage
(
media
.
getMiniProgramPage
());
attachments
.
add
(
messageBaseDTO
);
}
private
void
attachmentAddParamProgram
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
String
enterpriseId
,
String
wxEnterpriseId
,
String
relationKey
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
)
||
StringUtils
.
isEmpty
(
relationKey
))
{
log
.
info
(
"带参二维码无法发送"
);
return
;
}
log
.
info
(
"发送带参小程序:wxEnterpriseId:{}"
,
wxEnterpriseId
);
//发送小程序
TabMiniprogramSetting
miniprogramSetting
=
miniprogramSettingService
.
getMiniprogramSetting
(
wxEnterpriseId
,
enterpriseId
);
if
(
null
==
miniprogramSetting
)
{
log
.
info
(
"需要配置小程序配置:wxEnterpriseId:{},enterpriseId:{}"
,
wxEnterpriseId
,
enterpriseId
);
return
;
}
QywxMiniprogramExternalBaseDTO
messageBaseDTO
=
new
QywxMiniprogramExternalBaseDTO
();
messageBaseDTO
.
setAppid
(
miniprogramSetting
.
getAppId
());
messageBaseDTO
.
setPicMediaId
(
miniprogramSetting
.
getMediaId
());
messageBaseDTO
.
setTitle
(
miniprogramSetting
.
getTitle
());
messageBaseDTO
.
setPage
(
config
.
getMemberOpenPage
()
+
relationKey
);
attachments
.
add
(
messageBaseDTO
);
}
private
void
attachmentAddParamQrCode
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
String
enterpriseId
,
String
clerkId
,
String
corpid
,
String
relationKey
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
)
||
StringUtils
.
isEmpty
(
clerkId
))
{
log
.
info
(
"带参小程序无法发送"
);
return
;
}
//带参数的公众号二维码
String
sceneStr
=
"QWHY_"
+
relationKey
+
"_"
+
clerkId
;
//30天失效
QRcodeDTO
qRcodePic
=
imageService
.
getQRcodePic
(
enterpriseId
,
sceneStr
,
2592000
);
log
.
info
(
"参数的公众号二维码返回:{}"
,
JSON
.
toJSONString
(
qRcodePic
));
if
(
qRcodePic
!=
null
)
{
String
downloadUrl
=
qRcodePic
.
getPicUploadResDTO
().
downloadUrl
;
String
[]
arr
=
downloadUrl
.
split
(
"/"
);
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
downloadUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
log
.
info
(
"欢迎语发送带参数的公众号企微二维码返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
qywxImageExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxImageExternalBaseDTO
);
}
}
}
/**
/**
* 组装数据
* 组装数据
*
*
...
@@ -1869,10 +1570,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
...
@@ -1869,10 +1570,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
externalClerkRelatedApiService
.
bindMemberIdExternalById
(
externalClerkRelated
.
getExternalClerkRelatedId
(),
enterpriseId
,
memberId
,
unionid
);
externalClerkRelatedApiService
.
bindMemberIdExternalById
(
externalClerkRelated
.
getExternalClerkRelatedId
(),
enterpriseId
,
memberId
,
unionid
);
}
}
// @Override
// public void addDelFriendEventTest(String param) {
// log.info("addDelFriendEventTest:{}", param);
// }
/**
/**
* 获取客户详情列表
* 获取客户详情列表
*
*
...
...
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