From c649b8d239684694cae80279e27dda5d2130a576 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 16 四月 2019 18:48:05 +0800
Subject: [PATCH] 阿里云验证码完善
---
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java | 959 +++++++++++++++++++++++++++++++----------------------------
1 files changed, 505 insertions(+), 454 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
index ea47819..1696376 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -8,7 +8,6 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -16,6 +15,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.IPUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.NumberUtil;
@@ -27,7 +27,6 @@
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
-import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.Special;
import com.yeshi.fanli.entity.bus.homemodule.SuperSpecial;
@@ -36,29 +35,23 @@
import com.yeshi.fanli.entity.bus.recommend.Honest;
import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
import com.yeshi.fanli.entity.bus.recommend.RecommendBannerV2;
-import com.yeshi.fanli.entity.bus.recommend.RecommendSection;
-import com.yeshi.fanli.entity.bus.recommend.RecommendSectionGoods;
import com.yeshi.fanli.entity.bus.recommend.RecommendSpecial;
import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
-import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBannerV2;
-import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendSection;
import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendSpecial;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.ShamUser;
import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.common.ImageInfo;
import com.yeshi.fanli.entity.common.JumpDetail;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.ScanHistoryV2;
-import com.yeshi.fanli.entity.system.System;
+import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.SearchFilter;
-import com.yeshi.fanli.entity.taobao.TBPid;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
@@ -67,24 +60,22 @@
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.goods.CommonGoodsException;
import com.yeshi.fanli.exception.goods.ScanHistoryException;
+import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
import com.yeshi.fanli.exception.user.UserCustomSettingsException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
+import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.JumpDetailService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.service.inter.config.SystemConfigService;
-import com.yeshi.fanli.service.inter.config.SystemService;
import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
-import com.yeshi.fanli.service.inter.goods.RecommendBannerService;
-import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService;
import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerV2Service;
-import com.yeshi.fanli.service.inter.goods.SuperRecommendSectionService;
import com.yeshi.fanli.service.inter.goods.SuperRecommendSpecialService;
import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
@@ -92,6 +83,7 @@
import com.yeshi.fanli.service.inter.homemodule.SuperSpecialService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.monitor.MonitorService;
import com.yeshi.fanli.service.inter.order.OrderService;
@@ -99,7 +91,6 @@
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
-import com.yeshi.fanli.service.inter.user.ShareManageService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
@@ -108,12 +99,12 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.TimeUtil;
-import com.yeshi.fanli.util.Utils;
+import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.MonitorFactory;
import com.yeshi.fanli.util.taobao.TaoBaoCouponUtil;
-import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.user.UserSettingsVO;
@@ -125,32 +116,21 @@
@RequestMapping("api/v1/user")
public class RecommendController {
- @Resource
- private RecommendBannerService recommendService;
@Resource
- private SystemService systemService;
+ private BusinessSystemService businessSystemService;
@Resource
private SuperRecommendBannerService superRecommendBannerService;
@Resource
- private SuperRecommendSectionService superRecommendSectionService;
-
- @Resource
private SuperRecommendSpecialService superRecommendSpecialService;
-
- @Resource
- private RecommendSectionGoodsService recommendSectionGoodsService;
@Resource
private OrderService orderService;
@Resource
private ScanHistoryV2Service scanHistoryV2Service;
-
- @Resource
- private ShareManageService shareManageService;
@Resource
private ConfigService configService;
@@ -161,8 +141,6 @@
@Resource
private UserInfoService userInfoService;
- @Resource
- private TaoBaoOrderUtil taoBaoOrderUtil;
@Resource
private TaoBaoCouponService taoBaoCouponService;
@@ -175,9 +153,6 @@
@Resource
private CollectionGoodsV2Service collectionGoodsV2Service;
-
- @Resource
- private HongBaoManageMapper hongBaoManageMapper;
@Resource
private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
@@ -235,97 +210,19 @@
@Resource
private ShareGoodsActivityOrderService shareGoodsActivityOrderService;
-
+
@Resource
private UserInfoExtraService userInfoExtraService;
-
+
+ @Resource
+ private QualityFlashSaleService qualityFlashSaleService;
+
- @RequestMapping(value = "getrecommendsection")
- public void getRecommendSection(AcceptData acceptData, int index, PrintWriter out) {
-
- if (index < 0) {
- index = 0;
- }
-
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
- if (system == null) {
- out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
- return;
- }
- List<SuperRecommendSection> superRecommendSectionList = superRecommendSectionService
- .getSuperRecommendSectionBySystemId(system.getId());
- List<RecommendSection> recommendSectionList = null;
- for (SuperRecommendSection superRecommendSection : superRecommendSectionList) {
- if (recommendSectionList == null) {
- recommendSectionList = new ArrayList<RecommendSection>();
- }
- RecommendSection recommendSection = superRecommendSection.getRecommendSection();
-
- // 鏆傛椂鏀瑰彉娣樼壒浠风殑璺宠浆鍦板潃
- if (system.getId() == 7) {
- recommendSection.setJumpUrl(recommendSection.getJumpUrl().replace("column.html", "column_ttj.html"));
- }
-
- recommendSectionList.add(recommendSection);
- }
- if (recommendSectionList == null) {
- out.print(JsonUtil.loadFalseResult(1, "鏆傛棤鏁版嵁"));
- return;
- }
- Utils.sort(recommendSectionList);
- int size = recommendSectionList.size();
-
- List<RecommendSectionGoods> recommendSectionGoodsList = null;
- JSONObject data = new JSONObject();
- data.put("count", size);
- JSONArray dataArr = new JSONArray();
- JSONObject validData = null;
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
- BigDecimal proportion = manageService.getFanLiRate();
- Map<Long, List<RecommendSectionGoods>> map = recommendSectionGoodsService.getAllSectionGoodsMap();
- for (int i = 0; i < size; i++) {
- validData = new JSONObject();
- RecommendSection recommendSection = recommendSectionList.get(i);
- recommendSectionGoodsList = map.get(recommendSection.getId());
- if (recommendSectionGoodsList == null) {
- continue;
- }
- Utils.sort(recommendSectionGoodsList);
- if (recommendSection.getCounts() < recommendSectionGoodsList.size()) {
- recommendSectionGoodsList = recommendSectionGoodsList.subList(0, recommendSection.getCounts());
- }
- validData.put("count", recommendSectionGoodsList.size());
- validData.put("recommendSection", gson.toJson(recommendSection));
-
- // 鏇挎崲TaoBaoGoodsBrief
- JSONArray array = new JSONArray();
- Gson gson2 = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
- for (RecommendSectionGoods rss : recommendSectionGoodsList) {
- JSONObject obj = JSONObject.fromObject(gson2.toJson(rss));
- String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(
- gson2.fromJson(obj.optJSONObject("taoBaoGoodsBrief").toString(), TaoBaoGoodsBrief.class),
- proportion.toString(), ""));
- obj.put("taoBaoGoodsBrief", json);
- array.add(obj);
- }
-
- validData.put("recommendSectionGoodsList", array);
- dataArr.add(validData);
- }
- data.put("data", dataArr);
-
- String result = JsonUtil.loadTrueResult(data);
- if (Constant.IS_OUTNET)
- redisManager.cacheCommonString("client-api-getRecommendSection", result, 3 * 60);
-
- out.print(result);
- return;
- }
+ @Resource
+ private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
@RequestMapping(value = "getHonestList")
public void getHonestList(AcceptData acceptData, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
List<Honest> honestList = null;
List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
if ((Integer.parseInt(acceptData.getVersion()) >= 20 && "android".equalsIgnoreCase(acceptData.getPlatform()))
@@ -492,7 +389,8 @@
@RequestMapping(value = "getrecommendspecial")
public void getRecommendSpecial(AcceptData acceptData, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
@@ -503,25 +401,28 @@
if (!"1".equals(version) && "android".equalsIgnoreCase(acceptData.getPlatform())) {
jumpDetail = jumpDetailService.getlastJumpDetailCache();
}
+ List<RecommendSpecial> recommendSpecialList = null;
+
List<SuperRecommendSpecial> superRecommendSpecialList = superRecommendSpecialService
.getSuperRecommendSpecialBySystemId(system.getId());
+ if (superRecommendSpecialList != null && superRecommendSpecialList.size() > 0) {
- List<RecommendSpecial> recommendSpecialList = null;
- for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) {
- if (recommendSpecialList == null) {
- recommendSpecialList = new ArrayList<RecommendSpecial>();
+ recommendSpecialList = new ArrayList<RecommendSpecial>();
+
+ for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) {
+ RecommendSpecial recommendSpecial = superRecommendSpecial.getRecommendSpecial();
+ if (jumpDetail != null) {
+ recommendSpecial.setJumpDetail(jumpDetail);
+ }
+ recommendSpecialList.add(recommendSpecial);
}
- RecommendSpecial recommendSpecial = superRecommendSpecial.getRecommendSpecial();
- if (jumpDetail != null) {
- recommendSpecial.setJumpDetail(jumpDetail);
- }
- recommendSpecialList.add(recommendSpecial);
}
if (recommendSpecialList == null || recommendSpecialList.size() == 0) {
out.print(JsonUtil.loadFalseResult(1, "鏆傛棤鏁版嵁"));
return;
}
+
JSONObject data = new JSONObject();
data.put("count", recommendSpecialList.size());
Gson gson = new Gson();
@@ -534,7 +435,8 @@
@RequestMapping(value = "guessLike", method = RequestMethod.POST)
public void guessLike(AcceptData acceptData, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
@@ -572,7 +474,8 @@
@RequestMapping(value = "getrecommendbanner")
public void getRecommendBanner(AcceptData acceptData, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
JSONObject json = new JSONObject();
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
@@ -639,48 +542,42 @@
out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d"));
return;
}
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
- // 娣樼壒浠�
- if (system.getId() == 7) {
- system = systemService.getSystem("ANDROID", Constant.systemCommonConfig.getAndroidPackageName());
- }
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
}
+
+ // 鑾峰彇浼氬憳鎺ㄥ箍浣嶆垨鑰呴粯璁ゆ帹骞夸綅
+
+ TaoBaoGoodsBrief simpleGoods = null;
+ try {
+ simpleGoods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id));
+ } catch (NumberFormatException e2) {
+ e2.printStackTrace();
+ } catch (TaobaoGoodsDownException e2) {
+ e2.printStackTrace();
+ }
+
+ if (simpleGoods == null) {
+ out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�"));
+ return;
+ }
+
// 鑾峰彇娣樺鍙傛暟
ClientTBPid clientTBPid = null;
- // 鐢ㄦ埛宸茬粡鐧诲綍
- if (!StringUtil.isNullOrEmpty(uid) && Long.parseLong(uid) > 0) {
- TBPid tbPid = null;
- if (acceptData.getPlatform().equalsIgnoreCase("android")) {
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_ANDROID);
- if (tbPid != null) {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- } else {
- clientTBPid = tbPidService.getAndroidDefault();
- }
-
- } else {
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_IOS);
- if (tbPid != null) {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- } else {
- clientTBPid = tbPidService.getIOSDefault();
- }
- }
+ if (simpleGoods.getMaterialLibType() != null && simpleGoods.getMaterialLibType() == 1) {
+ String pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
+ clientTBPid = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
+ pid.split("_")[2], pid.split("_")[3]);
} else {
- if (acceptData.getPlatform().equalsIgnoreCase("android"))
+ if (acceptData.getPlatform().equalsIgnoreCase("android")) {
clientTBPid = tbPidService.getAndroidDefault();
- else
+ } else {
clientTBPid = tbPidService.getIOSDefault();
+ }
}
TaoBaoGoodsBrief tb = null;
@@ -783,11 +680,6 @@
} else {
out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�"));
- ThreadUtil.run(new Runnable() {
- public void run() {
- recommendSectionGoodsService.deleteRecommendSectionGoodsByTbAuctionId(Long.parseLong(id));
- }
- });
}
long end = java.lang.System.currentTimeMillis();
java.lang.System.out.println("鑰楁椂:" + (end - begin));
@@ -804,7 +696,8 @@
out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d"));
return;
}
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
@@ -823,38 +716,11 @@
// 鑾峰彇娣樺鍙傛暟
ClientTBPid clientTBPid = null;
// 鐢ㄦ埛宸茬粡鐧诲綍
- if (!StringUtil.isNullOrEmpty(uid)) {
- TBPid tbPid = null;
- if (acceptData.getPlatform().equalsIgnoreCase("android")) {
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_ANDROID);
- if (tbPid != null) {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- } else {
- clientTBPid = tbPidService.getAndroidDefault();
- }
- } else {
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_IOS);
- if (tbPid != null) {
-
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- } else {
- clientTBPid = tbPidService.getIOSDefault();
- }
- }
-
- } else {
- if (acceptData.getPlatform().equalsIgnoreCase("android"))
- clientTBPid = tbPidService.getAndroidDefault();
- else
- clientTBPid = tbPidService.getIOSDefault();
- }
+ if (acceptData.getPlatform().equalsIgnoreCase("android"))
+ clientTBPid = tbPidService.getAndroidDefault();
+ else
+ clientTBPid = tbPidService.getIOSDefault();
LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime));
@@ -1105,27 +971,10 @@
ClientTBPid clientTBPid = null;
// 鐢ㄦ埛宸茬粡鐧诲綍
if (!StringUtil.isNullOrEmpty(uid)) {
- TBPid tbPid = null;
if (acceptData.getPlatform().equalsIgnoreCase("android")) {
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_ANDROID);
- if (tbPid != null) {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- } else {
- clientTBPid = tbPidService.getAndroidDefault();
- }
+ clientTBPid = tbPidService.getAndroidDefault();
} else {
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_IOS);
- if (tbPid != null) {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- } else {
- clientTBPid = tbPidService.getIOSDefault();
- }
+ clientTBPid = tbPidService.getIOSDefault();
}
} else {
@@ -1171,7 +1020,8 @@
// 鏍规嵁鍟嗗搧鑾峰彇鎺ㄨ崘
@RequestMapping(value = "getgoodsrecommend", method = RequestMethod.POST)
public void getGoodsRecommend(final AcceptData acceptData, long id, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
@@ -1207,16 +1057,6 @@
goodsList.add(gds);
}
}
- }
-
- // 闇�瑕佸彟鍋氭帹鑽�
- if (goodsList.size() < 6) {
- List<RecommendSectionGoods> list = recommendSectionGoodsService.getSectionGoods(10);
- if (list != null)
- for (int i = 0; i < list.size(); i++) {
- if (goodsList.size() < 6)
- goodsList.add(list.get(i).getTaoBaoGoodsBrief());
- }
}
}
@@ -1307,7 +1147,8 @@
return;
}
page = page + 1;
- System sys = systemService.getSystem(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(),
+ acceptData.getPackages());
if (sys == null) {
out.print(JsonUtil.loadFalseResult(1, "涓嶅瓨鍦ㄨ绯荤粺"));
return;
@@ -1352,7 +1193,8 @@
@RequestMapping(value = "deletescanhistory", method = RequestMethod.POST)
public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) {
- System sys = systemService.getSystem(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(),
+ acceptData.getPackages());
if (sys == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
@@ -1450,7 +1292,6 @@
// 浠庢帹鑽愭潵
if (page <= 1) {
array.clear();
- Map<String, String> map = hongBaoManageService.convertMap();
BigDecimal proportion = manageService.getFanLiRate();
if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) {
long startTime = java.lang.System.currentTimeMillis();
@@ -1464,7 +1305,7 @@
for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
&& goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0
- && goods.getBiz30day() > 1000)
+ && goods.getBiz30day() > 1000 && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite()))
goodsList.add(goods);
}
try {
@@ -1492,14 +1333,12 @@
proportion.toString());
array.addAll(localArray);
} else {// 浠庣簿閫夊簱鏉�
- Map<String, String> map = hongBaoManageService.convertMap();
BigDecimal proportion = manageService.getFanLiRate();
array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString());
if (array == null) {
out.print(JsonUtil.loadFalseResult("娌℃湁鏇村浜�"));
return;
}
- long count = qualityGoodsService.countRecommendToIndex(proportion.toString());
}
JSONObject data = new JSONObject();
@@ -1517,33 +1356,16 @@
@RequestMapping(value = "getRecommendInfo")
public void getRecommendHomeInfo(AcceptData acceptData, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
}
// 棣栭〉Banner
- List<RecommendBannerV2> listBanner = null;
-
- List<SuperRecommendBannerV2> listRecommendBanner = superRecommendBannerV2Service
- .getSuperRecommendBannerV2sBySystem(system);
-
- if (listRecommendBanner != null && listRecommendBanner.size() > 0) {
-
- listBanner = new ArrayList<RecommendBannerV2>();
-
- for (SuperRecommendBannerV2 superRecommendBanner : listRecommendBanner) {
- RecommendBannerV2 recommendBanner = superRecommendBanner.getRecommendBanner();
- // 娣樼壒浠锋殏鏃朵慨鏀�
- if (system.getId() == 7) {
- recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity()
- .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial"));
- }
-
- listBanner.add(recommendBanner);
- }
- }
+ List<RecommendBannerV2> listBanner = superRecommendBannerV2Service
+ .getSuperRecommendBannerV2sBySystem(system.getId());
JSONObject root = new JSONObject();
root.put("banner", listBanner);
@@ -1624,7 +1446,8 @@
public void getNewRecommendInfo(AcceptData acceptData, Long uid, String specialCard, String swiperCard,
PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
@@ -1637,7 +1460,7 @@
listswiper = swiperPictureService.getByBannerCard(swiperCard);
if (listswiper == null) {
- listswiper = new ArrayList<SwiperPicture>();
+ listswiper = new ArrayList<SwiperPicture>();
}
} catch (Exception e) {
@@ -1668,7 +1491,7 @@
// 鍏朵粬涓撻
specialList.add(special);
}
-
+
}
}
@@ -1702,12 +1525,11 @@
}
JSONObject root = new JSONObject();
-
+
root.put("banner", JsonUtil.getApiCommonGson().toJson(listswiper));
root.put("honest", JsonUtil.getApiCommonGson().toJson(honestList));
root.put("special", JsonUtil.getApiCommonGson().toJson(specialList));
root.put("miaoSha", msJSON);
-
// 澧炲姞閭�璇锋湁濂�
JSONObject invite = new JSONObject();
@@ -1736,18 +1558,200 @@
root.put("invite", invite);
}
}
-
out.print(JsonUtil.loadTrueResult(root));
-
}
+
+ /**
+ * 鏂扮増鎺ㄨ崘涓撻绠$悊(1.5.3)
+ *
+ * @param acceptData
+ * @param out
+ */
+ @RequestMapping(value = "getRecommendIndex")
+ public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) {
+ try {
+ // 1銆佷笓棰樻ā鍧�
+ JSONObject root = specialService.listCacheSpecialToIndex(acceptData);
+
+ // 2銆侀《閮ㄨ疆鎾浘
+ List<SwiperPicture> topPicList = getSwiperByCard("index_top");
+ if (topPicList == null) {
+ topPicList = new ArrayList<SwiperPicture>();
+ }
+ root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList));
+
+
+ // 3銆侀個璇锋湁濂�
+ List<SwiperPicture> invitePicList = null;
+ if ("ios".equalsIgnoreCase(acceptData.getPlatform())
+ && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
+ // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥�
+ } else {
+ invitePicList = getSwiperByCard("index_invite");
+ }
+
+ if (invitePicList == null) {
+ invitePicList = new ArrayList<SwiperPicture>();
+ }
+ root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList));
+
+
+ // 4銆両OS鐨勫簳閮ㄧ綉椤甸摼鎺�
+ String platform = acceptData.getPlatform();
+ if ("ios".equalsIgnoreCase(platform)) {
+ root.put("htmlLink", configService.get("index_html_link_ios"));
+ }
+
+ out.print(JsonUtil.loadTrueResult(root));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult(1, "鑾峰彇鏁版嵁澶辫触"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 閭�璇锋湁濂栨槸鍚﹂渶瑕佽繑鍥�
+ * @param uid
+ * @param acceptData
+ * @return
+ */
+ public List<SwiperPicture> getInvitePicList(Long uid, AcceptData acceptData) {
+ // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥�
+ if ("ios".equalsIgnoreCase(acceptData.getPlatform())
+ && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
+ return null;
+ }
+
+ List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");
+
+
+
+ return invitePicList;
+ }
+
+
+ public List<SwiperPicture> getSwiperByCard(String card){
+ List<SwiperPicture> swiperList = null;
+ try {
+ swiperList = swiperPictureService.getByBannerCard(card);
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ e.printStackTrace();
+ }
+ return swiperList;
+ }
+
+
+ /**
+ * 闄愭椂绉掓潃 1.5.3
+ *
+ * @param acceptData
+ * @param out
+ */
+ @RequestMapping(value = "getSpikeGoods")
+ public void getSpikeGoods(AcceptData acceptData, PrintWriter out) {
+
+ // 涓嬩竴娆″�掕鏃剁殑鏃堕棿
+ int type = qualityFlashSaleService.getNowType() + 1;
+ int hour = 0;
+ switch(type) {
+ case 1:
+ hour = 0;
+ break;
+ case 2:
+ hour = 9;
+ break;
+ case 3:
+ hour = 12;
+ break;
+ case 4:
+ hour = 14;
+ break;
+ case 5:
+ hour = 16;
+ break;
+ case 6:
+ hour = 20;
+ break;
+ case 7:
+ hour = 22;
+ break;
+ default:
+ break;
+ }
+
+ Calendar nextTime = Calendar.getInstance();
+ nextTime.set(Calendar.HOUR_OF_DAY, hour);
+ nextTime.set(Calendar.MINUTE, 0);
+ nextTime.set(Calendar.SECOND, 0);
+ nextTime.set(Calendar.MILLISECOND, 0);
+
+
+ JSONArray array = null;
+ String timekey = "spikeGoods_hour";
+ String cachekey = "spikeGoodsList";
+
+ String timeValue = redisManager.getCommonString(timekey);
+ if (timeValue == null || !timeValue.equals(hour+"")) {
+ redisManager.cacheCommonString(timekey, hour+"", 60 * 30);
+ } else {
+ String cacheValue = redisManager.getCommonString(cachekey);
+ if (!StringUtil.isNullOrEmpty(cacheValue)) {
+ array = JSONArray.fromObject(cacheValue);
+ }
+ }
+
+ if (array == null) {
+ array = new JSONArray();
+
+ BigDecimal proportion = manageService.getFanLiRate();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ // 缂撳瓨涓笉瀛樺湪
+ List<QualityFactory> listGoods = qualityGoodsService.listFlashSaleRandGoods();
+ if (listGoods == null) {
+ listGoods = new ArrayList<QualityFactory>();
+ }
+
+ /* 閬嶅巻鍒楄〃鏁版嵁 */
+ for (QualityFactory qualityFactory : listGoods) {
+
+ TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ // 缂撳瓨鍗婁釜灏忔椂
+ redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30);
+ }
+
+ JSONObject root = new JSONObject();
+ root.put("time", nextTime.getTimeInMillis());
+ root.put("listgoods", array);
+ out.print(JsonUtil.loadTrueResult(root));
+ }
+
+
/**
* 鍟嗗搧鍩烘湰璇︽儏 (1.4.0)
*
* @param acceptData
* @param id
* @param uid
- * @param pageSource 椤甸潰鏉ユ簮
+ * @param pageSource
+ * 椤甸潰鏉ユ簮
* @param out
*/
@RequestMapping(value = "getgoodsinfo", method = RequestMethod.POST)
@@ -1762,7 +1766,8 @@
return;
}
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
@@ -1782,123 +1787,107 @@
// 鑾峰彇娣樺鍙傛暟
ClientTBPid clientTBPid = null;
- if (StringUtil.isNullOrEmpty(uid)) {
- // 鐢ㄦ埛鏈櫥褰�
- if (acceptData.getPlatform().equalsIgnoreCase("android")) {
- clientTBPid = tbPidService.getAndroidDefault();
- } else {
- clientTBPid = tbPidService.getIOSDefault();
- }
-
+ // 鐢ㄦ埛鏈櫥褰�
+ if (acceptData.getPlatform().equalsIgnoreCase("android")) {
+ clientTBPid = tbPidService.getAndroidDefault();
} else {
-
- // 鐢ㄦ埛宸茬粡鐧诲綍
- TBPid tbPid = null;
- if (acceptData.getPlatform().equalsIgnoreCase("android")) {
-
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_ANDROID);
-
- if (tbPid == null) {
- clientTBPid = tbPidService.getAndroidDefault();
- } else {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- }
-
- } else {
-
- tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_IOS);
-
- if (tbPid == null) {
- clientTBPid = tbPidService.getIOSDefault();
- } else {
- String siteId = tbPid.getPid().split("_")[2];
- String adzoneId = tbPid.getPid().split("_")[3];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
- clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
- }
- }
+ clientTBPid = tbPidService.getIOSDefault();
}
LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime));
- final String clientPid = clientTBPid.getPid();
final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
// 鏄惁鍦ㄦ湇鍔$杩涜杞摼
boolean convertInServer = configService.isConvertTaoBaoLinkInServer();
- List<String> taskList = new ArrayList<>();
- // 鑾峰彇鍟嗗搧鍩烘湰淇℃伅
- taskList.add("goods");
+ JSONObject ticket = new JSONObject();
+ TaoBaoGoodsBrief goods = null;
- taskList.stream().parallel().forEach(task -> {
- if (task.equalsIgnoreCase("goods")) {
- JSONObject ticket = new JSONObject();
- TaoBaoGoodsBrief goods = null;
-
- if (!convertInServer) {
-
- try {
- goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id));
- } catch (TaobaoGoodsDownException e) {
- // 鍟嗗搧涓嬫灦
- ThreadUtil.run(new Runnable() {
- public void run() {
- taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
- }
- });
-
- }
-
- } else {
- String appId = clientPid.split("_")[2];
- TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
+ if (!convertInServer) {
+ try {
+ goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(Long.parseLong(id));
+ if (goods == null) {
TaoKeAppInfo app = new TaoKeAppInfo();
- app.setAdzoneId(clientPid.split("_")[3]);
- app.setAppKey(config.getAppKey());
- app.setAppSecret(config.getAppSecret());
- app.setPid(clientPid);
-
- try {
- goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app);
- if (goods != null) {
- ticket.put("clickUrl", goods.getAuctionUrl());
- // 娴嬭瘯浣跨敤
- ticket.put("couponUrl", goods.getCouponLink());
- data.put("ticket", ticket);
- }
-
- } catch (NumberFormatException e) {
- e.printStackTrace();
- } catch (TaobaoGoodsDownException e) {
+ app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY);
+ app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET);
+ app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
+ app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
+ goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app);
+ final TaoBaoGoodsBrief finalGoods = goods;
+ if (goods != null) {
ThreadUtil.run(new Runnable() {
+ @Override
public void run() {
- taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
+ taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods);
}
});
}
-
}
+ } catch (TaobaoGoodsDownException e) {
+ // 鍟嗗搧涓嬫灦
+ ThreadUtil.run(new Runnable() {
+ public void run() {
+ taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
+ }
+ });
- if (goods != null) {
- goodsList.add(goods);
- final TaoBaoGoodsBrief newGoods = goods;
- ThreadUtil.run(new Runnable() {
- public void run() {
- try {
- // 鏇存柊鍟嗗搧
- LogHelper.test("鏇存柊鍟嗗搧璇︽儏:" + newGoods.getAuctionId());
- taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
- } catch (TaobaoGoodsUpdateException e) {
-
- }
- }
- });
- }
}
- });
+
+ } else {
+ final String clientPid = clientTBPid.getPid();
+ String appId = clientPid.split("_")[2];
+ TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
+ TaoKeAppInfo app = new TaoKeAppInfo();
+ app.setAdzoneId(clientPid.split("_")[3]);
+ app.setAppKey(config.getAppKey());
+ app.setAppSecret(config.getAppSecret());
+ app.setPid(clientPid);
+
+ try {
+ goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app);
+ if (goods != null) {
+ ticket.put("clickUrl", goods.getAuctionUrl());
+ // 娴嬭瘯浣跨敤
+ ticket.put("couponUrl", goods.getCouponLink());
+ data.put("ticket", ticket);
+ }
+
+ if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) {
+ TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
+ if (linkInfo != null) {
+ goods.setAuctionUrl(linkInfo.getAuctionUrl());
+ goods.setCouponLink(linkInfo.getCouponLink());
+ goods.setTkRate(linkInfo.getTkRate());
+ }
+ }
+
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ } catch (TaobaoGoodsDownException e) {
+ ThreadUtil.run(new Runnable() {
+ public void run() {
+ taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
+ }
+ });
+ }
+
+ }
+
+ if (goods != null) {
+ goodsList.add(goods);
+ final TaoBaoGoodsBrief newGoods = goods;
+ ThreadUtil.run(new Runnable() {
+ public void run() {
+ try {
+ // 鏇存柊鍟嗗搧
+ LogHelper.test("鏇存柊鍟嗗搧璇︽儏:" + newGoods.getAuctionId());
+ taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
+ } catch (TaobaoGoodsUpdateException e) {
+
+ }
+ }
+ });
+ }
TaoBaoGoodsBrief tb = null;
if (goodsList.size() > 0) {
@@ -1920,17 +1909,19 @@
for (String img : tb.getImgList()) {
finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
}
+ if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite()))
+ finalImgList.add(0, tb.getPictUrlWhite());
- JSONObject goods = new JSONObject();
- goods.put("auctionId", tb.getAuctionId());
- goods.put("imgList", finalImgList);
- goods.put("title", tb.getTitle());
- goods.put("userType", tb.getUserType() == 1 ? 2 : 1);
- goods.put("price", tb.getReservePrice().toString());
- goods.put("zkPrice", tb.getZkPrice().toString());
+ JSONObject goodsJson = new JSONObject();
+ goodsJson.put("auctionId", tb.getAuctionId());
+ goodsJson.put("imgList", finalImgList);
+ goodsJson.put("title", tb.getTitle());
+ goodsJson.put("userType", tb.getUserType() == 1 ? 2 : 1);
+ goodsJson.put("price", tb.getReservePrice().toString());
+ goodsJson.put("zkPrice", tb.getZkPrice().toString());
// 30澶╅攢閲�
- goods.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day()));
+ goodsJson.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day()));
// 鍒嗕韩璧�
BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
@@ -1964,51 +1955,64 @@
LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid));
// 鏄惁鏈夊埜
- goods.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true);
+ goodsJson.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true);
// 棰嗗埜浜哄垪琛�
List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
-
+
String hongBao = null;
-
+
// 鑾峰彇鍒镐俊鎭�
if (!StringUtil.isNullOrEmpty(tb.getCouponInfo())) {
BigDecimal quanPrice = TaoBaoUtil.getAfterUseCouplePrice(tb);
JSONObject couponInfo = new JSONObject();
couponInfo.put("couponPrice", quanPrice.toString());
-
+
if (from != null && from.equals("miandan")) {
// 鍏嶅崟鍟嗗搧
hongBao = "楼" + quanPrice.toString();
}
-
-
- // 鏈嶅姟绔浆閾�
- if (convertInServer && !StringUtil.isNullOrEmpty(tb.getCouponLink())) {
- couponInfo.put("couponUrl", tb.getCouponLink());
- } else {
- couponInfo.put("couponUrl",
- TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid, tb.getAuctionId() + ""));
+
+ String token = "";
+ if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) {
+ token = redisManager.getCommonTaoToken(tb.getAuctionId());
+ if (StringUtil.isNullOrEmpty(token)) {
+ token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink());
+ redisManager.saveCommonTaoToken(tb.getAuctionId(), token);
+ }
}
+ tb.setCouponLinkTaoToken(token);
+
+ // 鏈嶅姟绔浆閾�
+ // if (convertInServer &&
+ // !StringUtil.isNullOrEmpty(tb.getCouponLink())) {
+ couponInfo.put("couponUrl", tb.getCouponLink());
+ // } else {
+ // couponInfo.put("couponUrl",
+ // TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid,
+ // tb.getAuctionId() + ""));
+ // }
couponInfo.put("couponAmount", NumberUtil.subZeroAndDot(tb.getCouponAmount().toString()));
couponInfo.put("couponTime", "浣跨敤鏈熼檺锛�" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-"
+ tb.getCouponEffectiveEndTime().replace("-", "."));
- goods.put("couponInfo", couponInfo);
+ // 鍒哥殑鍙d护
+ couponInfo.put("couponToken", token);
+ goodsJson.put("couponInfo", couponInfo);
if (tb.getBiz30day() >= 1000) {
// 棰嗗埜浜哄垪琛�
listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
}
}
-
+
// 绾㈠寘
if (hongBao == null) {
BigDecimal proportion = manageService.getFanLiRate();
hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion);
}
- goods.put("hongBao", hongBao);
-
+ goodsJson.put("hongBao", hongBao);
+
data.put("tbPidInfo", clientTBPid);
String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId();
@@ -2025,7 +2029,7 @@
else
jumpUrl = tb.getAuctionUrl();
}
- goods.put("jumpUrl", jumpUrl);
+ goodsJson.put("jumpUrl", jumpUrl);
TaoBaoShopInfo tbShopInfo = redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId());
if (tbShopInfo != null) {
@@ -2037,7 +2041,7 @@
}
}
// 搴楅摵
- goods.put("shopInfo", tbShopInfo);
+ goodsJson.put("shopInfo", tbShopInfo);
// 鍒嗕韩璺緞
String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl());
@@ -2050,25 +2054,38 @@
data.put("storageState", storageState);
data.put("shareUrl", shareUrl);
- data.put("goods", goods);
+
+ data.put("goods", goodsJson);
data.put("shareUsers", listShareUser);
data.put("couponUsers", listCouponUser);
data.put("detailWebUrl", "http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
+ // 鍟嗗搧閾炬帴
+ String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
+ Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + "");
+ try {
+ data.put("h5Url", HttpUtil.getShortLink(h5Url));
+ } catch (Exception e) {
+ data.put("h5Url", h5Url);
+ }
-
-// 鍙栨秷鍒嗕韩娲诲姩
-// if (!StringUtil.isNullOrEmpty(uid)
-// && shareGoodsActivityOrderService.countShareGoodsActivityOrder(Long.parseLong(uid)) > 0) {
-// } else if(!"miandan".equals(from)) {
-// // 闈炲厤鍗曞晢鍝�
-// JSONObject shareActivity = new JSONObject();
-// shareActivity.put("moneyDesc", "鏄ヨ妭鐙傛濂栭噾:楼" + TaoBaoUtil.getGoodsHongBaoMoney(tb,
-// new BigDecimal(hongBaoManageService.get("share_activity_proportion"))));
-// shareActivity.put("ruleDescPicture", "http://img.flqapp.com/resource/share_activity_img.png");
-//
-// data.put("shareActivity", shareActivity);
-// }
-
+ // 鍙栨秷鍒嗕韩娲诲姩
+ // if (!StringUtil.isNullOrEmpty(uid)
+ // &&
+ // shareGoodsActivityOrderService.countShareGoodsActivityOrder(Long.parseLong(uid))
+ // > 0) {
+ // } else if(!"miandan".equals(from)) {
+ // // 闈炲厤鍗曞晢鍝�
+ // JSONObject shareActivity = new JSONObject();
+ // shareActivity.put("moneyDesc", "鏄ヨ妭鐙傛濂栭噾:楼" +
+ // TaoBaoUtil.getGoodsHongBaoMoney(tb,
+ // new
+ // BigDecimal(hongBaoManageService.get("share_activity_proportion"))));
+ // shareActivity.put("ruleDescPicture",
+ // "http://img.flqapp.com/resource/share_activity_img.png");
+ //
+ // data.put("shareActivity", shareActivity);
+ // }
+
out.print(JsonUtil.loadTrueResult(data));
final String tempUid = uid;
@@ -2145,7 +2162,8 @@
@RequestMapping(value = "getgoodsderivation", method = RequestMethod.POST)
public void getRecommendGoods(AcceptData acceptData, long id, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
@@ -2161,55 +2179,87 @@
List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
- goodsList.parallelStream().forEach(goods -> {
- // 鑾峰彇璇︽儏
- TaoBaoGoodsBrief taoBaoGoodsBrief = null;
- try {
- taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(goods.getAuctionId());
- } catch (Exception e) {
- e.printStackTrace();
- }
+ TaoKeAppInfo app = new TaoKeAppInfo();
+ app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
+ app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+ app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
+ app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
- if (taoBaoGoodsBrief != null) {
- listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""));
- }
-
- });
-
- List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>();
+ List<Long> ids = new ArrayList<>();
+ for (TaoBaoGoodsBrief goods : goodsList)
+ ids.add(goods.getAuctionId());
try {
- List<QualityFactory> listRecommend = qualityGoodsService.recommendByAuctionId(id);
-
- if (listRecommend != null && listRecommend.size() > 1) {
- for (QualityFactory quality : listRecommend) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- listQuality.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null));
- }
- }
- } catch (Exception e2) {
- e2.printStackTrace();
+ goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids);
+ } catch (TaoKeApiException e1) {
+ e1.printStackTrace();
+ } catch (TaobaoGoodsDownException e1) {
+ e1.printStackTrace();
}
+
+ if (goodsList != null)
+ goodsList.parallelStream().forEach(goods -> {
+
+ // 鑾峰彇璇︽儏
+ TaoBaoGoodsBrief taoBaoGoodsBrief = null;
+ try {
+ taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (taoBaoGoodsBrief == null) {
+ TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
+ goods.setCouponInfo(newGoods.getCouponInfo());
+ goods.setCouponLink(newGoods.getCouponLink());
+ goods.setTkRate(newGoods.getTkRate());
+ taoBaoGoodsBrief = goods;
+ }
+
+ if (taoBaoGoodsBrief != null) {
+ listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""));
+ }
+
+ });
+
+ List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>();
+ // 鍒犻櫎鎺ㄨ崘
+ //
+ // try {
+ // List<QualityFactory> listRecommend =
+ // qualityGoodsService.recommendByAuctionId(id);
+ //
+ // if (listRecommend != null && listRecommend.size() > 1) {
+ // for (QualityFactory quality : listRecommend) {
+ //
+ // TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
+ // if (taoBaoGoodsBrief == null) {
+ // continue;
+ // }
+ //
+ // int biz30day = taoBaoGoodsBrief.getBiz30day();
+ // if (biz30day >= 10000) {
+ // double sales = biz30day;
+ // String salesCountMidea = String.format("%.1f", sales / 10000);
+ // taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ // } else {
+ // taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ // }
+ //
+ // // 鏀瑰彉鍥剧墖灏哄
+ // String pictUrl = taoBaoGoodsBrief.getPictUrl();
+ // if (!StringUtil.isNullOrEmpty(pictUrl) &&
+ // !pictUrl.contains("320x320")) {
+ // taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
+ // }
+ //
+ // listQuality.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
+ // proportion.toString(), null));
+ // }
+ // }
+ // } catch (Exception e2) {
+ // e2.printStackTrace();
+ // }
// 鍙栧伓鏁颁釜鏁版嵁
if (listExtra.size() % 2 != 0) {
@@ -2221,8 +2271,8 @@
}
JSONObject data = new JSONObject();
- data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listExtra));
- data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listQuality));
+ data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
+ data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
out.print(JsonUtil.loadTrueResult(data));
}
@@ -2236,7 +2286,8 @@
@RequestMapping(value = "getSpecialActivities")
public void getSpecialActivities(AcceptData acceptData, Long uid, PrintWriter out) {
- System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+ BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+ acceptData.getPackages());
if (system == null) {
out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�"));
return;
@@ -2256,7 +2307,7 @@
JSONObject root = new JSONObject();
root.put("special", JsonUtil.getApiCommonGson().toJson(listSpecial));
out.print(JsonUtil.loadTrueResult(root));
-
+
} catch (Exception e) {
e.printStackTrace();
}
--
Gitblit v1.8.0