|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.core.domain.entity.SysDictData;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
|
|
|
|
|
import com.fs.common.service.ISmsService;
|
|
import com.fs.common.service.ISmsService;
|
|
@@ -51,6 +52,7 @@ import com.fs.sop.mapper.QwSopLogsMapper;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
|
|
+import com.fs.system.service.ISysDictTypeService;
|
|
|
import com.fs.utils.ShortCodeGeneratorUtils;
|
|
import com.fs.utils.ShortCodeGeneratorUtils;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import lombok.Synchronized;
|
|
import lombok.Synchronized;
|
|
@@ -132,6 +134,16 @@ public class SmsServiceImpl implements ISmsService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
private ISysConfigService configService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysDictTypeService sysDictTypeService;
|
|
|
|
|
+
|
|
|
|
|
+ private static final String SMS_SEND_URL_CONFIG = "sms_send_url_config";
|
|
|
|
|
+ private static final long DICT_SORT_SMS_SEND_URL_ENABLED = 1L;
|
|
|
|
|
+ private static final long DICT_SORT_SMS_SEND_URL_URL = 2L;
|
|
|
|
|
+ private static final long DICT_SORT_SMS_SEND_URL_ACCOUNT = 3L;
|
|
|
|
|
+ private static final long DICT_SORT_SMS_SEND_URL_PASSWORD = 4L;
|
|
|
|
|
+ private static final long DICT_SORT_SMS_SEND_URL_CODE = 5L;
|
|
|
|
|
+
|
|
|
private static final String LINK_SUFFIX = "?customer_channel=up:";
|
|
private static final String LINK_SUFFIX = "?customer_channel=up:";
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -727,8 +739,11 @@ public class SmsServiceImpl implements ISmsService
|
|
|
FsSmsConfig sms = JSON.parseObject(sysConfig.getConfigValue(), FsSmsConfig.class);
|
|
FsSmsConfig sms = JSON.parseObject(sysConfig.getConfigValue(), FsSmsConfig.class);
|
|
|
if (sms.getType().equals("rf")) {
|
|
if (sms.getType().equals("rf")) {
|
|
|
try {
|
|
try {
|
|
|
-// content = content.replace("${sms.sign}",sms.getRfSign2());
|
|
|
|
|
- urls = sms.getRfUrl2() + "sms?action=send&account=" + sms.getRfAccount2() + "&password=" + sms.getRfPassword2() + "&mobile=" + phone + "&content=" + URLEncoder.encode(content, "UTF-8") + "&extno=" + sms.getRfCode2() + "&rt=json";
|
|
|
|
|
|
|
+ String rfUrl = resolveRfSendUrlParam(DICT_SORT_SMS_SEND_URL_URL, sms.getRfUrl2());
|
|
|
|
|
+ String rfAccount = resolveRfSendUrlParam(DICT_SORT_SMS_SEND_URL_ACCOUNT, sms.getRfAccount2());
|
|
|
|
|
+ String rfPassword = resolveRfSendUrlParam(DICT_SORT_SMS_SEND_URL_PASSWORD, sms.getRfPassword2());
|
|
|
|
|
+ String rfCode = resolveRfSendUrlParam(DICT_SORT_SMS_SEND_URL_CODE, sms.getRfCode2());
|
|
|
|
|
+ urls = rfUrl + "sms?action=send&account=" + rfAccount + "&password=" + rfPassword + "&mobile=" + phone + "&content=" + URLEncoder.encode(content, "UTF-8") + "&extno=" + rfCode + "&rt=json";
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
log.error("{}发送失败", phone, e);
|
|
log.error("{}发送失败", phone, e);
|
|
|
return R.error("短信发送失败:" + e.getMessage());
|
|
return R.error("短信发送失败:" + e.getMessage());
|
|
@@ -818,6 +833,41 @@ public class SmsServiceImpl implements ISmsService
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private boolean isSmsSendUrlConfigEnabled() {
|
|
|
|
|
+ List<SysDictData> dictList = sysDictTypeService.selectDictDataByType(SMS_SEND_URL_CONFIG);
|
|
|
|
|
+ if (dictList == null || dictList.isEmpty()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return dictList.stream()
|
|
|
|
|
+ .filter(item -> "0".equals(item.getStatus()))
|
|
|
|
|
+ .filter(item -> item.getDictSort() != null && DICT_SORT_SMS_SEND_URL_ENABLED == item.getDictSort())
|
|
|
|
|
+ .anyMatch(item -> "1".equals(StringUtils.trimToEmpty(item.getDictValue())));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String getSmsSendUrlDictValue(long dictSort) {
|
|
|
|
|
+ List<SysDictData> dictList = sysDictTypeService.selectDictDataByType(SMS_SEND_URL_CONFIG);
|
|
|
|
|
+ if (dictList == null || dictList.isEmpty()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (SysDictData item : dictList) {
|
|
|
|
|
+ if (!"0".equals(item.getStatus())) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.getDictSort() != null && dictSort == item.getDictSort()) {
|
|
|
|
|
+ return StringUtils.trimToEmpty(item.getDictValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String resolveRfSendUrlParam(long dictSort, String defaultValue) {
|
|
|
|
|
+ if (!isSmsSendUrlConfigEnabled()) {
|
|
|
|
|
+ return defaultValue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String configValue = getSmsSendUrlDictValue(dictSort);
|
|
|
|
|
+ return StringUtils.isNotBlank(configValue) ? configValue : defaultValue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 发送简单短信
|
|
* 发送简单短信
|
|
|
* @param phone 接收方手机号
|
|
* @param phone 接收方手机号
|