优化 拉取回执代码

pull/26/head
3y 2 years ago
parent 5cf63b7661
commit 246e325e65

@ -1,47 +0,0 @@
package com.java3y.austin.common.dto.account;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
*
* [{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"AKIDhDUUDfffffMEqBF1WljQq","secretKey":"B4h39yWnfffff7D2btue7JErDJ8gxyi","smsSdkAppId":"140025","templateId":"11897","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}}]
*
* @author 3y
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TencentSmsAccount {
/**
* api
*/
private String url;
private String region ;
/**
*
*/
private String secretId;
private String secretKey;
private String smsSdkAppId;
private String templateId;
private String signName;
/**
* Id
*/
private Integer supplierId;
/**
*
*/
private String supplierName;
}

@ -1,7 +1,6 @@
package com.java3y.austin.common.dto.account.sms;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -20,9 +19,10 @@ public class SmsAccount {
protected String supplierName;
/**
*
*
* scriptName
* "下发"/"回执"
* ScriptName
*/
protected String scriptName;
}

@ -1,13 +1,12 @@
package com.java3y.austin.common.dto.account.sms;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* <p>
*
* {"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"AKIDhDxxxxxxxx1WljQq","secretKey":"B4hwww39yxxxrrrrgxyi","smsSdkAppId":"1423123125","templateId":"1182097","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云","scriptName":"TencentSmsScript"}
*
@ -22,7 +21,7 @@ public class TencentSmsAccount extends SmsAccount {
* api
*/
private String url;
private String region ;
private String region;
/**
*

@ -1,13 +1,12 @@
package com.java3y.austin.common.dto.account.sms;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* <p>
*
* {"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"caffff8234234231b5cd7","tpl_id":"523333332","supplierId":20,"supplierName":"云片","scriptName":"YunPianSmsScript"}
*

@ -25,7 +25,7 @@ public class SmsParam {
private Set<String> phones;
/**
*
*
*/
private String scriptName;

@ -24,5 +24,4 @@ public interface Handler {
*/
void recall(MessageTemplate messageTemplate);
}

@ -59,6 +59,7 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
private static final String SEND_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2";
private static final String RECALL_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/recall";
private static final String PULL_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/getsendresult";
private static final String DING_DING_RECALL_KEY_PREFIX = "RECALL_";
private static final String RECALL_BIZ_TYPE = "DingDingWorkNoticeHandler#recall";
@ -195,5 +196,23 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
}
});
}
/**
*
*/
public void pull(Long accountId) {
try {
// DingDingWorkNoticeAccount account = accountUtils.getAccountById(accountId, DingDingWorkNoticeAccount.class);
// String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + accountId);
// DingTalkClient client = new DefaultDingTalkClient(PULL_URL);
// OapiMessageCorpconversationGetsendresultRequest req = new OapiMessageCorpconversationGetsendresultRequest();
// req.setAgentId(Long.valueOf(account.getAgentId()));
// req.setTaskId(456L);
// OapiMessageCorpconversationGetsendresultResponse rsp = client.execute(req, accessToken);
// System.out.println(rsp.getBody());
} catch (Exception e) {
log.error("DingDingWorkNoticeHandler#pull fail:{}", Throwables.getStackTraceAsString(e));
}
}
}

@ -58,7 +58,7 @@ public class PushHandler extends BaseHandler implements Handler {
public boolean handler(TaskInfo taskInfo) {
try {
GeTuiAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(),GeTuiAccount.class);
GeTuiAccount account = accountUtils.getAccountById(taskInfo.getSendAccount(), GeTuiAccount.class);
String token = redisTemplate.opsForValue().get(SendAccountConstant.GE_TUI_ACCESS_TOKEN_PREFIX + taskInfo.getSendAccount());
PushParam pushParam = PushParam.builder().token(token).appId(account.getAppId()).taskInfo(taskInfo).build();
@ -83,6 +83,7 @@ public class PushHandler extends BaseHandler implements Handler {
/**
*
*
* @param pushParam
* @return http result
*/
@ -101,7 +102,7 @@ public class PushHandler extends BaseHandler implements Handler {
/**
*
*
* @param taskId Id
* @param taskId Id
* @param pushParam
* @return
*/
@ -122,6 +123,7 @@ public class PushHandler extends BaseHandler implements Handler {
/**
* taskId
*
* @param pushParam
* @return http result
*/
@ -161,6 +163,7 @@ public class PushHandler extends BaseHandler implements Handler {
}
return param;
}
@Override
public void recall(MessageTemplate messageTemplate) {

@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.SmsContentModel;

@ -1,51 +0,0 @@
package com.java3y.austin.handler.receipt;
import cn.hutool.core.util.StrUtil;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMessageCorpconversationGetsendresultRequest;
import com.dingtalk.api.response.OapiMessageCorpconversationGetsendresultResponse;
import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount;
import com.java3y.austin.support.utils.AccountUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
/**
*
*
* @author 3y
*/
@Component
@Slf4j
public class DingDingWorkReceipt {
private static final String URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/getsendresult";
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private AccountUtils accountUtils;
public void pull() {
// try {
// for (int index = SendAccountConstant.START; true; index = index + SendAccountConstant.STEP) {
// DingDingWorkNoticeAccount account = accountUtils.getAccountById(index, SendAccountConstant.DING_DING_WORK_NOTICE_ACCOUNT_KEY, SendAccountConstant.DING_DING_WORK_NOTICE_PREFIX, DingDingWorkNoticeAccount.class);
// if (account == null) {
// break;
// }
// String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + index);
// DingTalkClient client = new DefaultDingTalkClient(URL);
// OapiMessageCorpconversationGetsendresultRequest req = new OapiMessageCorpconversationGetsendresultRequest();
// req.setAgentId(Long.valueOf(account.getAgentId()));
// req.setTaskId(456L);
// OapiMessageCorpconversationGetsendresultResponse rsp = client.execute(req, accessToken);
// System.out.println(rsp.getBody());
// }
// } catch (Exception e) {
// log.error("DingDingWorkReceipt#pull");
// }
}
}

@ -1,15 +1,18 @@
package com.java3y.austin.handler.receipt;
import com.google.common.base.Throwables;
import com.java3y.austin.handler.receipt.stater.ReceiptMessageStater;
import com.java3y.austin.support.config.SupportThreadPoolConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
/**
*
*
*
* @author 3y
*/
@ -18,18 +21,20 @@ import javax.annotation.PostConstruct;
public class MessageReceipt {
@Autowired
private SmsPullReceipt smsPullReceipt;
private List<ReceiptMessageStater> receiptMessageStaterList;
@PostConstruct
private void init() {
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
while (true) {
// TODO 回执这里自行打开(免得报错)
// smsPullReceipt.pull();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
for (ReceiptMessageStater receiptMessageStater : receiptMessageStaterList) {
// 拉取回执需要打开下面一行注释
//receiptMessageStater.start();
}
Thread.sleep(2000);
} catch (Exception e) {
log.error("MessageReceiptApplication#fail:{}", Throwables.getStackTraceAsString(e));
}
}
});

@ -1,126 +0,0 @@
package com.java3y.austin.handler.receipt;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.sms.TencentSmsAccount;
import com.java3y.austin.common.dto.account.sms.YunPianSmsAccount;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.SmsStatus;
import com.java3y.austin.common.enums.SmsSupplier;
import com.java3y.austin.support.dao.ChannelAccountDao;
import com.java3y.austin.support.dao.SmsRecordDao;
import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.support.domain.SmsRecord;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatus;
import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatusRequest;
import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatusResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*
* @author 3y
*/
@Component
@Slf4j
public class SmsPullReceipt {
@Autowired
private ChannelAccountDao channelAccountDao;
@Autowired
private SmsRecordDao smsRecordDao;
/**
*
* <p>
* eg accountList[{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"234234","secretKey":"234324324","smsSdkAppId":"2343242","templateId":"234234","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"23423432","tpl_id":"23423432","supplierId":20,"supplierName":"云片"}}]
*/
public void pull() {
List<ChannelAccount> channelAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.SMS.getCode());
for (ChannelAccount channelAccount : channelAccountList) {
Integer supplierId = JSON.parseObject(channelAccount.getAccountConfig()).getInteger("supplierId");
if (SmsSupplier.TENCENT.getCode().equals(supplierId)) {
TencentSmsAccount tencentSmsAccount = JSON.parseObject(channelAccount.getAccountConfig(), TencentSmsAccount.class);
pullTencent(tencentSmsAccount);
} else if (SmsSupplier.YUN_PAIN.getCode().equals(supplierId)) {
YunPianSmsAccount yunPianSmsAccount = JSON.parseObject(channelAccount.getAccountConfig(), YunPianSmsAccount.class);
pullYunPain(yunPianSmsAccount);
}
}
}
/**
*
*
* @param account
*/
private void pullTencent(TencentSmsAccount account) {
try {
/**
*
*/
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint(account.getUrl());
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
SmsClient client = new SmsClient(new Credential(account.getSecretId(), account.getSecretKey()), account.getRegion(), clientProfile);
/**
* 10
*/
PullSmsSendStatusRequest req = new PullSmsSendStatusRequest();
req.setLimit(10L);
req.setSmsSdkAppId(account.getSmsSdkAppId());
/**
*
*/
PullSmsSendStatusResponse resp = client.PullSmsSendStatus(req);
List<SmsRecord> smsRecordList = new ArrayList<>();
if (resp != null && resp.getPullSmsSendStatusSet() != null && resp.getPullSmsSendStatusSet().length > 0) {
for (PullSmsSendStatus pullSmsSendStatus : resp.getPullSmsSendStatusSet()) {
SmsRecord smsRecord = SmsRecord.builder()
.sendDate(Integer.valueOf(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN)))
.messageTemplateId(0L)
.phone(Long.valueOf(pullSmsSendStatus.getSubscriberNumber()))
.supplierId(account.getSupplierId())
.supplierName(account.getSupplierName())
.msgContent("")
.seriesId(pullSmsSendStatus.getSerialNo())
.chargingNum(0)
.status("SUCCESS".equals(pullSmsSendStatus.getReportStatus()) ? SmsStatus.RECEIVE_SUCCESS.getCode() : SmsStatus.RECEIVE_FAIL.getCode())
.reportContent(pullSmsSendStatus.getDescription())
.updated(Math.toIntExact(pullSmsSendStatus.getUserReceiveTime()))
.created(Math.toIntExact(DateUtil.currentSeconds()))
.build();
smsRecordList.add(smsRecord);
}
}
if (!CollUtil.isEmpty(smsRecordList)) {
smsRecordDao.saveAll(smsRecordList);
}
} catch (Exception e) {
log.error("TencentSmsReceipt#init fail!{}", Throwables.getStackTraceAsString(e));
}
}
private void pullYunPain(YunPianSmsAccount yunPianSmsAccount) {
}
}

@ -0,0 +1,14 @@
package com.java3y.austin.handler.receipt.stater;
/**
*
*
* @author 3y
*/
public interface ReceiptMessageStater {
/**
*
*/
void start();
}

@ -0,0 +1,33 @@
package com.java3y.austin.handler.receipt.stater.impl;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.handler.impl.DingDingWorkNoticeHandler;
import com.java3y.austin.handler.receipt.stater.ReceiptMessageStater;
import com.java3y.austin.support.dao.ChannelAccountDao;
import com.java3y.austin.support.domain.ChannelAccount;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
*
*
* @author 3y
*/
public class DingDingWorkReceiptStaterImpl implements ReceiptMessageStater {
@Autowired
private DingDingWorkNoticeHandler workNoticeHandler;
@Autowired
private ChannelAccountDao channelAccountDao;
@Override
public void start() {
List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode());
for (ChannelAccount channelAccount : accountList) {
workNoticeHandler.pull(channelAccount.getId());
}
}
}

@ -0,0 +1,60 @@
package com.java3y.austin.handler.receipt.stater.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.sms.SmsAccount;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.receipt.stater.ReceiptMessageStater;
import com.java3y.austin.handler.script.SmsScript;
import com.java3y.austin.support.dao.ChannelAccountDao;
import com.java3y.austin.support.dao.SmsRecordDao;
import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.support.domain.SmsRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
*
*
* @author 3y
*/
@Component
@Slf4j
public class SmsPullReceiptStarterImpl implements ReceiptMessageStater {
@Autowired
private ChannelAccountDao channelAccountDao;
@Autowired
private Map<String, SmsScript> scriptMap;
@Autowired
private SmsRecordDao smsRecordDao;
/**
*
*/
public void start() {
try {
List<ChannelAccount> channelAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.SMS.getCode());
for (ChannelAccount channelAccount : channelAccountList) {
SmsAccount smsAccount = JSON.parseObject(channelAccount.getAccountConfig(), SmsAccount.class);
List<SmsRecord> smsRecordList = scriptMap.get(smsAccount.getScriptName()).pull(smsAccount.getScriptName());
if (CollUtil.isNotEmpty(smsRecordList)) {
smsRecordDao.saveAll(smsRecordList);
}
}
} catch (Exception e) {
log.error("SmsPullReceiptStarter#start fail:{}", Throwables.getStackTraceAsString(e));
}
}
}

@ -1,42 +0,0 @@
package com.java3y.austin.handler.script;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct;
import java.lang.annotation.Annotation;
/**
* sms
*
* @author 3y
*/
@Slf4j
public abstract class BaseSmsScript implements SmsScript {
@Autowired
private SmsScriptHolder smsScriptHolder;
@PostConstruct
public void registerProcessScript() {
if (ArrayUtils.isEmpty(this.getClass().getAnnotations())) {
log.error("BaseSmsScript can not find annotation!");
return;
}
Annotation handlerAnnotations = null;
for (Annotation annotation : this.getClass().getAnnotations()) {
if (annotation instanceof SmsScriptHandler) {
handlerAnnotations = annotation;
break;
}
}
if (handlerAnnotations == null) {
log.error("handler annotations not declared");
return;
}
//注册handler
smsScriptHolder.putHandler(((SmsScriptHandler) handlerAnnotations).value(), this);
}
}

@ -9,16 +9,25 @@ import java.util.List;
/**
*
*
* @author 3y
*/
public interface SmsScript {
/**
*
*
* @param smsParam
* @return
* @return
*/
List<SmsRecord> send(SmsParam smsParam);
/**
*
* @param scriptName
* @return
*/
List<SmsRecord> pull(String scriptName);
}

@ -1,27 +0,0 @@
package com.java3y.austin.handler.script;
import org.springframework.stereotype.Component;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
*
* @author 3y
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Component
public @interface SmsScriptHandler {
/**
*
*
* @return
*/
String value();
}

@ -1,25 +0,0 @@
package com.java3y.austin.handler.script;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* sendAccount->SmsScript
*
* @author 3y
*/
@Component
public class SmsScriptHolder {
private Map<String, SmsScript> handlers = new HashMap<>(8);
public void putHandler(String scriptName, SmsScript handler) {
handlers.put(scriptName, handler);
}
public SmsScript route(String scriptName) {
return handlers.get(scriptName);
}
}

@ -16,9 +16,7 @@ import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import com.tencentcloudapi.sms.v20210111.models.SendStatus;
import com.tencentcloudapi.sms.v20210111.models.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -49,17 +47,38 @@ public class TencentSmsScript implements SmsScript {
try {
TencentSmsAccount tencentSmsAccount = accountUtils.getSmsAccountByScriptName(smsParam.getScriptName(), TencentSmsAccount.class);
SmsClient client = init(tencentSmsAccount);
SendSmsRequest request = assembleReq(smsParam, tencentSmsAccount);
SendSmsRequest request = assembleSendReq(smsParam, tencentSmsAccount);
SendSmsResponse response = client.SendSms(request);
return assembleSmsRecord(smsParam, response, tencentSmsAccount);
return assembleSendSmsRecord(smsParam, response, tencentSmsAccount);
} catch (Exception e) {
log.error("TencentSmsScript#send fail:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(smsParam));
return null;
}
}
@Override
public List<SmsRecord> pull(String scriptName) {
try {
TencentSmsAccount account = accountUtils.getSmsAccountByScriptName(scriptName, TencentSmsAccount.class);
SmsClient client = init(account);
PullSmsSendStatusRequest req = assemblePullReq(account);
PullSmsSendStatusResponse resp = client.PullSmsSendStatus(req);
return assemblePullSmsRecord(account, resp);
} catch (Exception e) {
log.error("TencentSmsReceipt#pull fail!{}", Throwables.getStackTraceAsString(e));
return null;
}
}
private List<SmsRecord> assembleSmsRecord(SmsParam smsParam, SendSmsResponse response, TencentSmsAccount tencentSmsAccount) {
/**
*
*
* @param smsParam
* @param response
* @param tencentSmsAccount
* @return
*/
private List<SmsRecord> assembleSendSmsRecord(SmsParam smsParam, SendSmsResponse response, TencentSmsAccount tencentSmsAccount) {
if (response == null || ArrayUtil.isEmpty(response.getSendStatusSet())) {
return null;
}
@ -94,7 +113,7 @@ public class TencentSmsScript implements SmsScript {
/**
*
*/
private SendSmsRequest assembleReq(SmsParam smsParam, TencentSmsAccount account) {
private SendSmsRequest assembleSendReq(SmsParam smsParam, TencentSmsAccount account) {
SendSmsRequest req = new SendSmsRequest();
String[] phoneNumberSet1 = smsParam.getPhones().toArray(new String[smsParam.getPhones().size() - 1]);
req.setPhoneNumberSet(phoneNumberSet1);
@ -122,5 +141,50 @@ public class TencentSmsScript implements SmsScript {
return client;
}
/**
*
*
* @param account
* @param resp
* @return
*/
private List<SmsRecord> assemblePullSmsRecord(TencentSmsAccount account, PullSmsSendStatusResponse resp) {
List<SmsRecord> smsRecordList = new ArrayList<>();
if (resp != null && resp.getPullSmsSendStatusSet() != null && resp.getPullSmsSendStatusSet().length > 0) {
for (PullSmsSendStatus pullSmsSendStatus : resp.getPullSmsSendStatusSet()) {
SmsRecord smsRecord = SmsRecord.builder()
.sendDate(Integer.valueOf(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN)))
.messageTemplateId(0L)
.phone(Long.valueOf(pullSmsSendStatus.getSubscriberNumber()))
.supplierId(account.getSupplierId())
.supplierName(account.getSupplierName())
.msgContent("")
.seriesId(pullSmsSendStatus.getSerialNo())
.chargingNum(0)
.status("SUCCESS".equals(pullSmsSendStatus.getReportStatus()) ? SmsStatus.RECEIVE_SUCCESS.getCode() : SmsStatus.RECEIVE_FAIL.getCode())
.reportContent(pullSmsSendStatus.getDescription())
.updated(Math.toIntExact(pullSmsSendStatus.getUserReceiveTime()))
.created(Math.toIntExact(DateUtil.currentSeconds()))
.build();
smsRecordList.add(smsRecord);
}
}
return smsRecordList;
}
/**
*
*
* @param account
* @return
*/
private PullSmsSendStatusRequest assemblePullReq(TencentSmsAccount account) {
PullSmsSendStatusRequest req = new PullSmsSendStatusRequest();
req.setLimit(10L);
req.setSmsSdkAppId(account.getSmsSdkAppId());
return req;
}
}

@ -56,6 +56,13 @@ public class YunPianSmsScript implements SmsScript {
}
@Override
public List<SmsRecord> pull(String scriptName) {
YunPianSmsAccount account = accountUtils.getSmsAccountByScriptName(scriptName, YunPianSmsAccount.class);
// .....
return null;
}
/**
*
*

@ -1,10 +1,7 @@
package com.java3y.austin.support.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.constant.CommonConstant;
import com.java3y.austin.common.dto.account.sms.SmsAccount;
import com.java3y.austin.common.enums.ChannelType;
@ -84,7 +81,6 @@ public class AccountUtils {
} catch (Exception e) {
log.error("AccountUtils#getSmsAccount fail! e:{}", Throwables.getStackTraceAsString(e));
}
log.error("AccountUtils#getSmsAccount not found!:{}", scriptName);
return null;
}

Loading…
Cancel
Save