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
2f0d0fd4
Commit
2f0d0fd4
authored
Mar 28, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
欢迎语
parent
35d39090
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
329 additions
and
28 deletions
+329
-28
MemberUnionidRelatedApiServiceImpl.java
.../service/out/impl/MemberUnionidRelatedApiServiceImpl.java
+329
-28
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MemberUnionidRelatedApiServiceImpl.java
View file @
2f0d0fd4
...
...
@@ -7,8 +7,10 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.stream.Collectors
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -31,7 +33,10 @@ import com.gic.clerk.api.dto.ClerkDTO;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.EntityUtil
;
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.service.ImageService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.app.customer.dto.ChildDTO
;
import
com.gic.haoban.app.customer.dto.CustomerDTO
;
...
...
@@ -51,15 +56,20 @@ import com.gic.haoban.manage.api.dto.MemberStoreDTO;
import
com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO
;
import
com.gic.haoban.manage.api.dto.MemberUnionidWechatAccountQDTO
;
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.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.dto.qdto.hm.WxUserAddLogQDTO
;
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.ExternalClerkRelatedApiService
;
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.service.config.Config
;
import
com.gic.haoban.manage.service.dao.mapper.StaffMapper
;
...
...
@@ -71,26 +81,32 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import
com.gic.haoban.manage.service.entity.TabHaobanWxApplication
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
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.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.hm.HmLinkBO
;
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.ExternalClerkRelatedService
;
import
com.gic.haoban.manage.service.service.KeyDataService
;
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.SecretSettingService
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.WelcomeSe
ndSe
rvice
;
import
com.gic.haoban.manage.service.service.WelcomeService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseRelatedService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
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.WxUserAddLogService
;
import
com.gic.haoban.manage.service.util.CommonUtil
;
import
com.gic.haoban.manage.service.util.EmojiFilterUtil
;
import
com.gic.member.api.dto.MemberDTO
;
import
com.gic.member.api.dto.MemberSimpleDetailDTO
;
...
...
@@ -106,6 +122,14 @@ import com.gic.member.tag.api.service.MemberTagOpenApiService;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
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.QywxUserApiService
;
import
com.google.common.collect.Sets
;
...
...
@@ -152,6 +176,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
private
ExternalClerkRelatedService
externalClerkRelatedService
;
@Autowired
private
MiniprogramSettingService
miniprogramSettingService
;
@Autowired
private
WelcomeService
welcomeService
;
@Autowired
private
CheckQywxSettingApiService
checkQywxSettingApiService
;
@Autowired
private
CustomerApiService
customerApiService
;
...
...
@@ -166,6 +194,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
private
MemberStoreService
memberStoreService
;
@Autowired
private
ImageService
imageService
;
@Autowired
private
HmQrcodeApiService
hmQrcodeApiService
;
@Autowired
private
WxUserAddLogService
wxUserAddLogService
;
...
...
@@ -178,6 +208,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
private
MemberService
memberService
;
@Autowired
private
HmClerkRelationApiService
hmClerkRelationApiService
;
@Autowired
private
StaffMapper
staffMapper
;
@Autowired
private
MemberEntranceApiService
memberEntranceApiService
;
...
...
@@ -185,9 +217,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private
QywxSendService
qywxSendService
;
@Autowired
private
GroupChatService
groupChatService
;
@Autowired
private
WelcomeSendService
welcomeSendService
;
GicMQClient
instance
=
GICMQClientUtil
.
getClientInstance
();
private
static
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
()
;
@Override
public
void
dealQywxExternalUser
(
String
params
)
{
...
...
@@ -352,34 +384,19 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
DealQywxExternalUserPojo
dealQywxExternalUserPojo
=
new
DealQywxExternalUserPojo
();
dealQywxExternalUserPojo
.
setType
(
DealQywxExternalUserPojo
.
DealType
.
add
.
getType
());
dealQywxExternalUserPojo
.
setData
(
dto
);
this
.
sendWelcome
(
dto
);
GicMQClient
instance
=
GICMQClientUtil
.
getClientInstance
();
String
mqName
=
"dealQywxExternalUserMq"
;
if
(
this
.
mqCheck
(
dto
))
{
mqName
=
"dealQywxExternalUserMq2"
;
}
try
{
instance
.
sendMessage
(
mqName
,
JSONObject
.
toJSONString
(
dealQywxExternalUserPojo
)
,
180
);
instance
.
sendMessage
(
mqName
,
JSONObject
.
toJSONString
(
dealQywxExternalUserPojo
));
}
catch
(
Exception
e
)
{
log
.
info
(
"异步处理异常:{}"
,
e
);
}
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
private
boolean
mqCheck
(
QwFrientNoticeDTO
dto
)
{
int
maxCount
=
800
;
...
...
@@ -406,7 +423,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if
(
"wp59NLDQAAtTbif_SxAixUQVqMld4vug"
.
equals
(
corpid
))
{
maxCount
=
2
;
}
log
.
info
(
"dealQywxExternalUserMq2={},{},{}"
,
times
,
maxCount
,
wxEnterpriseId
);
log
.
info
(
"dealQywxExternalUserMq2={},{},{}"
,
wxEnterpriseId
,
times
,
maxCount
);
if
(
times
>
maxCount
)
{
if
(!
needToMq2
(
wxEnterpriseId
))
{
log
.
info
(
"加好友计数发送告警,id={}"
,
wxEnterpriseId
);
...
...
@@ -520,7 +537,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
return
;
}
memberLabelId
=
this
.
getMemberLabel
(
state
,
hmDTO
.
getMemberLabelId
(),
wxEnterpriseId
,
linkId
)
;
hyClerkId
=
this
.
welcomeSendService
.
getHmClerk
(
hmDTO
,
wxEnterpriseId
,
staffId
)
;
hyClerkId
=
this
.
getHmClerk
(
hmDTO
,
wxEnterpriseId
,
staffId
)
;
if
(
StringUtils
.
isBlank
(
hyClerkId
))
{
log
.
info
(
"【新增外部联系人】hm未获取到导购,staffId={}"
,
staffId
);
return
;
...
...
@@ -531,7 +548,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
TabHaobanClerkMainStoreRelated
mainStoreRelated
=
clerkMainStoreRelatedService
.
getMainStoreByStaffId
(
staffId
,
wxEnterpriseId
);
if
(
mainStoreRelated
==
null
)
{
log
.
info
(
"【新增外部联系人】主门店为空:staffId={}"
,
staffId
);
//
this.sendWelcome(dto, qwDTO, null, staffId, null , null);
this
.
sendWelcome
(
dto
,
qwDTO
,
null
,
staffId
,
null
,
null
);
return
;
}
staffClerkRelationDTO
=
staffClerkRelationService
.
getOneBindByStoreId
(
staffId
,
mainStoreRelated
.
getStoreId
());
...
...
@@ -586,6 +603,32 @@ 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配置的会员标签
private
String
getMemberLabel
(
String
state
,
String
hmMemberLableId
,
String
wxEnterpriseId
,
Long
linkId
)
{
if
(
state
.
startsWith
(
Manage3Constants
.
HM
))
{
...
...
@@ -670,7 +713,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
String
storeId
=
staffClerkRelationDTO
.
getStoreId
();
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
);
//回调给会员,更新是否为企微好友
...
...
@@ -809,11 +852,266 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
*/
private
void
addFriendByWelcome
(
MemberUnionidRelatedDTO
dto
,
StaffClerkRelationDTO
staffClerkRelationDTO
,
WxEnterpriseQwDTO
qwDTO
)
{
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
);
}
/**
* 发送欢迎语
*
* @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
);
}
}
}
/**
* 组装数据
*
...
...
@@ -1570,7 +1868,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
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