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
13980bf0
Commit
13980bf0
authored
Feb 10, 2022
by
墨竹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:好办欢迎语修改
parent
8c543db7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
22 deletions
+73
-22
MemberUnionidRelatedApiServiceImpl.java
.../service/out/impl/MemberUnionidRelatedApiServiceImpl.java
+73
-22
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MemberUnionidRelatedApiServiceImpl.java
View file @
13980bf0
...
...
@@ -29,7 +29,9 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.FriendSettingTypeEnum
;
import
com.gic.haoban.manage.api.enums.SecretTypeEnum
;
import
com.gic.haoban.manage.api.enums.WelcomeMediaTypeEnum
;
import
com.gic.haoban.manage.api.service.CheckQywxSettingApiService
;
import
com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService
;
import
com.gic.haoban.manage.api.service.MaterialApiService
;
...
...
@@ -44,6 +46,9 @@ import com.gic.haoban.manage.service.exception.WxApiLimitException;
import
com.gic.haoban.manage.service.pojo.DealQywxExternalUserPojo
;
import
com.gic.haoban.manage.service.pojo.ExternalUserPojo
;
import
com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo
;
import
com.gic.haoban.manage.service.pojo.bo.welcome.FriendSettingDetailBO
;
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.service.*
;
import
com.gic.haoban.manage.service.util.EmojiFilterUtil
;
import
com.gic.member.api.dto.MemberDTO
;
...
...
@@ -52,10 +57,8 @@ import com.gic.member.api.service.MemberOpenCardBusinessService;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.*
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxExternalMessageBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxImageExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxMiniprogramExternalBaseDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.QywxWelcomeMsgDTO
;
import
com.gic.wechat.api.dto.qywx.welcome.*
;
import
com.gic.wechat.api.enums.QywxExternalMessageTypeEnum
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.fwh.WeixinBaseFunService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
...
...
@@ -121,7 +124,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
private
MiniprogramSettingService
miniprogramSettingService
;
@Autowired
private
TabHaobanWelcomeMapper
welcomeMapper
;
private
WelcomeService
welcomeService
;
@Autowired
private
CheckQywxSettingApiService
checkQywxSettingApiService
;
@Autowired
...
...
@@ -513,8 +516,18 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private
void
sendWelcome
(
MemberUnionidRelatedDTO
dto
,
String
wxEnterpriseId
,
String
enterpriseId
,
String
staffId
,
boolean
sendApp
)
{
log
.
info
(
"发送欢迎语:dto:{},wxEnterpriseId:{},staffId:{},sendApp:{}"
,
JSONObject
.
toJSONString
(
dto
),
wxEnterpriseId
,
staffId
,
sendApp
);
String
relationKey
=
SecureUtil
.
md5
(
staffId
+
dto
.
getExternalUserid
());
TabWelcome
tabWelcome
=
welcomeMapper
.
selectByWxEnterpriseId
(
wxEnterpriseId
);
if
(
null
==
tabWelcome
||
tabWelcome
.
getOpenFlag
()
==
0
)
{
FriendSettingDetailBO
friendSetting
=
welcomeService
.
getFriendSetting
(
wxEnterpriseId
);
if
(
friendSetting
==
null
)
{
log
.
info
(
"欢迎语未配置:wxEnterpriseId:{}"
,
wxEnterpriseId
);
return
;
}
Integer
friendSettingType
=
friendSetting
.
getFriendSettingType
();
if
(
friendSettingType
.
equals
(
FriendSettingTypeEnum
.
NOT_TEXT
.
getCode
()))
{
log
.
info
(
"不发送好办欢迎语,用企微欢迎语:wxEnterpriseId:{}"
,
wxEnterpriseId
);
return
;
}
WelcomeDetailBO
welcomeDetailBO
=
welcomeService
.
getMatchWelcomeByDept
(
staffId
,
wxEnterpriseId
);
if
(
null
==
welcomeDetailBO
||
welcomeDetailBO
.
getOpenFlag
()
==
0
)
{
log
.
info
(
"欢迎语未配置:wxEnterpriseId:{}"
,
wxEnterpriseId
);
return
;
}
...
...
@@ -525,13 +538,13 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
String
externalName
=
dto
.
getExternalName
();
//内容
String
content
=
tabWelcome
.
getWelcomeContent
().
replaceAll
(
"<微信昵称>"
,
externalName
);
String
content
=
welcomeDetailBO
.
getWelcomeContent
().
replaceAll
(
"<微信昵称>"
,
externalName
);
QywxWelcomeMsgDTO
qywxWelcomeMsgDTO
=
new
QywxWelcomeMsgDTO
();
qywxWelcomeMsgDTO
.
setText
(
content
);
//欢迎语类型
List
<
QywxExternalMessageBaseDTO
>
attachments
=
new
ArrayList
<>();
// TODO: 2022/2/9 带参数的公众号二维码等配置
if
(
f
alse
)
{
if
(
f
riendSettingType
.
equals
(
FriendSettingTypeEnum
.
TEXT_AND_QRCODE
.
getCode
())
)
{
//带参数的公众号二维码
EnterpriseDTO
enterpriseDTO
=
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
String
sceneStr
=
"QWHY_"
+
relationKey
;
...
...
@@ -544,7 +557,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
qywxImageExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxImageExternalBaseDTO
);
}
}
else
{
}
else
if
(
friendSettingType
.
equals
(
FriendSettingTypeEnum
.
TEXT_AND_MINI_PROGRAM
.
getCode
()))
{
//小程序
//发送小程序
if
(
sendApp
)
{
...
...
@@ -561,17 +574,55 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
messageBaseDTO
.
setPage
(
config
.
getMemberOpenPage
()
+
relationKey
);
attachments
.
add
(
messageBaseDTO
);
}
//发送图片
String
welcomeImg
=
tabWelcome
.
getWelcomeImg
();
if
(
StringUtils
.
isNotBlank
(
welcomeImg
))
{
String
[]
arr
=
welcomeImg
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
(),
getFileByte
(
welcomeImg
),
arr
[
count
-
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
);
}
List
<
WelcomeMediaBO
>
welcomeMediaList
=
welcomeDetailBO
.
getWelcomeMediaList
();
if
(
CollectionUtils
.
isNotEmpty
(
welcomeMediaList
))
{
for
(
WelcomeMediaBO
welcomeMediaBO
:
welcomeMediaList
)
{
Integer
mediaType
=
welcomeMediaBO
.
getMediaType
();
if
(
mediaType
.
equals
(
WelcomeMediaTypeEnum
.
IMAGE
.
getCode
()))
{
String
mediaUrl
=
welcomeMediaBO
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
(),
getFileByte
(
mediaUrl
),
arr
[
count
-
1
],
QywxExternalMessageTypeEnum
.
IMAGE
.
getCode
());
log
.
info
(
"欢迎语发送图片返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
qywxImageExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxImageExternalBaseDTO
);
}
}
if
(
mediaType
.
equals
(
WelcomeMediaTypeEnum
.
VIDEO
.
getCode
()))
{
String
mediaUrl
=
welcomeMediaBO
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
(),
getFileByte
(
mediaUrl
),
arr
[
count
-
1
],
QywxExternalMessageTypeEnum
.
VIDEO
.
getCode
());
log
.
info
(
"欢迎语发送视频返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxVideoExternalBaseDTO
qywxVideoExternalBaseDTO
=
new
QywxVideoExternalBaseDTO
();
qywxVideoExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxVideoExternalBaseDTO
);
}
}
if
(
mediaType
.
equals
(
WelcomeMediaTypeEnum
.
FILE
.
getCode
()))
{
String
mediaUrl
=
welcomeMediaBO
.
getMediaUrl
();
String
[]
arr
=
mediaUrl
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
(),
getFileByte
(
mediaUrl
),
arr
[
count
-
1
],
QywxExternalMessageTypeEnum
.
FILE
.
getCode
());
log
.
info
(
"欢迎语发送文件返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxFileExternalBaseDTO
qywxFileExternalBaseDTO
=
new
QywxFileExternalBaseDTO
();
qywxFileExternalBaseDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
attachments
.
add
(
qywxFileExternalBaseDTO
);
}
}
if
(
mediaType
.
equals
(
WelcomeMediaTypeEnum
.
LINK
.
getCode
()))
{
String
mediaTitle
=
welcomeMediaBO
.
getMediaTitle
();
String
mediaUrl
=
welcomeMediaBO
.
getMediaUrl
();
QywxIinkExternalBaseDTO
qywxIinkExternalBaseDTO
=
new
QywxIinkExternalBaseDTO
();
qywxIinkExternalBaseDTO
.
setTitle
(
mediaTitle
);
qywxIinkExternalBaseDTO
.
setUrl
(
mediaUrl
);
attachments
.
add
(
qywxIinkExternalBaseDTO
);
}
}
}
...
...
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