This commit is contained in:
雷欧(林平凡)
2025-08-14 18:02:31 +08:00
parent 1a762eb50a
commit 11da6257d6
5 changed files with 130 additions and 19 deletions

View File

@@ -0,0 +1,89 @@
package cn.van.business.enums;
/**
* @author Leo
* @version 1.0
* @create 2023/12/19 0019 上午 10:27
* @description
*/
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum GroupType implements IEnum {
/**
* 类型1管理群2评论群3线报来源群4线报推送群
* */
MANAGEMENT(1, "管理群"),
COMMENT(2, "评论群"),
LINE_REPORT_SOURCE(3, "线报来源群"),
LINE_REPORT_PUSH(4, "线报推送群");
private final int key;
private final String name;
GroupType(int key, String name) {
this.key = key;
this.name = name;
}
public static GroupType get(int key) {
for (GroupType e : GroupType.values()) {
if (e.getKey() == key) {
return e;
}
}
return null;
}
public static String getName(Integer key) {
//if (Object.isNotEmpty(key)) {
GroupType[] items = GroupType.values();
for (GroupType item : items) {
if (item.getKey() == key) {
return item.getName();
}
}
//}
return "";
}
public static Map<String, String> getKeyVlue() {
Map<String, String> map = new HashMap<>();
GroupType[] items = GroupType.values();
for (GroupType 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>>();
GroupType[] items = GroupType.values();
for (GroupType item : items) {
Map<String, Object> map = new HashMap<>();
map.put("label", item.getName());
map.put("value", item.getKey());
result.add(map);
}
return result;
}
@Override
@JsonValue
public Integer getKey() {
return key;
}
@Override
public String getName() {
return name;
}
}

View File

@@ -11,7 +11,7 @@ import java.util.Map;
* @create 2023/12/19 0019 下午 02:31
* @description
*/
public enum MsgTypeEnum implements IEnum {
public enum MsgType implements IEnum {
/**
msgType
1|文本 3|图片 34|语音
@@ -38,13 +38,13 @@ public enum MsgTypeEnum implements IEnum {
private final String name;
MsgTypeEnum(int key, String name) {
MsgType(int key, String name) {
this.key = key;
this.name = name;
}
public static String getName(Integer key) {
for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
for (MsgType msgTypeEnum : MsgType.values()) {
if (msgTypeEnum.key == key) {
return msgTypeEnum.name;
}
@@ -54,7 +54,7 @@ public enum MsgTypeEnum implements IEnum {
public static Map<String, String> getKeyVlue() {
Map<String, String> map = new HashMap<>();
for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
for (MsgType msgTypeEnum : MsgType.values()) {
map.put(msgTypeEnum.key + "", msgTypeEnum.name);
}
return map;
@@ -62,7 +62,7 @@ public enum MsgTypeEnum implements IEnum {
public static List<Map<String, Object>> getSelectItems() {
List<Map<String, Object>> list = new ArrayList<>();
for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
for (MsgType msgTypeEnum : MsgType.values()) {
Map<String, Object> map = new HashMap<>();
map.put("key", msgTypeEnum.key);
map.put("value", msgTypeEnum.name);
@@ -71,8 +71,8 @@ public enum MsgTypeEnum implements IEnum {
return list;
}
public static MsgTypeEnum get(int key) {
for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
public static MsgType get(int key) {
for (MsgType msgTypeEnum : MsgType.values()) {
if (msgTypeEnum.key == key) {
return msgTypeEnum;
}

View File

@@ -5,7 +5,7 @@ import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Getter
@Setter
@@ -18,7 +18,7 @@ public class XbMessage {
private Integer id;
@Column(name = "create_date")
private LocalDate createDate;
private LocalDateTime createDate;
@Size(max = 100)
@Column(name = "skuid", length = 100)
@@ -43,4 +43,4 @@ public class XbMessage {
@Column(name = "first_price")
private Double firstPrice;
}
}

View File

@@ -5,7 +5,7 @@ import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Getter
@Setter
@@ -18,7 +18,7 @@ public class XbMessageItem {
private Integer id;
@Column(name = "create_date")
private LocalDate createDate;
private LocalDateTime createDate;
@Size(max = 100)
@Column(name = "skuid", length = 100)
@@ -68,4 +68,4 @@ public class XbMessageItem {
@Column(name = "json_category_info")
private String jsonCategoryInfo;
}
}

View File

@@ -1446,7 +1446,7 @@ public class JDUtil {
}
} else {
XbMessage xbMessage = new XbMessage();
xbMessage.setCreateDate(LocalDate.now());
xbMessage.setCreateDate(LocalDateTime.now());
xbMessage.setTipOriginalMessage(message);
xbMessage.setFromWxid(wxid);
String firstLine = message.split("\n")[0];
@@ -1475,7 +1475,7 @@ public class JDUtil {
} else {
// 商品信息
XbMessageItem xbMessageItem = new XbMessageItem();
xbMessageItem.setCreateDate(LocalDate.now());
xbMessageItem.setCreateDate(LocalDateTime.now());
xbMessageItem.setXbMessageId(String.valueOf(xbMessageId));
xbMessageItem.setJsonQueryResult(JSONObject.toJSONString(productInfo.getData()[0]));
xbMessageItem.setJsonCouponList(JSONObject.toJSONString(productInfo.getData()[0].getCouponInfo().getCouponList()));
@@ -2021,6 +2021,9 @@ public class JDUtil {
int usedCommentCount = 0;
int canUseComentCount = 0;
int addCommentCount = 0;
int allTbCommentCount = 0;
int usedTbCommentCount = 0;
int canUseTbCommentCount = 0;
boolean isTb = false;
getProductTypeMap();
@@ -2037,6 +2040,15 @@ public class JDUtil {
canUseComentCount = availableComments.size();
usedCommentCount = usedComments.size();
allCommentCount = canUseComentCount + usedCommentCount;
// 获取淘宝评论统计信息
getProductTypeMapForTB();
String taobaoProductId = productTypeMapTB.getOrDefault(product_id, product_id);
List<TaobaoComment> availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1);
List<TaobaoComment> usedTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 0);
canUseTbCommentCount = availableTbComments.size();
usedTbCommentCount = usedTbComments.size();
allTbCommentCount = canUseTbCommentCount + usedTbCommentCount;
Comment commentToUse = null;
@@ -2050,9 +2062,9 @@ public class JDUtil {
* ✅ 新增逻辑:先尝试从淘宝获取评论,但前提是 productTypeMapTB 存在对应映射
*/
getProductTypeMapForTB(); // 加载淘宝映射表
String taobaoProductId = productTypeMapTB.getOrDefault(product_id, null);
String taobaoProductIdMap = productTypeMapTB.getOrDefault(product_id, null);
if (taobaoProductId != null && !taobaoProductId.isEmpty()) {
if (taobaoProductIdMap != null && !taobaoProductIdMap.isEmpty()) {
logger.info("发现淘宝映射ID尝试从淘宝获取评论");
wxUtil.sendTextMessage(fromWxid, "本地无可用京东评论已发现淘宝映射ID从淘宝获取评论", 1, null, true);
Comment taobaoComment = generateTaobaoComment(productType);
@@ -2143,7 +2155,17 @@ public class JDUtil {
"已使用:" + usedCommentCount + "\n" +
"可用:" + canUseComentCount + "\n" +
"总数:" + allCommentCount, 1, fromWxid, true);
} else {
wxUtil.sendTextMessage(fromWxid,
"淘宝评论统计:\n" +
"型号 " + productType + "\n" +
"已使用:" + usedTbCommentCount + "\n" +
"可用:" + canUseTbCommentCount + "\n" +
"总数:" + allTbCommentCount, 1, fromWxid, true);
}
} else {
wxUtil.sendTextMessage(fromWxid, "本地和京东均无可用的评论数据请检查sku", 1, fromWxid, false);
return;
}
@@ -2802,8 +2824,8 @@ public class JDUtil {
}
// 添加调试信息,检查输入字符串的字符编码
logger.debug("输入字符串长度: {}", normalized.length());
logger.debug("输入字符串字节数组: {}", java.util.Arrays.toString(normalized.getBytes()));
//logger.debug("输入字符串长度: {}", normalized.length());
//logger.debug("输入字符串字节数组: {}", java.util.Arrays.toString(normalized.getBytes()));
// 第一次尝试 - 使用Unicode转义序列匹配支持前面可选的 \u239C再跟 \u25C9
Pattern pattern = Pattern.compile("(?:\\u239C)?(\\u25C9)[^\\d]*([\\d.]+)\\s*\\uD83D\\uDCB0?");