Skip to content

Commit

Permalink
Merge pull request #226 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber committed Sep 30, 2019
2 parents f100cb7 + 0cd447e commit 0a753c6
Show file tree
Hide file tree
Showing 26 changed files with 816 additions and 44 deletions.
2 changes: 2 additions & 0 deletions download.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<details>
<summary>Windows</summary>

[WePush-v4.1.0_190930-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.1.0_190930-x64-Setup.exe)
[WePush-v4.0.0_190928-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.0.0_190928-x64-Setup.exe)
[WePush-v3.9.0_190915-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.9.0_190915-x64-Setup.exe)
[WePush-v3.8.0_190909-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.8.0_190909-x64-Setup.exe)
Expand Down Expand Up @@ -112,6 +113,7 @@
<details>
<summary>Linux</summary>

[v4.1.0_190930](http://download.zhoubochina.com/linux/WePush-4.1.0.zip)
[v4.0.0_190928](http://download.zhoubochina.com/linux/WePush-4.0.0.zip)
[v3.9.0_190915](http://download.zhoubochina.com/linux/WePush-3.9.0.zip)
[v3.8.0_190909](http://download.zhoubochina.com/linux/WePush-3.8.0.zip)
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
+ 模板消息-小程序
+ 微信客服消息
+ 微信企业号/企业微信消息
+ 小程序统一服务消息
+ 钉钉
+ 阿里云短信
+ 阿里大于模板短信
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/fangxuele/tool/push/dao/TMsgWxUniformMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.fangxuele.tool.push.dao;

import com.fangxuele.tool.push.domain.TMsgWxUniform;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface TMsgWxUniformMapper {
int deleteByPrimaryKey(Integer id);

int insert(TMsgWxUniform record);

int insertSelective(TMsgWxUniform record);

TMsgWxUniform selectByPrimaryKey(Integer id);

int updateByPrimaryKeySelective(TMsgWxUniform record);

int updateByPrimaryKey(TMsgWxUniform record);

List<TMsgWxUniform> selectByMsgType(int msgType);

int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName);

List<TMsgWxUniform> selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName);

int updateByMsgTypeAndMsgName(TMsgWxUniform tMsgWxUniform);
}
127 changes: 127 additions & 0 deletions src/main/java/com/fangxuele/tool/push/domain/TMsgWxUniform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.fangxuele.tool.push.domain;

import java.io.Serializable;

public class TMsgWxUniform implements Serializable {
private Integer id;

private Integer msgType;

private String msgName;

private String mpTemplateId;

private String maTemplateId;

private String mpUrl;

private String maAppid;

private String maPagePath;

private String page;

private String emphasisKeyword;

private String createTime;

private String modifiedTime;

private static final long serialVersionUID = 1L;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getMsgType() {
return msgType;
}

public void setMsgType(Integer msgType) {
this.msgType = msgType;
}

public String getMsgName() {
return msgName;
}

public void setMsgName(String msgName) {
this.msgName = msgName == null ? null : msgName.trim();
}

public String getMpTemplateId() {
return mpTemplateId;
}

public void setMpTemplateId(String mpTemplateId) {
this.mpTemplateId = mpTemplateId == null ? null : mpTemplateId.trim();
}

public String getMaTemplateId() {
return maTemplateId;
}

public void setMaTemplateId(String maTemplateId) {
this.maTemplateId = maTemplateId == null ? null : maTemplateId.trim();
}

public String getMpUrl() {
return mpUrl;
}

public void setMpUrl(String mpUrl) {
this.mpUrl = mpUrl == null ? null : mpUrl.trim();
}

public String getMaAppid() {
return maAppid;
}

public void setMaAppid(String maAppid) {
this.maAppid = maAppid == null ? null : maAppid.trim();
}

public String getMaPagePath() {
return maPagePath;
}

public void setMaPagePath(String maPagePath) {
this.maPagePath = maPagePath == null ? null : maPagePath.trim();
}

public String getPage() {
return page;
}

public void setPage(String page) {
this.page = page == null ? null : page.trim();
}

public String getEmphasisKeyword() {
return emphasisKeyword;
}

public void setEmphasisKeyword(String emphasisKeyword) {
this.emphasisKeyword = emphasisKeyword == null ? null : emphasisKeyword.trim();
}

public String getCreateTime() {
return createTime;
}

public void setCreateTime(String createTime) {
this.createTime = createTime == null ? null : createTime.trim();
}

public String getModifiedTime() {
return modifiedTime;
}

public void setModifiedTime(String modifiedTime) {
this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum MessageTypeEnum {
HTTP(13, "HTTP请求"),
DING(14, "钉钉"),
BD_YUN(15, "百度云短信"),
QI_NIU_YUN(16, "七牛云短信");
QI_NIU_YUN(16, "七牛云短信"),
WX_UNIFORM_MESSAGE(17, "小程序-统一服务消息");

private int code;

Expand All @@ -47,6 +48,7 @@ public enum MessageTypeEnum {
public static final int DING_CODE = 14;
public static final int BD_YUN_CODE = 15;
public static final int QI_NIU_YUN_CODE = 16;
public static final int WX_UNIFORM_MESSAGE_CODE = 17;

MessageTypeEnum(int code, String name) {
this.code = code;
Expand Down Expand Up @@ -101,6 +103,9 @@ public static String getName(int code) {
case 16:
name = QI_NIU_YUN.name;
break;
case 17:
name = WX_UNIFORM_MESSAGE.name;
break;
default:
name = "";
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/fangxuele/tool/push/logic/PushControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.fangxuele.tool.push.dao.TPushHistoryMapper;
import com.fangxuele.tool.push.domain.TPushHistory;
import com.fangxuele.tool.push.logic.msgmaker.MsgMakerFactory;
import com.fangxuele.tool.push.logic.msgmaker.WxMaTemplateMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.WxMpTemplateMsgMaker;
import com.fangxuele.tool.push.logic.msgsender.IMsgSender;
import com.fangxuele.tool.push.logic.msgsender.MailMsgSender;
import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory;
Expand Down Expand Up @@ -149,7 +151,8 @@ public static boolean configCheck() {
switch (msgType) {
case MessageTypeEnum.MP_TEMPLATE_CODE:
case MessageTypeEnum.KEFU_CODE:
case MessageTypeEnum.KEFU_PRIORITY_CODE: {
case MessageTypeEnum.KEFU_PRIORITY_CODE:
case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE: {
if (App.config.isMpUseOutSideAt()) {
if (App.config.isMpManualAt() &&
(StringUtils.isEmpty(App.config.getMpAt()) || StringUtils.isEmpty(App.config.getMpAtExpiresIn()))) {
Expand Down Expand Up @@ -430,7 +433,12 @@ private static void savePushResult(String msgName, String resultInfo, File file)
* 准备消息构造器
*/
static void prepareMsgMaker() {
MsgMakerFactory.getMsgMaker().prepare();
if (App.config.getMsgType() == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE) {
new WxMpTemplateMsgMaker().prepare();
new WxMaTemplateMsgMaker().prepare();
} else {
MsgMakerFactory.getMsgMaker().prepare();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public SendResult send(String[] msgData) {
try {
//初始化acsClient,暂不支持region化
SendSmsRequest sendSmsRequest = aliyunMsgMaker.makeMsg(msgData);
sendSmsRequest.setPhoneNumbers(msgData[0]);
if (PushControl.dryRun) {
sendResult.setSuccess(true);
return sendResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public static IMsgSender getMsgSender() {
case MessageTypeEnum.KEFU_PRIORITY_CODE:
iMsgSender = new WxKefuPriorMsgSender();
break;
case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE:
iMsgSender = new WxUniformMsgSender();
break;
case MessageTypeEnum.ALI_YUN_CODE:
iMsgSender = new AliYunMsgSender();
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.fangxuele.tool.push.logic.msgsender;

import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage;
import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage.MiniProgram;
import com.fangxuele.tool.push.App;
import com.fangxuele.tool.push.logic.PushControl;
import com.fangxuele.tool.push.logic.msgmaker.WxMaTemplateMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.WxMpTemplateMsgMaker;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;

/**
* <pre>
* 微信统一服务消息发送器
* </pre>
*
* @author <a href="https://github.com/rememberber">RememBerBer</a>
* @since 2019/9/29.
*/
@Slf4j
public class WxUniformMsgSender implements IMsgSender {

private WxMpTemplateMsgMaker wxMpTemplateMsgMaker;

private WxMaTemplateMsgMaker wxMaTemplateMsgMaker;

public WxUniformMsgSender() {
wxMpTemplateMsgMaker = new WxMpTemplateMsgMaker();
wxMaTemplateMsgMaker = new WxMaTemplateMsgMaker();
}

@Override
public SendResult send(String[] msgData) {
SendResult sendResult = new SendResult();

try {
String openId = msgData[0];
WxMaTemplateMessage wxMaTemplateMessage = wxMaTemplateMsgMaker.makeMsg(msgData);
WxMpTemplateMessage wxMpTemplateMessage = wxMpTemplateMsgMaker.makeMsg(msgData);

WxMaUniformMessage wxMaUniformMessage = new WxMaUniformMessage();
wxMaUniformMessage.setMpTemplateMsg(true);
wxMaUniformMessage.setToUser(openId);
wxMaUniformMessage.setAppid(App.config.getMiniAppAppId());
wxMaUniformMessage.setTemplateId(wxMpTemplateMessage.getTemplateId());
wxMaUniformMessage.setUrl(wxMpTemplateMessage.getUrl());
wxMaUniformMessage.setPage(wxMaTemplateMessage.getPage());
wxMaUniformMessage.setFormId(msgData[1]);
MiniProgram miniProgram = new MiniProgram();
miniProgram.setAppid(App.config.getMiniAppAppId());
miniProgram.setPagePath(wxMaTemplateMessage.getPage());

wxMaUniformMessage.setMiniProgram(miniProgram);
wxMaUniformMessage.setData(wxMaTemplateMessage.getData());
wxMaUniformMessage.setEmphasisKeyword(wxMaTemplateMessage.getEmphasisKeyword());

if (PushControl.dryRun) {
sendResult.setSuccess(true);
return sendResult;
} else {
WxMaTemplateMsgSender.getWxMaService().getMsgService().sendUniformMsg(wxMaUniformMessage);
}
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
return sendResult;
}

sendResult.setSuccess(true);
return sendResult;
}

@Override
public SendResult asyncSend(String[] msgData) {
return null;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/fangxuele/tool/push/ui/UiConsts.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class UiConsts {
* 软件名称,版本
*/
public final static String APP_NAME = "WePush";
public final static String APP_VERSION = "v_4.0.0_190928";
public final static String APP_VERSION = "v_4.1.0_190930";

/**
* Logo-1024*1024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public static void switchMsgType(int msgType) {
messageEditForm.getMsgEditorPanel().add(KefuMsgForm.getInstance().getKefuMsgPanel(), gridConstraintsRow0);
messageEditForm.getMsgEditorPanel().add(MpTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow1);
break;
case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE:
messageEditForm.getMsgEditorPanel().setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
messageEditForm.getMsgEditorPanel().add(MaTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
messageEditForm.getMsgEditorPanel().add(MpTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow1);
break;
case MessageTypeEnum.ALI_YUN_CODE:
messageEditForm.getMsgEditorPanel().add(AliYunMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
break;
Expand Down
Loading

0 comments on commit 0a753c6

Please sign in to comment.