拼多多地址
This commit is contained in:
@@ -50,6 +50,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import static cn.van.business.util.JDUtil.UserInteractionState.GiftMoneyStep.*;
|
||||
import static cn.van.business.util.JDUtil.UserInteractionState.ProcessState.INIT;
|
||||
import static cn.van.business.util.WXUtil.chatRoom_BY;
|
||||
import static cn.van.business.util.WXUtil.super_admins;
|
||||
|
||||
/**
|
||||
@@ -186,6 +187,36 @@ public class JDUtil {
|
||||
// 具体逻辑
|
||||
}
|
||||
|
||||
public void cjwlm(String message) {
|
||||
logger.info("执行 cjwlm 方法,order: {}", message);
|
||||
if (message.contains("https://u.jd")) {
|
||||
// 2. 生成推广内容
|
||||
HashMap<String, List<String>> contentResult = generatePromotionContent(message);
|
||||
|
||||
// 3. 发送文本内容
|
||||
for (String text : contentResult.get("text")) {
|
||||
wxUtil.sendTextMessage(chatRoom_BY, text, 1, chatRoom_BY, true);
|
||||
}
|
||||
|
||||
// 4. 发送图片(如果有)
|
||||
List<String> images = contentResult.get("images");
|
||||
if (images != null) {
|
||||
try {
|
||||
Thread.sleep(6000);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
for (String imageUrl : images) {
|
||||
if (imageUrl != null) {
|
||||
wxUtil.sendImageMessage(chatRoom_BY, imageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 具体逻辑
|
||||
}
|
||||
|
||||
private OrderStats calculateStats(List<OrderRow> orders) {
|
||||
long paid = orders.stream().filter(o -> o.getValidCode() == 16).count();
|
||||
long pending = orders.stream().filter(o -> o.getValidCode() == 15).count();
|
||||
|
||||
@@ -36,6 +36,10 @@ public class WXUtil {
|
||||
public static Map<String, SuperAdmin> super_admins = new HashMap<>();
|
||||
public static Map<String, String> jdidToWxidMap = new HashMap<>();
|
||||
public static List<String> chatRoomList = new ArrayList<>();
|
||||
//玩乐买
|
||||
public static String chatRoom_WLM = "23143922156@chatroom";
|
||||
//搬运群
|
||||
public static String chatRoom_BY = "50400969285@chatroom";
|
||||
/**
|
||||
* url http://127.0.0.1:7777/DaenWxHook/httpapi/
|
||||
* 获取微信列表 (X0000)
|
||||
@@ -189,7 +193,8 @@ public class WXUtil {
|
||||
}
|
||||
|
||||
}
|
||||
public void sendImageMessage(String wxid, String imagePath){
|
||||
|
||||
public void sendImageMessage(String wxid, String imagePath) {
|
||||
WxReqDate wxReqDate = createWxReqData(WXReqType.SEND_IMAGE);
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("wxid", wxid);
|
||||
|
||||
@@ -3,14 +3,11 @@ package cn.van.business.util;
|
||||
|
||||
import cn.van.business.enums.FromType;
|
||||
import cn.van.business.model.wx.WxMessage;
|
||||
import cn.van.business.model.wx.WxMessageDataForChat;
|
||||
import cn.van.business.model.wx.WxUser;
|
||||
import cn.van.business.repository.SettingRepository;
|
||||
import cn.van.business.repository.WxMessageDataForChatRepository;
|
||||
import cn.van.business.repository.WxUserRepository;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -19,15 +16,11 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.van.business.util.WXUtil.chatRoomList;
|
||||
import static cn.van.business.util.WXUtil.super_admins;
|
||||
import static cn.van.business.util.WXUtil.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -195,8 +188,6 @@ public class WxMessageConsumer {
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void consume(WxMessage wxMessage) throws Exception {
|
||||
//logger.info("接收到消息 : {}", wxMessage);
|
||||
@@ -227,42 +218,43 @@ public class WxMessageConsumer {
|
||||
*
|
||||
* @param wxMessage
|
||||
*/
|
||||
private void handlePrivateMessage(WxMessage wxMessage) throws Exception {
|
||||
logger.info("处理私聊消息: {}", JSON.toJSONString(wxMessage));
|
||||
private void handlePrivateMessage(WxMessage wxMessage) throws Exception {
|
||||
logger.info("处理私聊消息: {}", JSON.toJSONString(wxMessage));
|
||||
|
||||
WxMessage.DataSection data = wxMessage.getData();
|
||||
WxMessage.DataSection.InnerData innerData = data.getData();
|
||||
if (Util.isAnyEmpty(innerData.getMsg(), innerData.getFromWxid())) {
|
||||
logger.info("消息内容为空,不处理");
|
||||
return;
|
||||
} else {
|
||||
logger.info("消息内容:{}", innerData.getMsg());
|
||||
WxMessage.DataSection data = wxMessage.getData();
|
||||
WxMessage.DataSection.InnerData innerData = data.getData();
|
||||
if (Util.isAnyEmpty(innerData.getMsg(), innerData.getFromWxid())) {
|
||||
logger.info("消息内容为空,不处理");
|
||||
return;
|
||||
} else {
|
||||
logger.info("消息内容:{}", innerData.getMsg());
|
||||
}
|
||||
|
||||
String fromWxid = innerData.getFromWxid();
|
||||
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
||||
if (Util.isEmpty(superAdmin)) {
|
||||
logger.info("不是超管消息,不处理");
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = innerData.getMsg();
|
||||
if (msg.startsWith("京")) {
|
||||
logger.info("消息以京开头,处理京东指令消息");
|
||||
jdUtils.sendOrderToWxByOrderJD(msg.replace("京", ""), fromWxid);
|
||||
return;
|
||||
} else {
|
||||
logger.info("消息不以京开头");
|
||||
}
|
||||
if (msg.startsWith("拼")) {
|
||||
logger.info("消息以拼开头,处理拼多多指令消息");
|
||||
jdUtils.sendOrderToWxByOrderPDD(msg.replace("拼", ""), fromWxid);
|
||||
return;
|
||||
}
|
||||
logger.info("未命中前置指令,开始命中 Default 流程");
|
||||
jdUtils.sendOrderToWxByOrderDefault(msg, fromWxid);
|
||||
}
|
||||
|
||||
String fromWxid = innerData.getFromWxid();
|
||||
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
||||
if (Util.isEmpty(superAdmin)) {
|
||||
logger.info("不是超管消息,不处理");
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = innerData.getMsg();
|
||||
if (msg.startsWith("京")) {
|
||||
logger.info("消息以京开头,处理京东指令消息");
|
||||
jdUtils.sendOrderToWxByOrderJD(msg.replace("京", ""), fromWxid);
|
||||
return;
|
||||
} else {
|
||||
logger.info("消息不以京开头");
|
||||
}
|
||||
if (msg.startsWith("拼")) {
|
||||
logger.info("消息以拼开头,处理拼多多指令消息");
|
||||
jdUtils.sendOrderToWxByOrderPDD(msg.replace("拼", ""), fromWxid);
|
||||
return;
|
||||
}
|
||||
logger.info("未命中前置指令,开始命中 Default 流程");
|
||||
jdUtils.sendOrderToWxByOrderDefault(msg, fromWxid);
|
||||
}
|
||||
private void handleGroupMessage (WxMessage wxMessage) {
|
||||
private void handleGroupMessage(WxMessage wxMessage) {
|
||||
logger.info("处理群聊消息: {}", JSON.toJSONString(wxMessage));
|
||||
|
||||
WxMessage.DataSection data = wxMessage.getData();
|
||||
@@ -275,12 +267,18 @@ private void handlePrivateMessage(WxMessage wxMessage) throws Exception {
|
||||
}
|
||||
|
||||
String fromWxid = innerData.getFromWxid();
|
||||
if ( !chatRoomList.contains(fromWxid)) {
|
||||
String msg = innerData.getMsg();
|
||||
|
||||
if (chatRoom_WLM.equals(fromWxid)) {
|
||||
logger.info("玩了买线报群消息");
|
||||
jdUtils.cjwlm(msg);
|
||||
return;
|
||||
}
|
||||
if (!chatRoomList.contains(fromWxid)) {
|
||||
logger.info("不是白名单群聊,不处理");
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = innerData.getMsg();
|
||||
if (msg.startsWith("拼")) {
|
||||
logger.info("消息以拼开头,处理拼多多指令消息");
|
||||
jdUtils.sendOrderToWxByOrderPDD(msg.replace("拼", ""), fromWxid);
|
||||
@@ -318,105 +316,105 @@ private void handlePrivateMessage(WxMessage wxMessage) throws Exception {
|
||||
* }
|
||||
* }*/
|
||||
}
|
||||
//else if (msg.startsWith("美团 ")) {
|
||||
// logger.info("处理美团的消息");
|
||||
// msg = msg.substring(msg.indexOf("https://i.meituan.com/mttouch/page/account"));
|
||||
// String[] all = msg.split("\\?");
|
||||
//
|
||||
// if (all.length == 2) {
|
||||
// String wxid = null;
|
||||
// if (wxMessage.getFromtype().equals(fromGR)) {
|
||||
// wxid = wxMessage.getFromid();
|
||||
// } else {
|
||||
// wxid = wxMessage.getFromgid();
|
||||
// }
|
||||
// String httpData = all[1];
|
||||
// String[] httpDataArr = httpData.split("&");
|
||||
// if (httpDataArr.length == 2) {
|
||||
// // 调用美团
|
||||
// //String result = mt20(wxid, httpDataArr[0].split("=")[1], httpDataArr[1].split("=")[1]);
|
||||
//
|
||||
// //wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
// } else {
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, "请检查提交的数据格式是否正确。", msgType, null);
|
||||
// }
|
||||
// }
|
||||
//} else if ("余额".equals(msg)) {
|
||||
// String wxid = null;
|
||||
// if (wxMessageDataForChat.getFromtype() == 1) {
|
||||
// wxid = wxMessageDataForChat.getFromwxid();
|
||||
// } else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||
// wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||
// }
|
||||
// WxUser wxUser = wxUserService.getOne(Wrappers.query(new WxUser()).eq("wxid", wxid));
|
||||
// String result = "";
|
||||
// if (Util.isNotEmpty(wxUser)) {
|
||||
// result = "您的余额为:" + wxUser.getMoneyLeiji() + "元\r";
|
||||
// result = result + " 您的消费次数为:" + wxUser.getCountXiaofei() + "次\r";
|
||||
// result = result + " 您的充值次数为:" + wxUser.getCountChongzhi() + "次\r";
|
||||
// result = result + " 您的累计充值为:" + wxUser.getMoneyLeiji() + "元";
|
||||
// } else {
|
||||
// result = "暂未查询到充值记录。\r";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
//} else if ("体验".equals(msg)) {
|
||||
// String wxid = null;
|
||||
// if (wxMessageDataForChat.getFromtype() == 1) {
|
||||
// wxid = wxMessageDataForChat.getFromwxid();
|
||||
// } else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||
// wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||
// }
|
||||
// String result = "";
|
||||
// if (heiMingDan(wxid)) {
|
||||
// result = "黑名单!";
|
||||
// } else {
|
||||
// WxUser wxUser = wxUserService.getOne(Wrappers.query(new WxUser()).eq("wxid", wxid));
|
||||
// if (isNew(wxUser.getIsnew())) {
|
||||
// wxUser.setMoneyLeiji(wxUser.getMoneyLeiji().add(new BigDecimal(1)));
|
||||
// wxUser.setMoneyShengyu(wxUser.getMoneyShengyu().add(new BigDecimal(1)));
|
||||
// wxUser.setCountChongzhi(wxUser.getCountChongzhi().add(BigDecimal.ONE));
|
||||
// wxUser.setIsnew(1);
|
||||
// wxUserService.updateById(wxUser);
|
||||
// result = "体验成功,您已成功充值" + 1.00 + "元,已成功存入账户。感谢您的使用。";
|
||||
// } else {
|
||||
// result = "您已体验过,请勿重复体验。";
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
//
|
||||
//}// 用户返回用户菜单
|
||||
//else if (order_caiDan.equals(msg)) {
|
||||
// String wxid = null;
|
||||
// if (wxMessageDataForChat.getFromtype() == 1) {
|
||||
// wxid = wxMessageDataForChat.getFromwxid();
|
||||
// } else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||
// wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||
// }
|
||||
// String result = "";
|
||||
// String puTong = getSetting(key_caiDan_user);
|
||||
// String chaoJi = getSetting(key_caiDan_admin);
|
||||
// if (isSuperAdminUser(wxid)) {
|
||||
// result = "用户菜单:" + puTong + " 管理员菜单:" + chaoJi;
|
||||
// } else {
|
||||
// result = "用户菜单:" + puTong;
|
||||
// }
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, wxMessageDataForChat.getFromwxid());
|
||||
//}
|
||||
// wxMessageDataForChatService.save(wxMessageDataForChat);
|
||||
//else if (msg.startsWith("美团 ")) {
|
||||
// logger.info("处理美团的消息");
|
||||
// msg = msg.substring(msg.indexOf("https://i.meituan.com/mttouch/page/account"));
|
||||
// String[] all = msg.split("\\?");
|
||||
//
|
||||
// if (all.length == 2) {
|
||||
// String wxid = null;
|
||||
// if (wxMessage.getFromtype().equals(fromGR)) {
|
||||
// wxid = wxMessage.getFromid();
|
||||
// } else {
|
||||
// wxid = wxMessage.getFromgid();
|
||||
// }
|
||||
// String httpData = all[1];
|
||||
// String[] httpDataArr = httpData.split("&");
|
||||
// if (httpDataArr.length == 2) {
|
||||
// // 调用美团
|
||||
// //String result = mt20(wxid, httpDataArr[0].split("=")[1], httpDataArr[1].split("=")[1]);
|
||||
//
|
||||
// //wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
// } else {
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, "请检查提交的数据格式是否正确。", msgType, null);
|
||||
// }
|
||||
// }
|
||||
//} else if ("余额".equals(msg)) {
|
||||
// String wxid = null;
|
||||
// if (wxMessageDataForChat.getFromtype() == 1) {
|
||||
// wxid = wxMessageDataForChat.getFromwxid();
|
||||
// } else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||
// wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||
// }
|
||||
// WxUser wxUser = wxUserService.getOne(Wrappers.query(new WxUser()).eq("wxid", wxid));
|
||||
// String result = "";
|
||||
// if (Util.isNotEmpty(wxUser)) {
|
||||
// result = "您的余额为:" + wxUser.getMoneyLeiji() + "元\r";
|
||||
// result = result + " 您的消费次数为:" + wxUser.getCountXiaofei() + "次\r";
|
||||
// result = result + " 您的充值次数为:" + wxUser.getCountChongzhi() + "次\r";
|
||||
// result = result + " 您的累计充值为:" + wxUser.getMoneyLeiji() + "元";
|
||||
// } else {
|
||||
// result = "暂未查询到充值记录。\r";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
//} else if ("体验".equals(msg)) {
|
||||
// String wxid = null;
|
||||
// if (wxMessageDataForChat.getFromtype() == 1) {
|
||||
// wxid = wxMessageDataForChat.getFromwxid();
|
||||
// } else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||
// wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||
// }
|
||||
// String result = "";
|
||||
// if (heiMingDan(wxid)) {
|
||||
// result = "黑名单!";
|
||||
// } else {
|
||||
// WxUser wxUser = wxUserService.getOne(Wrappers.query(new WxUser()).eq("wxid", wxid));
|
||||
// if (isNew(wxUser.getIsnew())) {
|
||||
// wxUser.setMoneyLeiji(wxUser.getMoneyLeiji().add(new BigDecimal(1)));
|
||||
// wxUser.setMoneyShengyu(wxUser.getMoneyShengyu().add(new BigDecimal(1)));
|
||||
// wxUser.setCountChongzhi(wxUser.getCountChongzhi().add(BigDecimal.ONE));
|
||||
// wxUser.setIsnew(1);
|
||||
// wxUserService.updateById(wxUser);
|
||||
// result = "体验成功,您已成功充值" + 1.00 + "元,已成功存入账户。感谢您的使用。";
|
||||
// } else {
|
||||
// result = "您已体验过,请勿重复体验。";
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, null);
|
||||
//
|
||||
//}// 用户返回用户菜单
|
||||
//else if (order_caiDan.equals(msg)) {
|
||||
// String wxid = null;
|
||||
// if (wxMessageDataForChat.getFromtype() == 1) {
|
||||
// wxid = wxMessageDataForChat.getFromwxid();
|
||||
// } else if (wxMessageDataForChat.getFromtype() == 2) {
|
||||
// wxid = wxMessageDataForChat.getFinalfromwxid();
|
||||
// }
|
||||
// String result = "";
|
||||
// String puTong = getSetting(key_caiDan_user);
|
||||
// String chaoJi = getSetting(key_caiDan_admin);
|
||||
// if (isSuperAdminUser(wxid)) {
|
||||
// result = "用户菜单:" + puTong + " 管理员菜单:" + chaoJi;
|
||||
// } else {
|
||||
// result = "用户菜单:" + puTong;
|
||||
// }
|
||||
//
|
||||
// wxUtil.sendTextMessage(wxid, result, msgType, wxMessageDataForChat.getFromwxid());
|
||||
//}
|
||||
// wxMessageDataForChatService.save(wxMessageDataForChat);
|
||||
|
||||
|
||||
/**
|
||||
* @param wxMessage
|
||||
* @return
|
||||
* @throws
|
||||
* @description 处理群聊消息
|
||||
*/
|
||||
/**
|
||||
* @param wxMessage
|
||||
* @return
|
||||
* @throws
|
||||
* @description 处理群聊消息
|
||||
*/
|
||||
// private void handleGroupMessage (WxMessage wxMessage){
|
||||
// Integer msgType = 2;
|
||||
// /**
|
||||
|
||||
Reference in New Issue
Block a user