公众号模板消息开发完成
This commit is contained in:
parent
0db3aeb14c
commit
b5b09e2677
@ -0,0 +1,21 @@
|
||||
package com.xinelu.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description 消息推送信息实体类
|
||||
* @Author 纪寒
|
||||
* @Date 2024-03-26 17:09:50
|
||||
*/
|
||||
@Data
|
||||
public class MessageValueEntity implements Serializable {
|
||||
private static final long serialVersionUID = -1257378392221120423L;
|
||||
|
||||
private String value;
|
||||
|
||||
public MessageValueEntity(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.xinelu.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Description 微信公众号事件枚举
|
||||
* @Author 纪寒
|
||||
* @Date 2024-03-25 14:38:27
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum OfficialAccountEventEnum {
|
||||
/**
|
||||
* 模板消息推送事件
|
||||
*/
|
||||
TEMPLATESENDJOBFINISH("TEMPLATESENDJOBFINISH"),
|
||||
|
||||
/**
|
||||
* 关系公众号事件
|
||||
*/
|
||||
SUBSCRIBE("subscribe"),
|
||||
|
||||
/**
|
||||
* 取关公众号事件
|
||||
*/
|
||||
UNSUBSCRIBE("unsubscribe"),
|
||||
;
|
||||
|
||||
final private String info;
|
||||
|
||||
OfficialAccountEventEnum(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package com.xinelu.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @Description 微信公众号模板事件消息发送状态枚举
|
||||
* @Author 纪寒
|
||||
* @Date 2024-03-25 14:38:27
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum TemplateEventSendStatusEnum {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS("success"),
|
||||
|
||||
/**
|
||||
* 用户拒绝接收
|
||||
*/
|
||||
REJECT("failed:user block"),
|
||||
|
||||
/**
|
||||
* 发送失败
|
||||
*/
|
||||
FAILED("failed:system failed"),
|
||||
;
|
||||
|
||||
final private String info;
|
||||
|
||||
TemplateEventSendStatusEnum(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package com.xinelu.manage.domain.officialaccountsubscribeevent;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xinelu.common.annotation.Excel;
|
||||
import com.xinelu.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 微信公众号关注和取消事件信息对象 official_account_subscribe_event
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-03-26
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "微信公众号关注和取消事件信息对象", description = "official_account_subscribe_event")
|
||||
public class OfficialAccountSubscribeEvent extends BaseEntity {
|
||||
private static final long serialVersionUID = 4235213866159646854L;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 微信公众号openid
|
||||
*/
|
||||
@ApiModelProperty(value = "微信公众号openid")
|
||||
@Excel(name = "微信公众号openid")
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 微信公众号id
|
||||
*/
|
||||
@ApiModelProperty(value = "微信公众号id")
|
||||
@Excel(name = "微信公众号id")
|
||||
private String officialAccountAppId;
|
||||
|
||||
/**
|
||||
* 消息创建时间 ,yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@ApiModelProperty(value = "消息创建时间 ,yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "消息创建时间 ,yyyy-MM-dd HH:mm:ss", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime sendTime;
|
||||
|
||||
/**
|
||||
* 消息类型是事件,固定取值为:event
|
||||
*/
|
||||
@ApiModelProperty(value = "消息类型是事件,固定取值为:event")
|
||||
@Excel(name = "消息类型是事件,固定取值为:event")
|
||||
private String msgType;
|
||||
|
||||
/**
|
||||
* 事件类型,订阅:subscribe,取消订阅:unsubscribe
|
||||
*/
|
||||
@ApiModelProperty(value = "事件类型,订阅:subscribe,取消订阅:unsubscribe")
|
||||
@Excel(name = "事件类型,订阅:subscribe,取消订阅:unsubscribe")
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* 订阅状态,关注:FOCUS,取消:CANCEL
|
||||
*/
|
||||
@ApiModelProperty(value = "订阅状态,关注:FOCUS,取消:CANCEL")
|
||||
@Excel(name = "订阅状态,关注:FOCUS,取消:CANCEL")
|
||||
private String subscribeStatus;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("openid", getOpenid())
|
||||
.append("officialAccountAppId", getOfficialAccountAppId())
|
||||
.append("sendTime", getSendTime())
|
||||
.append("msgType", getMsgType())
|
||||
.append("eventType", getEventType())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,7 @@ public class OfficialAccountTemplateEvent extends BaseEntity {
|
||||
private String patientName;
|
||||
|
||||
/**
|
||||
* 微信用户openid
|
||||
* 微信公众号openid
|
||||
*/
|
||||
@ApiModelProperty(value = "微信用户openid")
|
||||
@Excel(name = "微信用户openid")
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package com.xinelu.manage.mapper.officialaccountsubscribeevent;
|
||||
|
||||
import com.xinelu.manage.domain.officialaccountsubscribeevent.OfficialAccountSubscribeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信公众号关注和取消事件信息Mapper接口
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-03-26
|
||||
*/
|
||||
public interface OfficialAccountSubscribeEventMapper {
|
||||
/**
|
||||
* 查询微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param id 微信公众号关注和取消事件信息主键
|
||||
* @return 微信公众号关注和取消事件信息
|
||||
*/
|
||||
OfficialAccountSubscribeEvent selectOfficialAccountSubscribeEventById(Long id);
|
||||
|
||||
/**
|
||||
* 查询微信公众号关注和取消事件信息列表
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 微信公众号关注和取消事件信息集合
|
||||
*/
|
||||
List<OfficialAccountSubscribeEvent> selectOfficialAccountSubscribeEventList(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
|
||||
/**
|
||||
* 新增微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertOfficialAccountSubscribeEvent(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
|
||||
/**
|
||||
* 修改微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateOfficialAccountSubscribeEvent(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
|
||||
/**
|
||||
* 删除微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param id 微信公众号关注和取消事件信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteOfficialAccountSubscribeEventById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteOfficialAccountSubscribeEventByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据openid查询用户是否订阅公众号
|
||||
*
|
||||
* @param openId 公众号openID
|
||||
* @return 结果
|
||||
*/
|
||||
int getSubscribeEventInfo(String openId);
|
||||
|
||||
/**
|
||||
* 根据openid修改订阅信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSubscribeEventInfo(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.xinelu.manage.service.officialaccountsubscribeevent;
|
||||
|
||||
import com.xinelu.manage.domain.officialaccountsubscribeevent.OfficialAccountSubscribeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信公众号关注和取消事件信息Service接口
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-03-26
|
||||
*/
|
||||
public interface IOfficialAccountSubscribeEventService {
|
||||
/**
|
||||
* 查询微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param id 微信公众号关注和取消事件信息主键
|
||||
* @return 微信公众号关注和取消事件信息
|
||||
*/
|
||||
OfficialAccountSubscribeEvent selectOfficialAccountSubscribeEventById(Long id);
|
||||
|
||||
/**
|
||||
* 查询微信公众号关注和取消事件信息列表
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 微信公众号关注和取消事件信息集合
|
||||
*/
|
||||
List<OfficialAccountSubscribeEvent> selectOfficialAccountSubscribeEventList(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
|
||||
/**
|
||||
* 新增微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertOfficialAccountSubscribeEvent(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
|
||||
/**
|
||||
* 修改微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateOfficialAccountSubscribeEvent(OfficialAccountSubscribeEvent officialAccountSubscribeEvent);
|
||||
|
||||
/**
|
||||
* 批量删除微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param ids 需要删除的微信公众号关注和取消事件信息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteOfficialAccountSubscribeEventByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除微信公众号关注和取消事件信息信息
|
||||
*
|
||||
* @param id 微信公众号关注和取消事件信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteOfficialAccountSubscribeEventById(Long id);
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.xinelu.manage.service.officialaccountsubscribeevent.impl;
|
||||
|
||||
|
||||
import com.xinelu.manage.domain.officialaccountsubscribeevent.OfficialAccountSubscribeEvent;
|
||||
import com.xinelu.manage.mapper.officialaccountsubscribeevent.OfficialAccountSubscribeEventMapper;
|
||||
import com.xinelu.manage.service.officialaccountsubscribeevent.IOfficialAccountSubscribeEventService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信公众号关注和取消事件信息Service业务层处理
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-03-26
|
||||
*/
|
||||
@Service
|
||||
public class OfficialAccountSubscribeEventServiceImpl implements IOfficialAccountSubscribeEventService {
|
||||
@Resource
|
||||
private OfficialAccountSubscribeEventMapper officialAccountSubscribeEventMapper;
|
||||
|
||||
/**
|
||||
* 查询微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param id 微信公众号关注和取消事件信息主键
|
||||
* @return 微信公众号关注和取消事件信息
|
||||
*/
|
||||
@Override
|
||||
public OfficialAccountSubscribeEvent selectOfficialAccountSubscribeEventById(Long id) {
|
||||
return officialAccountSubscribeEventMapper.selectOfficialAccountSubscribeEventById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信公众号关注和取消事件信息列表
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 微信公众号关注和取消事件信息
|
||||
*/
|
||||
@Override
|
||||
public List<OfficialAccountSubscribeEvent> selectOfficialAccountSubscribeEventList(OfficialAccountSubscribeEvent officialAccountSubscribeEvent) {
|
||||
return officialAccountSubscribeEventMapper.selectOfficialAccountSubscribeEventList(officialAccountSubscribeEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertOfficialAccountSubscribeEvent(OfficialAccountSubscribeEvent officialAccountSubscribeEvent) {
|
||||
officialAccountSubscribeEvent.setCreateTime(LocalDateTime.now());
|
||||
return officialAccountSubscribeEventMapper.insertOfficialAccountSubscribeEvent(officialAccountSubscribeEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param officialAccountSubscribeEvent 微信公众号关注和取消事件信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateOfficialAccountSubscribeEvent(OfficialAccountSubscribeEvent officialAccountSubscribeEvent) {
|
||||
officialAccountSubscribeEvent.setUpdateTime(LocalDateTime.now());
|
||||
return officialAccountSubscribeEventMapper.updateOfficialAccountSubscribeEvent(officialAccountSubscribeEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除微信公众号关注和取消事件信息
|
||||
*
|
||||
* @param ids 需要删除的微信公众号关注和取消事件信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteOfficialAccountSubscribeEventByIds(Long[] ids) {
|
||||
return officialAccountSubscribeEventMapper.deleteOfficialAccountSubscribeEventByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除微信公众号关注和取消事件信息信息
|
||||
*
|
||||
* @param id 微信公众号关注和取消事件信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteOfficialAccountSubscribeEventById(Long id) {
|
||||
return officialAccountSubscribeEventMapper.deleteOfficialAccountSubscribeEventById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xinelu.manage.mapper.officialaccountsubscribeevent.OfficialAccountSubscribeEventMapper">
|
||||
|
||||
<resultMap type="OfficialAccountSubscribeEvent" id="OfficialAccountSubscribeEventResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="openid" column="openid"/>
|
||||
<result property="officialAccountAppId" column="official_account_app_id"/>
|
||||
<result property="sendTime" column="send_time"/>
|
||||
<result property="msgType" column="msg_type"/>
|
||||
<result property="eventType" column="event_type"/>
|
||||
<result property="subscribeStatus" column="subscribe_status"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectOfficialAccountSubscribeEventVo">
|
||||
select id, openid, official_account_app_id, send_time, msg_type, event_type, subscribe_status, create_by, create_time, update_by, update_time from official_account_subscribe_event
|
||||
</sql>
|
||||
|
||||
<select id="selectOfficialAccountSubscribeEventList" parameterType="OfficialAccountSubscribeEvent"
|
||||
resultMap="OfficialAccountSubscribeEventResult">
|
||||
<include refid="selectOfficialAccountSubscribeEventVo"/>
|
||||
<where>
|
||||
<if test="openid != null and openid != ''">
|
||||
and openid = #{openid}
|
||||
</if>
|
||||
<if test="officialAccountAppId != null and officialAccountAppId != ''">
|
||||
and official_account_app_id = #{officialAccountAppId}
|
||||
</if>
|
||||
<if test="sendTime != null ">
|
||||
and send_time = #{sendTime}
|
||||
</if>
|
||||
<if test="msgType != null and msgType != ''">
|
||||
and msg_type = #{msgType}
|
||||
</if>
|
||||
<if test="eventType != null and eventType != ''">
|
||||
and event_type = #{eventType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectOfficialAccountSubscribeEventById" parameterType="Long"
|
||||
resultMap="OfficialAccountSubscribeEventResult">
|
||||
<include refid="selectOfficialAccountSubscribeEventVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertOfficialAccountSubscribeEvent" parameterType="OfficialAccountSubscribeEvent"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into official_account_subscribe_event
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="openid != null">openid,
|
||||
</if>
|
||||
<if test="officialAccountAppId != null">official_account_app_id,
|
||||
</if>
|
||||
<if test="sendTime != null">send_time,
|
||||
</if>
|
||||
<if test="msgType != null">msg_type,
|
||||
</if>
|
||||
<if test="eventType != null">event_type,
|
||||
</if>
|
||||
<if test="subscribeStatus != null">subscribe_status,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="updateBy != null">update_by,
|
||||
</if>
|
||||
<if test="updateTime != null">update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="openid != null">#{openid},
|
||||
</if>
|
||||
<if test="officialAccountAppId != null">#{officialAccountAppId},
|
||||
</if>
|
||||
<if test="sendTime != null">#{sendTime},
|
||||
</if>
|
||||
<if test="msgType != null">#{msgType},
|
||||
</if>
|
||||
<if test="eventType != null">#{eventType},
|
||||
</if>
|
||||
<if test="subscribeStatus != null">#{subscribeStatus},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="updateBy != null">#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateOfficialAccountSubscribeEvent" parameterType="OfficialAccountSubscribeEvent">
|
||||
update official_account_subscribe_event
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="openid != null">openid =
|
||||
#{openid},
|
||||
</if>
|
||||
<if test="officialAccountAppId != null">official_account_app_id =
|
||||
#{officialAccountAppId},
|
||||
</if>
|
||||
<if test="sendTime != null">send_time =
|
||||
#{sendTime},
|
||||
</if>
|
||||
<if test="msgType != null">msg_type =
|
||||
#{msgType},
|
||||
</if>
|
||||
<if test="eventType != null">event_type =
|
||||
#{eventType},
|
||||
</if>
|
||||
<if test="subscribeStatus != null">subscribe_status =
|
||||
#{subscribeStatus},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteOfficialAccountSubscribeEventById" parameterType="Long">
|
||||
delete from official_account_subscribe_event where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOfficialAccountSubscribeEventByIds" parameterType="String">
|
||||
delete from official_account_subscribe_event where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getSubscribeEventInfo" resultType="int">
|
||||
select count(1) from official_account_subscribe_event where openid = #{openid}
|
||||
</select>
|
||||
|
||||
<update id="updateSubscribeEventInfo" parameterType="OfficialAccountSubscribeEvent">
|
||||
update official_account_subscribe_event
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="openid != null">openid =
|
||||
#{openid},
|
||||
</if>
|
||||
<if test="officialAccountAppId != null">official_account_app_id =
|
||||
#{officialAccountAppId},
|
||||
</if>
|
||||
<if test="sendTime != null">send_time =
|
||||
#{sendTime},
|
||||
</if>
|
||||
<if test="msgType != null">msg_type =
|
||||
#{msgType},
|
||||
</if>
|
||||
<if test="eventType != null">event_type =
|
||||
#{eventType},
|
||||
</if>
|
||||
<if test="subscribeStatus != null">subscribe_status =
|
||||
#{subscribeStatus},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
where openid = #{openid}
|
||||
</update>
|
||||
</mapper>
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.mobile.controller.wechatofficialaccountcallback;
|
||||
|
||||
import com.xinelu.common.config.WeChatOfficialAccountConfig;
|
||||
import com.xinelu.common.enums.OfficialAccountEventEnum;
|
||||
import com.xinelu.common.utils.aes.AesException;
|
||||
import com.xinelu.common.utils.aes.WXBizMsgCrypt;
|
||||
import com.xinelu.mobile.dto.wechatappletcallback.MessageSignDTO;
|
||||
@ -71,7 +72,15 @@ public class WeChatOfficialAccountCallbackController {
|
||||
log.info("院后微信公众号模板消息事件解析事件数据为空!");
|
||||
return;
|
||||
}
|
||||
weChatOfficialAccountCallbackService.handleOfficialAccountTemplateEvent(eventPush);
|
||||
//微信模板公众号消息事件
|
||||
if (OfficialAccountEventEnum.TEMPLATESENDJOBFINISH.getInfo().equals(eventPush.getEvent())) {
|
||||
weChatOfficialAccountCallbackService.handleOfficialAccountTemplateEvent(eventPush);
|
||||
}
|
||||
//微信公众号关注和取消事件
|
||||
if (OfficialAccountEventEnum.SUBSCRIBE.getInfo().equals(eventPush.getEvent()) ||
|
||||
OfficialAccountEventEnum.UNSUBSCRIBE.getInfo().equals(eventPush.getEvent())) {
|
||||
weChatOfficialAccountCallbackService.handleOfficialAccountSubscribeEvent(eventPush);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,4 +15,11 @@ public interface WeChatOfficialAccountCallbackService {
|
||||
* @param eventPushVO 模板消息事件回调数据
|
||||
*/
|
||||
void handleOfficialAccountTemplateEvent(WeChatOfficialAccountEventPushVO eventPushVO);
|
||||
|
||||
/**
|
||||
* 院后微信公众号取消和关注事件回调处理
|
||||
*
|
||||
* @param eventPushVO 公众号取消和关注事件回调数据
|
||||
*/
|
||||
void handleOfficialAccountSubscribeEvent(WeChatOfficialAccountEventPushVO eventPushVO);
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.xinelu.mobile.service.wechatofficialaccountcallback.impl;
|
||||
|
||||
import com.xinelu.common.enums.OfficialAccountEventEnum;
|
||||
import com.xinelu.common.enums.SubscribeStatusEnum;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.DateUtils;
|
||||
import com.xinelu.manage.domain.officialaccountsubscribeevent.OfficialAccountSubscribeEvent;
|
||||
import com.xinelu.manage.domain.officialaccounttemplateevent.OfficialAccountTemplateEvent;
|
||||
import com.xinelu.manage.domain.patientinfo.PatientInfo;
|
||||
import com.xinelu.manage.mapper.officialaccountsubscribeevent.OfficialAccountSubscribeEventMapper;
|
||||
import com.xinelu.manage.mapper.officialaccounttemplateevent.OfficialAccountTemplateEventMapper;
|
||||
import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper;
|
||||
import com.xinelu.mobile.service.wechatofficialaccountcallback.WeChatOfficialAccountCallbackService;
|
||||
@ -14,6 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -30,6 +35,8 @@ public class WeChatOfficialAccountCallbackServiceImpl implements WeChatOfficialA
|
||||
private PatientInfoMapper patientInfoMapper;
|
||||
@Resource
|
||||
private OfficialAccountTemplateEventMapper officialAccountTemplateEventMapper;
|
||||
@Resource
|
||||
private OfficialAccountSubscribeEventMapper officialAccountSubscribeEventMapper;
|
||||
|
||||
/**
|
||||
* 院后微信公众号模板消息事件回调处理
|
||||
@ -55,6 +62,8 @@ public class WeChatOfficialAccountCallbackServiceImpl implements WeChatOfficialA
|
||||
templateEvent.setEventType(StringUtils.isBlank(eventPushVO.getEvent()) ? "" : eventPushVO.getEvent());
|
||||
templateEvent.setMsgId(StringUtils.isBlank(eventPushVO.getMsgId()) ? "" : eventPushVO.getMsgId());
|
||||
templateEvent.setStatus(StringUtils.isBlank(eventPushVO.getStatus()) ? "" : eventPushVO.getStatus());
|
||||
templateEvent.setCreateTime(LocalDateTime.now());
|
||||
templateEvent.setCreateBy("xinyilu");
|
||||
int insertTemplateEventCount = officialAccountTemplateEventMapper.insertOfficialAccountTemplateEvent(templateEvent);
|
||||
if (insertTemplateEventCount < 0) {
|
||||
log.error("院后微信公众号模板事件推送,新增模板事件消息信息失败,信息为:[{}]", templateEvent);
|
||||
@ -62,4 +71,63 @@ public class WeChatOfficialAccountCallbackServiceImpl implements WeChatOfficialA
|
||||
}
|
||||
log.info("院后微信公众号模板事件推送处理成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 院后微信公众号取消和关注事件回调处理
|
||||
*
|
||||
* @param eventPushVO 公众号取消和关注事件回调数据
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void handleOfficialAccountSubscribeEvent(WeChatOfficialAccountEventPushVO eventPushVO) {
|
||||
//关注公众号事件
|
||||
if (OfficialAccountEventEnum.SUBSCRIBE.getInfo().equals(eventPushVO.getEvent())) {
|
||||
handleSubscribeEventInfo(eventPushVO, SubscribeStatusEnum.accept.getValue());
|
||||
}
|
||||
//取消关注公众号事件
|
||||
if (OfficialAccountEventEnum.UNSUBSCRIBE.getInfo().equals(eventPushVO.getEvent())) {
|
||||
handleSubscribeEventInfo(eventPushVO, SubscribeStatusEnum.rejet.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理公众号订阅信息
|
||||
*
|
||||
* @param eventPushVO 公众号取消和关注事件回调数据
|
||||
* @param subscribeStatus 订阅状态
|
||||
*/
|
||||
private void handleSubscribeEventInfo(WeChatOfficialAccountEventPushVO eventPushVO, String subscribeStatus) {
|
||||
int subscribeEventCount = officialAccountSubscribeEventMapper.getSubscribeEventInfo(eventPushVO.getFromUserName());
|
||||
if (subscribeEventCount == 0) {
|
||||
//没有订阅过,直接新增
|
||||
OfficialAccountSubscribeEvent subscribeEvent = new OfficialAccountSubscribeEvent();
|
||||
subscribeEvent.setOpenid(eventPushVO.getFromUserName());
|
||||
subscribeEvent.setOfficialAccountAppId(StringUtils.isBlank(eventPushVO.getToUserName()) ? "" : eventPushVO.getToUserName());
|
||||
subscribeEvent.setSendTime(StringUtils.isBlank(eventPushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(eventPushVO.getCreateTime()) * 1000L));
|
||||
subscribeEvent.setMsgType(StringUtils.isBlank(eventPushVO.getMsgType()) ? "" : eventPushVO.getMsgType());
|
||||
subscribeEvent.setEventType(StringUtils.isBlank(eventPushVO.getEvent()) ? "" : eventPushVO.getEvent());
|
||||
subscribeEvent.setSubscribeStatus(subscribeStatus);
|
||||
subscribeEvent.setCreateTime(LocalDateTime.now());
|
||||
subscribeEvent.setCreateBy("xinyilu");
|
||||
int insertSubscribeEvent = officialAccountSubscribeEventMapper.insertOfficialAccountSubscribeEvent(subscribeEvent);
|
||||
if (insertSubscribeEvent < 0) {
|
||||
log.error("院后微信公众号关注和取消事件,新增信息失败,信息为:[{}]", subscribeEvent);
|
||||
throw new ServiceException("新增院后微信公众号关注和取消事件信息失败!");
|
||||
}
|
||||
} else {
|
||||
//订阅过,修改
|
||||
OfficialAccountSubscribeEvent subscribeEvent = new OfficialAccountSubscribeEvent();
|
||||
subscribeEvent.setOpenid(eventPushVO.getFromUserName());
|
||||
subscribeEvent.setSendTime(StringUtils.isBlank(eventPushVO.getCreateTime()) ? null : DateUtils.timestampToLocalDateTime(Long.parseLong(eventPushVO.getCreateTime()) * 1000L));
|
||||
subscribeEvent.setEventType(StringUtils.isBlank(eventPushVO.getEvent()) ? "" : eventPushVO.getEvent());
|
||||
subscribeEvent.setSubscribeStatus(subscribeStatus);
|
||||
subscribeEvent.setUpdateTime(LocalDateTime.now());
|
||||
subscribeEvent.setUpdateBy("xinyilu");
|
||||
int updateSubscribeEvent = officialAccountSubscribeEventMapper.updateSubscribeEventInfo(subscribeEvent);
|
||||
if (updateSubscribeEvent < 0) {
|
||||
log.error("院后微信公众号关注和取消事件,修改信息失败,信息为:[{}]", subscribeEvent);
|
||||
throw new ServiceException("修改院后微信公众号关注和取消事件信息失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.xinelu.common.config.WeChatOfficialAccountConfig;
|
||||
import com.xinelu.common.constant.Constants;
|
||||
import com.xinelu.common.entity.AccessToken;
|
||||
import com.xinelu.common.entity.MessageValueEntity;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.http.HttpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -81,7 +82,7 @@ public class WeChatOfficialAccountUtils {
|
||||
String accessToken = this.getWeChatOfficialAccountAccessToken();
|
||||
//定义模板内容,公众模板内容
|
||||
Map<String, Object> paramsMap = new LinkedHashMap<>();
|
||||
paramsMap.put("touser", "oHBuH5T90TghJdYKfBlxE4fhayBc");
|
||||
paramsMap.put("touser", "oSwvX5qknp3DrAXfBgFjoMvG6WCI");
|
||||
paramsMap.put("template_id", "WUCYtSbH-QFRV_fMcfmn86QLsz1zo881QW7fQNTWOjc");
|
||||
//微信小程序跳转内容
|
||||
Map<String, Object> miniprogramMap = new LinkedHashMap<>();
|
||||
@ -89,11 +90,11 @@ public class WeChatOfficialAccountUtils {
|
||||
miniprogramMap.put("pagepath", "pages/startup/startup");
|
||||
//微信小程序模板data内容
|
||||
Map<String, Object> dataMap = new LinkedHashMap<>();
|
||||
dataMap.put("phrase7", "泉医陪护服务");
|
||||
dataMap.put("character_string3", "000026315412331612100");
|
||||
dataMap.put("time6", "2024-03-25 16:21:32");
|
||||
dataMap.put("time10", "2024-03-27 10:00:00");
|
||||
dataMap.put("thing11", "济南市槐荫区首诺城市之光东座22楼E10");
|
||||
dataMap.put("phrase7", new MessageValueEntity("泉医陪护"));
|
||||
dataMap.put("character_string3", new MessageValueEntity("000026315412331612100"));
|
||||
dataMap.put("time6", new MessageValueEntity("2024-03-25 16:21:32"));
|
||||
dataMap.put("time10", new MessageValueEntity("2024-03-27 10:00:00"));
|
||||
dataMap.put("thing11", new MessageValueEntity("济南市槐荫区首诺城市之光东座22楼E10"));
|
||||
paramsMap.put("miniprogram", miniprogramMap);
|
||||
paramsMap.put("data", dataMap);
|
||||
//拼接请求地址并发送
|
||||
|
||||
Loading…
Reference in New Issue
Block a user