|
@@ -2338,108 +2338,106 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
- if (welcomeCode != null && welcomeCode != "") {
|
|
|
|
|
- if (qwUser != null) {
|
|
|
|
|
- // 查询成员的欢迎语以及欢迎图片
|
|
|
|
|
- log.info("qw_user_id:{},external_id:{}: 查询欢迎语开始", qwUser.getId(), externalUserID);
|
|
|
|
|
- QwFriendWelcomeVO qwFriendWelcomeVO = qwFriendWelcomeMapper.selectQwFriendWelcomeByUserIdVO(qwUser.getId(), corpId);
|
|
|
|
|
- log.info("qw_user_id:{},external_id:{}: 查询欢迎语结束", qwUser.getId(), externalUserID);
|
|
|
|
|
- if (qwFriendWelcomeVO != null) {
|
|
|
|
|
- SendWelcomeMsgParam sendWelcomeMsgParam = new SendWelcomeMsgParam();
|
|
|
|
|
- sendWelcomeMsgParam.setWelcome_code(welcomeCode);
|
|
|
|
|
- ArrayList<String> msgParamList=new ArrayList<>();
|
|
|
|
|
- if (qwFriendWelcomeVO.getIsDayparting().equals("1")) {
|
|
|
|
|
- List<QwFriendWelcomeDayPart.Schedule> schedules = JSON.parseArray(qwFriendWelcomeVO.getDaypartingItemlist(), QwFriendWelcomeDayPart.Schedule.class);
|
|
|
|
|
- LocalTime now = LocalTime.now();
|
|
|
|
|
- Integer week = LocalDate.now().getDayOfWeek().getValue();
|
|
|
|
|
- boolean match = false;
|
|
|
|
|
- for (QwFriendWelcomeDayPart.Schedule schedule : schedules) {
|
|
|
|
|
- if (schedule.getWeek().contains(week)) {
|
|
|
|
|
- LocalTime start = LocalTime.parse(schedule.getStartTime());
|
|
|
|
|
- LocalTime end = LocalTime.parse(schedule.getEndTime().equals("24:00") ? "23:59:59" : schedule.getEndTime());
|
|
|
|
|
- if (!now.isBefore(start) && !now.isAfter(end)) {
|
|
|
|
|
- TextMessage textMessage = new TextMessage();
|
|
|
|
|
- textMessage.setContent(schedule.getWelcomeText());
|
|
|
|
|
- sendWelcomeMsgParam.setText(textMessage);
|
|
|
|
|
- msgParamList.add(schedule.getWelcomeText());
|
|
|
|
|
- List<SendWelcomeMsgParam.Attachment> attachments = schedule.getAttachments();
|
|
|
|
|
- List<SendWelcomeMsgParam.Attachment> attachmentsMatch = attachmentsTools(attachments, qwUser, corpId, contact.getId());
|
|
|
|
|
- sendWelcomeMsgParam.setAttachments(attachmentsMatch);
|
|
|
|
|
- attachmentsMatch.forEach(item->{
|
|
|
|
|
- if (("link").equals(item.getMsgtype())) {
|
|
|
|
|
- msgParamList.add(item.getLink().getUrl());
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- match = true;
|
|
|
|
|
- break; // 找到匹配项后退出整个for循环
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (welcomeCode != null && !welcomeCode.isEmpty()) {
|
|
|
|
|
+ // 查询成员的欢迎语以及欢迎图片
|
|
|
|
|
+ log.info("qw_user_id:{},external_id:{}: 查询欢迎语开始", qwUser.getId(), externalUserID);
|
|
|
|
|
+ QwFriendWelcomeVO qwFriendWelcomeVO = qwFriendWelcomeMapper.selectQwFriendWelcomeByUserIdVO(qwUser.getId(), corpId);
|
|
|
|
|
+ log.info("qw_user_id:{},external_id:{}: 查询欢迎语结束", qwUser.getId(), externalUserID);
|
|
|
|
|
+ if (qwFriendWelcomeVO != null) {
|
|
|
|
|
+ SendWelcomeMsgParam sendWelcomeMsgParam = new SendWelcomeMsgParam();
|
|
|
|
|
+ sendWelcomeMsgParam.setWelcome_code(welcomeCode);
|
|
|
|
|
+ List<String> msgParamList = new ArrayList<>();
|
|
|
|
|
+ if (qwFriendWelcomeVO.getIsDayparting().equals("1")) {
|
|
|
|
|
+ List<QwFriendWelcomeDayPart.Schedule> schedules = JSON.parseArray(qwFriendWelcomeVO.getDaypartingItemlist(), QwFriendWelcomeDayPart.Schedule.class);
|
|
|
|
|
+ LocalTime now = LocalTime.now();
|
|
|
|
|
+ Integer week = LocalDate.now().getDayOfWeek().getValue();
|
|
|
|
|
+ boolean match = false;
|
|
|
|
|
+ for (QwFriendWelcomeDayPart.Schedule schedule : schedules) {
|
|
|
|
|
+ if (schedule.getWeek().contains(week)) {
|
|
|
|
|
+ LocalTime start = LocalTime.parse(schedule.getStartTime());
|
|
|
|
|
+ LocalTime end = LocalTime.parse(schedule.getEndTime().equals("24:00") ? "23:59:59" : schedule.getEndTime());
|
|
|
|
|
+ if (!now.isBefore(start) && !now.isAfter(end)) {
|
|
|
|
|
+ TextMessage textMessage = new TextMessage();
|
|
|
|
|
+ textMessage.setContent(schedule.getWelcomeText());
|
|
|
|
|
+ sendWelcomeMsgParam.setText(textMessage);
|
|
|
|
|
+ msgParamList.add(schedule.getWelcomeText());
|
|
|
|
|
+ List<SendWelcomeMsgParam.Attachment> attachments = schedule.getAttachments();
|
|
|
|
|
+ List<SendWelcomeMsgParam.Attachment> attachmentsMatch = attachmentsTools(attachments, qwUser, corpId, contact.getId());
|
|
|
|
|
+ sendWelcomeMsgParam.setAttachments(attachmentsMatch);
|
|
|
|
|
+ attachmentsMatch.forEach(item->{
|
|
|
|
|
+ if (("link").equals(item.getMsgtype())) {
|
|
|
|
|
+ msgParamList.add(item.getLink().getUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ match = true;
|
|
|
|
|
+ break; // 找到匹配项后退出整个for循环
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 如果没有找到匹配项
|
|
|
|
|
- if (!match) {
|
|
|
|
|
- TextMessage textMessage = new TextMessage();
|
|
|
|
|
- textMessage.setContent(qwFriendWelcomeVO.getWelcomeText());
|
|
|
|
|
- sendWelcomeMsgParam.setText(textMessage);
|
|
|
|
|
- msgParamList.add(qwFriendWelcomeVO.getWelcomeText());
|
|
|
|
|
- List<SendWelcomeMsgParam.Attachment> attachmentsAll = JSON.parseArray(qwFriendWelcomeVO.getAttachments(), SendWelcomeMsgParam.Attachment.class);
|
|
|
|
|
- List<SendWelcomeMsgParam.Attachment> attachmentsNotMach = attachmentsTools(attachmentsAll, qwUser, corpId, contact.getId());
|
|
|
|
|
- sendWelcomeMsgParam.setAttachments(attachmentsNotMach);
|
|
|
|
|
- attachmentsNotMach.forEach(item->{
|
|
|
|
|
- if (("link").equals(item.getMsgtype())) {
|
|
|
|
|
- msgParamList.add(item.getLink().getUrl());
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- // 不分时段
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果没有找到匹配项
|
|
|
|
|
+ if (!match) {
|
|
|
TextMessage textMessage = new TextMessage();
|
|
TextMessage textMessage = new TextMessage();
|
|
|
textMessage.setContent(qwFriendWelcomeVO.getWelcomeText());
|
|
textMessage.setContent(qwFriendWelcomeVO.getWelcomeText());
|
|
|
sendWelcomeMsgParam.setText(textMessage);
|
|
sendWelcomeMsgParam.setText(textMessage);
|
|
|
msgParamList.add(qwFriendWelcomeVO.getWelcomeText());
|
|
msgParamList.add(qwFriendWelcomeVO.getWelcomeText());
|
|
|
- // 设置所有附件
|
|
|
|
|
List<SendWelcomeMsgParam.Attachment> attachmentsAll = JSON.parseArray(qwFriendWelcomeVO.getAttachments(), SendWelcomeMsgParam.Attachment.class);
|
|
List<SendWelcomeMsgParam.Attachment> attachmentsAll = JSON.parseArray(qwFriendWelcomeVO.getAttachments(), SendWelcomeMsgParam.Attachment.class);
|
|
|
- //加短链
|
|
|
|
|
- List<SendWelcomeMsgParam.Attachment> attachments = attachmentsTools(attachmentsAll, qwUser, corpId, contact.getId());
|
|
|
|
|
- sendWelcomeMsgParam.setAttachments(attachments);
|
|
|
|
|
- attachments.forEach(item->{
|
|
|
|
|
|
|
+ List<SendWelcomeMsgParam.Attachment> attachmentsNotMach = attachmentsTools(attachmentsAll, qwUser, corpId, contact.getId());
|
|
|
|
|
+ sendWelcomeMsgParam.setAttachments(attachmentsNotMach);
|
|
|
|
|
+ attachmentsNotMach.forEach(item->{
|
|
|
if (("link").equals(item.getMsgtype())) {
|
|
if (("link").equals(item.getMsgtype())) {
|
|
|
msgParamList.add(item.getLink().getUrl());
|
|
msgParamList.add(item.getLink().getUrl());
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
- log.info("qw_user_id:{},external_id:{}: 请求发送欢迎语开始", qwUser.getId(), externalUserID);
|
|
|
|
|
- QwResult qwResult = qwApiService.sendWelcomeMsg(sendWelcomeMsgParam, corpId);
|
|
|
|
|
- log.info("qw_user_id:{},external_id:{}: 请求发送欢迎语结束", qwUser.getId(), externalUserID);
|
|
|
|
|
- logger.info("发送好友欢迎语的参数:" + sendWelcomeMsgParam+"发送好友欢迎语结果:" + qwResult);
|
|
|
|
|
- if (qwResult.getErrcode()==41050||qwResult.getErrcode()==41051){
|
|
|
|
|
- log.info("qw_user_id:{},external_id:{}: 欢迎语状态错误进入补发逻辑:{}", qwUser.getId(), externalUserID, qwResult.getErrcode());
|
|
|
|
|
- try {
|
|
|
|
|
- QwSopLogs sopLogs=new QwSopLogs();
|
|
|
|
|
- sopLogs.setQwUserid(userID);
|
|
|
|
|
- sopLogs.setExternalUserId(externalUserID);
|
|
|
|
|
- sopLogs.setExternalId(contact.getId());
|
|
|
|
|
- sopLogs.setLogType(2);
|
|
|
|
|
- sopLogs.setSendStatus(3L);
|
|
|
|
|
- sopLogs.setSendTime(sdf.format(new Date()));
|
|
|
|
|
- sopLogs.setCompanyId(qwUser.getCompanyId());
|
|
|
|
|
- sopLogs.setReceivingStatus(0L);
|
|
|
|
|
- sopLogs.setCorpId(qwUser.getCorpId());
|
|
|
|
|
- sopLogs.setSort(99999999);
|
|
|
|
|
- sopLogs.setSendType(7);
|
|
|
|
|
- sopLogs.setExternalUserName("补发欢迎语无客户昵称");
|
|
|
|
|
- sopLogs.setQwUserKey(qwUser.getId());
|
|
|
|
|
- //组装发送数据
|
|
|
|
|
- sopLogs.setContentJson(JSON.toJSONString(reissueFriendWelcomeSettings(sendWelcomeMsgParam)));
|
|
|
|
|
- iQwSopLogsService.insertQwSopLogs(sopLogs);
|
|
|
|
|
- logger.info("补欢迎语:" + qwExternalContact.getExternalUserId());
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
- logger.error("补发欢迎语异常:" + qwExternalContact.getExternalUserId(),e);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 不分时段
|
|
|
|
|
+ TextMessage textMessage = new TextMessage();
|
|
|
|
|
+ textMessage.setContent(qwFriendWelcomeVO.getWelcomeText());
|
|
|
|
|
+ sendWelcomeMsgParam.setText(textMessage);
|
|
|
|
|
+ msgParamList.add(qwFriendWelcomeVO.getWelcomeText());
|
|
|
|
|
+ // 设置所有附件
|
|
|
|
|
+ List<SendWelcomeMsgParam.Attachment> attachmentsAll = JSON.parseArray(qwFriendWelcomeVO.getAttachments(), SendWelcomeMsgParam.Attachment.class);
|
|
|
|
|
+ //加短链
|
|
|
|
|
+ List<SendWelcomeMsgParam.Attachment> attachments = attachmentsTools(attachmentsAll, qwUser, corpId, contact.getId());
|
|
|
|
|
+ sendWelcomeMsgParam.setAttachments(attachments);
|
|
|
|
|
+ attachments.forEach(item->{
|
|
|
|
|
+ if (("link").equals(item.getMsgtype())) {
|
|
|
|
|
+ msgParamList.add(item.getLink().getUrl());
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ log.info("qw_user_id:{},external_id:{}: 请求发送欢迎语开始", qwUser.getId(), externalUserID);
|
|
|
|
|
+ QwResult qwResult = qwApiService.sendWelcomeMsg(sendWelcomeMsgParam, corpId);
|
|
|
|
|
+ log.info("qw_user_id:{},external_id:{}: 请求发送欢迎语结束", qwUser.getId(), externalUserID);
|
|
|
|
|
+ logger.info("发送好友欢迎语的参数:" + sendWelcomeMsgParam+"发送好友欢迎语结果:" + qwResult);
|
|
|
|
|
+ if (qwResult.getErrcode()==41050||qwResult.getErrcode()==41051){
|
|
|
|
|
+ log.info("qw_user_id:{},external_id:{}: 欢迎语状态错误进入补发逻辑:{}", qwUser.getId(), externalUserID, qwResult.getErrcode());
|
|
|
|
|
+ try {
|
|
|
|
|
+ QwSopLogs sopLogs=new QwSopLogs();
|
|
|
|
|
+ sopLogs.setQwUserid(userID);
|
|
|
|
|
+ sopLogs.setExternalUserId(externalUserID);
|
|
|
|
|
+ sopLogs.setExternalId(contact.getId());
|
|
|
|
|
+ sopLogs.setLogType(2);
|
|
|
|
|
+ sopLogs.setSendStatus(3L);
|
|
|
|
|
+ sopLogs.setSendTime(sdf.format(new Date()));
|
|
|
|
|
+ sopLogs.setCompanyId(qwUser.getCompanyId());
|
|
|
|
|
+ sopLogs.setReceivingStatus(0L);
|
|
|
|
|
+ sopLogs.setCorpId(qwUser.getCorpId());
|
|
|
|
|
+ sopLogs.setSort(99999999);
|
|
|
|
|
+ sopLogs.setSendType(7);
|
|
|
|
|
+ sopLogs.setExternalUserName("补发欢迎语无客户昵称");
|
|
|
|
|
+ sopLogs.setQwUserKey(qwUser.getId());
|
|
|
|
|
+ //组装发送数据
|
|
|
|
|
+ sopLogs.setContentJson(JSON.toJSONString(reissueFriendWelcomeSettings(sendWelcomeMsgParam)));
|
|
|
|
|
+ iQwSopLogsService.insertQwSopLogs(sopLogs);
|
|
|
|
|
+ logger.info("补欢迎语:" + qwExternalContact.getExternalUserId());
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ logger.error("补发欢迎语异常:" + qwExternalContact.getExternalUserId(),e);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|