diff --git a/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java b/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java index 3a6755cbd..697888ba5 100644 --- a/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java +++ b/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java @@ -3,10 +3,7 @@ package com.iformall.mq; import com.iformall.domain.po.*; import com.iformall.enums.*; import com.iformall.mapper.WxMsgRecordMapper; -import com.iformall.service.impl.SendCallBackSmsServiceImpl; -import com.iformall.service.impl.SendEmailServiceImpl; -import com.iformall.service.impl.SendSmartAppMsgServiceImpl; -import com.iformall.service.impl.SendSmsServiceImpl; +import com.iformall.service.impl.*; import com.iformall.utils.JsonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,6 +26,8 @@ public class MqBaseConsumer { private SendEmailServiceImpl sendEmailService; @Autowired private SendSmartAppMsgServiceImpl sendSmartAppMsgService; + @Autowired + private SendMpMsgServiceImpl sendMpMsgService; // @Autowired // private MqBaseProducer mqBaseProducer; @@ -42,15 +41,18 @@ public class MqBaseConsumer { if(EnumMsgRecordType.SMS.getCode().equals(baseMsg.getMsgType())){ //短信 sendSmsService.send((WxMsgRecord)JsonUtil.readValue(message,WxMsgRecord.class)); - }else if(EnumMsgRecordType.SMS_CALLBACK.getCode().equals(baseMsg.getMsgType())){ + } else if(EnumMsgRecordType.SMS_CALLBACK.getCode().equals(baseMsg.getMsgType())){ //业务短信 sendCallBackSmsService.send((WxMsg)JsonUtil.readValue(message,WxMsg.class)); - }else if(EnumMsgRecordType.EMAIL.getCode().equals(baseMsg.getMsgType())){ + } else if(EnumMsgRecordType.EMAIL.getCode().equals(baseMsg.getMsgType())){ //邮件 sendEmailService.send((MailMsg)JsonUtil.readValue(message,MailMsg.class)); - }else if(EnumMsgRecordType.SMART_APP.getCode().equals(baseMsg.getMsgType())){ - //微信小程序 + } else if(EnumMsgRecordType.SMART_APP.getCode().equals(baseMsg.getMsgType())){ + //微信小程序-模板消息 sendSmartAppMsgService.send((SmartAppMsg)JsonUtil.readValue(message,SmartAppMsg.class)); + } else if(EnumMsgRecordType.PUBLIC.getCode().equals(baseMsg.getMsgType())) { + //公众号-模板消息 + sendMpMsgService.send((MpAppMsg)JsonUtil.readValue(message,MpAppMsg.class)); } baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); wxMsgRecordMapper.update(baseMsg); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/BaseMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/BaseMsg.java index c2516a546..5ce31b32c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/BaseMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/BaseMsg.java @@ -1,5 +1,7 @@ package com.iformall.domain.po; +import lombok.Data; + import javax.persistence.Transient; import java.io.Serializable; @@ -7,101 +9,37 @@ import java.io.Serializable; * @author luozukai * @date 2019/3/7 10:05 */ +@Data public class BaseMsg implements Serializable { private static final long serialVersionUID = 923764283764823L; - //域0全部 1sys 2a端 3c端 4b端 + @io.swagger.annotations.ApiModelProperty(value="域0全部 1sys 2a端 3c端 4b端",name="domain") private Integer domain = 0; - //租户id + @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") private String tenantId; - //唯一标识 + @io.swagger.annotations.ApiModelProperty(value="唯一标识",name="uuid") @Transient private String uuid; - //接收人,手机号邮件地址等 + @io.swagger.annotations.ApiModelProperty(value="接收人,手机号邮件地址等",name="receiver") @Transient private String receiver; - //消息类型 1短信 2回调短信 3邮件 4微信小程序模板 5微信公众号模板 6系统通知 + @io.swagger.annotations.ApiModelProperty(value="消息类型 1短信 2回调短信 3邮件 4微信小程序模板 5微信公众号模板 6系统通知 7websocket",name="msgType") @Transient private Integer msgType; - //消息状态 0默认1发送成功2消费成功3消费失败 + @io.swagger.annotations.ApiModelProperty(value="消息状态 0默认1发送成功2消费成功3消费失败",name="msgStatus") @Transient private Integer msgStatus; - //结果信息 + @io.swagger.annotations.ApiModelProperty(value="结果信息",name="statusMessage") @Transient private String statusMessage; - //rocketMQ延迟消息1s,5s,10s,30s,1m,2m,3m,4m,5m,6m,7m,8m,9m,10m,20m,30m,1h,2h + @io.swagger.annotations.ApiModelProperty(value="rocketMQ延迟消息1s,5s,10s,30s,1m,2m,3m,4m,5m,6m,7m,8m,9m,10m,20m,30m,1h,2h",name="delayTimeLevel") @Transient private Integer delayTimeLevel = 0; - - - public Integer getDomain() { - return domain; - } - - public void setDomain(Integer domain) { - this.domain = domain; - } - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - public String getReceiver() { - return receiver; - } - - public void setReceiver(String receiver) { - this.receiver = receiver; - } - - public Integer getDelayTimeLevel() { - return delayTimeLevel; - } - - public void setDelayTimeLevel(Integer delayTimeLevel) { - this.delayTimeLevel = delayTimeLevel; - } - - public String getStatusMessage() { - return statusMessage; - } - - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public Integer getMsgStatus() { - return msgStatus; - } - - public void setMsgStatus(Integer msgStatus) { - this.msgStatus = msgStatus; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/MailMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/MailMsg.java index b3de76d13..5e2287bcd 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/MailMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/MailMsg.java @@ -1,11 +1,18 @@ package com.iformall.domain.po; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + import java.util.Map; /** * @author luozukai * @date 2019/3/7 10:05 */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) public class MailMsg extends BaseMsg { private static final long serialVersionUID = 923764283760321L; // 模板id @@ -26,84 +33,4 @@ public class MailMsg extends BaseMsg { //动态替换内容 private Map dynamicContentMap; - - public Map getDynamicContentMap() { - return dynamicContentMap; - } - - public void setDynamicContentMap(Map dynamicContentMap) { - this.dynamicContentMap = dynamicContentMap; - } - - public Integer getModelId() { - return modelId; - } - - public void setModelId(Integer modelId) { - this.modelId = modelId; - } - - public String[] getTo() { - return to; - } - - public void setTo(String[] to) { - this.to = to; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public boolean isHtml() { - return isHtml; - } - - public void setHtml(boolean html) { - isHtml = html; - } - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public String getRscPath() { - return rscPath; - } - - public void setRscPath(String rscPath) { - this.rscPath = rscPath; - } - - public String getRscI() { - return rscI; - } - - public void setRscI(String rscI) { - this.rscI = rscI; - } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/MpAppMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/MpAppMsg.java new file mode 100644 index 000000000..1f8d694dc --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/MpAppMsg.java @@ -0,0 +1,35 @@ +package com.iformall.domain.po; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; + +import java.util.List; + +/** + * 微信公众号模板消息 + * @author Stormeye + * @date 2019/4/9 13:55 + */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class MpAppMsg extends BaseMsg { + private static final long serialVersionUID = 223232132183760321L; + + @io.swagger.annotations.ApiModelProperty(value="公众号AppId",name="appId") + private String appId; + @io.swagger.annotations.ApiModelProperty(value="公众号openid",name="to") + private String to; + @io.swagger.annotations.ApiModelProperty(value="模板类型",name="templateType") + private Integer templateType; + @io.swagger.annotations.ApiModelProperty(value="小程序AppId",name="miniAppId") + private String miniAppId; + @io.swagger.annotations.ApiModelProperty(value="小程序路径",name="miniPagePath") + private String miniPagePath; + @io.swagger.annotations.ApiModelProperty(value="公众号AppId",name="appId") + private String emphasisKeyword; + @io.swagger.annotations.ApiModelProperty(value="公众号模板主体",name="templateDataList") + private List templateDataList; +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/SmartAppMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/SmartAppMsg.java index 411e5ffa8..fac78419b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/SmartAppMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/SmartAppMsg.java @@ -1,6 +1,10 @@ package com.iformall.domain.po; import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + import java.util.List; /** @@ -8,71 +12,24 @@ import java.util.List; * @author luozukai * @date 2019/3/7 10:05 */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) public class SmartAppMsg extends BaseMsg { private static final long serialVersionUID = 223232132183760321L; - //小程序的appId + @io.swagger.annotations.ApiModelProperty(value="小程序AppId",name="appId") private String appId; + @io.swagger.annotations.ApiModelProperty(value="小程序用户openId",name="to") private String to; - private String from; + @io.swagger.annotations.ApiModelProperty(value="小程序formId",name="formId") + private String formId; + @io.swagger.annotations.ApiModelProperty(value="小程序模板类型",name="templateType") private Integer templateType; + @io.swagger.annotations.ApiModelProperty(value="小程序路径",name="gotopage") private String gotopage; + @io.swagger.annotations.ApiModelProperty(value="小程序模板消息标题",name="emphasisKeyword") private String emphasisKeyword; + @io.swagger.annotations.ApiModelProperty(value="小程序模板实体",name="templateDataList") private List templateDataList; - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getEmphasisKeyword() { - return emphasisKeyword; - } - - public void setEmphasisKeyword(String emphasisKeyword) { - this.emphasisKeyword = emphasisKeyword; - } - - public String getGotopage() { - return gotopage; - } - - public void setGotopage(String gotopage) { - this.gotopage = gotopage; - } - - public String getTo() { - return to; - } - - public void setTo(String to) { - this.to = to; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public Integer getTemplateType() { - return templateType; - } - - public void setTemplateType(Integer templateType) { - this.templateType = templateType; - } - - public List getTemplateDataList() { - return templateDataList; - } - - public void setTemplateDataList(List templateDataList) { - this.templateDataList = templateDataList; - } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java index 35b3a5ecf..56004d379 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java @@ -1,5 +1,9 @@ package com.iformall.domain.po; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; @@ -8,6 +12,9 @@ import java.util.Date; import java.util.List; @Table(name = "wx_msg") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) public class WxMsg extends BaseMsg { private static final long serialVersionUID = 1L; @@ -19,66 +26,32 @@ public class WxMsg extends BaseMsg { @Transient protected String sortColumns; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getSortColumns() { - return sortColumns; - } - - public List getIds() { - return ids; - } - - public void setIds(List ids) { - this.ids = ids; - } - - /*租户ID**/ @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") private String tenantId; - /*模板id**/ @io.swagger.annotations.ApiModelProperty(value = "模板id", name = "modelId") private Long modelId; - /*内容**/ @io.swagger.annotations.ApiModelProperty(value = "内容", name = "msg") private String msg; - /*发送时间**/ @io.swagger.annotations.ApiModelProperty(value = "发送时间", name = "sendtime") private String sendtime; - /*发送时间**/ @io.swagger.annotations.ApiModelProperty(value = "发送时间", name = "createtime") private Date createtime; - /*预计发送数量**/ @io.swagger.annotations.ApiModelProperty(value = "预计发送数量", name = "expectSendNumber") private Integer expectSendNumber; - /*成功数量**/ @io.swagger.annotations.ApiModelProperty(value = "成功数量", name = "successNumber") private Integer successNumber; - /*错误数量**/ @io.swagger.annotations.ApiModelProperty(value = "错误数量", name = "errorNumber") private Integer errorNumber; - /***/ @io.swagger.annotations.ApiModelProperty(value = "", name = "returnResult") private String returnResult; - /***/ @io.swagger.annotations.ApiModelProperty(value = "", name = "phones") private String phones; - /***/ @io.swagger.annotations.ApiModelProperty(value = "", name = "signature") private String signature; - /***/ @io.swagger.annotations.ApiModelProperty(value = "", name = "isright") private Integer isright; - /***/ @io.swagger.annotations.ApiModelProperty(value = "", name = "name") private String name; - /*发送状态0未发送 1已发送 2草稿箱**/ @io.swagger.annotations.ApiModelProperty(value = "发送状态0失败1成功", name = "sendstatus") private Integer sendstatus; @@ -121,168 +94,23 @@ public class WxMsg extends BaseMsg { this.couponInject = couponInject; } - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String _tenantId) { - tenantId = _tenantId; - } - - public Long getModelId() { - return modelId; - } - - public void setModelId(Long _modelId) { - modelId = _modelId; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String _msg) { - msg = _msg; - } - - public String getSendtime() { - return sendtime; - } - - public void setSendtime(String _sendtime) { - sendtime = _sendtime; - } - - public Date getCreatetime() { - return createtime; - } - - public void setCreatetime(Date _createtime) { - createtime = _createtime; - } - - public Integer getExpectSendNumber() { - return expectSendNumber; - } - - public void setExpectSendNumber(Integer _expectSendNumber) { - expectSendNumber = _expectSendNumber; - } - - public Integer getSuccessNumber() { - return successNumber; - } - - public void setSuccessNumber(Integer _successNumber) { - successNumber = _successNumber; - } - - public Integer getErrorNumber() { - return errorNumber; - } - - public void setErrorNumber(Integer _errorNumber) { - errorNumber = _errorNumber; - } - - public String getReturnResult() { - return returnResult; - } - - public void setReturnResult(String _returnResult) { - returnResult = _returnResult; - } - - public String getPhones() { - return phones; - } - - public void setPhones(String _phones) { - phones = _phones; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String _signature) { - signature = _signature; - } - - public Integer getIsright() { - return isright; - } - - public void setIsright(Integer _isright) { - isright = _isright; - } - - public String getName() { - return name; - } - - public void setName(String _name) { - name = _name; - } - - public Integer getSendstatus() { - return sendstatus; - } - - public void setSendstatus(Integer _sendstatus) { - sendstatus = _sendstatus; - } - - public String getExcelpath() { - return excelpath; - } - - public void setExcelpath(String excelpath) { - this.excelpath = excelpath; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Integer getWay() { - return way; - } - - public void setWay(Integer way) { - this.way = way; - } - - public List getTagsList() { - return tagsList; - } - - public void setTagsList(List tagsList) { - this.tagsList = tagsList; - } - - public Long getCouponInjectId() { - return couponInjectId; - } - - public void setCouponInjectId(Long couponInjectId) { - this.couponInjectId = couponInjectId; - } - public static enum Field { - Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), ModelId_ASC("`model_id` ASC"), ModelId_DESC("`model_id` DESC"), Msg_ASC("`msg` ASC"), Msg_DESC("`msg` DESC"), Sendtime_ASC("`sendtime` ASC"), Sendtime_DESC("`sendtime` DESC"), Createtime_ASC("`createtime` ASC"), Createtime_DESC("`createtime` DESC"), ExpectSendNumber_ASC("`expect_send_number` ASC"), ExpectSendNumber_DESC("`expect_send_number` DESC"), SuccessNumber_ASC("`success_number` ASC"), SuccessNumber_DESC("`success_number` DESC"), ErrorNumber_ASC("`error_number` ASC"), ErrorNumber_DESC("`error_number` DESC"), ReturnResult_ASC("`return_result` ASC"), ReturnResult_DESC("`return_result` DESC"), Phones_ASC("`phones` ASC"), Phones_DESC("`phones` DESC"), Signature_ASC("`signature` ASC"), Signature_DESC("`signature` DESC"), Isright_ASC("`isright` ASC"), Isright_DESC("`isright` DESC"), Name_ASC("`name` ASC"), Name_DESC("`name` DESC"), Sendstatus_ASC("`sendstatus` ASC"), Sendstatus_DESC("`sendstatus` DESC"); + Id_ASC("`id` ASC"), Id_DESC("`id` DESC") + , TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC") + , ModelId_ASC("`model_id` ASC"), ModelId_DESC("`model_id` DESC") + , Msg_ASC("`msg` ASC"), Msg_DESC("`msg` DESC") + , Sendtime_ASC("`sendtime` ASC"), Sendtime_DESC("`sendtime` DESC") + , Createtime_ASC("`createtime` ASC"), Createtime_DESC("`createtime` DESC") + , ExpectSendNumber_ASC("`expect_send_number` ASC"), ExpectSendNumber_DESC("`expect_send_number` DESC") + , SuccessNumber_ASC("`success_number` ASC"), SuccessNumber_DESC("`success_number` DESC") + , ErrorNumber_ASC("`error_number` ASC"), ErrorNumber_DESC("`error_number` DESC") + , ReturnResult_ASC("`return_result` ASC"), ReturnResult_DESC("`return_result` DESC") + , Phones_ASC("`phones` ASC"), Phones_DESC("`phones` DESC") + , Signature_ASC("`signature` ASC"), Signature_DESC("`signature` DESC") + , Isright_ASC("`isright` ASC"), Isright_DESC("`isright` DESC") + , Name_ASC("`name` ASC"), Name_DESC("`name` DESC") + , Sendstatus_ASC("`sendstatus` ASC"), Sendstatus_DESC("`sendstatus` DESC") + ; private String value; Field(String value) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMsgRecord.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMsgRecord.java index b471f8c37..d4cf64a94 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMsgRecord.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMsgRecord.java @@ -1,201 +1,59 @@ package com.iformall.domain.po; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + import javax.persistence.Id; import javax.persistence.Table; import java.util.Date; import java.util.Map; @Table(name = "wx_msg_record") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) public class WxMsgRecord extends BaseMsg { private static final long serialVersionUID = 18957895653478L; @Id protected Long id; - //租户id - private String tenantId; //msg 消息类型1短信 2回调短信 邮件 3微信小程序模板 4微信公众号模板 5系统通 + @io.swagger.annotations.ApiModelProperty(value="消息类型 1短信 2回调短信 3邮件 4微信小程序模板 5微信公众号模板 6系统通知 7websocket",name="msg") private String msg; - //发送时间 + @io.swagger.annotations.ApiModelProperty(value="发送时间",name="sendTime") private String sendTime; - //model_id + @io.swagger.annotations.ApiModelProperty(value="modelId",name="modelId") private Long modelId; - //from,手机号邮件地址等 + @io.swagger.annotations.ApiModelProperty(value="from,手机号邮件地址等",name="sender") private String sender; - //发送人id + @io.swagger.annotations.ApiModelProperty(value="发送人id",name="senderUserId") private Long senderUserId; - //发送人姓名 + @io.swagger.annotations.ApiModelProperty(value="发送人姓名",name="senderUserName") private String senderUserName; - //接收人用户id + @io.swagger.annotations.ApiModelProperty(value="接收人用户id",name="receiverUserId") private Long receiverUserId; - //接收人姓名 + @io.swagger.annotations.ApiModelProperty(value="接收人姓名",name="receiverUserName") private String receiverUserName; - //签名 + @io.swagger.annotations.ApiModelProperty(value="签名",name="signature") private String signature; - //模板类型 + @io.swagger.annotations.ApiModelProperty(value="模板类型",name="modelType") private Integer modelType; - //消息json + @io.swagger.annotations.ApiModelProperty(value="消息json",name="msgJson") private String msgJson; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime") private Date createtime; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") private Date updatetime; + @io.swagger.annotations.ApiModelProperty(value="消息状态",name="msgStatus") private Integer msgStatus; + @io.swagger.annotations.ApiModelProperty(value="结果信息",name="statusMessage") private String statusMessage; - //动态替换内容 + @io.swagger.annotations.ApiModelProperty(value="动态替换内容",name="dynamicContentMap") private Map dynamicContentMap; - @Override - public Integer getMsgStatus() { - return msgStatus; - } - - @Override - public void setMsgStatus(Integer msgStatus) { - this.msgStatus = msgStatus; - } - - @Override - public String getStatusMessage() { - return statusMessage; - } - - @Override - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - - public String getMsgJson() { - return msgJson; - } - - public void setMsgJson(String msgJson) { - this.msgJson = msgJson; - } - - public Map getDynamicContentMap() { - return dynamicContentMap; - } - - - public void setDynamicContentMap(Map dynamicContentMap) { - this.dynamicContentMap = dynamicContentMap; - } - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public Long getSenderUserId() { - return senderUserId; - } - - public void setSenderUserId(Long senderUserId) { - this.senderUserId = senderUserId; - } - - public String getSenderUserName() { - return senderUserName; - } - - public void setSenderUserName(String senderUserName) { - this.senderUserName = senderUserName; - } - - public Long getReceiverUserId() { - return receiverUserId; - } - - public void setReceiverUserId(Long receiverUserId) { - this.receiverUserId = receiverUserId; - } - - public String getReceiverUserName() { - return receiverUserName; - } - - public void setReceiverUserName(String receiverUserName) { - this.receiverUserName = receiverUserName; - } - - public Integer getModelType() { - return modelType; - } - - public void setModelType(Integer modelType) { - this.modelType = modelType; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public String getSendTime() { - return sendTime; - } - - public void setSendTime(String sendTime) { - this.sendTime = sendTime; - } - - public Long getModelId() { - return modelId; - } - - public void setModelId(Long modelId) { - this.modelId = modelId; - } - - public Date getCreatetime() { - return createtime; - } - - public void setCreatetime(Date createtime) { - this.createtime = createtime; - } - - public Date getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(Date updatetime) { - this.updatetime = updatetime; - } - } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumMsgRecordType.java b/mallinkService/src/main/java/com/iformall/enums/EnumMsgRecordType.java index d212db91d..6459462ca 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumMsgRecordType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumMsgRecordType.java @@ -10,6 +10,7 @@ public enum EnumMsgRecordType { SMART_APP(4, "小程序"), PUBLIC(5, "公众号"), SYSTEM(6, "系统通知"), + WEBSOCKET_APP(7, "小程序websocket"), ; public static EnumMsgRecordType getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumTemplateType.java b/mallinkService/src/main/java/com/iformall/enums/EnumTemplateType.java index e0a960f11..06150bb75 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumTemplateType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumTemplateType.java @@ -7,9 +7,10 @@ public enum EnumTemplateType { // 1-核销成功消息, 2-核销失败消息 - VERIFY_SUCCESS(1, "核销成功消息"), - VERIFY_FAIL(2, "核销失败消息"), - AUDIT_MESSAGE(3, "审核结果通知") + VERIFY_SUCCESS(1, "核销成功消息"), // 小程序 + VERIFY_FAIL(2, "核销失败消息"), // 小程序 + AUDIT_MESSAGE(101, "公众号审核结果通知"), // 公众号 + VERIFY_RESULT(102, "公众号卡券核销通知"), // 公众号 ; public static EnumTemplateType getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/SendMpMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/SendMpMsgServiceImpl.java new file mode 100644 index 000000000..6db4232e5 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/SendMpMsgServiceImpl.java @@ -0,0 +1,65 @@ +package com.iformall.service.impl; + +import com.iformall.common.ErrorCode; +import com.iformall.domain.po.*; +import com.iformall.exception.MallinkException; +import com.iformall.mapper.WxTemplateMsgMapper; +import com.iformall.service.MsgSendService; +import com.iformall.service.wechat.FmOpenService; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 发送微信公众号模板消息 + * @author Stormeye + * @date 2019/4/9 13:51 + */ +@Service +public class SendMpMsgServiceImpl implements MsgSendService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + private WxTemplateMsgMapper wxTemplateMsgMapper; + + @Autowired + private FmOpenService openService; + + @Override + public void send(BaseMsg baseMsg) throws Exception{ + MpAppMsg mpAppMsg = (MpAppMsg)baseMsg; + WxTemplateMsg msg = null; + + WxMpService wxMpService = openService.getWxOpenComponentService().getWxMpServiceByAppid(mpAppMsg.getAppId()); + + // 查询信息模板 + WxTemplateMsg msgQ = new WxTemplateMsg(); + msgQ.setTenantId(mpAppMsg.getTenantId()); + msgQ.setType(mpAppMsg.getTemplateType()); + try { + msg = wxTemplateMsgMapper.selectOne(msgQ); + } catch (Exception e) { + logger.error("公众号消息模板错误: " + e.getMessage()); + } + if (msg == null) { + logger.error("找不到模板Id"); + throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); + } + + WxMpTemplateMessage.MiniProgram miniprogram = new WxMpTemplateMessage.MiniProgram(); + miniprogram.setAppid(mpAppMsg.getMiniAppId()); + miniprogram.setPagePath(mpAppMsg.getMiniPagePath()); + miniprogram.setUsePath(true); + + WxMpTemplateMessage mpTemplateMessage = WxMpTemplateMessage.builder() + .toUser(mpAppMsg.getTo()) + .templateId(msg.getTemplateId()) + .miniProgram(miniprogram) + .data(mpAppMsg.getTemplateDataList()) + .build(); + String retStr = wxMpService.getTemplateMsgService().sendTemplateMsg(mpTemplateMessage); + logger.info(retStr); + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/SendSmartAppMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/SendSmartAppMsgServiceImpl.java index 4c5a02b41..5231903d0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/SendSmartAppMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/SendSmartAppMsgServiceImpl.java @@ -69,7 +69,7 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { */ templateMessage = WxMaTemplateMessage.builder() .toUser(smartAppMsg.getTo()) - .formId(smartAppMsg.getFrom()) // 微信支付的formId是prepayId + .formId(smartAppMsg.getFormId()) // 微信支付的formId是prepayId .page(smartAppMsg.getGotopage()) .data(smartAppMsg.getTemplateDataList()) .templateId(msg.getTemplateId())