|
|
@@ -33,6 +33,8 @@ import com.fs.course.dto.BatchUrgeCourseTaskDTO;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
+import com.fs.course.param.FsCourseLinkCreateParam;
|
|
|
+import com.fs.course.service.IFsUserCourseService;
|
|
|
import com.fs.fastGpt.service.AiHookService;
|
|
|
import com.fs.his.config.FsSmsConfig;
|
|
|
import com.fs.his.domain.FsDoctor;
|
|
|
@@ -136,6 +138,8 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
private SysConfigMapper sysConfigMapper;
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
+ @Autowired
|
|
|
+ private IFsUserCourseService fsUserCourseService;
|
|
|
|
|
|
|
|
|
// @Value("${openIM.prefix}")
|
|
|
@@ -1310,7 +1314,12 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
responseDTO.setErrMsg("短信发课参数不完整");
|
|
|
return responseDTO;
|
|
|
}
|
|
|
- CompanySmsTemp smsTemp = companySmsTempService.selectCompanySmsTempByCode(tempCode);
|
|
|
+ CompanySmsTemp smsTemp;
|
|
|
+ if (StringUtils.isNotEmpty(batchSmsLinkDTO.getProjectId().toString())) {
|
|
|
+ smsTemp = companySmsTempService.selectCompanySmsTempByCodeAndProject(tempCode, batchSmsLinkDTO.getProjectId().toString());
|
|
|
+ } else {
|
|
|
+ smsTemp = companySmsTempService.selectCompanySmsTempByCode(tempCode);
|
|
|
+ }
|
|
|
if (smsTemp == null) {
|
|
|
responseDTO.setErrCode(400);
|
|
|
responseDTO.setErrMsg("短信模板不存在");
|
|
|
@@ -1321,6 +1330,19 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
responseDTO.setErrMsg("短信模板未启用或未审核");
|
|
|
return responseDTO;
|
|
|
}
|
|
|
+ String configuredSign = "";
|
|
|
+ FsSmsConfig smsConfig = null;
|
|
|
+ try {
|
|
|
+ SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.sms");
|
|
|
+ smsConfig = JSON.parseObject(sysConfig.getConfigValue(), FsSmsConfig.class);
|
|
|
+ configuredSign = "rf".equals(smsConfig.getType()) ? smsConfig.getRfSign() : smsConfig.getDhSign();
|
|
|
+ if (StringUtils.isEmpty(configuredSign)) {
|
|
|
+ configuredSign = "";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取短信签名配置失败", e);
|
|
|
+ }
|
|
|
+ String strippedContent = smsTemp.getContent().replaceFirst("^【[^】]*】\\s*", "");
|
|
|
int successCount = 0;
|
|
|
int failCount = 0;
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
@@ -1332,10 +1354,20 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
continue;
|
|
|
}
|
|
|
FsSmsShortLink shortLink = createSmsShortLink(batchSmsLinkDTO, fsUser, phone);
|
|
|
+ String smsContent = strippedContent;
|
|
|
+ smsContent = smsContent.replace("${sms.link}", shortLink.getShortLink());
|
|
|
+ smsContent = smsContent.replace("${link}", shortLink.getShortLink());
|
|
|
+ if (!smsContent.contains(shortLink.getShortLink())) {
|
|
|
+ smsContent = smsContent + shortLink.getShortLink();
|
|
|
+ }
|
|
|
+ String customerAcquisitionContent = strippedContent;
|
|
|
+ customerAcquisitionContent = customerAcquisitionContent.replace("${sms.sign}", "");
|
|
|
+ customerAcquisitionContent = customerAcquisitionContent.replace("${sms.link}", "");
|
|
|
+ customerAcquisitionContent = customerAcquisitionContent.replace("${link}", "");
|
|
|
+ shortLink.setCustomerAcquisitionTitle(smsTemp.getTitle());
|
|
|
+ shortLink.setCustomerAcquisitionContent(configuredSign + customerAcquisitionContent);
|
|
|
fsSmsShortLinkMapper.insertFsSmsShortLink(shortLink);
|
|
|
-
|
|
|
- String smsContent = buildSmsContent(smsTemp, shortLink.getShortLink());
|
|
|
- SendSmsResult sendSmsResult = sendSmsByConfig(smsTemp, batchSmsLinkDTO.getCompanyId(), phone, smsContent);
|
|
|
+ SendSmsResult sendSmsResult = sendSmsByConfig(smsTemp, smsConfig, batchSmsLinkDTO.getCompanyId(), phone, smsContent);
|
|
|
String actualSmsContent = StringUtils.isEmpty(sendSmsResult.content) ? smsContent : sendSmsResult.content;
|
|
|
shortLink.setSmsContent(actualSmsContent);
|
|
|
shortLink.setSendStatus(sendSmsResult.success ? 1 : 2);
|
|
|
@@ -1426,9 +1458,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
Date now = new Date();
|
|
|
shortLink.setCreateTime(now);
|
|
|
shortLink.setUpdateTime(now);
|
|
|
- if (param.getEffectiveDuration() != null && param.getEffectiveDuration() > 0) {
|
|
|
- shortLink.setExpireTime(new Date(now.getTime() + TimeUnit.MINUTES.toMillis(param.getEffectiveDuration())));
|
|
|
- }
|
|
|
+ shortLink.setExpireTime(new Date(now.getTime() + TimeUnit.DAYS.toMillis(1)));
|
|
|
return shortLink;
|
|
|
}
|
|
|
|
|
|
@@ -1492,46 +1522,45 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
return sign + content;
|
|
|
}
|
|
|
|
|
|
- private SendSmsResult sendSmsByConfig(CompanySmsTemp smsTemp, Long companyId, String phone, String content) {
|
|
|
+ private SendSmsResult sendSmsByConfig(CompanySmsTemp smsTemp, FsSmsConfig sms, Long companyId, String phone, String content) {
|
|
|
SendSmsResult result = new SendSmsResult();
|
|
|
try {
|
|
|
- SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.sms");
|
|
|
- FsSmsConfig sms = JSON.parseObject(sysConfig.getConfigValue(), FsSmsConfig.class);
|
|
|
result.smsType = sms.getType();
|
|
|
String sendContent = buildSmsSendContent(content, sms);
|
|
|
result.content = sendContent;
|
|
|
- if ("rf".equals(sms.getType())) {
|
|
|
- String urls;
|
|
|
- if (Integer.valueOf(1).equals(smsTemp.getTempType())) {
|
|
|
- urls = sms.getRfUrl1() + "sms?action=send&account=" + sms.getRfAccount1()
|
|
|
- + "&password=" + sms.getRfPassword1()
|
|
|
- + "&mobile=" + phone
|
|
|
- + "&content=" + URLEncoder.encode(sendContent, "UTF-8")
|
|
|
- + "&extno=" + sms.getRfCode1()
|
|
|
- + "&rt=json";
|
|
|
- } else {
|
|
|
- urls = sms.getRfUrl2() + "sms?action=send&account=" + sms.getRfAccount2()
|
|
|
- + "&password=" + sms.getRfPassword2()
|
|
|
- + "&mobile=" + phone
|
|
|
- + "&content=" + URLEncoder.encode(sendContent + "拒收请回复R", "UTF-8")
|
|
|
- + "&extno=" + sms.getRfCode2()
|
|
|
- + "&rt=json";
|
|
|
- }
|
|
|
- String post = HttpRequest.get(urls).execute().body();
|
|
|
- cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(post);
|
|
|
- result.success = Objects.equals(jsonObject.getInt("status"), 0);
|
|
|
- result.message = post;
|
|
|
- return result;
|
|
|
- }
|
|
|
+// if ("rf".equals(sms.getType())) {
|
|
|
+// String urls;
|
|
|
+// if (Integer.valueOf(1).equals(smsTemp.getTempType())) {
|
|
|
+// urls = sms.getRfUrl1() + "sms?action=send&account=" + sms.getRfAccount1()
|
|
|
+// + "&password=" + sms.getRfPassword1()
|
|
|
+// + "&mobile=" + phone
|
|
|
+// + "&content=" + URLEncoder.encode(sendContent, "UTF-8")
|
|
|
+// + "&extno=" + sms.getRfCode1()
|
|
|
+// + "&rt=json";
|
|
|
+// } else {
|
|
|
+// urls = sms.getRfUrl2() + "sms?action=send&account=" + sms.getRfAccount2()
|
|
|
+// + "&password=" + sms.getRfPassword2()
|
|
|
+// + "&mobile=" + phone
|
|
|
+// + "&content=" + URLEncoder.encode(sendContent + "拒收请回复R", "UTF-8")
|
|
|
+// + "&extno=" + sms.getRfCode2()
|
|
|
+// + "&rt=json";
|
|
|
+// }
|
|
|
+// String post = HttpRequest.get(urls).execute().body();
|
|
|
+// cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(post);
|
|
|
+// result.success = Objects.equals(jsonObject.getInt("status"), 0);
|
|
|
+// result.msgId = getRfMsgId(jsonObject);
|
|
|
+// result.message = post;
|
|
|
+// return result;
|
|
|
+// }
|
|
|
SendSmsReturn sendSmsReturn;
|
|
|
- if (Integer.valueOf(1).equals(smsTemp.getTempType())) {
|
|
|
- sendSmsReturn = smsTService.sendSms(sms.getDhAccount1(), sms.getDhPassword1(), sendContent, phone);
|
|
|
- } else {
|
|
|
- sendSmsReturn = smsTService.sendSms(sms.getDhAccount2(), sms.getDhPassword2(), sendContent + "拒收请回复R", phone);
|
|
|
- }
|
|
|
- result.success = sendSmsReturn != null && "0".equals(sendSmsReturn.getResult());
|
|
|
- result.msgId = sendSmsReturn == null ? null : sendSmsReturn.getMsgid();
|
|
|
- result.message = sendSmsReturn == null ? "短信发送无响应" : sendSmsReturn.getDesc();
|
|
|
+// if (Integer.valueOf(1).equals(smsTemp.getTempType())) {
|
|
|
+// sendSmsReturn = smsTService.sendSms(sms.getDhAccount1(), sms.getDhPassword1(), sendContent, phone);
|
|
|
+// } else {
|
|
|
+// sendSmsReturn = smsTService.sendSms(sms.getDhAccount2(), sms.getDhPassword2(), sendContent + "拒收请回复R", phone);
|
|
|
+// }
|
|
|
+// result.success = sendSmsReturn != null && "0".equals(sendSmsReturn.getResult());
|
|
|
+// result.msgId = sendSmsReturn == null ? null : sendSmsReturn.getMsgid();
|
|
|
+// result.message = sendSmsReturn == null ? "短信发送无响应" : sendSmsReturn.getDesc();
|
|
|
} catch (Exception e) {
|
|
|
result.success = false;
|
|
|
result.message = e.getMessage();
|
|
|
@@ -1540,6 +1569,14 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private String getRfMsgId(cn.hutool.json.JSONObject jsonObject) {
|
|
|
+ String msgId = jsonObject.getStr("mid");
|
|
|
+ if (StringUtils.isNotEmpty(msgId)) {
|
|
|
+ return msgId;
|
|
|
+ }
|
|
|
+ return StringUtils.isNotEmpty(msgId) ? msgId : jsonObject.getStr("msgId");
|
|
|
+ }
|
|
|
+
|
|
|
private void saveSmsLog(CompanySmsTemp smsTemp, BatchSmsLinkDTO param, FsUser fsUser, String phone, String content, SendSmsResult sendSmsResult) {
|
|
|
CompanySmsLogs logs = new CompanySmsLogs();
|
|
|
logs.setPhone(phone);
|
|
|
@@ -1726,6 +1763,17 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
batchSendCourseDTO.setUrgeTime(batchUrgeCourseTaskDTO.getUrgeTime());
|
|
|
batchSendCourseDTO.setTitle(batchUrgeCourseTaskDTO.getTitle());
|
|
|
batchSendCourseDTO.setUrgeContent(batchUrgeCourseTaskDTO.getUrgeContent());
|
|
|
+ if (Boolean.TRUE.equals(batchUrgeCourseTaskDTO.getSendCourse())) {
|
|
|
+ FsCourseLinkCreateParam fsCourseLinkCreateParam = new FsCourseLinkCreateParam();
|
|
|
+ BeanUtils.copyProperties(batchSendCourseDTO, fsCourseLinkCreateParam);
|
|
|
+ fsCourseLinkCreateParam.setId(batchUrgeCourseTaskDTO.getPeriodDaysId());
|
|
|
+ R courseSortLink = fsUserCourseService.createAppCourseSortLink(fsCourseLinkCreateParam);
|
|
|
+ Object url = courseSortLink.get("url");
|
|
|
+ if (url == null) {
|
|
|
+ throw new ServiceException("生成看课链接失败");
|
|
|
+ }
|
|
|
+ batchSendCourseDTO.setUrl(url.toString());
|
|
|
+ }
|
|
|
|
|
|
FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(batchUrgeCourseTaskDTO.getCourseId());
|
|
|
Long project = fsUserCourse != null ? fsUserCourse.getProject() : null;
|