mirror of https://github.com/ZhongFuCheng3y/austin
commit
9d1221d8e7
@ -0,0 +1,30 @@
|
||||
package com.java3y.austin.handler.domain.sms;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 对于每种消息类型的 短信配置
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageTypeSmsConfig {
|
||||
|
||||
/**
|
||||
* 权重(决定着流量的占比)
|
||||
*/
|
||||
private Integer weights;
|
||||
|
||||
/**
|
||||
* script名称
|
||||
*/
|
||||
private String scriptName;
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.java3y.austin.handler.domain.sms;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class YunPianSendResult {
|
||||
|
||||
/**
|
||||
* totalCount
|
||||
*/
|
||||
@JSONField(name = "total_count")
|
||||
private Integer totalCount;
|
||||
/**
|
||||
* totalFee
|
||||
*/
|
||||
@JSONField(name = "total_fee")
|
||||
private String totalFee;
|
||||
/**
|
||||
* unit
|
||||
*/
|
||||
@JSONField(name = "unit")
|
||||
private String unit;
|
||||
/**
|
||||
* data
|
||||
*/
|
||||
@JSONField(name = "data")
|
||||
private List<DataDTO> data;
|
||||
|
||||
/**
|
||||
* DataDTO
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DataDTO {
|
||||
/**
|
||||
* httpStatusCode
|
||||
*/
|
||||
@JSONField(name = "http_status_code")
|
||||
private Integer httpStatusCode;
|
||||
/**
|
||||
* code
|
||||
*/
|
||||
@JSONField(name = "code")
|
||||
private Integer code;
|
||||
/**
|
||||
* msg
|
||||
*/
|
||||
@JSONField(name = "msg")
|
||||
private String msg;
|
||||
/**
|
||||
* count
|
||||
*/
|
||||
@JSONField(name = "count")
|
||||
private Integer count;
|
||||
/**
|
||||
* fee
|
||||
*/
|
||||
@JSONField(name = "fee")
|
||||
private Integer fee;
|
||||
/**
|
||||
* unit
|
||||
*/
|
||||
@JSONField(name = "unit")
|
||||
private String unit;
|
||||
/**
|
||||
* mobile
|
||||
*/
|
||||
@JSONField(name = "mobile")
|
||||
private String mobile;
|
||||
/**
|
||||
* sid
|
||||
*/
|
||||
@JSONField(name = "sid")
|
||||
private String sid;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
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.SendAccountConstant;
|
||||
import com.java3y.austin.common.dto.account.TencentSmsAccount;
|
||||
import com.java3y.austin.common.enums.SmsStatus;
|
||||
import com.java3y.austin.support.config.SupportThreadPoolConfig;
|
||||
import com.java3y.austin.support.domain.SmsRecord;
|
||||
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 javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拉取短信回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsReceipt {
|
||||
|
||||
@Autowired
|
||||
private TencentSmsReceipt tencentSmsReceipt;
|
||||
|
||||
@Autowired
|
||||
private YunPianSmsReceipt yunPianSmsReceipt;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
|
||||
while (true) {
|
||||
tencentSmsReceipt.pull();
|
||||
yunPianSmsReceipt.pull();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.java3y.austin.handler.receipt;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 拉取云片网短信回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class YunPianSmsReceipt {
|
||||
/**
|
||||
* 拉取消息并入库
|
||||
*/
|
||||
public void pull() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
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();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
package com.java3y.austin.handler.wechat;
|
||||
|
||||
import com.java3y.austin.handler.domain.wechat.WeChatMiniProgramParam;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
package com.java3y.austin.handler.wechat;
|
||||
|
||||
import com.java3y.austin.handler.domain.wechat.WeChatOfficialParam;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
@ -1,9 +1,9 @@
|
||||
package com.java3y.austin.handler.script.impl;
|
||||
package com.java3y.austin.handler.wechat.impl;
|
||||
|
||||
import com.java3y.austin.common.constant.SendAccountConstant;
|
||||
import com.java3y.austin.common.dto.account.WeChatOfficialAccount;
|
||||
import com.java3y.austin.handler.domain.wechat.WeChatOfficialParam;
|
||||
import com.java3y.austin.handler.script.OfficialAccountService;
|
||||
import com.java3y.austin.handler.wechat.OfficialAccountService;
|
||||
import com.java3y.austin.support.utils.AccountUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
Loading…
Reference in new issue