Skip to content

Commit

Permalink
Merge pull request #26 from rememberber/develop
Browse files Browse the repository at this point in the history
新增支持变量消息,可实习每个用户/每条消息内容不同
  • Loading branch information
rememberber authored Feb 7, 2018
2 parents 2dc668c + 82d0e6a commit 21f11ef
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void run() {
TaobaoClient client = new DefaultTaobaoClient(Init.configer.getAliServerUrl(), Init.configer.getAliAppKey(), Init.configer.getAliAppSecret());

// 组织模板消息
AlibabaAliqinFcSmsNumSendRequest alibabaAliqinFcSmsNumSendRequest = PushManage.makeAliTemplateMessage();
AlibabaAliqinFcSmsNumSendRequest alibabaAliqinFcSmsNumSendRequest;

AlibabaAliqinFcSmsNumSendResponse response;

Expand All @@ -44,8 +44,11 @@ public void run() {
return;
}

String telNum = list.get(i);
// 本条消息所需的数据
String[] msgData = list.get(i);
String telNum = msgData[0];
try {
alibabaAliqinFcSmsNumSendRequest = PushManage.makeAliTemplateMessage(msgData);
alibabaAliqinFcSmsNumSendRequest.setRecNum(telNum);

// 空跑控制
Expand All @@ -61,14 +64,14 @@ public void run() {
tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2);

// 保存发送成功
PushData.sendSuccessList.add(telNum);
PushData.sendSuccessList.add(msgData);
} else {
// 总发送失败+1
PushData.increaseFail();
MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords));

// 保存发送失败
PushData.sendFailList.add(telNum);
PushData.sendFailList.add(msgData);

// 失败异常信息输出控制台
PushManage.console(new StringBuffer().append("发送失败:").append(response.getBody()).append(";ErrorCode:")
Expand All @@ -88,7 +91,7 @@ public void run() {
tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2);

// 保存发送成功
PushData.sendSuccessList.add(telNum);
PushData.sendSuccessList.add(msgData);
}

} catch (Exception e) {
Expand All @@ -97,7 +100,7 @@ public void run() {
MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords));

// 保存发送失败
PushData.sendFailList.add(telNum);
PushData.sendFailList.add(msgData);

// 失败异常信息输出控制台
PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";telNum:").append(telNum).toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class BaseMsgServiceThread extends Thread {
/**
* 当前线程要发送的list
*/
public List<String> list;
public List<String[]> list;

/**
* 微信工具服务
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void run() {
// 初始化当前线程
initCurrentThread();

WxMpKefuMessage wxMpKefuMessage = PushManage.makeKefuMessage();
WxMpKefuMessage wxMpKefuMessage;

for (int i = 0; i < list.size(); i++) {
if (!PushData.running) {
Expand All @@ -35,12 +35,14 @@ public void run() {
return;
}

String openId = list.get(i);
// 本条消息所需的数据
String[] msgData = list.get(i);
String openId = msgData[0];
try {
wxMpKefuMessage.setToUser(openId);

// 空跑控制
if (!MainWindow.mainWindow.getDryRunCheckBox().isSelected()) {
wxMpKefuMessage = PushManage.makeKefuMessage(msgData);
wxMpKefuMessage.setToUser(openId);
wxMpService.getKefuService().sendKefuMessage(wxMpKefuMessage);
}

Expand All @@ -53,14 +55,14 @@ public void run() {
tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2);

// 保存发送成功
PushData.sendSuccessList.add(openId);
PushData.sendSuccessList.add(msgData);
} catch (Exception e) {
// 总发送失败+1
PushData.increaseFail();
MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords));

// 保存发送失败
PushData.sendFailList.add(openId);
PushData.sendFailList.add(msgData);

// 失败异常信息输出控制台
PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void run() {
// 初始化当前线程
initCurrentThread();

WxMpKefuMessage wxMpKefuMessage = PushManage.makeKefuMessage();
WxMpTemplateMessage wxMpTemplateMessage = PushManage.makeTemplateMessage();
WxMpKefuMessage wxMpKefuMessage;
WxMpTemplateMessage wxMpTemplateMessage;

for (int i = 0; i < list.size(); i++) {
if (!PushData.running) {
Expand All @@ -37,8 +37,13 @@ public void run() {
return;
}

String openId = list.get(i);
// 本条消息所需的数据
String[] msgData = list.get(i);
String openId = msgData[0];
try {
wxMpKefuMessage = PushManage.makeKefuMessage(msgData);
wxMpTemplateMessage = PushManage.makeTemplateMessage(msgData);

wxMpKefuMessage.setToUser(openId);
wxMpTemplateMessage.setToUser(openId);
try {// 空跑控制
Expand All @@ -60,14 +65,14 @@ public void run() {
tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2);

// 保存发送成功
PushData.sendSuccessList.add(openId);
PushData.sendSuccessList.add(msgData);
} catch (Exception e) {
// 总发送失败+1
PushData.increaseFail();
MainWindow.mainWindow.getPushFailCount().setText(String.valueOf(PushData.failRecords));

// 保存发送失败
PushData.sendFailList.add(openId);
PushData.sendFailList.add(msgData);

// 失败异常信息输出控制台
PushManage.console(new StringBuffer().append("发送失败:").append(e.getMessage()).append(";openid:").append(openId).toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PushData {
/**
* 导入的用户
*/
public static List<String> allUser;
public static List<String[]> allUser;

/**
* 总记录数
Expand All @@ -32,17 +32,17 @@ public class PushData {
/**
* 准备发送的列表
*/
public static List<String> toSendList;
public static List<String[]> toSendList;

/**
* 发送成功的列表
*/
public static List<String> sendSuccessList;
public static List<String[]> sendSuccessList;

/**
* 发送失败的列表
*/
public static List<String> sendFailList;
public static List<String[]> sendFailList;

/**
* 停止标志
Expand Down
Loading

0 comments on commit 21f11ef

Please sign in to comment.