|
|
@@ -9,6 +9,7 @@ import com.fs.course.mapper.FsCourseSopAppLinkMapper;
|
|
|
import com.fs.gtPush.service.uniPush2Service;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
+import com.fs.his.utils.LinkUtil;
|
|
|
import com.fs.im.dto.OpenImMsgDTO;
|
|
|
import com.fs.im.dto.OpenImResponseDTO;
|
|
|
import com.fs.im.service.OpenIMService;
|
|
|
@@ -559,6 +560,123 @@ public class AsyncSopTestService {
|
|
|
return success;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * APP直播短链:加密为「太乙云养+码」后走 OpenIM 文本发送(与企微 pad 侧 sendAppShortLink 内容一致)
|
|
|
+ */
|
|
|
+ public boolean asyncSendMsgBySopAppLiveShortLinkNormalIM(
|
|
|
+ List<QwSopCourseFinishTempSetting.Setting> setting,
|
|
|
+ String cropId,
|
|
|
+ Long companyUserId,
|
|
|
+ Long fsUserId,
|
|
|
+ String logId) {
|
|
|
+
|
|
|
+ boolean success = true;
|
|
|
+ String remark = "APP直播短链发送成功";
|
|
|
+ final String appLiveShortLinkPrefix = "/pages_live/livingList?link=";
|
|
|
+
|
|
|
+ try {
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(fsUserId);
|
|
|
+
|
|
|
+ for (QwSopCourseFinishTempSetting.Setting item : setting) {
|
|
|
+ item.setSendStatus(2);
|
|
|
+ item.setSendRemarks("APP直播短链发送失败");
|
|
|
+
|
|
|
+ if (fsUser == null) {
|
|
|
+ item.setSendRemarks("未找到对应的用户信息");
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String miniProgramPage = StringUtils.isNotEmpty(item.getMiniprogramPage())
|
|
|
+ ? item.getMiniprogramPage() : item.getAppLinkUrl();
|
|
|
+ if (StringUtils.isEmpty(miniProgramPage)) {
|
|
|
+ item.setSendRemarks("APP直播短链页面路径为空");
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String sendShortLink = resolveAppLiveShortLink(miniProgramPage, appLiveShortLinkPrefix);
|
|
|
+ if (StringUtils.isEmpty(sendShortLink)) {
|
|
|
+ item.setSendRemarks("APP直播短链解析失败");
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ sendShortLink = sendShortLink.replace(".html", "");
|
|
|
+ String invitationCode = LinkUtil.encryptLink(sendShortLink);
|
|
|
+ if (StringUtils.isEmpty(invitationCode)) {
|
|
|
+ item.setSendRemarks("APP直播短链加密失败");
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ OpenImMsgDTO dto = new OpenImMsgDTO();
|
|
|
+ dto.setSendID("C" + companyUserId);
|
|
|
+ dto.setRecvID("U" + fsUserId);
|
|
|
+ dto.setContentType(101);
|
|
|
+ dto.setSessionType(1);
|
|
|
+
|
|
|
+ OpenImMsgDTO.Content content = new OpenImMsgDTO.Content();
|
|
|
+ content.setContent("太乙云养" + invitationCode);
|
|
|
+ dto.setContent(content);
|
|
|
+
|
|
|
+ OpenImResponseDTO resp = openIMService.openIMSendMsg(dto);
|
|
|
+ if (resp != null && resp.getErrCode() != null && resp.getErrCode() == 0) {
|
|
|
+ item.setSendStatus(1);
|
|
|
+ item.setSendRemarks("发送成功");
|
|
|
+ } else {
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ if (resp != null) {
|
|
|
+ item.setSendRemarks(resp.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ item.setSendRemarks("异常:" + e.getMessage());
|
|
|
+ log.error("APP直播短链发送异常 logId={}", logId, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ success = false;
|
|
|
+ remark = "APP直播短链发送失败";
|
|
|
+ log.error("APP直播短链发送外层异常 logId={}", logId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("APP直播短链发送完成,logId={},结果={}", logId, remark);
|
|
|
+ return success;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String resolveAppLiveShortLink(String miniProgramPage, String appLiveShortLinkPrefix) {
|
|
|
+ try {
|
|
|
+ if (miniProgramPage.startsWith(appLiveShortLinkPrefix)) {
|
|
|
+ com.alibaba.fastjson.JSONObject obj = com.alibaba.fastjson.JSONObject.parseObject(
|
|
|
+ miniProgramPage.substring(appLiveShortLinkPrefix.length()));
|
|
|
+ String linkId = obj != null ? obj.getString("link") : null;
|
|
|
+ if (StringUtils.isNotEmpty(linkId)) {
|
|
|
+ return appLiveShortLinkPrefix + linkId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (miniProgramPage.contains("livingInvite") && miniProgramPage.contains("s=")) {
|
|
|
+ String jsonPart = miniProgramPage.substring(miniProgramPage.indexOf("s=") + 2);
|
|
|
+ com.alibaba.fastjson.JSONObject obj = com.alibaba.fastjson.JSONObject.parseObject(jsonPart);
|
|
|
+ String linkId = obj != null ? obj.getString("link") : null;
|
|
|
+ if (StringUtils.isNotEmpty(linkId)) {
|
|
|
+ return appLiveShortLinkPrefix + linkId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析APP直播短链失败 page={}", miniProgramPage, e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
public boolean asyncSendMsgBySopAppLiveCardNormalIM(
|
|
|
List<QwSopCourseFinishTempSetting.Setting> setting,
|
|
|
String cropId,
|