1
This commit is contained in:
@@ -492,7 +492,7 @@ public class JDUtils {
|
||||
/**
|
||||
* 接收京粉指令指令
|
||||
*/
|
||||
public void sendOrderToWxByOrderJD(String order) {
|
||||
public void sendOrderToWxByOrderJD(String order,String fromWxid) {
|
||||
int[] param = {-1};
|
||||
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(param);
|
||||
/**
|
||||
@@ -781,10 +781,10 @@ public class JDUtils {
|
||||
}
|
||||
|
||||
default:
|
||||
sendOrderToWxByOrderJDAdvanced(order);
|
||||
sendOrderToWxByOrderJDAdvanced(order,fromWxid);
|
||||
}
|
||||
if (content.length() > 0) {
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, WXUtil.super_admin_wxid);
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1,fromWxid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -793,7 +793,7 @@ public class JDUtils {
|
||||
* 接收京粉指令指令
|
||||
* 高级菜单
|
||||
*/
|
||||
public void sendOrderToWxByOrderJDAdvanced(String order) {
|
||||
public void sendOrderToWxByOrderJDAdvanced(String order,String fromWxid) {
|
||||
int[] parm = {-1};
|
||||
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
|
||||
|
||||
@@ -855,13 +855,13 @@ public class JDUtils {
|
||||
for (String s : split) {
|
||||
content.append("https://item.jd.com/").append(s).append(".html").append("\r\n");
|
||||
}
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, WXUtil.super_admin_wxid);
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, fromWxid);
|
||||
content = new StringBuilder();
|
||||
content.append("手机端").append("\r\n");
|
||||
for (String s : split) {
|
||||
content.append("https://item.m.jd.com/product/").append(s).append(".html").append("\r\n");
|
||||
}
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, WXUtil.super_admin_wxid);
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, fromWxid);
|
||||
content = new StringBuilder();
|
||||
|
||||
|
||||
@@ -876,13 +876,13 @@ public class JDUtils {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
sendOrderToWxByOrderJD("菜单");
|
||||
sendOrderToWxByOrderJD("菜单",fromWxid);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if (content.length() > 0) {
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, WXUtil.super_admin_wxid);
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content.toString(), 1, fromWxid);
|
||||
}
|
||||
}
|
||||
//public UnionOpenGoodsBigfieldQueryResponse getUnionOpenGoodsBigfieldQueryResponse(){
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import static cn.van.business.util.WXUtil.jdidToWxidMap;
|
||||
|
||||
|
||||
/**
|
||||
* @author Leo
|
||||
@@ -49,7 +51,8 @@ public class OrderUtil {
|
||||
if (!isAutoFlush || !lastValidCode.equals(newValidCode)) {
|
||||
// 当 isAutoFlush 为 false 或状态确实有变化时,进行消息发送
|
||||
String content = getFormattedOrderInfo(orderRow, lastValidCode);
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content, 1, WXUtil.super_admin_wxid);
|
||||
String wxId = jdidToWxidMap.get(orderRow.getUnionId());
|
||||
wxUtil.sendTextMessage(wxId, content, 1, wxId);
|
||||
}
|
||||
|
||||
// 更新 Redis 状态值
|
||||
|
||||
@@ -15,10 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Leo
|
||||
@@ -31,6 +28,38 @@ public class WXUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(WXUtil.class);
|
||||
public static final String super_admin_wxid = "wxid_ytpc72mdoskt22";
|
||||
public static Map<String, SuperAdmin> super_admins = new HashMap<>();
|
||||
public static Map<String, String> jdidToWxidMap = new HashMap<>();
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SuperAdmin {
|
||||
private String wxid;
|
||||
private String name;
|
||||
// 联盟ID
|
||||
private String unionId;
|
||||
private String appKey ;
|
||||
private String secretKey ;
|
||||
}
|
||||
|
||||
// 初始化超级管理员
|
||||
public void initSuperAdmins() {
|
||||
SuperAdmin admin1 = new SuperAdmin("wxid_ytpc72mdoskt22", "凡", "2014264913","98e21c89ae5610240ec3f5f575f86a59","3dcb6b23a1104639ac433fd07adb6dfb");
|
||||
super_admins.put(admin1.getWxid(), admin1);
|
||||
jdidToWxidMap.put(admin1.getUnionId(), admin1.getWxid());
|
||||
|
||||
SuperAdmin admin2 = new SuperAdmin("wxid_yneqf1implxu12", "源", "","","");
|
||||
super_admins.put(admin2.getWxid(), admin2);
|
||||
jdidToWxidMap.put(admin2.getUnionId(), admin2.getWxid());
|
||||
|
||||
// add more admins as needed...
|
||||
}
|
||||
|
||||
public static String getWxidFromJdid(String jdid) {
|
||||
return jdidToWxidMap.get(jdid);
|
||||
}
|
||||
|
||||
/**
|
||||
* url http://127.0.0.1:7777/DaenWxHook/httpapi/
|
||||
* 获取微信列表 (X0000)
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.van.business.util.WXUtil.super_admin_wxid;
|
||||
import static cn.van.business.util.WXUtil.super_admins;
|
||||
|
||||
|
||||
/**
|
||||
@@ -286,7 +287,8 @@ public class WxMessageConsumer {
|
||||
return;
|
||||
}
|
||||
// 只处理超管的消息
|
||||
if (!Objects.equals(innerData.getFromWxid(), super_admin_wxid)) {
|
||||
String fromWxid = innerData.getFromWxid();
|
||||
if (!Objects.equals(fromWxid, super_admins.get(super_admin_wxid).getWxid())) {
|
||||
logger.info("不是超管消息,不处理");
|
||||
return;
|
||||
}
|
||||
@@ -314,7 +316,7 @@ public class WxMessageConsumer {
|
||||
// wxUtil.sendTextMessage(wxid, transferResultUrl, msgType, null);
|
||||
//}
|
||||
} else if (msg.startsWith("京")) {
|
||||
jdUtils.sendOrderToWxByOrderJD(msg.replace("京", ""));
|
||||
jdUtils.sendOrderToWxByOrderJD(msg.replace("京", ""),fromWxid);
|
||||
}
|
||||
//else if (msg.startsWith("美团 ")) {
|
||||
// logger.info("处理美团的消息");
|
||||
|
||||
Reference in New Issue
Block a user