diff --git a/src/main/java/cn/van/business/enums/GroupType.java b/src/main/java/cn/van/business/enums/GroupType.java new file mode 100644 index 0000000..8952051 --- /dev/null +++ b/src/main/java/cn/van/business/enums/GroupType.java @@ -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 getKeyVlue() { + Map map = new HashMap<>(); + GroupType[] items = GroupType.values(); + for (GroupType item : items) { + map.put(item.getKey() + "", item.getName()); + } + return map; + } + + public static List> getSelectItems() { + List> result = new ArrayList>(); + GroupType[] items = GroupType.values(); + for (GroupType item : items) { + Map 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; + } + +} + diff --git a/src/main/java/cn/van/business/enums/MsgTypeEnum.java b/src/main/java/cn/van/business/enums/MsgType.java similarity index 83% rename from src/main/java/cn/van/business/enums/MsgTypeEnum.java rename to src/main/java/cn/van/business/enums/MsgType.java index c7cf72d..96682b5 100644 --- a/src/main/java/cn/van/business/enums/MsgTypeEnum.java +++ b/src/main/java/cn/van/business/enums/MsgType.java @@ -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 getKeyVlue() { Map 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> getSelectItems() { List> list = new ArrayList<>(); - for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) { + for (MsgType msgTypeEnum : MsgType.values()) { Map 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; } diff --git a/src/main/java/cn/van/business/model/cj/XbMessage.java b/src/main/java/cn/van/business/model/cj/XbMessage.java index fdd797d..7708153 100644 --- a/src/main/java/cn/van/business/model/cj/XbMessage.java +++ b/src/main/java/cn/van/business/model/cj/XbMessage.java @@ -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; -} \ No newline at end of file +} diff --git a/src/main/java/cn/van/business/model/cj/XbMessageItem.java b/src/main/java/cn/van/business/model/cj/XbMessageItem.java index 8a9b7d0..db9518a 100644 --- a/src/main/java/cn/van/business/model/cj/XbMessageItem.java +++ b/src/main/java/cn/van/business/model/cj/XbMessageItem.java @@ -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; -} +} \ No newline at end of file diff --git a/src/main/java/cn/van/business/util/JDUtil.java b/src/main/java/cn/van/business/util/JDUtil.java index f740128..3e9566b 100644 --- a/src/main/java/cn/van/business/util/JDUtil.java +++ b/src/main/java/cn/van/business/util/JDUtil.java @@ -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 availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1); + List 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?");