From eb227aabf6451c3665a78867c28337e2035d108d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 02 八月 2019 16:06:19 +0800
Subject: [PATCH] 兼容圆形专题
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java | 63 ++++++++++++++++++++++++++-----
1 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
index 30e7e26..a49eb0f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -32,6 +32,7 @@
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.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -56,6 +57,7 @@
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
@@ -116,6 +118,8 @@
out.print(JsonUtil.loadFalseResult("鍊间负绌�"));
return;
}
+ //鍘婚櫎鍓嶅悗绌烘牸
+ text=text.trim();
if (text.length() > 256) {
out.print(JsonUtil.loadFalseResult("鍊艰繃闀�"));
@@ -128,13 +132,10 @@
Pattern p = Pattern.compile(URL_REGEX);
Matcher matcher = p.matcher(text);
if (!matcher.find()) {// 涓嶅寘鍚摼鎺�
- // 鍟嗗搧璇︽儏
- // 鍙戠幇
- // 娌℃湁閾炬帴锛屾爣棰樿繃闀夸篃涓嶅鐞�
- if (text.startsWith("銆�") && text.contains("銆�")) {
- int end = text.indexOf("銆�");
- if (end > 2)
- text = text.substring(1, end);
+ String pattern = "^[A-Za-z0-9-]+$";
+ if (Pattern.matches(pattern, text)) {
+ out.println(JsonUtil.loadFalseResult("涓嶆敮鎸佹帹鑽�"));
+ return;
}
LogHelper.test("鏍规嵁绮樿创鏉挎帹鑽�:" + text);
@@ -143,6 +144,11 @@
out.print(JsonUtil.loadFalseResult("鍊艰繃闀�"));
return;
}
+
+ if (analysisTaoToken(text, out)) {
+ return;
+ }
+
JSONObject root = new JSONObject();
root.put("type", 2);
@@ -210,6 +216,44 @@
root.put("data", data);
out.print(JsonUtil.loadTrueResult(root));
+ }
+
+ 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("id", tb.getAuctionId());
+ taoBaoGoodsJSON.put("goodsType", Constant.SOURCE_TYPE_TAOBAO);
+ taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + tb.getAuctionId());
+ data.put("goods", taoBaoGoodsJSON);
+ if (!StringUtil.isNullOrEmpty(tb.getPictUrl())) {
+ if (tb.getImgList() == null)
+ tb.setImgList(new ArrayList<>());
+ tb.getImgList().add(0, TbImgUtil.getTBSize220Img(tb.getPictUrl()));
+ }
+ data.put("imgs", tb.getImgList());
+ JSONObject root = new JSONObject();
+ root.put("type", 1);
+ root.put("data", data);
+ out.print(JsonUtil.loadTrueResult(root));
+ return true;
+ }
+ }
+ }
+ return false;
}
/**
@@ -604,7 +648,7 @@
}
/**
- * 鎷煎澶�
+ * 鎷煎澶�
*
* @param kw
* @param page
@@ -668,8 +712,7 @@
BigDecimal shareRate = hongBaoManageService.getShareRate();
for (PDDGoodsDetail goods : goodsList) {
- GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate,
- shareRate);
+ GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate);
array.add(gson.toJson(goodsDetailVO));
}
}
--
Gitblit v1.8.0