From 8c0f5b3a9955a345ec7efbc5c5cb5b3005695326 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 26 九月 2019 12:06:13 +0800
Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java | 65 +++++++++++++++++++++++++++++++-
1 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java
index f071f6f..48a08c3 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicRecommendController.java
@@ -20,14 +20,17 @@
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import net.sf.json.JSONObject;
@@ -64,7 +67,6 @@
TaoBaoGoodsBrief tb = null;
String URL_REGEX = "(((http|https)://)|(www\\.))[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6}(:[0-9]{1,4})?(/[a-zA-Z0-9\\&%_\\./-~-]*)?";
-
Pattern p = Pattern.compile(URL_REGEX);
Matcher matcher = p.matcher(url);
if (!matcher.find()) {// 涓嶅寘鍚摼鎺�
@@ -150,10 +152,23 @@
Pattern p = Pattern.compile(URL_REGEX);
Matcher matcher = p.matcher(text);
if (!matcher.find()) {// 涓嶅寘鍚摼鎺�
+ // 瑙f瀽娣樺彛浠�
+ if (analysisTaoToken(text, out))
+ return;
// 鍟嗗搧璇︽儏
// 鍙戠幇
// 娌℃湁閾炬帴锛屾爣棰樿繃闀夸篃涓嶅鐞�
- if (text.length() > 50) {
+ if (text.startsWith("銆�") && text.contains("銆�")) {
+ int end = text.indexOf("銆�");
+ if (end > 2)
+ text = text.substring(1, end);
+ }
+
+ LogHelper.test("鏍规嵁绮樿创鏉挎帹鑽�:" + text);
+
+
+
+ if (text.length() > 80) {
out.print(JsonUtil.loadFalseResult("鍊艰繃闀�"));
return;
}
@@ -249,4 +264,48 @@
out.print(JsonUtil.loadTrueResult(root));
}
+ /**
+ * 瑙f瀽娣樺彛浠�
+ *
+ * @param text
+ * @param out
+ * @return
+ */
+ private boolean analysisTaoToken(String text, PrintWriter out) {
+ String token = StringUtil.picUpTaoToken(text);
+ if (!StringUtil.isNullOrEmpty(token)) {
+ Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
+ if (auctionId != null) {
+ TaoBaoGoodsBrief tb = null;
+ try {
+ tb = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
+ } catch (TaobaoGoodsDownException e) {
+ e.printStackTrace();
+ }
+
+ if (tb != null) {
+ JSONObject data = new JSONObject();
+ JSONObject taoBaoGoodsJSON = new JSONObject();
+ taoBaoGoodsJSON.put("title", tb.getTitle());
+ taoBaoGoodsJSON.put("zkPrice", tb.getZkPrice());
+ taoBaoGoodsJSON.put("auctionId", tb.getAuctionId());
+ taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + tb.getAuctionId());
+ data.put("taoBaoGoodsBrief", taoBaoGoodsJSON);
+ if (!StringUtil.isNullOrEmpty(tb.getPictUrl())) {
+ if (tb.getImgList() == null)
+ tb.setImgList(new ArrayList<>());
+ tb.getImgList().add(0, TbImgUtil.getTBSize220Img(tb.getPictUrl()));
+ }
+ data.put("tbImgs", tb.getImgList());
+ JSONObject root = new JSONObject();
+ root.put("type", 1);
+ root.put("data", data);
+ out.print(JsonUtil.loadTrueResult(root));
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
}
--
Gitblit v1.8.0