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
37c541be
Commit
37c541be
authored
Apr 18, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自建-群发
parent
caaf2091
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
24 deletions
+74
-24
WelcomeSendServiceImpl.java
...n/manage/service/service/impl/WelcomeSendServiceImpl.java
+36
-16
MaterialApiServiceImpl.java
...nage/service/service/out/impl/MaterialApiServiceImpl.java
+26
-6
MiniprogramSettingServiceImpl.java
...rvice/service/out/impl/MiniprogramSettingServiceImpl.java
+12
-2
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/WelcomeSendServiceImpl.java
View file @
37c541be
...
...
@@ -171,13 +171,13 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
mediaList
.
forEach
(
one
->
{
Integer
mediaType
=
one
.
getMediaType
();
if
(
WelcomeMediaTypeEnum
.
IMAGE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddImage
(
attachments
,
one
,
corpid
);
attachmentAddImage
(
attachments
,
one
,
corpid
,
qwDTO
);
}
if
(
WelcomeMediaTypeEnum
.
VIDEO
.
getCode
().
equals
(
mediaType
))
{
attachmentAddVideo
(
attachments
,
one
,
corpid
);
attachmentAddVideo
(
attachments
,
one
,
corpid
,
qwDTO
);
}
if
(
WelcomeMediaTypeEnum
.
FILE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddFile
(
attachments
,
one
,
corpid
);
attachmentAddFile
(
attachments
,
one
,
corpid
,
qwDTO
);
}
if
(
WelcomeMediaTypeEnum
.
LINK
.
getCode
().
equals
(
mediaType
))
{
attachmentAddLink
(
attachments
,
one
);
...
...
@@ -196,7 +196,7 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
}
}
if
(
WelcomeMediaTypeEnum
.
PARAM_QRCODE
.
getCode
().
equals
(
mediaType
))
{
attachmentAddParamQrCode
(
attachments
,
enterpriseId
,
clerkId
,
corpid
,
relationKey
);
attachmentAddParamQrCode
(
attachments
,
enterpriseId
,
clerkId
,
corpid
,
relationKey
,
qwDTO
);
}
if
(
WelcomeMediaTypeEnum
.
PARAM_PROGRAM
.
getCode
().
equals
(
mediaType
))
{
attachmentAddParamProgram
(
attachments
,
enterpriseId
,
wxEnterpriseId
,
relationKey
);
...
...
@@ -256,11 +256,16 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
return
welcomeReferBo
;
}
private
void
attachmentAddImage
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
private
void
attachmentAddImage
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
,
WxEnterpriseQwDTO
qwDTO
)
{
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
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
secret
,
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
(),
selfFlag
);
log
.
info
(
"欢迎语发送图片返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
...
...
@@ -269,11 +274,16 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
}
}
private
void
attachmentAddVideo
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
private
void
attachmentAddVideo
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
,
WxEnterpriseQwDTO
qwDTO
)
{
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
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
secret
,
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
VIDEO
.
getCode
(),
selfFlag
);
log
.
info
(
"欢迎语发送视频返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxVideoExternalBaseDTO
qywxVideoExternalBaseDTO
=
new
QywxVideoExternalBaseDTO
();
...
...
@@ -282,11 +292,16 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
}
}
private
void
attachmentAddFile
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
)
{
private
void
attachmentAddFile
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
WelcomeMediaBO
media
,
String
corpid
,
WxEnterpriseQwDTO
qwDTO
)
{
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
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
secret
,
CommonUtil
.
getFileByte
(
mediaUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
FILE
.
getCode
(),
selfFlag
);
log
.
info
(
"欢迎语发送文件返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxFileExternalBaseDTO
qywxFileExternalBaseDTO
=
new
QywxFileExternalBaseDTO
();
...
...
@@ -344,7 +359,7 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
}
private
void
attachmentAddParamQrCode
(
List
<
QywxExternalMessageBaseDTO
>
attachments
,
String
enterpriseId
,
String
clerkId
,
String
corpid
,
String
relationKey
)
{
String
clerkId
,
String
corpid
,
String
relationKey
,
WxEnterpriseQwDTO
qwDTO
)
{
if
(
StringUtils
.
isEmpty
(
enterpriseId
)
||
StringUtils
.
isEmpty
(
clerkId
))
{
log
.
info
(
"带参小程序无法发送"
);
return
;
...
...
@@ -357,8 +372,13 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
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
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corpid
,
secret
,
CommonUtil
.
getFileByte
(
downloadUrl
),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
(),
selfFlag
);
log
.
info
(
"欢迎语发送带参数的公众号企微二维码返回:{}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
==
0
)
{
QywxImageExternalBaseDTO
qywxImageExternalBaseDTO
=
new
QywxImageExternalBaseDTO
();
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MaterialApiServiceImpl.java
View file @
37c541be
...
...
@@ -153,7 +153,12 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if
(
fileType
!=
null
)
{
String
[]
arr
=
url
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
()
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
()
,
secret
,
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
(),
selfFlag
);
if
(
jp
.
getErrorCode
()
==
0
)
{
materialDTO
.
setWxLastUploadTime
(
new
Date
());
materialDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
...
...
@@ -218,7 +223,12 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if
(
fileType
!=
null
&&
!
url
.
equals
(
oldUrl
))
{
String
[]
arr
=
url
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
secret
,
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
(),
selfFlag
);
if
(
jp
.
getErrorCode
()
==
0
)
{
materialDTO
.
setWxLastUploadTime
(
new
Date
());
materialDTO
.
setMediaId
(
jp
.
getResult
().
toString
());
...
...
@@ -267,7 +277,12 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
String
[]
arr
=
url
.
split
(
"/"
);
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
());
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
String
secret
=
config
.
getWxSuiteid
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
secret
,
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
(),
selfFlag
);
if
(
jp
.
getErrorCode
()
==
0
)
{
old
.
setWxLastUploadTime
(
new
Date
());
old
.
setMediaId
(
jp
.
getResult
().
toString
());
...
...
@@ -427,7 +442,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
materialDTO
.
setMaterialTitle
(
material
.
getMaterialTitle
());
}
materialDTO
.
setImgUrl
(
one
.
getMediaUrl
());
String
mediaId
=
uploadMediaToWx
(
qwDTO
.
getThirdCorpid
(),
one
.
getMediaUrl
());
String
mediaId
=
uploadMediaToWx
(
qwDTO
.
getThirdCorpid
(),
one
.
getMediaUrl
()
,
qwDTO
);
if
(
StringUtils
.
isNotEmpty
(
mediaId
))
{
materialDTO
.
setWxLastUploadTime
(
new
Date
());
materialDTO
.
setMediaId
(
mediaId
);
...
...
@@ -438,12 +453,17 @@ public class MaterialApiServiceImpl implements MaterialApiService {
materialService
.
batchInsertMaterial
(
materialList
);
}
private
String
uploadMediaToWx
(
String
corPid
,
String
url
)
{
private
String
uploadMediaToWx
(
String
corPid
,
String
url
,
WxEnterpriseQwDTO
qwDTO
)
{
String
[]
arr
=
url
.
split
(
"/"
);
// 先写死为图片类型, 以后有别的再扩展
QywxMediaTypeEnum
fileType
=
QywxMediaTypeEnum
.
IMAGE
;
int
count
=
arr
.
length
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corPid
,
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
());
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
String
secret
=
config
.
getWxSuiteid
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
corPid
,
secret
,
CommonUtil
.
getFileByte
(
url
),
arr
[
count
-
1
],
fileType
.
getCode
(),
selfFlag
);
if
(
jp
.
getErrorCode
()
==
0
)
{
return
jp
.
getResult
().
toString
();
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MiniprogramSettingServiceImpl.java
View file @
37c541be
...
...
@@ -62,7 +62,12 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
}
String
[]
arr
=
miniprogramSetting
.
getImageUrl
().
split
(
"/"
);
WxEnterpriseQwDTO
qwDTO
=
this
.
wxEnterpriseService
.
getQwInfo
(
miniprogramSetting
.
getWxEnterpriseId
())
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
miniprogramSetting
.
getImageUrl
()),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
secret
,
CommonUtil
.
getFileByte
(
miniprogramSetting
.
getImageUrl
()),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
(),
selfFlag
);
if
(
jp
.
getErrorCode
()
==
0
)
{
miniprogramSetting
.
setMediaTime
(
date
);
miniprogramSetting
.
setMediaId
(
jp
.
getResult
().
toString
());
...
...
@@ -116,7 +121,12 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
}
String
[]
arr
=
miniprogramSetting
.
getImageUrl
().
split
(
"/"
);
WxEnterpriseQwDTO
qwDTO
=
this
.
wxEnterpriseService
.
getQwInfo
(
wxEnterpriseId
)
;
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
config
.
getWxSuiteid
(),
CommonUtil
.
getFileByte
(
miniprogramSetting
.
getImageUrl
()),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
String
secret
=
config
.
getWxSuiteid
()
;
boolean
selfFlag
=
qwDTO
.
isSelf
()
;
if
(
selfFlag
)
{
secret
=
qwDTO
.
getSelfSecret
()
;
}
JSONResponse
jp
=
qywxSuiteApiService
.
uploadMedia
(
qwDTO
.
getThirdCorpid
(),
secret
,
CommonUtil
.
getFileByte
(
miniprogramSetting
.
getImageUrl
()),
arr
[
arr
.
length
-
1
],
QywxMediaTypeEnum
.
IMAGE
.
getCode
(),
selfFlag
);
if
(
jp
.
getErrorCode
()
==
0
)
{
miniprogramSetting
.
setMediaTime
(
date
);
miniprogramSetting
.
setMediaId
(
jp
.
getResult
().
toString
());
...
...
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