查询美团token和手机号,并返回消息
This commit is contained in:
@@ -63,5 +63,12 @@ public class WXListener {
|
|||||||
wxMessageConsumer.consume(message);
|
wxMessageConsumer.consume(message);
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
@RequestMapping("/test")
|
||||||
|
public String test(@RequestBody String requestBody) {
|
||||||
|
|
||||||
|
System.out.println("测试接口收到数据:");
|
||||||
|
System.out.println(requestBody);
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2023/12/19 0019 上午 10:33
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
public interface IEnumForString {
|
||||||
|
|
||||||
|
String getKey();
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
}
|
||||||
131
src/main/java/cn/van333/mt2ql/wxMessage/enums/WXReqType.java
Normal file
131
src/main/java/cn/van333/mt2ql/wxMessage/enums/WXReqType.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2023/12/19 0019 上午 10:27
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public enum WXReqType {
|
||||||
|
/**
|
||||||
|
* * 获取微信列表 (X0000)
|
||||||
|
* * 微信状态检测(Q0000)
|
||||||
|
* * 发送文本消息(Q0001)
|
||||||
|
* * 修改下载图片 (Q0002)
|
||||||
|
* * 获取个人信息 (Q0003)
|
||||||
|
* * 查询对象信(Q0004)
|
||||||
|
* * 获取好友列表(Q0005)
|
||||||
|
* * 获取群聊列表(Q0006)
|
||||||
|
* * 获取公众号列表(Q0007)
|
||||||
|
* * 获取群成员列表(Q0008)
|
||||||
|
* * 发送聊天记录(Q0009)
|
||||||
|
* * 发送图片 (Q0010)
|
||||||
|
* * 发送本地文件(Q0011)
|
||||||
|
* * 发送分享链接(Q0012)
|
||||||
|
* * 发送小程序(Q0013)
|
||||||
|
* * 发送音乐分享(Q0014)
|
||||||
|
* * 发送XML (Q0015)
|
||||||
|
* * 确认收款 (Q0016)
|
||||||
|
* * 同意好友请求(Q0017)
|
||||||
|
* * 添加好友通过v3(Q0018)
|
||||||
|
* * 添加好友_通过wxid (Q0019)
|
||||||
|
* * 查询陌生人信息(Q0020)
|
||||||
|
* * 邀请进群(Q0021)
|
||||||
|
* * 删除好友(Q0022)
|
||||||
|
* * 修改对象备注(Q0023)
|
||||||
|
* * 修改群聊名称(Q0024)
|
||||||
|
* * 发送名片(Q0025)
|
||||||
|
*/
|
||||||
|
GET_WX_LIST("X0000", "获取微信列表"),
|
||||||
|
GET_WX_STATUS("Q0000", "微信状态检测"),
|
||||||
|
SEND_TEXT_MESSAGE("Q0001", "发送文本消息"),
|
||||||
|
UPDATE_DOWNLOAD_IMAGE("Q0002", "修改下载图片"),
|
||||||
|
GET_USER_INFO("Q0003", "获取个人信息"),
|
||||||
|
QUERY_OBJECT_INFO("Q0004", "查询对象信"),
|
||||||
|
GET_FRIEND_LIST("Q0005", "获取好友列表"),
|
||||||
|
GET_GROUP_LIST("Q0006", "获取群聊列表"),
|
||||||
|
GET_MP_LIST("Q0007", "获取公众号列表"),
|
||||||
|
GET_GROUP_MEMBER_LIST("Q0008", "获取群成员列表"),
|
||||||
|
SEND_CHAT_RECORD("Q0009", "发送聊天记录"),
|
||||||
|
SEND_IMAGE("Q0010", "发送图片"),
|
||||||
|
SEND_LOCAL_FILE("Q0011", "发送本地文件"),
|
||||||
|
SEND_SHARE_LINK("Q0012", "发送分享链接"),
|
||||||
|
SEND_MINIPROGRAM("Q0013", "发送小程序"),
|
||||||
|
SEND_MUSIC_SHARE("Q0014", "发送音乐分享"),
|
||||||
|
SEND_XML("Q0015", "发送XML"),
|
||||||
|
CONFIRM_RECEIPT("Q0016", "确认收款"),
|
||||||
|
AGREE_FRIEND_REQUEST("Q0017", "同意好友请求"),
|
||||||
|
ADD_FRIEND_V3("Q0018", "添加好友通过v3"),
|
||||||
|
ADD_FRIEND_WXID("Q0019", "添加好友_通过wxid"),
|
||||||
|
QUERY_STRANGER_INFO("Q0020", "查询陌生人信息"),
|
||||||
|
INVITE_GROUP("Q0021", "邀请进群"),
|
||||||
|
DELETE_FRIEND("Q0022", "删除好友"),
|
||||||
|
MODIFY_OBJECT_REMARK("Q0023", "修改对象备注"),
|
||||||
|
MODIFY_GROUP_NAME("Q0024", "修改群聊名称");
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
WXReqType(String key, String name) {
|
||||||
|
this.key = key;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WXReqType get(String key) {
|
||||||
|
for (WXReqType e : WXReqType.values()) {
|
||||||
|
if (Objects.equals(e.getKey(), key)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getName(String key) {
|
||||||
|
//if (Object.isNotEmpty(key)) {
|
||||||
|
WXReqType[] items = WXReqType.values();
|
||||||
|
for (WXReqType item : items) {
|
||||||
|
if (Objects.equals(item.getKey(), key)) {
|
||||||
|
return item.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> getKeyVlue() {
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
WXReqType[] items = WXReqType.values();
|
||||||
|
for (WXReqType item : items) {
|
||||||
|
map.put(item.getKey() + "", item.getName());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Map<String, Object>> getSelectItems() {
|
||||||
|
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||||
|
WXReqType[] items = WXReqType.values();
|
||||||
|
for (WXReqType item : items) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("label", item.getName());
|
||||||
|
map.put("value", item.getKey());
|
||||||
|
result.add(map);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.mapper;
|
||||||
|
|
||||||
|
import cn.van333.mt2ql.wxMessage.model.WxMessageDataForChat;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 80787
|
||||||
|
* @description 针对表【wx_message_data_for_chat】的数据库操作Mapper
|
||||||
|
* @createDate 2023-12-19 17:38:29
|
||||||
|
* @Entity cn.van333.mt2ql.demos.model.WxMessageDataForChat
|
||||||
|
*/
|
||||||
|
public interface WxMessageDataForChatMapper extends BaseMapper<WxMessageDataForChat> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.mapper;
|
||||||
|
|
||||||
|
import cn.van333.mt2ql.wxMessage.model.WxUser;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 80787
|
||||||
|
* @description 针对表【wx_user】的数据库操作Mapper
|
||||||
|
* @createDate 2023-12-21 14:18:10
|
||||||
|
* @Entity cn.van333.mt2ql.wxMessage.model.WxUser
|
||||||
|
*/
|
||||||
|
public interface WxUserMapper extends BaseMapper<WxUser> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2023/12/19 0019 上午 11:46
|
||||||
|
* @description:
|
||||||
|
* 收到群聊消息 (10008)
|
||||||
|
* 收到私聊消息 (10009)
|
||||||
|
* 自己发出消息 (10010)
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName wx_message_data_for_chat
|
||||||
|
*/
|
||||||
|
@TableName(value ="wx_message_data_for_chat")
|
||||||
|
@Data
|
||||||
|
public class WxMessageDataForChat implements Serializable {
|
||||||
|
/**
|
||||||
|
* 收到这条消息的13位现行时间戳
|
||||||
|
*/
|
||||||
|
private Long timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源类型:1|私聊 2|群聊 3|公众号
|
||||||
|
*/
|
||||||
|
private Integer fromtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型:1|文本 3|图片 34|语音 42|名片 43|视频 47|动态表情 48|地理位置 49|分享链接或附件 2001|红包 2002|小程序 2003|群邀请 10000|系统消息
|
||||||
|
*/
|
||||||
|
private Integer msgtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息来源:0|别人发送 1|自己手机发送
|
||||||
|
*/
|
||||||
|
private Integer msgsource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fromType=1时为好友wxid,fromType=2时为群wxid,fromType=3时公众号wxid
|
||||||
|
*/
|
||||||
|
private String fromwxid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅fromType=2时有效,为群内发言人wxid
|
||||||
|
*/
|
||||||
|
private String finalfromwxid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅fromType=2,且msgSource=0时有效,为消息中艾特人wxid列表
|
||||||
|
*/
|
||||||
|
private String atwxidlist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅fromType=2时有效,0
|
||||||
|
*/
|
||||||
|
private Integer silence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅fromType=2时有效,群成员数量
|
||||||
|
*/
|
||||||
|
private Integer membercount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息签名
|
||||||
|
*/
|
||||||
|
private String signature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容的Base64
|
||||||
|
*/
|
||||||
|
private String msgbase64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息的唯一标识
|
||||||
|
*/
|
||||||
|
private String msgid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型的字符串表示
|
||||||
|
*/
|
||||||
|
private String msgtypestr;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WxMessageDataForChat other = (WxMessageDataForChat) that;
|
||||||
|
return (this.getTimestamp() == null ? other.getTimestamp() == null : this.getTimestamp().equals(other.getTimestamp()))
|
||||||
|
&& (this.getFromtype() == null ? other.getFromtype() == null : this.getFromtype().equals(other.getFromtype()))
|
||||||
|
&& (this.getMsgtype() == null ? other.getMsgtype() == null : this.getMsgtype().equals(other.getMsgtype()))
|
||||||
|
&& (this.getMsgsource() == null ? other.getMsgsource() == null : this.getMsgsource().equals(other.getMsgsource()))
|
||||||
|
&& (this.getFromwxid() == null ? other.getFromwxid() == null : this.getFromwxid().equals(other.getFromwxid()))
|
||||||
|
&& (this.getFinalfromwxid() == null ? other.getFinalfromwxid() == null : this.getFinalfromwxid().equals(other.getFinalfromwxid()))
|
||||||
|
&& (this.getAtwxidlist() == null ? other.getAtwxidlist() == null : this.getAtwxidlist().equals(other.getAtwxidlist()))
|
||||||
|
&& (this.getSilence() == null ? other.getSilence() == null : this.getSilence().equals(other.getSilence()))
|
||||||
|
&& (this.getMembercount() == null ? other.getMembercount() == null : this.getMembercount().equals(other.getMembercount()))
|
||||||
|
&& (this.getSignature() == null ? other.getSignature() == null : this.getSignature().equals(other.getSignature()))
|
||||||
|
&& (this.getMsg() == null ? other.getMsg() == null : this.getMsg().equals(other.getMsg()))
|
||||||
|
&& (this.getMsgbase64() == null ? other.getMsgbase64() == null : this.getMsgbase64().equals(other.getMsgbase64()))
|
||||||
|
&& (this.getMsgid() == null ? other.getMsgid() == null : this.getMsgid().equals(other.getMsgid()))
|
||||||
|
&& (this.getMsgtypestr() == null ? other.getMsgtypestr() == null : this.getMsgtypestr().equals(other.getMsgtypestr()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getTimestamp() == null) ? 0 : getTimestamp().hashCode());
|
||||||
|
result = prime * result + ((getFromtype() == null) ? 0 : getFromtype().hashCode());
|
||||||
|
result = prime * result + ((getMsgtype() == null) ? 0 : getMsgtype().hashCode());
|
||||||
|
result = prime * result + ((getMsgsource() == null) ? 0 : getMsgsource().hashCode());
|
||||||
|
result = prime * result + ((getFromwxid() == null) ? 0 : getFromwxid().hashCode());
|
||||||
|
result = prime * result + ((getFinalfromwxid() == null) ? 0 : getFinalfromwxid().hashCode());
|
||||||
|
result = prime * result + ((getAtwxidlist() == null) ? 0 : getAtwxidlist().hashCode());
|
||||||
|
result = prime * result + ((getSilence() == null) ? 0 : getSilence().hashCode());
|
||||||
|
result = prime * result + ((getMembercount() == null) ? 0 : getMembercount().hashCode());
|
||||||
|
result = prime * result + ((getSignature() == null) ? 0 : getSignature().hashCode());
|
||||||
|
result = prime * result + ((getMsg() == null) ? 0 : getMsg().hashCode());
|
||||||
|
result = prime * result + ((getMsgbase64() == null) ? 0 : getMsgbase64().hashCode());
|
||||||
|
result = prime * result + ((getMsgid() == null) ? 0 : getMsgid().hashCode());
|
||||||
|
result = prime * result + ((getMsgtypestr() == null) ? 0 : getMsgtypestr().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", timestamp=").append(timestamp);
|
||||||
|
sb.append(", fromtype=").append(fromtype);
|
||||||
|
sb.append(", msgtype=").append(msgtype);
|
||||||
|
sb.append(", msgsource=").append(msgsource);
|
||||||
|
sb.append(", fromwxid=").append(fromwxid);
|
||||||
|
sb.append(", finalfromwxid=").append(finalfromwxid);
|
||||||
|
sb.append(", atwxidlist=").append(atwxidlist);
|
||||||
|
sb.append(", silence=").append(silence);
|
||||||
|
sb.append(", membercount=").append(membercount);
|
||||||
|
sb.append(", signature=").append(signature);
|
||||||
|
sb.append(", msg=").append(msg);
|
||||||
|
sb.append(", msgbase64=").append(msgbase64);
|
||||||
|
sb.append(", msgid=").append(msgid);
|
||||||
|
sb.append(", msgtypestr=").append(msgtypestr);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
109
src/main/java/cn/van333/mt2ql/wxMessage/model/WxUser.java
Normal file
109
src/main/java/cn/van333/mt2ql/wxMessage/model/WxUser.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName wx_user
|
||||||
|
*/
|
||||||
|
@TableName(value ="wx_user")
|
||||||
|
@Data
|
||||||
|
public class WxUser implements Serializable {
|
||||||
|
/**
|
||||||
|
* wxid
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private String wxid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计充值
|
||||||
|
*/
|
||||||
|
private BigDecimal moneyLeiji;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 余额
|
||||||
|
*/
|
||||||
|
private BigDecimal moneyShengyu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计充值次数
|
||||||
|
*/
|
||||||
|
private BigDecimal countChongzhi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计消费次数
|
||||||
|
*/
|
||||||
|
private BigDecimal countXiaofei;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信昵称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 正常 2 拉黑
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WxUser other = (WxUser) that;
|
||||||
|
return (this.getWxid() == null ? other.getWxid() == null : this.getWxid().equals(other.getWxid()))
|
||||||
|
&& (this.getMoneyLeiji() == null ? other.getMoneyLeiji() == null : this.getMoneyLeiji().equals(other.getMoneyLeiji()))
|
||||||
|
&& (this.getMoneyShengyu() == null ? other.getMoneyShengyu() == null : this.getMoneyShengyu().equals(other.getMoneyShengyu()))
|
||||||
|
&& (this.getCountChongzhi() == null ? other.getCountChongzhi() == null : this.getCountChongzhi().equals(other.getCountChongzhi()))
|
||||||
|
&& (this.getCountXiaofei() == null ? other.getCountXiaofei() == null : this.getCountXiaofei().equals(other.getCountXiaofei()))
|
||||||
|
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||||
|
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getWxid() == null) ? 0 : getWxid().hashCode());
|
||||||
|
result = prime * result + ((getMoneyLeiji() == null) ? 0 : getMoneyLeiji().hashCode());
|
||||||
|
result = prime * result + ((getMoneyShengyu() == null) ? 0 : getMoneyShengyu().hashCode());
|
||||||
|
result = prime * result + ((getCountChongzhi() == null) ? 0 : getCountChongzhi().hashCode());
|
||||||
|
result = prime * result + ((getCountXiaofei() == null) ? 0 : getCountXiaofei().hashCode());
|
||||||
|
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||||
|
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", wxid=").append(wxid);
|
||||||
|
sb.append(", moneyLeiji=").append(moneyLeiji);
|
||||||
|
sb.append(", moneyShengyu=").append(moneyShengyu);
|
||||||
|
sb.append(", countChongzhi=").append(countChongzhi);
|
||||||
|
sb.append(", countXiaofei=").append(countXiaofei);
|
||||||
|
sb.append(", name=").append(name);
|
||||||
|
sb.append(", status=").append(status);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.service;
|
||||||
|
|
||||||
|
import cn.van333.mt2ql.wxMessage.model.WxMessageDataForChat;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 80787
|
||||||
|
* @description 针对表【wx_message_data_for_chat】的数据库操作Service
|
||||||
|
* @createDate 2023-12-19 17:38:29
|
||||||
|
*/
|
||||||
|
public interface WxMessageDataForChatService extends IService<WxMessageDataForChat> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.service;
|
||||||
|
|
||||||
|
import cn.van333.mt2ql.wxMessage.model.WxUser;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 80787
|
||||||
|
* @description 针对表【wx_user】的数据库操作Service
|
||||||
|
* @createDate 2023-12-21 14:18:10
|
||||||
|
*/
|
||||||
|
public interface WxUserService extends IService<WxUser> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.service.impl;
|
||||||
|
|
||||||
|
import cn.van333.mt2ql.wxMessage.service.WxMessageDataForChatService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import cn.van333.mt2ql.wxMessage.model.WxMessageDataForChat;
|
||||||
|
import cn.van333.mt2ql.wxMessage.mapper.WxMessageDataForChatMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 80787
|
||||||
|
* @description 针对表【wx_message_data_for_chat】的数据库操作Service实现
|
||||||
|
* @createDate 2023-12-19 17:38:29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WxMessageDataForChatServiceImpl extends ServiceImpl<WxMessageDataForChatMapper, WxMessageDataForChat>
|
||||||
|
implements WxMessageDataForChatService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import cn.van333.mt2ql.wxMessage.model.WxUser;
|
||||||
|
import cn.van333.mt2ql.wxMessage.service.WxUserService;
|
||||||
|
import cn.van333.mt2ql.wxMessage.mapper.WxUserMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 80787
|
||||||
|
* @description 针对表【wx_user】的数据库操作Service实现
|
||||||
|
* @createDate 2023-12-21 14:18:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser>
|
||||||
|
implements WxUserService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
313
src/main/java/cn/van333/mt2ql/wxMessage/utils/QLUtil.java
Normal file
313
src/main/java/cn/van333/mt2ql/wxMessage/utils/QLUtil.java
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static cn.hutool.core.thread.ThreadUtil.sleep;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2023/12/22 0022 上午 09:59
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
public class QLUtil {
|
||||||
|
/**
|
||||||
|
* 1. 在系统设置 -> 应用设置 -> 添加应用,权限目前支持5个模块,可以选择多个模块。选择一个模块之后,可读写此模块的所有接口。
|
||||||
|
* 2. 使用生成的 client_id 和 client_secret 请求获取token接口 http://localhost:5700/open/auth/token?client_id=xxxxxx&client_secret=xxxxxxxx
|
||||||
|
* 3. 上面接口返回的token有效期为30天,可用于请求青龙的接口 curl 'http://localhost:5700/open/envs?searchValue=&t=1630032278171' -H 'Authorization: Bearer
|
||||||
|
* 接口返回的token'
|
||||||
|
* 4. openapi的接口与系统正常接口的区别就是青龙里的是/api/envs,openapi是/open/envs,即就是青龙接口中的api换成open
|
||||||
|
*/
|
||||||
|
public static final String QL_BASE_URL = "http://134.175.126.60:45700";
|
||||||
|
public static final String GET_TOKEN = QL_BASE_URL + "/open/auth/token";
|
||||||
|
|
||||||
|
// /open/envs
|
||||||
|
public static final String GET_ENV = QL_BASE_URL + "/open/envs";
|
||||||
|
// /open/crons
|
||||||
|
public static final String GET_CRON = QL_BASE_URL + "/open/crons";
|
||||||
|
|
||||||
|
//client_id
|
||||||
|
public static final String CLIENT_ID = "Ouv_S9gk5LpV";
|
||||||
|
//client_secret
|
||||||
|
public static final String CLIENT_SECRET = "1pLjAIfBBzu1_UA9q-hOj778";
|
||||||
|
public static final String QL_TOKEN_KEY = "QL_TOKEN_KEY";
|
||||||
|
|
||||||
|
private static final RedisCache redisCache = SpringUtil.getBean(RedisCache.class);
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
|
||||||
|
String token = redisCache.getCacheObject(QL_TOKEN_KEY);
|
||||||
|
if (StrUtil.isNotEmpty(token)) {
|
||||||
|
return token;
|
||||||
|
} else {
|
||||||
|
//HashMap<String, String> map = new HashMap<>();
|
||||||
|
//map.put("client_id", CLIENT_ID);
|
||||||
|
//map.put("client_secret", CLIENT_SECRET);
|
||||||
|
//String jsonStr = JSON.toJSONString(map);
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
//* 2. 使用生成的 client_id 和 client_secret 请求获取token接口 http://localhost:5700/open/auth/token?client_id=xxxxxx&client_secret=xxxxxxxx
|
||||||
|
String responseStr = HttpRequest.get(GET_TOKEN + "?client_id=" + CLIENT_ID + "&client_secret=" + CLIENT_SECRET).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
//{"code":200,"data":{"token":"950e3060-d714-4f6a-9839-c098a116f0a8","token_type":"Bearer","expiration":1705743778}}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(responseStr);
|
||||||
|
|
||||||
|
System.out.println(jsonObject.getString("code"));
|
||||||
|
if (Objects.equals(String.valueOf(jsonObject.getString("code")), "200")) {
|
||||||
|
JSONObject response = jsonObject.getJSONObject("data");
|
||||||
|
redisCache.setCacheObject(QL_TOKEN_KEY, (String) response.get("token"), (int) response.get("expiration"), TimeUnit.SECONDS);
|
||||||
|
return (String) response.get("token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get /envs
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* @throws
|
||||||
|
* @description 获取所有环境变量
|
||||||
|
*/
|
||||||
|
public JSONObject getEnv() {
|
||||||
|
String token = getToken();
|
||||||
|
if (StrUtil.isNotEmpty(token)) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
String responseStr = HttpRequest.get(GET_ENV + "?searchValue=&t=1630032278171").header("Authorization", "Bearer " + token).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
QLResponse qlResponse = JSON.parseObject(responseStr, QLResponse.class);
|
||||||
|
if (Objects.equals(String.valueOf(qlResponse.getCode()), "200")) {
|
||||||
|
return qlResponse.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
* @throws
|
||||||
|
* @description 检查是否存在环境变量,存在返回值,不存在返回null
|
||||||
|
*/
|
||||||
|
public String getEnvValue(String name) {
|
||||||
|
JSONObject jsonObject = getEnv();
|
||||||
|
if (ObjectUtil.isNotEmpty(jsonObject)) {
|
||||||
|
return jsonObject.getJSONObject(name).getString("value");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// post /envs
|
||||||
|
// {
|
||||||
|
// "value": "123",
|
||||||
|
// "name": "test_add",
|
||||||
|
// "remarks": "新建测试"
|
||||||
|
//}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param remarks
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
* @throws
|
||||||
|
* @description 添加环境变量
|
||||||
|
*/
|
||||||
|
public JSONObject addEnv(String value, String name, String remarks) {
|
||||||
|
String token = getToken();
|
||||||
|
if (StrUtil.isNotEmpty(token)) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
String responseStr = HttpRequest.post(GET_ENV).header("Authorization", "Bearer " + token).body(JSON.toJSONString(new QLEnv(value, name, remarks))).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
QLResponse qlResponse = JSON.parseObject(responseStr, QLResponse.class);
|
||||||
|
if (Objects.equals(String.valueOf(qlResponse.getCode()), "200")) {
|
||||||
|
return qlResponse.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://134.175.126.60:45700/api/crons?searchValue=&page=1&size=20&filters={}&queryString={%22filters%22:null,%22sorts%22:null,%22filterRelation%22:%22and%22}&t=1703148561868
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param queryString
|
||||||
|
* @return
|
||||||
|
* @throws
|
||||||
|
* @description 获取定时任务列表
|
||||||
|
*/
|
||||||
|
public JSONObject getCron(String queryString) {
|
||||||
|
if (StrUtil.isNotEmpty(queryString)) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
String responseStr = HttpRequest.get(GET_CRON + "?" + queryString).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
QLResponse qlResponse = JSON.parseObject(responseStr, QLResponse.class);
|
||||||
|
if (Objects.equals(String.valueOf(qlResponse.getCode()), "200")) {
|
||||||
|
return qlResponse.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
String responseStr = HttpRequest.get(GET_CRON).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
QLResponse qlResponse = JSON.parseObject(responseStr, QLResponse.class);
|
||||||
|
if (Objects.equals(String.valueOf(qlResponse.getCode()), "200")) {
|
||||||
|
return qlResponse.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 请求网址:
|
||||||
|
* http://134.175.126.60:45700/api/crons/run?t=1703148561868
|
||||||
|
* 请求方法:
|
||||||
|
* PUT*/
|
||||||
|
public JSONObject runCron(String cronId) {
|
||||||
|
String token = getToken();
|
||||||
|
if (StrUtil.isNotEmpty(token)) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
String responseStr = HttpRequest.put(GET_CRON + "?cronId=" + cronId).header("Authorization", "Bearer " + token).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
QLResponse qlResponse = JSON.parseObject(responseStr, QLResponse.class);
|
||||||
|
if (Objects.equals(String.valueOf(qlResponse.getCode()), "200")) {
|
||||||
|
return qlResponse.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* }
|
||||||
|
* async ["getLoginedUserInfo"](_0x4ef1fe = {}) {
|
||||||
|
* let _0x26ac1b = false;
|
||||||
|
* try {
|
||||||
|
* const _0x3daa7c = {
|
||||||
|
* "token": this.token
|
||||||
|
* };
|
||||||
|
* const _0xe8bb64 = {
|
||||||
|
* "fn": "getLoginedUserInfo",
|
||||||
|
* "method": "get",
|
||||||
|
* "url": "https://i.meituan.com/wrapapi/getLoginedUserInfo",
|
||||||
|
* "searchParams": _0x3daa7c
|
||||||
|
* };
|
||||||
|
* let {
|
||||||
|
* result: _0x48e5d7
|
||||||
|
* } = await this.request(_0xe8bb64);
|
||||||
|
* if (_0x48e5d7?.["mobile"]) {
|
||||||
|
* _0x26ac1b = true;
|
||||||
|
* this.name = _0x48e5d7.nickName;
|
||||||
|
* this.userId = Number(_0x48e5d7.userId);
|
||||||
|
* this.log("登录成功");
|
||||||
|
* } else {
|
||||||
|
* this.log("获取账号信息失败, ck可能失效");//, {"notify": true}
|
||||||
|
* await expireNotify(this.userId, this.index);
|
||||||
|
* }
|
||||||
|
* } catch (_0x232c57) {
|
||||||
|
* console.log(_0x232c57);
|
||||||
|
* } finally {
|
||||||
|
* return _0x26ac1b;
|
||||||
|
* }
|
||||||
|
* }*/
|
||||||
|
|
||||||
|
// 通过token 获取用户信息
|
||||||
|
// url https://i.meituan.com/wrapapi/getLoginedUserInfo
|
||||||
|
// 参数 token
|
||||||
|
// get
|
||||||
|
public HashMap<String,String> getLoginedUserInfo(String token) {
|
||||||
|
String responseStr = HttpRequest.get("https://i.meituan.com/wrapapi/getLoginedUserInfo"+"?token="+token).header("token", token).execute().body();
|
||||||
|
HashMap<String,String> result = new HashMap<>();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
JSONObject qlResponse = JSON.parseObject(responseStr);
|
||||||
|
//{"userId":"3822095266","nickName":"XLP200660795","growthValue":null,"growthLevel":null,"avatarUrl":"","mobile":"15817969021"}
|
||||||
|
if (qlResponse.containsKey("mobile")) {
|
||||||
|
result.put("mobile",qlResponse.getString("mobile"));
|
||||||
|
}
|
||||||
|
if (qlResponse.containsKey("nickName")) {
|
||||||
|
result.put("nickName",qlResponse.getString("nickName"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// new QLEnv(value, name, remarks)
|
||||||
|
private static class QLEnv {
|
||||||
|
private String value;
|
||||||
|
private String name;
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
public QLEnv(String value, String name, String remarks) {
|
||||||
|
this.value = value;
|
||||||
|
this.name = name;
|
||||||
|
this.remarks = remarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemarks() {
|
||||||
|
return remarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemarks(String remarks) {
|
||||||
|
this.remarks = remarks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class QLResponse {
|
||||||
|
private String code;
|
||||||
|
private JSONObject data;
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(JSONObject data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
262
src/main/java/cn/van333/mt2ql/wxMessage/utils/WXUtil.java
Normal file
262
src/main/java/cn/van333/mt2ql/wxMessage/utils/WXUtil.java
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
package cn.van333.mt2ql.wxMessage.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.van333.mt2ql.wxMessage.enums.WXReqType;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2023/12/22 0022 上午 09:59
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
public class WXUtil {
|
||||||
|
/**
|
||||||
|
* url http://127.0.0.1:7777/DaenWxHook/httpapi/
|
||||||
|
* 获取微信列表 (X0000)
|
||||||
|
* 微信状态检测(Q0000)
|
||||||
|
* 发送文本消息(Q0001)
|
||||||
|
* 修改下载图片 (Q0002)
|
||||||
|
* 获取个人信息 (Q0003)
|
||||||
|
* 查询对象信(Q0004)
|
||||||
|
* 获取好友列表(Q0005)
|
||||||
|
* 获取群聊列表(Q0006)
|
||||||
|
* 获取公众号列表(Q0007)
|
||||||
|
* 获取群成员列表(Q0008)
|
||||||
|
* 发送聊天记录(Q0009)
|
||||||
|
* 发送图片 (Q0010)
|
||||||
|
* 发送本地文件(Q0011)
|
||||||
|
* 发送分享链接(Q0012)
|
||||||
|
* 发送小程序(Q0013)
|
||||||
|
* 发送音乐分享(Q0014)
|
||||||
|
* 发送XML (Q0015)
|
||||||
|
* 确认收款 (Q0016)
|
||||||
|
* 同意好友请求(Q0017)
|
||||||
|
* 添加好友通过v3(Q0018)
|
||||||
|
* 添加好友_通过wxid (Q0019)
|
||||||
|
* 查询陌生人信息(Q0020)
|
||||||
|
* 邀请进群(Q0021)
|
||||||
|
* 删除好友(Q0022)
|
||||||
|
* 修改对象备注(Q0023)
|
||||||
|
* 修改群聊名称(Q0024)
|
||||||
|
* 发送名片(Q0025)
|
||||||
|
*/
|
||||||
|
public static final String WX_BASE_URL = "http://134.175.126.60:47777/DaenWxHook/httpapi/";
|
||||||
|
private static final RedisCache redisCache = SpringUtil.getBean(RedisCache.class);
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(WXUtil.class);
|
||||||
|
|
||||||
|
|
||||||
|
// 获取微信列表
|
||||||
|
public JSONObject getWxList() {
|
||||||
|
WxReqDate wxReqDate = createWxReqData(WXReqType.GET_WX_LIST);
|
||||||
|
String responseStr = HttpRequest.post(WX_BASE_URL).body(JSON.toJSONString(wxReqDate)).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
return JSON.parseObject(responseStr);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送文本消息
|
||||||
|
public JSONObject sendTextMessage(String wxid, String content) {
|
||||||
|
String botWxid = "";
|
||||||
|
JSONObject wxList = getWxList();
|
||||||
|
JSONObject wxBotInfo = (JSONObject) wxList.getJSONArray("result").get(0);
|
||||||
|
botWxid = wxBotInfo.getString("wxid");
|
||||||
|
|
||||||
|
//
|
||||||
|
WxReqDate wxReqDate = createWxReqData(WXReqType.SEND_TEXT_MESSAGE);
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("wxid", wxid);
|
||||||
|
//[@,wxid=对象wxid,nick=对象昵称,isAuto=true]
|
||||||
|
content = "[@,wxid=" + wxid + ",nick=6,isAuto=true] " + content;
|
||||||
|
jsonObject.put("msg", content);
|
||||||
|
wxReqDate.setData(jsonObject);
|
||||||
|
while (Util.isNotEmpty(botWxid)) {
|
||||||
|
String responseStr = HttpRequest.post(WX_BASE_URL + "?wxid=" + botWxid).body(JSON.toJSONString(wxReqDate)).execute().body();
|
||||||
|
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
JSONObject response = JSON.parseObject(responseStr);
|
||||||
|
//WxResponse wxResponse = JSON.parseObject(responseStr, WxResponse.class);
|
||||||
|
//System.out.println(wxResponse);
|
||||||
|
//if (Objects.equals(String.valueOf(wxResponse.getCode()), "200")) {
|
||||||
|
// return wxResponse.getData();
|
||||||
|
//}
|
||||||
|
//JSONObject jsonObject = HttpUtil.sendPost(url, wxReqDate.getData());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//private JSONObject sendWxReq(WxReqDate wxReqDate) {
|
||||||
|
// if (wxReqDate == null) {
|
||||||
|
// return null;
|
||||||
|
// } else {
|
||||||
|
// logger.info("wxReqDate: {}", wxReqDate);
|
||||||
|
//
|
||||||
|
// String responseStr = HttpRequest.post(WX_BASE_URL).body(JSON.toJSONString(wxReqDate)).execute().body();
|
||||||
|
// if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||||
|
// JSONObject jsonObject = JSON.parseObject(responseStr);
|
||||||
|
// //WxResponse wxResponse = JSON.parseObject(responseStr, WxResponse.class);
|
||||||
|
// //System.out.println(wxResponse);
|
||||||
|
// //if (Objects.equals(String.valueOf(wxResponse.getCode()), "200")) {
|
||||||
|
// // return wxResponse.getData();
|
||||||
|
// //}
|
||||||
|
// //JSONObject jsonObject = HttpUtil.sendPost(url, wxReqDate.getData());
|
||||||
|
// return jsonObject;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
public WxReqDate createWxReqData(WXReqType wxReqType) {
|
||||||
|
|
||||||
|
WxReqDate wxReqDate = new WxReqDate(wxReqType.getKey(), null);
|
||||||
|
|
||||||
|
return wxReqDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class WxResponse {
|
||||||
|
/**
|
||||||
|
* {
|
||||||
|
* "code": 200,
|
||||||
|
* "msg": "操作成功",
|
||||||
|
* "result": {},
|
||||||
|
* "wxid": "wxid_3sq4tklb6c3121",
|
||||||
|
* "port": 7305,
|
||||||
|
* "pid": 12384,
|
||||||
|
* "flag": "7777",
|
||||||
|
* "timestamp": "1657462661814"
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
private Integer code;
|
||||||
|
private String msg;
|
||||||
|
private JSONObject result;
|
||||||
|
private String wxid;
|
||||||
|
private Integer port;
|
||||||
|
private Integer pid;
|
||||||
|
private String flag;
|
||||||
|
private String timestamp;
|
||||||
|
|
||||||
|
public WxResponse(Integer code, String msg, JSONObject result, String wxid, Integer port, Integer pid, String flag, String timestamp) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.result = result;
|
||||||
|
this.wxid = wxid;
|
||||||
|
this.port = port;
|
||||||
|
this.pid = pid;
|
||||||
|
this.flag = flag;
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(JSONObject result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWxid() {
|
||||||
|
return wxid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWxid(String wxid) {
|
||||||
|
this.wxid = wxid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(Integer port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPid(Integer pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlag() {
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlag(String flag) {
|
||||||
|
this.flag = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(String timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class WxReqDate {
|
||||||
|
//{
|
||||||
|
// "type": "X0000",
|
||||||
|
// "data": {}
|
||||||
|
//}
|
||||||
|
private String type;
|
||||||
|
private JSONObject data;
|
||||||
|
|
||||||
|
public WxReqDate(String type, JSONObject data) {
|
||||||
|
this.type = type;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxReqDate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(JSONObject data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
package cn.van333.mt2ql.wxMessage.utils;
|
package cn.van333.mt2ql.wxMessage.utils;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
|
||||||
import cn.van333.mt2ql.wxMessage.enums.EventType;
|
import cn.van333.mt2ql.wxMessage.enums.EventType;
|
||||||
import cn.van333.mt2ql.wxMessage.model.WxMessage;
|
import cn.van333.mt2ql.wxMessage.model.WxMessage;
|
||||||
import cn.van333.mt2ql.wxMessage.model.WxMessageDataForChat;
|
import cn.van333.mt2ql.wxMessage.model.WxMessageDataForChat;
|
||||||
import cn.van333.mt2ql.wxMessage.model.WxUser;
|
import cn.van333.mt2ql.wxMessage.model.WxUser;
|
||||||
import cn.van333.mt2ql.wxMessage.service.WxMessageDataForChatService;
|
import cn.van333.mt2ql.wxMessage.service.WxMessageDataForChatService;
|
||||||
import cn.van333.mt2ql.wxMessage.service.WxUserService;
|
import cn.van333.mt2ql.wxMessage.service.WxUserService;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -22,10 +19,6 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static cn.hutool.core.thread.ThreadUtil.sleep;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Leo
|
* @author Leo
|
||||||
@@ -35,18 +28,10 @@ import static cn.hutool.core.thread.ThreadUtil.sleep;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class WxMessageConsumer {
|
public class WxMessageConsumer {
|
||||||
public static final String QL_BASE_URL = "http://134.175.126.60:45700";
|
|
||||||
public static final String GET_TOKEN = QL_BASE_URL + "/open/auth/token";
|
|
||||||
|
|
||||||
//client_id
|
|
||||||
public static final String CLIENT_ID = "Ouv_S9gk5LpV";
|
|
||||||
//client_secret
|
|
||||||
public static final String CLIENT_SECRET = "1pLjAIfBBzu1_UA9q-hOj778";
|
|
||||||
public static final String QL_TOKEN_KEY = "QL_TOKEN_KEY";
|
|
||||||
|
|
||||||
|
public static final String meituanCookie = "meituanCookie";
|
||||||
/**/
|
/**/
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WxMessageConsumer.class);
|
private static final Logger logger = LoggerFactory.getLogger(WxMessageConsumer.class);
|
||||||
|
|
||||||
private static final RedisCache redisCache = SpringUtil.getBean(RedisCache.class);
|
private static final RedisCache redisCache = SpringUtil.getBean(RedisCache.class);
|
||||||
/**
|
/**
|
||||||
* 临时参数
|
* 临时参数
|
||||||
@@ -62,9 +47,9 @@ public class WxMessageConsumer {
|
|||||||
this.wxUserService = wxUserService;
|
this.wxUserService = wxUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async("threadPoolTaskExecutor")
|
//@Async("threadPoolTaskExecutor")
|
||||||
public void consume(WxMessage wxMessage) {
|
public void consume(WxMessage wxMessage) {
|
||||||
logger.info("接收到消息 : {}", wxMessage);
|
//logger.info("接收到消息 : {}", wxMessage);
|
||||||
if (wxMessage.getEvent() == null) {
|
if (wxMessage.getEvent() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -96,9 +81,6 @@ public class WxMessageConsumer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
System.out.println("+++++++++++"+getToken());
|
|
||||||
|
|
||||||
/**{"type":"D0003","des":"收到消息","data":{"timeStamp":"1702957325031","fromType":1,"msgType":1,"msgSource":0,"fromWxid":"wxid_ytpc72mdoskt22","finalFromWxid":"","atWxidList":[],"silence":0,"membercount":0,"signature":"v1_OJXJYpvM","msg":"在不","msgBase64":"5Zyo5LiN"},"timestamp":"1702957325041","wxid":"wxid_kr145nk7l0an31","port":16888,"pid":10468,"flag":"7777"}
|
/**{"type":"D0003","des":"收到消息","data":{"timeStamp":"1702957325031","fromType":1,"msgType":1,"msgSource":0,"fromWxid":"wxid_ytpc72mdoskt22","finalFromWxid":"","atWxidList":[],"silence":0,"membercount":0,"signature":"v1_OJXJYpvM","msg":"在不","msgBase64":"5Zyo5LiN"},"timestamp":"1702957325041","wxid":"wxid_kr145nk7l0an31","port":16888,"pid":10468,"flag":"7777"}
|
||||||
* */
|
* */
|
||||||
WxMessageDataForChat wxMessageDataForChat = data.to(WxMessageDataForChat.class);
|
WxMessageDataForChat wxMessageDataForChat = data.to(WxMessageDataForChat.class);
|
||||||
@@ -126,24 +108,25 @@ public class WxMessageConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String msg = wxMessageDataForChat.getMsg();
|
String msg = wxMessageDataForChat.getMsg();
|
||||||
/**
|
//美团 20-7 + https://i.meituan.com/mttouch/page/account?userId=3822095266&token=AgHdIkm2tAGHc9SQSiG7M8xCx1LbTue9D2HPOAun2eYl3ou7BeEw1uGrGZH-DxmEiUgsbA1v9SM4DQAAAAC6HAAAz0rTXmkB_CIHin08hCu68mFv5k6nUc2q6_CfZqEdBcngRK_xD8Sx5fE4rfdq-yAJ, msgbase64=576O5ZuiIDIwLTcgKyBodHRwczovL2kubWVpdHVhbi5jb20vbXR0b3VjaC9wYWdlL2FjY291bnQ/dXNlcklkPTM4MjIwOTUyNjYmdG9rZW49QWdIZElrbTJ0QUdIYzlTUVNpRzdNOHhDeDFMYlR1ZTlEMkhQT0F1bjJlWWwzb3U3QmVFdzF1R3JHWkgtRHhtRWlVZ3NiQTF2OVNNNERRQUFBQUM2SEFBQXowclRYbWtCX0NJSGluMDhoQ3U2OG1GdjVrNm5VYzJxNl9DZlpxRWRCY25nUktfeEQ4U3g1ZkU0cmZkcS15QUo=
|
||||||
* https://i.meituan.com/mttouch/page/account
|
|
||||||
* ?userId=3822095266
|
|
||||||
* &token=AgHdIkm2tAGHc9SQSiG7M8xCx1LbTue9D2HPOAun2eYl3ou7BeEw1uGrGZH-DxmEiUgsbA1v9SM4DQAAAAC6HAAAz0rTXmkB_CIHin08hCu68mFv5k6nUc2q6_CfZqEdBcngRK_xD8Sx5fE4rfdq-yAJ
|
|
||||||
* */
|
|
||||||
if (msg.startsWith("美团 20-7 ")) {
|
if (msg.startsWith("美团 20-7 ")) {
|
||||||
logger.info("处理美团的消息");
|
logger.info("处理美团的消息");
|
||||||
if (msg.contains("https://i.meituan.com/mttouch/page/account")) {
|
msg = msg.substring(msg.indexOf("https://i.meituan.com/mttouch/page/account"));
|
||||||
|
String[] all = msg.split("\\?");
|
||||||
|
|
||||||
|
if (all.length == 2) {
|
||||||
String wxid = null;
|
String wxid = null;
|
||||||
if (wxMessageDataForChat.getFromtype() == 1) {
|
if (wxMessageDataForChat.getFromtype() == 1) {
|
||||||
wxid = wxMessageDataForChat.getFromwxid();
|
wxid = wxMessageDataForChat.getFromwxid();
|
||||||
} else if (wxMessageDataForChat.getFromtype() == 2) {
|
} else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||||
wxid = wxMessageDataForChat.getFinalfromwxid();
|
wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||||
}
|
}
|
||||||
String token = msg.substring(msg.indexOf("token=") + 6, msg.indexOf("&"));
|
String httpData = all[1];
|
||||||
String userId = msg.substring(msg.indexOf("userId=") + 7);
|
String[] httpDataArr = httpData.split("&");
|
||||||
logger.info("token: {}, userId: {}", token, userId);
|
if (httpDataArr.length == 2) {
|
||||||
mt20(wxid, userId, token);
|
mt20(wxid, httpDataArr[0].split("=")[1], httpDataArr[1].split("=")[1]);
|
||||||
|
}
|
||||||
|
//mt20(wxid, userId, token);
|
||||||
//if (runResult) {
|
//if (runResult) {
|
||||||
// logger.info("领券成功");
|
// logger.info("领券成功");
|
||||||
// String newMsg = msg.replace("https://i.meituan.com/mttouch/page/account", "https://i.meituan.com/mttouch/page/account?userId=" + userId + "&token=" + token);
|
// String newMsg = msg.replace("https://i.meituan.com/mttouch/page/account", "https://i.meituan.com/mttouch/page/account?userId=" + userId + "&token=" + token);
|
||||||
@@ -179,6 +162,7 @@ public class WxMessageConsumer {
|
|||||||
Boolean isRun = (Boolean) checkYuE.get("isRun");
|
Boolean isRun = (Boolean) checkYuE.get("isRun");
|
||||||
String info = (String) checkYuE.get("info");
|
String info = (String) checkYuE.get("info");
|
||||||
BigDecimal yuE = (BigDecimal) checkYuE.get("yuE");
|
BigDecimal yuE = (BigDecimal) checkYuE.get("yuE");
|
||||||
|
isRun = true;
|
||||||
|
|
||||||
// 余额可以支持一次扣费
|
// 余额可以支持一次扣费
|
||||||
if (isRun) {
|
if (isRun) {
|
||||||
@@ -208,17 +192,19 @@ public class WxMessageConsumer {
|
|||||||
WxUser wxUser = wxUserService.getOne(Wrappers.query(new WxUser()).eq("wxid", wxid));
|
WxUser wxUser = wxUserService.getOne(Wrappers.query(new WxUser()).eq("wxid", wxid));
|
||||||
if (Util.isEmpty(wxUser)) {
|
if (Util.isEmpty(wxUser)) {
|
||||||
info = "未进行过充值,请先充值后使用。";
|
info = "未进行过充值,请先充值后使用。";
|
||||||
}
|
} else {
|
||||||
// 如果余额小于等于零
|
// 如果余额小于等于零
|
||||||
if (wxUser.getMoneyShengyu().compareTo(BigDecimal.ZERO) <= 0) {
|
if (wxUser.getMoneyShengyu().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
info = "账户余额不足,请先充值后使用。";
|
info = "账户余额不足,请先充值后使用。";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wxUser.getMoneyShengyu().compareTo(priceOfMT20) < 0) {
|
||||||
|
info = "剩余余额不足以支持本次扣费,请先充值后使用。";
|
||||||
|
} else {
|
||||||
|
isRun = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wxUser.getMoneyShengyu().compareTo(priceOfMT20) < 0) {
|
|
||||||
info = "剩余余额不足以支持本次扣费,请先充值后使用。";
|
|
||||||
} else {
|
|
||||||
isRun = true;
|
|
||||||
}
|
|
||||||
// 返回结果
|
// 返回结果
|
||||||
result.put("yuE", yuE);
|
result.put("yuE", yuE);
|
||||||
result.put("info", info);
|
result.put("info", info);
|
||||||
@@ -234,7 +220,7 @@ public class WxMessageConsumer {
|
|||||||
* @throws
|
* @throws
|
||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
private String runQL(String token, String remark, Integer time) {
|
private String runQL(String token, String wxid, Integer time) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. 在系统设置 -> 应用设置 -> 添加应用,权限目前支持5个模块,可以选择多个模块。选择一个模块之后,可读写此模块的所有接口。
|
* 1. 在系统设置 -> 应用设置 -> 添加应用,权限目前支持5个模块,可以选择多个模块。选择一个模块之后,可读写此模块的所有接口。
|
||||||
@@ -244,46 +230,41 @@ public class WxMessageConsumer {
|
|||||||
* 4. openapi的接口与系统正常接口的区别就是青龙里的是/api/envs,openapi是/open/envs,即就是青龙接口中的api换成open
|
* 4. openapi的接口与系统正常接口的区别就是青龙里的是/api/envs,openapi是/open/envs,即就是青龙接口中的api换成open
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
//String responseStr = HttpRequest.post(QL_BASE_URL + getToken())
|
//String responseStr = HttpRequest.post(QL_BASE_URL + getToken())
|
||||||
// .body(JSON.toJSONString(jsonMap))//头信息,多个头信息多次调用此方法即可
|
// .body(JSON.toJSONString(jsonMap))//头信息,多个头信息多次调用此方法即可
|
||||||
// .execute().body();
|
// .execute().body();
|
||||||
|
|
||||||
System.out.println("+++++++++++"+getToken());
|
/*
|
||||||
|
* 1.查询有没有这个环境变量
|
||||||
|
* 2.没有就创建
|
||||||
|
* 3.有就修改 环境变量名 需要 wxid + 手机号
|
||||||
|
* 4.执行crons
|
||||||
|
* 5.如果是一次性的,time = 1 ,就删除环境变量(考虑改成禁用)
|
||||||
|
* 6.拿到青龙的结果
|
||||||
|
* */
|
||||||
|
//new QLUtil().getEnv(remark)
|
||||||
|
QLUtil qlUtil = new QLUtil();
|
||||||
|
WXUtil wxUtil = new WXUtil();
|
||||||
|
|
||||||
|
|
||||||
|
HashMap<String, String> loginedUserInfo = qlUtil.getLoginedUserInfo(token);
|
||||||
|
if (Util.isNotEmpty(loginedUserInfo)) {
|
||||||
|
String mobile = loginedUserInfo.get("mobile");
|
||||||
|
String nickName = loginedUserInfo.get("nickName");
|
||||||
|
String remark = nickName + "+" + mobile;
|
||||||
|
//qlUtil.addEnv(token, meituanCookie, remark);
|
||||||
|
wxUtil.sendTextMessage(wxid, remark);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
wxUtil.sendTextMessage(wxid, "获取用户信息失败");
|
||||||
|
|
||||||
|
return "获取用户信息失败";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getToken() {
|
|
||||||
|
|
||||||
String token = redisCache.getCacheObject(QL_TOKEN_KEY);
|
|
||||||
if (StrUtil.isNotEmpty(token)) {
|
|
||||||
return token;
|
|
||||||
} else {
|
|
||||||
//HashMap<String, String> map = new HashMap<>();
|
|
||||||
//map.put("client_id", CLIENT_ID);
|
|
||||||
//map.put("client_secret", CLIENT_SECRET);
|
|
||||||
//String jsonStr = JSON.toJSONString(map);
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
//* 2. 使用生成的 client_id 和 client_secret 请求获取token接口 http://localhost:5700/open/auth/token?client_id=xxxxxx&client_secret=xxxxxxxx
|
|
||||||
String responseStr = HttpRequest.get(GET_TOKEN+"?client_id="+CLIENT_ID+"&client_secret="+CLIENT_SECRET)
|
|
||||||
.execute().body();
|
|
||||||
if (ObjectUtil.isNotEmpty(responseStr)) {
|
|
||||||
//{"code":200,"data":{"token":"950e3060-d714-4f6a-9839-c098a116f0a8","token_type":"Bearer","expiration":1705743778}}
|
|
||||||
JSONObject jsonObject = JSON.parseObject(responseStr);
|
|
||||||
|
|
||||||
System.out.println(jsonObject.getString("code"));
|
|
||||||
if (Objects.equals(String.valueOf(jsonObject.getString("code")), "200")) {
|
|
||||||
JSONObject response = jsonObject.getJSONObject("data");
|
|
||||||
redisCache.setCacheObject(QL_TOKEN_KEY, (String)response.get("token"), (int)response.get("expiration"), TimeUnit.SECONDS);
|
|
||||||
return (String) response.get("token");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sleep(500);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/main/resources/mapper/WxMessageDataForChatMapper.xml
Normal file
31
src/main/resources/mapper/WxMessageDataForChatMapper.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?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="cn.van333.mt2ql.wxMessage.mapper.WxMessageDataForChatMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="cn.van333.mt2ql.wxMessage.model.WxMessageDataForChat">
|
||||||
|
<result property="timestamp" column="timeStamp" jdbcType="BIGINT"/>
|
||||||
|
<result property="fromtype" column="fromType" jdbcType="INTEGER"/>
|
||||||
|
<result property="msgtype" column="msgType" jdbcType="INTEGER"/>
|
||||||
|
<result property="msgsource" column="msgSource" jdbcType="INTEGER"/>
|
||||||
|
<result property="fromwxid" column="fromWxid" jdbcType="VARCHAR"/>
|
||||||
|
<result property="finalfromwxid" column="finalFromWxid" jdbcType="VARCHAR"/>
|
||||||
|
<result property="atwxidlist" column="atWxidList" jdbcType="VARCHAR"/>
|
||||||
|
<result property="silence" column="silence" jdbcType="INTEGER"/>
|
||||||
|
<result property="membercount" column="membercount" jdbcType="INTEGER"/>
|
||||||
|
<result property="signature" column="signature" jdbcType="VARCHAR"/>
|
||||||
|
<result property="msg" column="msg" jdbcType="VARCHAR"/>
|
||||||
|
<result property="msgbase64" column="msgBase64" jdbcType="VARCHAR"/>
|
||||||
|
<result property="msgid" column="msgId" jdbcType="VARCHAR"/>
|
||||||
|
<result property="msgtypestr" column="msgTypeStr" jdbcType="VARCHAR"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
timeStamp,fromType,msgType,
|
||||||
|
msgSource,fromWxid,finalFromWxid,
|
||||||
|
atWxidList,silence,membercount,
|
||||||
|
signature,msg,msgBase64,
|
||||||
|
msgId,msgTypeStr
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
22
src/main/resources/mapper/WxUserMapper.xml
Normal file
22
src/main/resources/mapper/WxUserMapper.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?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="cn.van333.mt2ql.wxMessage.mapper.WxUserMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="cn.van333.mt2ql.wxMessage.model.WxUser">
|
||||||
|
<id property="wxid" column="wxid" jdbcType="VARCHAR"/>
|
||||||
|
<result property="moneyLeiji" column="money_leiji" jdbcType="DECIMAL"/>
|
||||||
|
<result property="moneyShengyu" column="money_shengyu" jdbcType="DECIMAL"/>
|
||||||
|
<result property="countChongzhi" column="count_chongzhi" jdbcType="DECIMAL"/>
|
||||||
|
<result property="countXiaofei" column="count_xiaofei" jdbcType="DECIMAL"/>
|
||||||
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
wxid,money_leiji,money_shengyu,
|
||||||
|
count_chongzhi,count_xiaofei,name,
|
||||||
|
status
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user