From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java | 5062 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 2,474 insertions(+), 2,588 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java index 95f49a4..a01a5c2 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java @@ -1,2588 +1,2474 @@ -package com.yeshi.fanli.controller.client.v1; - -import java.io.PrintWriter; -import java.lang.reflect.Type; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - -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; -import org.yeshi.utils.taobao.TbImgUtil; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.bus.homemodule.Special; -import com.yeshi.fanli.entity.bus.homemodule.SuperSpecial; -import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; -import com.yeshi.fanli.entity.bus.lable.QualityFactory; -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.RecommendSpecial; -import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner; -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.UserMoneyExtra; -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.BusinessSystem; -import com.yeshi.fanli.entity.system.ConfigKeyEnum; -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.TLJBuyGoods; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; -import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; -import com.yeshi.fanli.entity.taobao.TaoBaoShop; -import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo; -import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; -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.goods.CollectionGoodsV2Service; -import com.yeshi.fanli.service.inter.goods.CommonGoodsService; -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.SuperRecommendSpecialService; -import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService; -import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; -import com.yeshi.fanli.service.inter.goods.recommend.HomeRecommendGoodsService; -import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService; -import com.yeshi.fanli.service.inter.homemodule.DeviceSexService; -import com.yeshi.fanli.service.inter.homemodule.SpecialService; -import com.yeshi.fanli.service.inter.homemodule.SuperSpecialService; -import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; -import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService; -import com.yeshi.fanli.service.inter.lable.QualityGoodsService; -import com.yeshi.fanli.service.inter.money.UserMoneyExtraService; -import com.yeshi.fanli.service.inter.monitor.MonitorService; -import com.yeshi.fanli.service.inter.order.OrderService; -import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService; -import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; -import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; -import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service; -import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; -import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; -import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService; -import com.yeshi.fanli.service.inter.user.ShamUserService; -import com.yeshi.fanli.service.inter.user.TBPidService; -import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; -import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; -import com.yeshi.fanli.service.inter.user.UserInfoExtraService; -import com.yeshi.fanli.service.inter.user.UserInfoService; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.MoneyBigDecimalUtil; -import com.yeshi.fanli.util.RedisKeyEnum; -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.VersionUtil; -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.TaoBaoUtil; -import com.yeshi.fanli.util.taobao.TaoKeApiUtil; -import com.yeshi.fanli.util.taobao.TaoLiJinUtil; -import com.yeshi.fanli.vo.goods.taobao.TLJBuyHongBaoVO; -import com.yeshi.fanli.vo.msg.ClientTextStyleVO; -import com.yeshi.fanli.vo.tlj.SpreadHongBao; -import com.yeshi.fanli.vo.user.UserSettingsVO; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -@Controller -@RequestMapping("api/v1/user") -public class RecommendController { - - @Resource - private BusinessSystemService businessSystemService; - - @Resource - private SuperRecommendBannerService superRecommendBannerService; - - @Resource - private SuperRecommendSpecialService superRecommendSpecialService; - - @Resource - private OrderService orderService; - - @Resource - private ScanHistoryV2Service scanHistoryV2Service; - - @Resource - private ConfigService configService; - - @Resource - private HongBaoManageService hongBaoManageService; - - @Resource - private UserInfoService userInfoService; - - @Resource - private TaoBaoCouponService taoBaoCouponService; - - @Resource - private JumpDetailService jumpDetailService; - - @Resource - private SystemConfigService systemConfigService; - - @Resource - private CollectionGoodsV2Service collectionGoodsV2Service; - - @Resource - private TaoBaoGoodsBriefService taoBaoGoodsBriefService; - - @Resource - private RedisManager redisManager; - - @Resource - private TBPidService tbPidService; - - @Resource - private SystemClientParamsService systemClientParamsService; - - @Resource - private HongBaoManageService manageService; - - @Resource - private TaoBaoUnionConfigService taoBaoUnionConfigService; - - @Resource - private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; - - @Resource - private QualityGoodsService qualityGoodsService; - - @Resource - private SuperSpecialService superSpecialService; - - @Resource - private SuperRecommendBannerV2Service superRecommendBannerV2Service; - - @Resource - private ShamUserService shamUserService; - - @Resource - private SpecialService specialService; - - @Resource - private SwiperPictureService swiperPictureService; - - @Resource - private MonitorService monitorService; - - @Resource - private CommonGoodsService commonGoodsService; - - @Resource - private UserGoodsStorageService userGoodsStorageService; - - @Resource - private JumpDetailV2Service jumpDetailV2Service; - - @Resource - private UserCustomSettingsService userCustomSettingsService; - - @Resource - private ShareGoodsActivityOrderService shareGoodsActivityOrderService; - - @Resource - private UserInfoExtraService userInfoExtraService; - - @Resource - private QualityFlashSaleService qualityFlashSaleService; - - @Resource - private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; - - @Resource - private TaoBaoShopService taoBaoShopService; - - @Resource - private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; - - @Resource - private UserMoneyExtraService userMoneyExtraService; - - @Resource - private UserTaoLiJinOriginService userTaoLiJinOriginService; - - @Resource - private ConfigTaoLiJinService configTaoLiJinService; - - @Resource - private DeviceSexService deviceSexService; - - @Resource - private UserTaoLiJinRecordService userTaoLiJinRecordService; - - @Resource - private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService; - - @Resource - private HomeRecommendGoodsService homeRecommendGoodsService; - - @Resource - private TLJBuyGoodsService tljBuyGoodsService; - - @RequestMapping(value = "getHonestList") - public void getHonestList(AcceptData acceptData, PrintWriter out) { - List<Honest> honestList = null; - List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); - if ((Integer.parseInt(acceptData.getVersion()) >= 20 && "android".equalsIgnoreCase(acceptData.getPlatform())) - || ("ios".equalsIgnoreCase(acceptData.getPlatform()) - && Integer.parseInt(acceptData.getVersion()) >= 32))// Android - // 澶т簬20鐨勭増鏈拰ios澶т簬31鐨勭増鏈繑鍥炴柊鐨勫唴瀹� - { - honestList = new ArrayList<>(); - JumpDetail detail = new JumpDetail(); - detail.setActivity(String.format("%s.ui.invite.ShareBrowserActivity", - Constant.systemCommonConfig.getAndroidBaseactivityName())); - detail.setName("缃戦〉"); - detail.setController("ShonpingShareViewController"); - - Honest honest = new Honest(); - honest.setName("9.9鍖呴偖"); - honest.setJumpDetail(detail); - JSONObject params = new JSONObject(); - params.put("url", "http://cdn.apph5.yeshitv.com/special/jingXuanN_9.html?type=9_9"); - honest.setParams(params.toString()); - honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/special/9k9.jpg"); - honest.setType(1); /* 1:9鍧�9 2:19鍧�9 3锛氱壒浠峰ソ璐� 4锛氬垎浜湁绀� */ - honestList.add(honest); - - honest = new Honest(); - honest.setName("浠婃棩鏂板搧"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", "http://cdn.apph5.yeshitv.com/special/todayNew.html"); - honest.setParams(params.toString()); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/special/%E4%BB%8A%E6%97%A5%E6%96%B0%E5%93%81.jpg"); - honest.setType(1); - honestList.add(honest); - - honest = new Honest(); - honest.setName("澶ч鍒�"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", "http://cdn.apph5.yeshitv.com/special/daEQuan.html"); - honest.setParams(params.toString()); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/special/%E5%A4%A7%E9%A2%9D%E5%88%B8.jpg"); - honest.setType(1); - honestList.add(honest); - - honest = new Honest(); - honest.setName("瓒呴珮杩�"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); - honest.setParams(params.toString()); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); - honest.setType(1); - honestList.add(honest); - - if (Constant.IS_TEST) { - honest = new Honest(); - honest.setName("瓒呴珮杩�"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); - honest.setParams(params.toString()); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); - honest.setType(1); - honestList.add(honest); - } - - // if (acceptData.getPlatform().equalsIgnoreCase("ios") - // && - // configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) - // { - // honest = new Honest(); - // honest.setName("浠婃棩蹇呮姠"); - // honest.setJumpDetail(detail); - // params = new JSONObject(); - // params.put("url", - // "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); - // honest.setParams(params.toString()); - // honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); - // honest.setType(1); - // honestList.add(honest); - // } else { - // honest = new Honest(); - // honest.setType(4); - // honest.setName("閭�璇锋湁濂�"); - // honest.setJumpDetail(null); - // honest.setPicture( - // "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); - // honestList.add(honest); - // } - } else { - honestList = new ArrayList<>(); - JumpDetail detail = new JumpDetail(); - detail.setActivity( - String.format("%s.ui.BrowserActivity", Constant.systemCommonConfig.getAndroidBaseactivityName())); - detail.setName("缃戦〉"); - // GoodsDetailController - detail.setController("BrowserController"); - - Honest honest = new Honest(); - honest.setName("9鍧�9"); - honest.setJumpDetail(detail); - JSONObject params = new JSONObject(); - params.put("url", "https://temai.m.taobao.com/9k9?pid=" + configList.get(0).getDefaultPid()); - honest.setParams(params.toString()); - honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/9.9.png"); - honest.setType(1); /* 1:9鍧�9 2:19鍧�9 3锛氱壒浠峰ソ璐� 4锛氬垎浜湁绀� */ - honestList.add(honest); - - honest = new Honest(); - honest.setName("娣樺疂鐗瑰崠"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", "https://temai.m.taobao.com/index.htm?pid=" + configList.get(0).getDefaultPid()); - honest.setParams(params.toString()); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/%E7%89%B9%E4%BB%B7%E5%A5%BD%E8%B4%A7.png"); - honest.setType(1); - honestList.add(honest); - - honest = new Honest(); - honest.setName("鏃呮父鍑鸿"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", - "https://s.click.taobao.com/t?e=m%3D2%26s%3DBYnJkWG4TG0cQipKwQzePCperVdZeJviEViQ0P1Vf2kguMN8XjClAu02u1KR7qygWNI3LssOJ1ZWrun95JZUdbCdKVyILC1Y4MhN4biK4jW7lfuQJIvfPIK88P%2FKzi0kxxWvg6Zgs%2BufKdnhu%2B44hB9qAVPM25K0cj5d26O5JTnBV7GfGbfBR06AKI8EMgZwgGJ6r9DajuEo%2Bq0qHgj4%2Fr%2BOY9SrDkfyH5S%2BAXadU8u31WUvb1IPCiGFCzYOOqAQ"); - honest.setParams(params.toString()); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/%E6%97%85%E6%B8%B8%E5%87%BA%E8%A1%8C.png"); - honest.setType(1); - honestList.add(honest); - - if (acceptData.getPlatform().equalsIgnoreCase("ios") - && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) { - honest = new Honest(); - honest.setName("浠婃棩蹇呮姠"); - honest.setJumpDetail(detail); - params = new JSONObject(); - params.put("url", - "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); - honest.setParams(params.toString()); - honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); - honest.setType(1); - honestList.add(honest); - } else { - honest = new Honest(); - honest.setType(4); - honest.setName("閭�璇锋湁濂�"); - honest.setJumpDetail(null); - honest.setPicture( - "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); - honestList.add(honest); - } - - } - String result = JsonUtil.loadTrueResult(honestList); - out.print(result); - return; - } - - @RequestMapping(value = "getrecommendspecial") - public void getRecommendSpecial(AcceptData acceptData, PrintWriter out) { - - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - String version = acceptData.getVersion(); - JumpDetail jumpDetail = null; - 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) { - - recommendSpecialList = new ArrayList<RecommendSpecial>(); - - for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) { - 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(); - data.put("data", gson.toJson(recommendSpecialList)); - String json = JsonUtil.loadTrueResult(data); - out.print(json); - } - - // 鐚滀綘鍠滄 - @RequestMapping(value = "guessLike", method = RequestMethod.POST) - public void guessLike(AcceptData acceptData, PrintWriter out) { - - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - List<TaoBaoGoodsBrief> taoBaoGoodsBriefs1 = taoBaoCouponService.getTaoBaoCouponList(2); - List<TaoBaoGoodsBrief> taoBaoGoodsBriefs2 = new ArrayList<>(); - taoBaoGoodsBriefs2.addAll(taoBaoGoodsBriefs1); - - List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = new ArrayList<>(); - for (int i = 0; i < taoBaoGoodsBriefs2.size(); i++) { - if (taoBaoGoodsBriefs2.size() > 0 && taoBaoGoodsBriefs.size() < 6) { - int pos = (int) (Math.random() * taoBaoGoodsBriefs2.size()); - taoBaoGoodsBriefs.add(taoBaoGoodsBriefs2.get(pos)); - taoBaoGoodsBriefs2.remove(pos); - i--; - } - } - - BigDecimal proportion = manageService.getFanLiRate(); - JSONArray array = new JSONArray(); - TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; - Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); - - for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { - taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); - array.add(gson.toJson(taoBaoGoodsBriefExtra)); - } - JSONObject data = new JSONObject(); - data.put("goods", array); - data.put("count", array.size()); - out.print(JsonUtil.loadTrueResult(data)); - } - - @RequestMapping(value = "getrecommendbanner") - public void getRecommendBanner(AcceptData acceptData, PrintWriter out) { - - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - JSONObject json = new JSONObject(); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - List<SuperRecommendBanner> superRecommendBanners = superRecommendBannerService - .getSuperRecommendBannersBySystem(system); - List<RecommendBanner> list = null; - for (SuperRecommendBanner superRecommendBanner : superRecommendBanners) { - if (list == null) { - list = new ArrayList<RecommendBanner>(); - } - RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner(); - // 娣樼壒浠锋殏鏃朵慨鏀� - if (system.getId() == 7) { - recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity() - .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial")); - } - - list.add(recommendBanner); - } - - // 娴嬭瘯 - // 娣诲姞璺宠浆鍟嗗搧璇︽儏 - // RecommendBanner banner = new RecommendBanner(); - // banner.setId(1); - // JumpDetail jumpDetail = new JumpDetail(); - // jumpDetail.setActivity("com.yeshi.ec.rebate.myapplication.ui.recommend.GoodsBrowserActivity"); - // jumpDetail.setController("GoodsDetailController"); - // jumpDetail.setName("鍟嗗搧璇︽儏"); - // - // banner.setJumpDetail(jumpDetail); - // banner.setName("璇︽儏"); - // banner.setOrderby(1); - // JSONObject param = new JSONObject(); - // param.put("id", "568650986077"); - // banner.setParams(param.toString()); - // banner.setPicture( - // "https://gd3.alicdn.com/imgextra/i2/266969832/TB2iiKjoAyWBuNjy0FpXXassXXa_!!266969832.jpg_400x400.jpg_.webp"); - // list.add(banner); - - if (list == null) { - json.put("code", "1"); - json.put("msg", "鏆傛棤鏁版嵁"); - out.print(json); - java.lang.System.out.println("json-" + json); - return; - } - json.put("code", 0); - JSONObject data = new JSONObject(); - data.put("count", list.size()); - Gson gson = new Gson(); - data.put("data", gson.toJson(list)); - json.put("data", data); - out.print(json); - return; - } - - // 鑾峰彇鍟嗗搧璇︽儏 - @RequestMapping(value = "getgoodsdetail", method = RequestMethod.POST) - public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, PrintWriter out) { - long begin = java.lang.System.currentTimeMillis(); - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } - 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 (TaoBaoUtil.isSpecialGoods(simpleGoods.getMaterialLibType())) { - 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")) { - clientTBPid = tbPidService.getAndroidDefault(); - } else { - clientTBPid = tbPidService.getIOSDefault(); - } - } - - TaoBaoGoodsBrief tb = null; - try { - TaoKeAppInfo app = new TaoKeAppInfo(); - TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(clientTBPid.getSiteId()); - app.setAdzoneId(clientTBPid.getAdZoneId()); - app.setAppKey(clientTBPid.getAppKey()); - app.setAppSecret(config.getAppSecret()); - app.setPid(clientTBPid.getPid()); - tb = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app); - } catch (NumberFormatException e1) { - e1.printStackTrace(); - } catch (TaobaoGoodsDownException e1) { - out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�")); - return; - } - - if (tb != null) { - // tb.setAuctionUrl(null); - tb.setId(null); - int type = 0; - if ("android".equalsIgnoreCase(acceptData.getPlatform())) - type = PidUser.TYPE_FANLI_ANDROID; - else - type = PidUser.TYPE_FANLI_IOS; - - List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(type); - - Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - JSONObject data = new JSONObject(); - TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, configList.get(0)); - if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) - taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink()); - taoBaoGoodsBriefExtra.setAuctionUrl(tb.getAuctionUrl()); - if (uid != null && !"".equals(uid.trim())) { - CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), - Long.parseLong(id), Constant.SOURCE_TYPE_TAOBAO); - data.put("collection", collectionGoods != null ? true : false); - } - - data.put("tbPidInfo", clientTBPid); - - JSONObject taobaoJson = JSONObject.fromObject(gson.toJson(taoBaoGoodsBriefExtra)); - if (taoBaoGoodsBriefExtra.getImgList() != null) - taoBaoGoodsBriefExtra.getImgList().add(0, taoBaoGoodsBriefExtra.getPictUrl()); - taobaoJson.put("imgList", taoBaoGoodsBriefExtra.getImgList()); - taobaoJson.put("saleCount", taoBaoGoodsBriefExtra.getSalesCount());// 閿�閲忥紙鍜宻alesCount涓�鑷达紝姝ゅ澶勭悊鍏煎锛� - if (taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) - taobaoJson.put("coupon", true); - else - taobaoJson.put("coupon", false); - - // taoBaoGoodsBriefExtra.setAuctionUrl(null); - data.put("taobao", taobaoJson); - String info = configService.get(ConfigKeyEnum.detailPrompt.getKey()); - data.put("info", info); - String onlyInfo = configService.get(ConfigKeyEnum.onlyInfo.getKey()); - data.put("only", onlyInfo); - data.put("helpUrl", configService.get(ConfigKeyEnum.oldGoodsDetailHelpUrl.getKey())); - - int showType = taoBaoGoodsBriefExtra.getShowType(); - String price = ""; - if (showType == 1 || showType == 3) { - price = taoBaoGoodsBriefExtra.getQuanPrice() + ""; - } else { - price = taoBaoGoodsBriefExtra.getZkPrice() + ""; - } - String appName = systemConfigService.get("appName", system); - data.put("sharePrice", "楼" + price + "鍏� 閫�" + appName + "绾㈠寘楼" - + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "鍏� "); - data.put("shareTitle", taoBaoGoodsBriefExtra.getTitle()); - data.put("shareContent", "楼" + price + "鍏�"); - data.put("shareImg", taoBaoGoodsBriefExtra.getPictUrl()); - String html = configService.get(ConfigKeyEnum.downAPP.getKey()); - data.put("downAPP", html); - String shareSinaContent = configService.get("shareSinaContent"); - data.put("shareSina", - "楼" + price + "鍏� 閫�" + appName + "绾㈠寘楼" - + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "鍏� " - + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent); - - data.put("sharemoney", "鍒嗕韩濂栭噾 楼" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb) + "鍏�"); - - data.put("shareHongBao", "楼" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb)); - - out.print(JsonUtil.loadTrueResult(data)); - final TaoBaoGoodsBrief tbb = tb; - ThreadUtil.run(new Runnable() { - public void run() { - // 娣诲姞娴忚璁板綍 - try { - scanHistoryV2Service.addScanHistory(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), - acceptData.getDevice(), tbb); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - - } else { - out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�")); - } - long end = java.lang.System.currentTimeMillis(); - java.lang.System.out.println("鑰楁椂:" + (end - begin)); - return; - } - - // 鏂扮増鍟嗗搧鍥炬枃璇︽儏 - @RequestMapping(value = "getnewgoodsdetail", method = RequestMethod.POST) - public void getNewGoodsDetail(AcceptData acceptData, String id, String uid, HttpServletRequest request, - PrintWriter out) { - if ("0".equalsIgnoreCase(uid)) - uid = ""; - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - JSONObject data = new JSONObject(); - data.put("invalid", false); - // IOS鏄惁姝e湪涓婄嚎 - if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { - data.put("iosOnling", configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))); - } - - long startTime = java.lang.System.currentTimeMillis(); - - // 鑾峰彇娣樺鍙傛暟 - ClientTBPid clientTBPid = null; - // 鐢ㄦ埛宸茬粡鐧诲綍 - - if (acceptData.getPlatform().equalsIgnoreCase("android")) - clientTBPid = tbPidService.getAndroidDefault(); - else - clientTBPid = tbPidService.getIOSDefault(); - - LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime)); - - // 鏄惁鍦ㄦ湇鍔$杩涜杞摼 - boolean convertInServer = configService.isConvertTaoBaoLinkInServer(); - final String clientPid = clientTBPid.getPid(); - List<String> taskList = new ArrayList<>(); - taskList.add("goods"); - taskList.add("imgs"); - - List<String> detailImgs = new ArrayList<>(); - JSONArray detailImgsSize = new JSONArray(); - - final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); - taskList.stream().parallel().forEach(task -> { - if (task.equalsIgnoreCase("goods")) {// 鑾峰彇鍟嗗搧璇︽儏 - // TaoBaoGoodsBrief tb = null; - JSONObject ticket = new JSONObject(); - TaoBaoGoodsBrief goods = null; - if (convertInServer) { - 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); - } - - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (TaobaoGoodsDownException e) { - try { - monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "鍟嗗搧涓嬫灦")); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } else { - try { - goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id)); - } catch (TaobaoGoodsDownException e) { - try { - monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "鍟嗗搧涓嬫灦")); - } catch (Exception e1) { - e1.printStackTrace(); - } - // 鍟嗗搧涓嬫灦 - ThreadUtil.run(new Runnable() { - public void run() { - taoBaoGoodsUpdateService.deleteTaoBaoGoods(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 if (task.equalsIgnoreCase("imgs")) {// 鑾峰彇鍥炬枃璇︽儏 - List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(Long.parseLong(id)); - if (imgs != null && imgs.size() > 0) { - detailImgs.clear(); - detailImgsSize.clear(); - for (ImageInfo imgInfo : imgs) { - detailImgs.add(imgInfo.getPicture()); - } - - for (ImageInfo imgInfo : imgs) { - if (imgInfo.getWidth() <= 0) { - detailImgsSize.clear(); - break; - } else { - JSONObject size = new JSONObject(); - size.put("w", imgInfo.getWidth()); - size.put("h", imgInfo.getHeight()); - detailImgsSize.add(size); - } - } - - } - } - }); - - TaoBaoGoodsBrief tb = null; - if (goodsList.size() > 0) - tb = goodsList.get(0); - - if (tb == null) { - out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�")); - return; - } - - // 鑾峰彇PID - String pid = ""; - - JSONObject goods = new JSONObject(); - // - if (tb.getImgList() == null) - tb.setImgList(new ArrayList<>()); - tb.getImgList().add(0, tb.getPictUrl()); - - List<String> finalImgList = new ArrayList<>(); - for (String img : tb.getImgList()) { - // img=TbImgUtil.getTBSizeImgWebp(img, 600); - finalImgList.add(img); - } - - 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()); - - BigDecimal proportion = manageService.getFanLiRate(); - String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion); - goods.put("hongBao", hongBao); - - // 30澶╅攢閲� - goods.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); - - // 鑾峰彇璇︾粏鐨勫浘鏂囦俊鎭� - goods.put("detailImgs", detailImgs); - goods.put("detailImgsSize", detailImgsSize); - - String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); - - // 鍒嗕韩璧� - data.put("shareMoney", "楼" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb)); - - // 鍒ゆ柇鏀惰棌 - if (!StringUtil.isNullOrEmpty(uid)) { - CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), - Long.parseLong(id), Constant.SOURCE_TYPE_TAOBAO); - data.put("collected", collectionGoods != null ? true : false); - } else - data.put("collected", false); - - pid = clientTBPid.getPid(); - - LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); - - SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, - "goods_detail_jump_taobao"); - // 娴嬭瘯 - if ("1".equalsIgnoreCase((params.getValue() + "").trim())) - data.put("native", true); - else - data.put("native", false); - - goods.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); - // 鑾峰彇鍒镐俊鎭� - if (!StringUtil.isNullOrEmpty(tb.getCouponInfo())) { - BigDecimal quanPrice = TaoBaoUtil.getAfterUseCouplePrice(tb); - JSONObject couponInfo = new JSONObject(); - couponInfo.put("couponPrice", quanPrice.toString()); - // 鏈嶅姟绔浆閾� - 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); - } - - // 娓│ - // clientTBPid.setAdZoneId("12"); - // clientTBPid.setPid("mm_123123_123123_123213"); - - data.put("tbPidInfo", clientTBPid); - - if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 鏈夊埜锛岃烦杞埜閾炬帴 - jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), - "" + tb.getAuctionId()); - } - - // 璁剧疆璺宠浆閾炬帴 - if (convertInServer) { - if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) - jumpUrl = tb.getCouponLink(); - else - jumpUrl = tb.getAuctionUrl(); - } - - goods.put("jumpUrl", jumpUrl); - goods.put("shopInfo", redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId())); - data.put("goods", goods); - - String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); - data.put("shareUrl", shareUrl); - - out.print(JsonUtil.loadTrueResult(data)); - - final String tempUid = uid; - final TaoBaoGoodsBrief goodsInfo = tb; - ThreadUtil.run(new Runnable() { - public void run() { - // 娣诲姞娴忚璁板綍 - try { - scanHistoryV2Service.addScanHistory( - StringUtil.isNullOrEmpty(tempUid) ? null : Long.parseLong(tempUid), acceptData.getDevice(), - goodsInfo); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (CommonGoodsException e) { - e.printStackTrace(); - } catch (ScanHistoryException e) { - e.printStackTrace(); - } - } - }); - } - - /** - * 娣樺疂杞摼 - * - * @param acceptData - * @param uid - * @param id - * @param out - */ - @RequestMapping(value = "gettaobaolink") - public void getTaobaoLink(AcceptData acceptData, String uid, Long id, PrintWriter out) { - ClientTBPid clientTBPid = null; - // 鐢ㄦ埛宸茬粡鐧诲綍 - if (!StringUtil.isNullOrEmpty(uid)) { - if (acceptData.getPlatform().equalsIgnoreCase("android")) { - clientTBPid = tbPidService.getAndroidDefault(); - } else { - clientTBPid = tbPidService.getIOSDefault(); - } - - } else { - if (acceptData.getPlatform().equalsIgnoreCase("android")) - clientTBPid = tbPidService.getAndroidDefault(); - else - clientTBPid = tbPidService.getIOSDefault(); - } - - JSONObject data = new JSONObject(); - - // 鏄惁鍦ㄦ湇鍔$杩涜杞摼 - boolean convertInServer = configService.isConvertTaoBaoLinkInServer(); - TaoBaoGoodsBrief tb = null; - JSONObject ticket = new JSONObject(); - if (convertInServer) { - String appId = clientTBPid.getPid().split("_")[2]; - TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); - TaoKeAppInfo app = new TaoKeAppInfo(); - app.setAdzoneId(clientTBPid.getPid().split("_")[3]); - app.setAppKey(config.getAppKey()); - app.setAppSecret(config.getAppSecret()); - app.setPid(clientTBPid.getPid()); - try { - tb = TaoKeApiUtil.searchGoodsDetail(id, app); - if (tb != null) { - ticket.put("clickUrl", tb.getAuctionUrl()); - ticket.put("couponUrl", tb.getCouponLink()); - data.put("ticket", ticket); - } - - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - } - - data.put("pidInfo", clientTBPid); - out.print(JsonUtil.loadTrueResult(data)); - } - - // 鏍规嵁鍟嗗搧鑾峰彇鎺ㄨ崘 - @RequestMapping(value = "getgoodsrecommend", method = RequestMethod.POST) - public void getGoodsRecommend(final AcceptData acceptData, long id, PrintWriter out) { - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 6); - if (goodsList == null) - goodsList = new ArrayList<>(); - - if (goodsList == null || goodsList.size() == 0)// 閲嶆柊鍋氭帹鑽� - { - TaoBaoGoodsBrief goods = null; - try { - goods = redisManager.getTaoBaoGoodsBrief(id); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - if (goods == null)// 鍟嗗搧涓嬬嚎 - { - // 浠庢垜浠殑鍟嗗搧搴撴悳绱� - CommonGoods cgoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(id, - CommonGoods.GOODS_TYPE_TB); - - if (cgoods != null) {// 鍟嗗搧鏈夋湰鍦扮紦瀛� - // 鎸夊悕瀛楁悳绱㈠晢鍝� - SearchFilter sf = new SearchFilter(); - sf.setKey(cgoods.getTitle().substring(0, cgoods.getTitle().length() / 2)); - TaoBaoSearchResult result = TaoBaoUtil.search(sf); - if (result != null && result.getTaoBaoGoodsBriefs() != null - && result.getTaoBaoGoodsBriefs().size() > 0) - for (TaoBaoGoodsBrief gds : result.getTaoBaoGoodsBriefs()) { - if (goodsList.size() < 6) - goodsList.add(gds); - } - } - } - } - - final List<TaoBaoGoodsBrief> recommendGoodsList = new ArrayList<>(); - - goodsList.parallelStream().forEach(goods -> { - // 鑾峰彇璇︽儏 - TaoBaoGoodsBrief taoBaoGoodsBrief = null; - try { - taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(goods.getAuctionId()); - } catch (Exception e) { - e.printStackTrace(); - } - if (taoBaoGoodsBrief != null) - recommendGoodsList.add(taoBaoGoodsBrief); - }); - - // 鍙栧伓鏁颁釜鏁版嵁 - if (recommendGoodsList.size() % 2 != 0) { - recommendGoodsList.remove(recommendGoodsList.size() - 1); - } - - List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); - - BigDecimal proportion = manageService.getFanLiRate(); - if (recommendGoodsList != null) - for (TaoBaoGoodsBrief taoBaoGoodsBrief : recommendGoodsList) { - if (taoBaoGoodsBrief == null) - continue; - - re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); - } - out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(re))); - } - - // 涓婁紶璁㈠崟 - @RequestMapping(value = "reportorder", method = RequestMethod.POST) - public void reportOrder(AcceptData acceptData, String order, String auctionUrl, String money, long uid, - PrintWriter out, HttpServletRequest request) { - LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "],涓婁紶鐨勬窐瀹濊鍗旾D锛�" + order + ",鐢ㄦ埛ID:" + uid + ",璁㈠崟閲戦:" - + money + ",鍟嗗搧閾炬帴:" + auctionUrl); - if (StringUtil.isNullOrEmpty(order)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爋rder")); - LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 涓婁紶鐨勮鍗曚负绌猴紒涓婁紶璁㈠崟澶辫触锛�"); - return; - } - - UserInfo user = userInfoService.getUserById(uid); - if (user == null) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爑id")); - LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 鐢ㄦ埛涓嶅瓨鍦�!涓婁紶璁㈠崟澶辫触锛�"); - return; - } - order = order.replace("[", "").replace("]", ""); - String[] orderArr = order.split(","); - for (String tbOrder : orderArr) { - Order or = new Order(); - or.setBeizhu("鎺ュ彛娣诲姞"); - or.setCreatetime(java.lang.System.currentTimeMillis()); - or.setDrawbackTime(0L); - or.setOrderId(tbOrder.trim()); - or.setOrderType(1); - or.setState(1); - or.setUserInfo(new UserInfo(uid)); - or.setVersion(2); - boolean b; - try { - b = orderService.addOrder(or); - } catch (Exception e) { - e.printStackTrace(); - b = false; - } - if (b) { - LogHelper.userOrder("鐢ㄦ埛ID" + uid + "涓嬪崟鎴愬姛锛佽鍗旾D[" + or.getOrderId() + "]"); - } else { - LogHelper.userOrder("鐢ㄦ埛ID" + uid + "涓嬪崟澶辫触锛佽鍗旾D[" + or.getOrderId() + "]"); - } - } - out.print(JsonUtil.loadTrueResult("涓婃姤鎴愬姛")); - return; - } - - // 鑾峰彇娴忚璁板綍 - @RequestMapping(value = "getscanhistory", method = RequestMethod.POST) - public void getScanHistory(AcceptData acceptData, String uid, int page, PrintWriter out) { - - if (page < 0) { - out.print(JsonUtil.loadFalseResult(1, "page涓嶅皬浜�0")); - return; - } - page = page + 1; - BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), - acceptData.getPackages()); - if (sys == null) { - out.print(JsonUtil.loadFalseResult(1, "涓嶅瓨鍦ㄨ绯荤粺")); - return; - } - try { - - List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid( - StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20, - Constant.SOURCE_TYPE_TAOBAO); - long count = scanHistoryV2Service.getCountByDeviceOrUid( - StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), - Constant.SOURCE_TYPE_TAOBAO); - - JSONObject data = new JSONObject(); - data.put("count", count); - JSONArray array = new JSONArray(); - - GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); - gsonBuilder.excludeFieldsWithoutExposeAnnotation(); - gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { - @Override - public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { - if (value == null) { - return new JsonPrimitive(""); - } else { - return new JsonPrimitive(value.getTime() + ""); - } - } - }); - - Gson gson = gsonBuilder.create(); - - if (list != null) { - BigDecimal proportion = manageService.getFanLiRate(); - for (ScanHistoryV2 sh : list) { - TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods()); - goods.setId(sh.getId()); - TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), ""); - extra.setCreatetime(sh.getCreateTime()); - array.add(gson.toJson(extra)); - } - } - data.put("data", array); - out.print(JsonUtil.loadTrueResult(data)); - return; - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - JSONObject data = new JSONObject(); - data.put("data", new JSONArray()); - data.put("count", 0); - out.print(JsonUtil.loadTrueResult(data)); - } - - } - - @RequestMapping(value = "deletescanhistory", method = RequestMethod.POST) - public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) { - BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), - acceptData.getPackages()); - if (sys == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - if ("0".equals(type)) { - String[] idStr = ids.split(","); - for (String auctionIdStr : idStr) { - scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid( - StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), - Long.parseLong(auctionIdStr)); - } - } else { - scanHistoryV2Service.deleteByDeviceOrUid(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), - acceptData.getDevice()); - } - out.print(JsonUtil.loadTrueResult("")); - - return; - } - - // 鏍规嵁鍘熼摼鎺ヨ幏鍙栨帹骞块摼鎺� - - @RequestMapping(value = "getTaoBaoLink", method = RequestMethod.POST) - public void getTaoBaoLink(AcceptData acceptData, String url, PrintWriter out) { - if (!url.contains("//detail.m.tmall.com/item.htm") && !url.contains("h5.m.taobao.com/awp/core/detail.htm") - && !url.contains("item.taobao.com/item.htm")) { - out.print(JsonUtil.loadFalseResult(1, "閾炬帴閿欒")); - return; - } - - String params = url.split("\\?")[1]; - String[] ps = params.split("&"); - String id = ""; - for (String st : ps) { - if (st.contains("id=")) { - id = st.replace("id=", ""); - break; - } - } - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧ID閿欒")); - return; - } - - /** - * 闃叉璇锋眰棰戠巼杩囬珮 - * - */ - // if (Constant.IS_OUTNET) { - String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaolinkParse, acceptData.getDevice() + "-" + id); - String value = redisManager.getCommonString(key); - if (!StringUtil.isNullOrEmpty(value)) { - out.print(JsonUtil.loadFalseResult(11, "璇锋眰棰戠巼闄愬埗")); - return; - } - redisManager.cacheCommonString(key, "1", 5);// 5s闂撮殧 - // } - TaoBaoGoodsBrief goods = null; - try { - goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id)); - } catch (NumberFormatException e) { - e.printStackTrace(); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - if (goods == null) { - out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧")); - return; - } - - JSONObject data = new JSONObject(); - data.put("id", id); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - - /** - * 鏍规嵁璁惧淇℃伅鑾峰彇鐚滀綘鍠滄鐨勫唴瀹� - * - * @param acceptData - * @param imei - * -Android鐨処MEI淇℃伅 - * @param idfa - * -IOS鐨刬dfa骞垮憡鏍囪瘑淇℃伅 - */ - @RequestMapping(value = "guessLikeByDevice") - public void guessUserLikeByDevice(AcceptData acceptData, String imei, String idfa, int page, - HttpServletRequest request, PrintWriter out) { - int pageSize = Constant.PAGE_SIZE; - JSONArray array = new JSONArray(); - - Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); - if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) { - List<TaoBaoGoodsBrief> goodsList = homeRecommendGoodsService.listGoodsByPage(null, acceptData.getDevice(), - imei, idfa, page); - - if (page < 4) {// 鍓嶄笁椤靛姞鍏ユ洿鏂� - try { - taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); - } catch (Exception e) { - } - } - - BigDecimal rate = hongBaoManageService.getFanLiRate(); - for (TaoBaoGoodsBrief goods : goodsList) { - TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null); - if (page < 3) - extra.setRecommend(true); - - try { - array.add(gson.toJson(extra)); - } catch (Exception e) { - e.printStackTrace(); - System.out.println(new Gson().toJson(goods)); - } - } - - if (page == 1) { - List<TLJBuyGoods> list = null; - try { - list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); - } catch (Exception e) { - } - if (list != null && list.size() > 0) - for (int i = list.size() - 1; i >= 0; i--) { - TLJBuyGoods goods = list.get(i); - TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods.getGoods(), - TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE + "", null); - String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(goods.getGoods(), - TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE); - TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); - vo.setLeft(goods.getLeftHongBaoCount()); - vo.setMoney(hongBao); - vo.setTagName("浠樻绔嬪噺 " + hongBao); - vo.setTip(""); - vo.setTotal(goods.getTotalHongBaoCount()); - extra.setTljBuyHongBao(vo); - extra.setPictureTag(new ClientTextStyleVO("绔嬪噺TOP" + (i + 1), "#E5005C", "#FCE431", null)); - extra.setRecommend(true); - extra.setSpreadMoney(vo.getTagName()); - array.add(0, gson.toJson(extra)); - } - } - - JSONObject data = new JSONObject(); - data.put("data", array); - data.put("count", 1000); - out.print(JsonUtil.loadTrueResult(data)); - return; - } - - // 浠庢帹鑽愭潵 - if (page <= 1) { - array.clear(); - BigDecimal proportion = manageService.getFanLiRate(); - if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) { - long startTime = java.lang.System.currentTimeMillis(); - - TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa,""); - - if (result != null && result.getTaoBaoGoodsBriefs() != null) { - // 绛涢�� - List<TaoBaoGoodsBriefExtra> goodsList = new ArrayList<>(); - - List<TaoBaoGoodsBrief> gList = recommendGoodsDeleteHistoryService - .filterGoods(acceptData.getDevice(), result.getTaoBaoGoodsBriefs()); - - // filter - try { - - gList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(gList); - } catch (Exception e) { - } - - // 璁惧鎺ㄨ崘 - if (gList != null) - for (TaoBaoGoodsBrief goods : gList) { - if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null - && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0 - && goods.getBiz30day() > 1000 - && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { - - TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, - proportion.toString(), ""); - - extra.setRecommend(true); - goodsList.add(extra); - } - } - try { - monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, - (int) (java.lang.System.currentTimeMillis() - startTime), "鎺ㄨ崘鏁伴噺:" + goodsList.size())); - } catch (Exception e) { - e.printStackTrace(); - } - - Collections.shuffle(goodsList); - goodsList = goodsList.size() > 20 ? goodsList.subList(0, 20) : goodsList; - for (TaoBaoGoodsBriefExtra goods : goodsList) { - array.add(gson.toJson(goods)); - } - } else { - try { - monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, - (int) (java.lang.System.currentTimeMillis() - startTime), "鏃犳帹鑽�")); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - JSONArray localArray = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, - proportion.toString()); - array.addAll(localArray); - } else {// 浠庣簿閫夊簱鏉� - BigDecimal proportion = manageService.getFanLiRate(); - array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString()); - if (array == null) { - out.print(JsonUtil.loadFalseResult("娌℃湁鏇村浜�")); - return; - } - } - - JSONObject data = new JSONObject(); - data.put("data", array); - data.put("count", 1000); - out.print(JsonUtil.loadTrueResult(data)); - } - - /** - * 鑾峰彇棣栭〉鎺ㄨ崘淇℃伅 - * - * @param acceptData - * @param out - */ - @RequestMapping(value = "getRecommendInfo") - public void getRecommendHomeInfo(AcceptData acceptData, PrintWriter out) { - - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - // 棣栭〉Banner - List<RecommendBannerV2> listBanner = superRecommendBannerV2Service - .getSuperRecommendBannerV2sBySystem(system.getId()); - - JSONObject root = new JSONObject(); - root.put("banner", listBanner); - - List<Special> honestList = null; - List<Special> specialList = null; - - Special miaoShaSpecial = new Special(); - - // 棣栭〉鎺ㄨ崘涓撻 - List<SuperSpecial> listSuper = superSpecialService.listBySystemAndCardCache(system.getId(), "index"); - - if (listSuper != null && listSuper.size() > 0) { - - honestList = new ArrayList<Special>(); - - specialList = new ArrayList<Special>(); - - for (int i = 0; i < listSuper.size(); i++) { - - Special special = listSuper.get(i).getSpecial(); - special.setCreatetime(null); - special.setUpdatetime(null); - - if ("闄愭椂绉掓潃".equals(special.getName())) { - miaoShaSpecial = special; - continue; - } - - if (i < 5) { - // 5澶т笓棰� - honestList.add(special); - } else { - // 鍏朵粬涓撻 - specialList.add(special); - } - - } - } - - root.put("honest", honestList); - root.put("special", specialList); - - /* 闄愭椂绉掓潃 - 鏃堕棿澶勭悊 */ - JSONObject msJSON = JSONObject.fromObject(new Gson().toJson(miaoShaSpecial)); - - // 鑾峰彇绉掓潃 - int[] hours = new int[] { 0, 9, 12, 14, 16, 20, 22 }; - int hour = -1; - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(Long.parseLong(acceptData.getTime())); - int nowHour = calendar.get(Calendar.HOUR_OF_DAY); - for (int i = 0; i < hours.length - 1; i++) { - if (nowHour >= hours[i] && nowHour < hours[i + 1]) { - hour = hours[i + 1]; - break; - } - } - - if (hour < 0) - hour = 24; - long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd"), - "yyyy-MM-dd") + 1000 * 60 * 60 * hour; - msJSON.put("time", time); - - root.put("miaoSha", msJSON); - - out.print(JsonUtil.loadTrueResult(root)); - } - - /** - * 鏂扮増鎺ㄨ崘涓撻绠$悊(1.4.0) - * - * @param acceptData - * @param out - */ - @RequestMapping(value = "getNewRecommendInfo") - public void getNewRecommendInfo(AcceptData acceptData, Long uid, String specialCard, String swiperCard, - PrintWriter out) { - - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - List<SwiperPicture> listswiper = null; - if (!StringUtil.isNullOrEmpty(specialCard)) { - try { - - listswiper = swiperPictureService.getByBannerCardAndVersion(swiperCard, acceptData.getPlatform(), - Integer.parseInt(acceptData.getVersion())); - - if (listswiper == null) { - listswiper = new ArrayList<SwiperPicture>(); - } - - } catch (Exception e) { - e.printStackTrace(); - } - } - - Special miaoShaSpecial = null; - List<Special> honestList = new ArrayList<Special>(); - List<Special> specialList = new ArrayList<Special>(); - - if (!StringUtil.isNullOrEmpty(specialCard)) { - try { - List<Special> listSpecial = specialService.listBySystemAndCard(specialCard, system.getId()); - - if (listSpecial != null && listSpecial.size() > 0) { - for (Special special : listSpecial) { - - if ("闄愭椂绉掓潃".equals(special.getName())) { - miaoShaSpecial = special; - continue; - } - - if ("arc".equals(special.getShowType())) { - // 鍚屼竴琛屼笓棰� - honestList.add(special); - } else { - // 鍏朵粬涓撻 - specialList.add(special); - } - - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - /* 闄愭椂绉掓潃 - 鏃堕棿澶勭悊 */ - JSONObject msJSON = JSONObject.fromObject(new Gson().toJson(miaoShaSpecial)); - if (miaoShaSpecial != null) { - // 鑾峰彇绉掓潃 - int[] hours = new int[] { 0, 9, 12, 14, 16, 20, 22 }; - int hour = -1; - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(Long.parseLong(acceptData.getTime())); - int nowHour = calendar.get(Calendar.HOUR_OF_DAY); - for (int i = 0; i < hours.length - 1; i++) { - if (nowHour >= hours[i] && nowHour < hours[i + 1]) { - hour = hours[i + 1]; - break; - } - } - - if (hour < 0) - hour = 24; - long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd"), - "yyyy-MM-dd") + 1000 * 60 * 60 * hour; - msJSON.put("time", time); - } - - 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(); - JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("invite"); - invite.put("jumpDetail", jumpDetail); - invite.put("picture", configService.get(ConfigKeyEnum.homeInviteBanner.getKey())); - - if ("ios".equalsIgnoreCase(acceptData.getPlatform()) - && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) { - // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥� - } else { - - // 鎸夌収鐗堟湰杩斿洖锛岀増鏈鐩栬冻澶熷悗鍙垹闄� - if (("android".equalsIgnoreCase(acceptData.getPlatform()) && Integer.parseInt(acceptData.getVersion()) > 30) - || ("ios".equalsIgnoreCase(acceptData.getPlatform()) - && Integer.parseInt(acceptData.getVersion()) > 37)) { - if (uid != null) { - try { - UserSettingsVO vo = userCustomSettingsService.getMySettings(uid); - if (vo == null || vo.getNoInvitationBonus() == null || vo.getNoInvitationBonus() == 0)// 娌℃湁鍏抽棴閭�璇� - root.put("invite", invite); - } catch (UserCustomSettingsException e) { - e.printStackTrace(); - } - } else - 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 { - // 鑾峰彇璁惧瀹氫箟鎬у埆 - int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice()); - - // 1銆佷笓棰樻ā鍧� - JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex); - - // 2銆侀《閮ㄨ疆鎾浘 - List<SwiperPicture> topPicList = getSwiperByCard("index_top", acceptData); - 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", acceptData); - } - - 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(ConfigKeyEnum.indexHtmlLinkIos.getKey())); - } - - root.put("spikeGoods", getSpikeGoodsContent(acceptData)); - - 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", acceptData); - - return invitePicList; - } - - public List<SwiperPicture> getSwiperByCard(String card, AcceptData acceptData) { - List<SwiperPicture> swiperList = null; - try { - swiperList = swiperPictureService.getByBannerCardAndVersion(card, acceptData.getPlatform(), - Integer.parseInt(acceptData.getVersion())); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - e.printStackTrace(); - } - return swiperList; - } - - private JSONObject getSpikeGoodsContent(AcceptData acceptData) { - // 涓嬩竴娆″�掕鏃剁殑鏃堕棿 - 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 = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsHour,acceptData.getPlatform() +"-"+acceptData.getVersion()); - String cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsList,acceptData.getPlatform() +"-"+acceptData.getVersion()); - - 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); - } - } - JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web"); - 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; - } - JSONObject goods = new JSONObject(); - goods.put("goods", gson - .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null))); - goods.put("jumpDetail", jumpDetail); - JSONObject params = new JSONObject(); - params.put("url", configService.get(ConfigKeyEnum.spikeGoodsLink.getKey()) + "?id=" + taoBaoGoodsBrief.getAuctionId()); - goods.put("params", params); - - // 1.5.4鍙婁互鍚庤繑鍥� - if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { - array.add(goods); - } else { - array.add(goods.optJSONObject("goods")); - } - } - - // 缂撳瓨鍗婁釜灏忔椂 - redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30); - } - Long endTime = nextTime.getTimeInMillis() - java.lang.System.currentTimeMillis(); - - JSONObject root = new JSONObject(); - root.put("time", nextTime.getTimeInMillis()); - root.put("endTime", endTime > 0 ? endTime : 0); - root.put("listgoods", array); - - JSONObject params = new JSONObject(); - params.put("url", configService.get(ConfigKeyEnum.spikeGoodsLink.getKey())); - - root.put("params", params); - root.put("jumpDetail", jumpDetail); - - return root; - } - - /** - * 闄愭椂绉掓潃 1.5.3 - * - * @param acceptData - * @param out - */ - @RequestMapping(value = "getSpikeGoods") - public void getSpikeGoods(AcceptData acceptData, PrintWriter out) { - JSONObject root = getSpikeGoodsContent(acceptData); - out.print(JsonUtil.loadTrueResult(root)); - } - - /** - * 鍟嗗搧鍩烘湰璇︽儏 (1.4.0) - * - * @param acceptData - * @param id - * @param uid - * @param pageSource - * 椤甸潰鏉ユ簮 - * @param out - */ - @RequestMapping(value = "getgoodsinfo", method = RequestMethod.POST) - public void getGoodsInfo(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { - - if (id == null) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } - - BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), - acceptData.getPackages()); - if (system == null) { - out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); - return; - } - - JSONObject data = new JSONObject(); - data.put("invalid", false); - - // IOS鏄惁姝e湪涓婄嚎 - if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { - String version = acceptData.getVersion(); - data.put("iosOnling", configService.iosOnLining(Integer.parseInt(version))); - } - - long startTime = java.lang.System.currentTimeMillis(); - - // 鑾峰彇娣樺鍙傛暟 - ClientTBPid clientTBPid = null; - - // 鐢ㄦ埛鏈櫥褰� - if (acceptData.getPlatform().equalsIgnoreCase("android")) { - clientTBPid = tbPidService.getAndroidDefault(); - } else { - clientTBPid = tbPidService.getIOSDefault(); - } - - LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime)); - - final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); - // 鏄惁鍦ㄦ湇鍔$杩涜杞摼 - boolean convertInServer = configService.isConvertTaoBaoLinkInServer(); - - JSONObject ticket = new JSONObject(); - TaoBaoGoodsBrief goods = null; - - if (!convertInServer) { - try { - goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); - if (goods == null) { - TaoKeAppInfo app = new TaoKeAppInfo(); - 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(id, app); - final TaoBaoGoodsBrief finalGoods = goods; - if (goods != null) { - ThreadUtil.run(new Runnable() { - @Override - public void run() { - taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods); - } - }); - } - } - } catch (TaobaoGoodsDownException e) { - // 鍟嗗搧涓嬫灦 - ThreadUtil.run(new Runnable() { - public void run() { - taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); - } - }); - - } - - } 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(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(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) { - tb = goodsList.get(0); - } - - if (tb == null) { - out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�")); - return; - } - - if (tb.getImgList() == null) { - tb.setImgList(new ArrayList<>()); - } - - tb.getImgList().add(0, tb.getPictUrl()); - - List<String> finalImgList = new ArrayList<>(); - for (String img : tb.getImgList()) { - finalImgList.add(TbImgUtil.getTBSizeImg(img, 600)); - } - if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) - finalImgList.add(0, tb.getPictUrlWhite()); - - // 澶ф窐瀹㈠晢鍝佽繃婊� - try { - goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - 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", MoneyBigDecimalUtil.getWithNoZera(tb.getZkPrice()).toString()); - - // 30澶╅攢閲� - goodsJson.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); - goodsJson.put("salesCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); - - // 鍒嗕韩璧� - BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb); - data.put("shareMoney", "楼" + shareMoney); - // 鍒嗕韩璧氫汉鎻愮ず - List<ShamUser> listShareUser = new ArrayList<ShamUser>(); - if (tb.getBiz30day() >= 1000) { - listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5); - } - - // 鍒ゆ柇鏀惰棌 - if (uid == null) { - data.put("collected", false); - } else { - CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, - Constant.SOURCE_TYPE_TAOBAO); - data.put("collected", collectionGoods != null ? true : false); - } - - // 娴嬭瘯 - SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, - "goods_detail_jump_taobao"); - if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { - data.put("native", true); - } else { - data.put("native", false); - } - - // 鑾峰彇PID - String pid = clientTBPid.getPid(); - LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); - - // 鏄惁鏈夊埜 - goodsJson.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); - - // 棰嗗埜浜哄垪琛� - List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); - - String hongBao = null; - - // 鑾峰彇鍒镐俊鎭� - if (!StringUtil.isNullOrEmpty(tb.getCouponInfo()) && tb.getCouponAmount() != null - && tb.getCouponAmount().compareTo(new BigDecimal(0)) > 0 && tb.getCouponEffectiveStartTime() != null - && tb.getCouponEffectiveEndTime() != null) { - BigDecimal quanPrice = TaoBaoUtil.getAfterUseCouplePrice(tb); - JSONObject couponInfo = new JSONObject(); - couponInfo.put("couponPrice", MoneyBigDecimalUtil.getWithNoZera(quanPrice).toString()); - - if (from != null && from.equals("miandan")) { - // 鍏嶅崟鍟嗗搧 - hongBao = "楼" + quanPrice.toString(); - } - - String token = ""; - if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) - && VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) { - token = redisManager.getCommonTaoToken(tb.getAuctionId()); - if (StringUtil.isNullOrEmpty(token)) { - token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink()); - redisManager.saveCommonTaoToken(tb.getAuctionId(), token); - } - } - if (!VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) - 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", MoneyBigDecimalUtil.getWithNoZera(tb.getCouponAmount()).toString()); - couponInfo.put("couponTime", "浣跨敤鏈熼檺锛�" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-" - + tb.getCouponEffectiveEndTime().replace("-", ".")); - // 鍒哥殑鍙d护 - - if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) - couponInfo.put("couponToken", ""); - else - 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(); - if ("taolijin".equalsIgnoreCase(from)) - proportion = manageService.getTLJShareRate(System.currentTimeMillis()); - hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion); - } - goodsJson.put("hongBao", hongBao); - - List<ClientTextStyleVO> labels = new ArrayList<>(); - goodsJson.put("labels", labels); - - data.put("tbPidInfo", clientTBPid); - - String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); - - if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 鏈夊埜锛岃烦杞埜閾炬帴 - jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), - "" + tb.getAuctionId()); - } - - // 璁剧疆璺宠浆閾炬帴 - if (convertInServer) { - if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) - jumpUrl = tb.getCouponLink(); - else - jumpUrl = tb.getAuctionUrl(); - } - goodsJson.put("jumpUrl", jumpUrl); - - TaoBaoShopInfo tbShopInfo = redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId()); - if (tbShopInfo != null) { - String shopType = tbShopInfo.getShopType(); - if (!StringUtil.isNullOrEmpty(shopType) && shopType.contains("tm.png")) { - tbShopInfo.setUserType("1"); - } else { - tbShopInfo.setUserType("0"); - } - - String shopLink = tbShopInfo.getShopUrl(); - if (StringUtil.isNullOrEmpty(shopLink)) { - tbShopInfo.setShopUrl(TaoBaoUtil.getShopLink(tbShopInfo.getUserId())); - } - } - - // 搴楅摵1.5.4鍙婁互鍚庣増鏈� - if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { - TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); - if (shop != null) { - String shopLink = shop.getShopLink(); - if (StringUtil.isNullOrEmpty(shopLink)) { - shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); - } - goodsJson.put("shopInfo", shop); - } - } else { - goodsJson.put("shopInfo", tbShopInfo); - } - - // 鍒嗕韩璺緞 - String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); - - // 鏄惁鍔犲叆閫夊搧搴擄細 0鏈姞鍏� 1 宸插姞鍏� - boolean storageState = false; - if (uid != null) { - storageState = userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO); - } - - data.put("storageState", storageState); - data.put("shareUrl", shareUrl); - data.put("shareUsers", listShareUser); - data.put("couponUsers", listCouponUser); - data.put("detailWebUrl", "http://apph5.banliapp.com/apppage/goods_img.html?id=" + id); - - String noRebateHelpLink = null; - - // 鍟嗗搧閾炬帴 - 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); - } - - // 鏄惁鏈夎繑鍒� - boolean fanliValid = true; - // 璧勯噾绫诲瀷 1-杩� 2-濂� - int moneyType = 1; - - // 鎺ㄥ箍绾㈠寘 - if (from != null && from.equals("taolijin")) { - // 璁$畻鎺ㄥ箍绾㈠寘 - String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); - BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); - - // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1 - if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { - out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�")); - return; - } - - // 鏄惁涓烘柊鐢ㄦ埛 - boolean isNewUser = userInfoExtraService.isNewUser(uid); - if (isNewUser) { - // 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜�� - long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); - if (countRecord > 0) { - isNewUser = false; - } - } - - SpreadHongBao spreadHongBao = new SpreadHongBao(); - if (isNewUser) { - spreadHongBao.setMoney("1"); - } else { - spreadHongBao.setMoney(spreadMoney.toString()); - - moneyType = 2; - fanliValid = false; - ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); - textStyleVO1.setContent("鍒嗕韩"); - textStyleVO1.setColor("#666666"); - ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO(); - textStyleVO2.setContent("璧氬閲�"); - textStyleVO2.setColor("#F14242"); - ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO(); - textStyleVO3.setContent("锛屽ソ鍙�"); - textStyleVO3.setColor("#666666"); - ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO(); - textStyleVO4.setContent("棰嗙孩鍖咃紒"); - textStyleVO4.setColor("#F14242"); - - List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>(); - listText.add(textStyleVO1); - listText.add(textStyleVO2); - listText.add(textStyleVO3); - listText.add(textStyleVO4); - - data.put("listTip", listText); - } - spreadHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�"); - goodsJson.put("spreadHongBao", spreadHongBao); - - // 鐢ㄦ埛鍓╀綑鍙互娣樼ぜ閲戦獙璇� - UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); - if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) { - data.put("userHongbao", new BigDecimal(0).setScale(2).toString()); - } else { - data.put("userHongbao", userMoneyExtra.getTlj().setScale(2).toString()); - } - - noRebateHelpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", null); - - if (Constant.IS_TEST) { - fanliValid = true; - goodsJson.put("shareValid", false); - JSONObject tljNum = new JSONObject(); - tljNum.put("percent", "80"); - tljNum.put("num", "8825"); - goodsJson.put("tljNum", tljNum); - } - - } else if (from != null && from.equals("taolijin_buy")) { - noRebateHelpLink = configService.get(ConfigKeyEnum.zigoulijianNofanliHelp.getKey()); - // 鏌ヨ鍒嗕韩搴� - TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(goods.getAuctionId(), - TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); - if (buyGoods == null) { - out.print(JsonUtil.loadFalseResult(2, "鑷喘绔嬪噺绾㈠寘杩囨湡")); - return; - } - - fanliValid = true; - goodsJson.put("shareValid", false); - String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70)).toString(); - TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); - vo.setLeft(buyGoods.getLeftHongBaoCount()); - vo.setMoney(tljHongBao); - vo.setTagName("浠樻绔嬪噺 楼" + tljHongBao); - vo.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�"); - vo.setTotal(buyGoods.getTotalHongBaoCount()); - goodsJson.put("tljBuyHongBao", vo); - moneyType = 2; - } - - goodsJson.put("moneyType", moneyType); - goodsJson.put("fanliValid", fanliValid); - data.put("goods", goodsJson); - - if (!StringUtil.isNullOrEmpty(noRebateHelpLink)) { - data.put("noRebateHelpLink", noRebateHelpLink); - } else { - data.put("noRebateHelpLink", configService.get(ConfigKeyEnum.noRebateHelpLink.getKey())); - } - - // 鍙栨秷鍒嗕韩娲诲姩 - // 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 TaoBaoGoodsBrief goodsInfo = tb; - ThreadUtil.run(new Runnable() { - public void run() { - // 娣诲姞娴忚璁板綍 - try { - scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - /** - * 鑾峰彇鍥炬枃璇︽儏(1.4.0) - * - * @param acceptData - * @param id - * @param out - */ - @RequestMapping(value = "getgoodsdetailimgs", method = RequestMethod.POST) - public void getgoodsdetailimgs(AcceptData acceptData, String id, PrintWriter out) { - - if (StringUtil.isNullOrEmpty(id)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); - return; - } - - List<String> detailImgs = new ArrayList<>(); - JSONArray detailImgsSize = new JSONArray(); - - List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(Long.parseLong(id)); - - if (imgs != null && imgs.size() > 0) { - - for (ImageInfo imgInfo : imgs) { - detailImgs.add(imgInfo.getPicture()); - } - - for (ImageInfo imgInfo : imgs) { - - if (imgInfo.getWidth() <= 0) { - detailImgsSize.clear(); - break; - } - - JSONObject size = new JSONObject(); - size.put("w", imgInfo.getWidth()); - size.put("h", imgInfo.getHeight()); - detailImgsSize.add(size); - } - - } - - JSONObject data = new JSONObject(); - data.put("detailImgs", detailImgs); - data.put("detailImgsSize", detailImgsSize); - - out.print(JsonUtil.loadTrueResult(data)); - } - - /** - * 鍟嗗搧璇︽儏鎺ㄨ崘1.4.0 - * - * @param acceptData - * @param id - * @param out - */ - @RequestMapping(value = "getgoodsderivation", method = RequestMethod.POST) - public void getRecommendGoods(AcceptData acceptData, long id, PrintWriter out) { - - try { - - List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); - // 鍒濆鍖� - if (goodsList == null) { - goodsList = new ArrayList<TaoBaoGoodsBrief>(); - } - - BigDecimal proportion = manageService.getFanLiRate(); - - List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); - - 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); - - List<Long> ids = new ArrayList<>(); - for (TaoBaoGoodsBrief goods : goodsList) - ids.add(goods.getAuctionId()); - - try { - goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); - } catch (TaoKeApiException e1) { - e1.printStackTrace(); - } catch (TaobaoGoodsDownException e1) { - e1.printStackTrace(); - } - - if (goodsList != null && goodsList.size() > 0) - goodsList.parallelStream().forEach(goods -> { - if (goods != null) { - // 鑾峰彇璇︽儏 - 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>(); - - // 鍙栧伓鏁颁釜鏁版嵁 - if (listExtra.size() % 2 != 0) { - listExtra.remove(listExtra.size() - 1); - } - - if (listQuality.size() % 2 != 0) { - listQuality.remove(listQuality.size() - 1); - } - - JSONObject data = new JSONObject(); - data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); - data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); - out.print(JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JSONObject data = new JSONObject(); - data.put("listQuality", new JSONArray()); - data.put("listGuess", new JSONArray()); - out.print(JsonUtil.loadTrueResult(data)); - } - } - - /** - * 娲诲姩鍒楄〃 - * - * @param acceptData - * @param out - */ - @RequestMapping(value = "getSpecialActivities") - public void getSpecialActivities(AcceptData acceptData, Long uid, PrintWriter out, String callback) { - List<Special> listSpecial = specialService.listByVersion(0, Integer.MAX_VALUE, "special_activities", - acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion())); - - List<Special> list = new ArrayList<Special>(); - if (listSpecial != null) { - list.addAll(listSpecial); - } - - for (int i = 0; i < list.size(); i++) { - Special special = list.get(i); - - JumpDetailV2 jumpDetail = special.getJumpDetail(); - if (jumpDetail != null) { - jumpDetail.setNeedLogin(special.isJumpLogin()); - special.setJumpDetail(jumpDetail); - } - - String name = special.getName(); - if (StringUtil.isNullOrEmpty(name)) { - continue; - } - } - - JSONObject root = new JSONObject(); - root.put("special", JsonUtil.getApiCommonGson().toJson(list)); - if (StringUtil.isNullOrEmpty(callback)) - out.print(JsonUtil.loadTrueResult(root)); - else - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(root)); - } -} +package com.yeshi.fanli.controller.client.v1; + +import java.io.PrintWriter; +import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +import com.yeshi.fanli.entity.SystemPIDInfo; +import com.yeshi.fanli.entity.config.SystemConfigKeyEnum; +import com.yeshi.fanli.service.manger.PIDManager; +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; +import org.yeshi.utils.taobao.TbImgUtil; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.homemodule.Special; +import com.yeshi.fanli.entity.bus.homemodule.SuperSpecial; +import com.yeshi.fanli.entity.bus.lable.QualityFactory; +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.RecommendSpecial; +import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner; +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.UserMoneyExtra; +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.BusinessSystem; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; +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.TLJBuyGoods; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; +import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; +import com.yeshi.common.entity.taobao.TaoBaoShop; +import com.yeshi.common.entity.taobao.TaoBaoShopInfo; +import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; +import com.yeshi.common.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.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.goods.CollectionGoodsV2Service; +import com.yeshi.fanli.service.inter.goods.CommonGoodsService; +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.SuperRecommendSpecialService; +import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService; +import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; +import com.yeshi.fanli.service.inter.goods.recommend.HomeRecommendGoodsService; +import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService; +import com.yeshi.fanli.service.inter.homemodule.DeviceSexService; +import com.yeshi.fanli.service.inter.homemodule.SpecialService; +import com.yeshi.fanli.service.inter.homemodule.SuperSpecialService; +import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; +import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService; +import com.yeshi.fanli.service.inter.lable.QualityGoodsService; +import com.yeshi.fanli.service.inter.money.UserMoneyExtraService; +import com.yeshi.fanli.service.inter.monitor.MonitorService; +import com.yeshi.fanli.service.inter.order.OrderService; +import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService; +import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; +import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; +import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service; +import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; +import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; +import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService; +import com.yeshi.fanli.service.inter.user.ShamUserService; +import com.yeshi.fanli.service.inter.user.TBPidService; +import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; +import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; +import com.yeshi.fanli.service.inter.user.UserInfoExtraService; +import com.yeshi.fanli.service.inter.user.UserInfoService; +import com.yeshi.fanli.util.Constant; +import org.yeshi.utils.MoneyBigDecimalUtil; +import com.yeshi.fanli.util.RedisKeyEnum; +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 org.yeshi.utils.TimeUtil; +import com.yeshi.fanli.util.VersionUtil; +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.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; +import com.yeshi.fanli.util.taobao.TaoLiJinUtil; +import com.yeshi.goods.facade.entity.taobao.TLJBuyHongBaoVO; +import com.yeshi.fanli.vo.homemodule.BannerVO; +import com.yeshi.fanli.vo.homemodule.SpecialVO; +import com.yeshi.common.vo.ClientTextStyleVO; +import com.yeshi.fanli.vo.tlj.SpreadHongBao; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +@Controller +@RequestMapping("api/v1/user") +public class RecommendController { + + @Resource + private BusinessSystemService businessSystemService; + + @Resource + private SuperRecommendBannerService superRecommendBannerService; + + @Resource + private SuperRecommendSpecialService superRecommendSpecialService; + + @Resource + private OrderService orderService; + + @Resource + private ScanHistoryV2Service scanHistoryV2Service; + + @Resource + private ConfigService configService; + + @Resource + private HongBaoManageService hongBaoManageService; + + @Resource + private UserInfoService userInfoService; + + @Resource + private TaoBaoCouponService taoBaoCouponService; + + @Resource + private JumpDetailService jumpDetailService; + + @Resource + private SystemConfigService systemConfigService; + + @Resource + private CollectionGoodsV2Service collectionGoodsV2Service; + + @Resource + private TaoBaoGoodsBriefService taoBaoGoodsBriefService; + + @Resource + private RedisManager redisManager; + + @Resource + private TBPidService tbPidService; + + @Resource + private SystemClientParamsService systemClientParamsService; + + @Resource + private HongBaoManageService manageService; + + @Resource + private TaoBaoUnionConfigService taoBaoUnionConfigService; + + @Resource + private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; + + @Resource + private QualityGoodsService qualityGoodsService; + + @Resource + private SuperSpecialService superSpecialService; + + @Resource + private SuperRecommendBannerV2Service superRecommendBannerV2Service; + + @Resource + private ShamUserService shamUserService; + + @Resource + private SpecialService specialService; + + @Resource + private SwiperPictureService swiperPictureService; + + @Resource + private MonitorService monitorService; + + @Resource + private CommonGoodsService commonGoodsService; + + @Resource + private UserGoodsStorageService userGoodsStorageService; + + @Resource + private JumpDetailV2Service jumpDetailV2Service; + + @Resource + private UserCustomSettingsService userCustomSettingsService; + + @Resource + private ShareGoodsActivityOrderService shareGoodsActivityOrderService; + + @Resource + private UserInfoExtraService userInfoExtraService; + + @Resource + private QualityFlashSaleService qualityFlashSaleService; + + @Resource + private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; + + @Resource + private TaoBaoShopService taoBaoShopService; + + @Resource + private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; + + @Resource + private UserMoneyExtraService userMoneyExtraService; + + @Resource + private UserTaoLiJinOriginService userTaoLiJinOriginService; + + @Resource + private ConfigTaoLiJinService configTaoLiJinService; + + @Resource + private DeviceSexService deviceSexService; + + @Resource + private UserTaoLiJinRecordService userTaoLiJinRecordService; + + @Resource + private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService; + + @Resource + private HomeRecommendGoodsService homeRecommendGoodsService; + + @Resource + private TLJBuyGoodsService tljBuyGoodsService; + + @Resource + private PIDManager pidManager; + + + @RequestMapping(value = "getHonestList") + public void getHonestList(AcceptData acceptData, PrintWriter out) { + List<Honest> honestList = null; + List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); + if ((Integer.parseInt(acceptData.getVersion()) >= 20 && "android".equalsIgnoreCase(acceptData.getPlatform())) + || ("ios".equalsIgnoreCase(acceptData.getPlatform()) + && Integer.parseInt(acceptData.getVersion()) >= 32))// Android + // 澶т簬20鐨勭増鏈拰ios澶т簬31鐨勭増鏈繑鍥炴柊鐨勫唴瀹� + { + honestList = new ArrayList<>(); + JumpDetail detail = new JumpDetail(); + detail.setActivity(String.format("%s.ui.invite.ShareBrowserActivity", + systemConfigService.getValueCache(SystemConfigKeyEnum.androidBaseActivityName,acceptData.getSystem()))); + detail.setName("缃戦〉"); + detail.setController("ShonpingShareViewController"); + + Honest honest = new Honest(); + honest.setName("9.9鍖呴偖"); + honest.setJumpDetail(detail); + JSONObject params = new JSONObject(); + params.put("url", "http://cdn.apph5.yeshitv.com/special/jingXuanN_9.html?type=9_9"); + honest.setParams(params.toString()); + honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/special/9k9.jpg"); + honest.setType(1); /* 1:9鍧�9 2:19鍧�9 3锛氱壒浠峰ソ璐� 4锛氬垎浜湁绀� */ + honestList.add(honest); + + honest = new Honest(); + honest.setName("浠婃棩鏂板搧"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", "http://cdn.apph5.yeshitv.com/special/todayNew.html"); + honest.setParams(params.toString()); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/special/%E4%BB%8A%E6%97%A5%E6%96%B0%E5%93%81.jpg"); + honest.setType(1); + honestList.add(honest); + + honest = new Honest(); + honest.setName("澶ч鍒�"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", "http://cdn.apph5.yeshitv.com/special/daEQuan.html"); + honest.setParams(params.toString()); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/special/%E5%A4%A7%E9%A2%9D%E5%88%B8.jpg"); + honest.setType(1); + honestList.add(honest); + + honest = new Honest(); + honest.setName("瓒呴珮杩�"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); + honest.setParams(params.toString()); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); + honest.setType(1); + honestList.add(honest); + + if (Constant.IS_TEST) { + honest = new Honest(); + honest.setName("瓒呴珮杩�"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); + honest.setParams(params.toString()); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); + honest.setType(1); + honestList.add(honest); + } + + // if (acceptData.getPlatform().equalsIgnoreCase("ios") + // && + // configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) + // { + // honest = new Honest(); + // honest.setName("浠婃棩蹇呮姠"); + // honest.setJumpDetail(detail); + // params = new JSONObject(); + // params.put("url", + // "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); + // honest.setParams(params.toString()); + // honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); + // honest.setType(1); + // honestList.add(honest); + // } else { + // honest = new Honest(); + // honest.setType(4); + // honest.setName("閭�璇锋湁濂�"); + // honest.setJumpDetail(null); + // honest.setPicture( + // "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); + // honestList.add(honest); + // } + } else { + honestList = new ArrayList<>(); + JumpDetail detail = new JumpDetail(); + detail.setActivity( + String.format("%s.ui.BrowserActivity", systemConfigService.getValueCache(SystemConfigKeyEnum.androidBaseActivityName,acceptData.getSystem()))); + detail.setName("缃戦〉"); + // GoodsDetailController + detail.setController("BrowserController"); + + Honest honest = new Honest(); + honest.setName("9鍧�9"); + honest.setJumpDetail(detail); + JSONObject params = new JSONObject(); + params.put("url", "https://temai.m.taobao.com/9k9?pid=" + configList.get(0).getDefaultPid()); + honest.setParams(params.toString()); + honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/9.9.png"); + honest.setType(1); /* 1:9鍧�9 2:19鍧�9 3锛氱壒浠峰ソ璐� 4锛氬垎浜湁绀� */ + honestList.add(honest); + + honest = new Honest(); + honest.setName("娣樺疂鐗瑰崠"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", "https://temai.m.taobao.com/index.htm?pid=" + configList.get(0).getDefaultPid()); + honest.setParams(params.toString()); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/%E7%89%B9%E4%BB%B7%E5%A5%BD%E8%B4%A7.png"); + honest.setType(1); + honestList.add(honest); + + honest = new Honest(); + honest.setName("鏃呮父鍑鸿"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", + "https://s.click.taobao.com/t?e=m%3D2%26s%3DBYnJkWG4TG0cQipKwQzePCperVdZeJviEViQ0P1Vf2kguMN8XjClAu02u1KR7qygWNI3LssOJ1ZWrun95JZUdbCdKVyILC1Y4MhN4biK4jW7lfuQJIvfPIK88P%2FKzi0kxxWvg6Zgs%2BufKdnhu%2B44hB9qAVPM25K0cj5d26O5JTnBV7GfGbfBR06AKI8EMgZwgGJ6r9DajuEo%2Bq0qHgj4%2Fr%2BOY9SrDkfyH5S%2BAXadU8u31WUvb1IPCiGFCzYOOqAQ"); + honest.setParams(params.toString()); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/%E6%97%85%E6%B8%B8%E5%87%BA%E8%A1%8C.png"); + honest.setType(1); + honestList.add(honest); + + if (acceptData.getPlatform().equalsIgnoreCase("ios") + && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { + honest = new Honest(); + honest.setName("浠婃棩蹇呮姠"); + honest.setJumpDetail(detail); + params = new JSONObject(); + params.put("url", + "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); + honest.setParams(params.toString()); + honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); + honest.setType(1); + honestList.add(honest); + } else { + honest = new Honest(); + honest.setType(4); + honest.setName("閭�璇锋湁濂�"); + honest.setJumpDetail(null); + honest.setPicture( + "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); + honestList.add(honest); + } + + } + String result = JsonUtil.loadTrueResult(honestList); + out.print(result); + return; + } + + @RequestMapping(value = "getrecommendspecial") + public void getRecommendSpecial(AcceptData acceptData, PrintWriter out) { + + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + String version = acceptData.getVersion(); + JumpDetail jumpDetail = null; + 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) { + + recommendSpecialList = new ArrayList<RecommendSpecial>(); + + for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) { + 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(); + data.put("data", gson.toJson(recommendSpecialList)); + String json = JsonUtil.loadTrueResult(data); + out.print(json); + } + + // 鐚滀綘鍠滄 + @RequestMapping(value = "guessLike", method = RequestMethod.POST) + public void guessLike(AcceptData acceptData, PrintWriter out) { + + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + List<TaoBaoGoodsBrief> taoBaoGoodsBriefs1 = taoBaoCouponService.getTaoBaoCouponList(2); + List<TaoBaoGoodsBrief> taoBaoGoodsBriefs2 = new ArrayList<>(); + taoBaoGoodsBriefs2.addAll(taoBaoGoodsBriefs1); + + List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = new ArrayList<>(); + for (int i = 0; i < taoBaoGoodsBriefs2.size(); i++) { + if (taoBaoGoodsBriefs2.size() > 0 && taoBaoGoodsBriefs.size() < 6) { + int pos = (int) (Math.random() * taoBaoGoodsBriefs2.size()); + taoBaoGoodsBriefs.add(taoBaoGoodsBriefs2.get(pos)); + taoBaoGoodsBriefs2.remove(pos); + i--; + } + } + + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + JSONArray array = new JSONArray(); + TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); + + for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { + taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); + array.add(gson.toJson(taoBaoGoodsBriefExtra)); + } + JSONObject data = new JSONObject(); + data.put("goods", array); + data.put("count", array.size()); + out.print(JsonUtil.loadTrueResult(data)); + } + + @RequestMapping(value = "getrecommendbanner") + public void getRecommendBanner(AcceptData acceptData, PrintWriter out) { + + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + JSONObject json = new JSONObject(); + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + List<SuperRecommendBanner> superRecommendBanners = superRecommendBannerService + .getSuperRecommendBannersBySystem(system); + List<RecommendBanner> list = null; + for (SuperRecommendBanner superRecommendBanner : superRecommendBanners) { + if (list == null) { + list = new ArrayList<RecommendBanner>(); + } + RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner(); + // 娣樼壒浠锋殏鏃朵慨鏀� + if (system.getId() == 7) { + recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity() + .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial")); + } + + list.add(recommendBanner); + } + + // 娴嬭瘯 + // 娣诲姞璺宠浆鍟嗗搧璇︽儏 + // RecommendBanner banner = new RecommendBanner(); + // banner.setId(1); + // JumpDetail jumpDetail = new JumpDetail(); + // jumpDetail.setActivity("com.yeshi.ec.rebate.myapplication.ui.recommend.GoodsBrowserActivity"); + // jumpDetail.setController("GoodsDetailController"); + // jumpDetail.setName("鍟嗗搧璇︽儏"); + // + // banner.setJumpDetail(jumpDetail); + // banner.setName("璇︽儏"); + // banner.setOrderby(1); + // JSONObject param = new JSONObject(); + // param.put("id", "568650986077"); + // banner.setParams(param.toString()); + // banner.setPicture( + // "https://gd3.alicdn.com/imgextra/i2/266969832/TB2iiKjoAyWBuNjy0FpXXassXXa_!!266969832.jpg_400x400.jpg_.webp"); + // list.add(banner); + + if (list == null) { + json.put("code", "1"); + json.put("msg", "鏆傛棤鏁版嵁"); + out.print(json); + java.lang.System.out.println("json-" + json); + return; + } + json.put("code", 0); + JSONObject data = new JSONObject(); + data.put("count", list.size()); + Gson gson = new Gson(); + data.put("data", gson.toJson(list)); + json.put("data", data); + out.print(json); + return; + } + + // 鑾峰彇鍟嗗搧璇︽儏 + @RequestMapping(value = "getgoodsdetail", method = RequestMethod.POST) + public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, PrintWriter out) { + long begin = java.lang.System.currentTimeMillis(); + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + // 鑾峰彇浼氬憳鎺ㄥ箍浣嶆垨鑰呴粯璁ゆ帹骞夸綅 + + TaoBaoGoodsBrief simpleGoods = null; + try { + simpleGoods = redisManager.getTaoBaoGoodsBrief(id); + } catch (NumberFormatException e2) { + e2.printStackTrace(); + } catch (TaobaoGoodsDownException e2) { + e2.printStackTrace(); + } + + if (simpleGoods == null) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�")); + return; + } + + // 鑾峰彇娣樺鍙傛暟 + ClientTBPid clientTBPid = null; + if (TaoBaoUtil.isSpecialGoods(simpleGoods.getMaterialLibType())) { + String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli); + clientTBPid = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, + pid.split("_")[2], pid.split("_")[3]); + } else { + if (acceptData.getPlatform().equalsIgnoreCase("android")) { + clientTBPid = tbPidService.getAndroidDefault(); + } else { + clientTBPid = tbPidService.getIOSDefault(); + } + } + + TaoBaoGoodsBrief tb = null; + try { + TaoKeAppInfo app = new TaoKeAppInfo(); + TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(clientTBPid.getSiteId()); + app.setAdzoneId(clientTBPid.getAdZoneId()); + app.setAppKey(clientTBPid.getAppKey()); + app.setAppSecret(config.getAppSecret()); + app.setPid(clientTBPid.getPid()); + tb = TaoKeApiUtil.searchGoodsDetail(id, app); + } catch (NumberFormatException e1) { + e1.printStackTrace(); + } catch (TaobaoGoodsDownException e1) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�")); + return; + } + + if (tb != null) { + // tb.setAuctionUrl(null); + tb.setId(null); + int type = 0; + if ("android".equalsIgnoreCase(acceptData.getPlatform())) + type = PidUser.TYPE_FANLI_ANDROID; + else + type = PidUser.TYPE_FANLI_IOS; + + List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(type); + + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + JSONObject data = new JSONObject(); + TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, configList.get(0), acceptData.getSystem()); + if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) + taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink()); + taoBaoGoodsBriefExtra.setAuctionUrl(tb.getAuctionUrl()); + if (uid != null && !"".equals(uid.trim())) { + CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), + id, Constant.SOURCE_TYPE_TAOBAO); + data.put("collection", collectionGoods != null ? true : false); + } + + data.put("tbPidInfo", clientTBPid); + + JSONObject taobaoJson = JSONObject.fromObject(gson.toJson(taoBaoGoodsBriefExtra)); + if (taoBaoGoodsBriefExtra.getImgList() != null) + taoBaoGoodsBriefExtra.getImgList().add(0, taoBaoGoodsBriefExtra.getPictUrl()); + taobaoJson.put("imgList", taoBaoGoodsBriefExtra.getImgList()); + taobaoJson.put("saleCount", taoBaoGoodsBriefExtra.getSalesCount());// 閿�閲忥紙鍜宻alesCount涓�鑷达紝姝ゅ澶勭悊鍏煎锛� + if (taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) + taobaoJson.put("coupon", true); + else + taobaoJson.put("coupon", false); + + // taoBaoGoodsBriefExtra.setAuctionUrl(null); + data.put("taobao", taobaoJson); + String info = configService.getValue(ConfigKeyEnum.detailPrompt.getKey(), acceptData.getSystem()); + data.put("info", info); + String onlyInfo = configService.getValue(ConfigKeyEnum.onlyInfo.getKey(), acceptData.getSystem()); + data.put("only", onlyInfo); + data.put("helpUrl", configService.getValue(ConfigKeyEnum.oldGoodsDetailHelpUrl.getKey(), acceptData.getSystem())); + + int showType = taoBaoGoodsBriefExtra.getShowType(); + String price = ""; + if (showType == 1 || showType == 3) { + price = taoBaoGoodsBriefExtra.getQuanPrice() + ""; + } else { + price = taoBaoGoodsBriefExtra.getZkPrice() + ""; + } + String appName = systemConfigService.getValueCache(SystemConfigKeyEnum.appName, acceptData.getSystem()); + data.put("sharePrice", "楼" + price + "鍏� 閫�" + appName + "绾㈠寘楼" + + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "鍏� "); + data.put("shareTitle", taoBaoGoodsBriefExtra.getTitle()); + data.put("shareContent", "楼" + price + "鍏�"); + data.put("shareImg", taoBaoGoodsBriefExtra.getPictUrl()); + String html = configService.getValue(ConfigKeyEnum.downAPP.getKey(), acceptData.getSystem()); + data.put("downAPP", html); + String shareSinaContent = configService.getValue("shareSinaContent", acceptData.getSystem()); + data.put("shareSina", + "楼" + price + "鍏� 閫�" + appName + "绾㈠寘楼" + + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "鍏� " + + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent); + + data.put("sharemoney", "鍒嗕韩濂栭噾 楼" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem()) + "鍏�"); + + data.put("shareHongBao", "楼" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem())); + + out.print(JsonUtil.loadTrueResult(data)); + final TaoBaoGoodsBrief tbb = tb; + ThreadUtil.run(new Runnable() { + public void run() { + // 娣诲姞娴忚璁板綍 + try { + scanHistoryV2Service.addScanHistory(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), + acceptData.getDevice(), tbb); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + } else { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧宸蹭笅鏋�")); + } + long end = java.lang.System.currentTimeMillis(); + java.lang.System.out.println("鑰楁椂:" + (end - begin)); + return; + } + + // 鏂扮増鍟嗗搧鍥炬枃璇︽儏 + @RequestMapping(value = "getnewgoodsdetail", method = RequestMethod.POST) + public void getNewGoodsDetail(AcceptData acceptData, String id, String uid, HttpServletRequest request, + PrintWriter out) { + if ("0".equalsIgnoreCase(uid)) + uid = ""; + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + JSONObject data = new JSONObject(); + data.put("invalid", false); + // IOS鏄惁姝e湪涓婄嚎 + if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { + data.put("iosOnling", configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())); + } + + long startTime = java.lang.System.currentTimeMillis(); + + // 鑾峰彇娣樺鍙傛暟 + ClientTBPid clientTBPid = null; + // 鐢ㄦ埛宸茬粡鐧诲綍 + + if (acceptData.getPlatform().equalsIgnoreCase("android")) + clientTBPid = tbPidService.getAndroidDefault(); + else + clientTBPid = tbPidService.getIOSDefault(); + + LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime)); + + // 鏄惁鍦ㄦ湇鍔$杩涜杞摼 + boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); + final String clientPid = clientTBPid.getPid(); + List<String> taskList = new ArrayList<>(); + taskList.add("goods"); + taskList.add("imgs"); + + List<String> detailImgs = new ArrayList<>(); + JSONArray detailImgsSize = new JSONArray(); + + final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + taskList.stream().parallel().forEach(task -> { + if (task.equalsIgnoreCase("goods")) {// 鑾峰彇鍟嗗搧璇︽儏 + // TaoBaoGoodsBrief tb = null; + JSONObject ticket = new JSONObject(); + TaoBaoGoodsBrief goods = null; + if (convertInServer) { + 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(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) { + try { + monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "鍟嗗搧涓嬫灦")); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } else { + try { + goods = redisManager.getTaoBaoGoodsBrief(id); + } catch (TaobaoGoodsDownException e) { + try { + monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "鍟嗗搧涓嬫灦")); + } catch (Exception e1) { + e1.printStackTrace(); + } + // 鍟嗗搧涓嬫灦 + ThreadUtil.run(new Runnable() { + public void run() { + taoBaoGoodsUpdateService.deleteTaoBaoGoods(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 if (task.equalsIgnoreCase("imgs")) {// 鑾峰彇鍥炬枃璇︽儏 + List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(id, acceptData.getSystem()); + if (imgs != null && imgs.size() > 0) { + detailImgs.clear(); + detailImgsSize.clear(); + for (ImageInfo imgInfo : imgs) { + detailImgs.add(imgInfo.getPicture()); + } + + for (ImageInfo imgInfo : imgs) { + if (imgInfo.getWidth() <= 0) { + detailImgsSize.clear(); + break; + } else { + JSONObject size = new JSONObject(); + size.put("w", imgInfo.getWidth()); + size.put("h", imgInfo.getHeight()); + detailImgsSize.add(size); + } + } + + } + } + }); + + TaoBaoGoodsBrief tb = null; + if (goodsList.size() > 0) + tb = goodsList.get(0); + + if (tb == null) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�")); + return; + } + + // 鑾峰彇PID + String pid = ""; + + JSONObject goods = new JSONObject(); + // + if (tb.getImgList() == null) + tb.setImgList(new ArrayList<>()); + tb.getImgList().add(0, tb.getPictUrl()); + + List<String> finalImgList = new ArrayList<>(); + for (String img : tb.getImgList()) { + // img=TbImgUtil.getTBSizeImgWebp(img, 600); + finalImgList.add(img); + } + + 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()); + + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion, false); + goods.put("hongBao", hongBao); + + // 30澶╅攢閲� + goods.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); + + // 鑾峰彇璇︾粏鐨勫浘鏂囦俊鎭� + goods.put("detailImgs", detailImgs); + goods.put("detailImgsSize", detailImgsSize); + + String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); + + // 鍒嗕韩璧� + data.put("shareMoney", "楼" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem())); + + // 鍒ゆ柇鏀惰棌 + if (!StringUtil.isNullOrEmpty(uid)) { + CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), + id, Constant.SOURCE_TYPE_TAOBAO); + data.put("collected", collectionGoods != null ? true : false); + } else + data.put("collected", false); + + pid = clientTBPid.getPid(); + + LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); + + SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, + "goods_detail_jump_taobao"); + // 娴嬭瘯 + if ("1".equalsIgnoreCase((params.getValue() + "").trim())) + data.put("native", true); + else + data.put("native", false); + + goods.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); + // 鑾峰彇鍒镐俊鎭� + if (!StringUtil.isNullOrEmpty(tb.getCouponInfo())) { + BigDecimal quanPrice = TaoBaoUtil.getCouponPrice(tb); + JSONObject couponInfo = new JSONObject(); + couponInfo.put("couponPrice", quanPrice.toString()); + // 鏈嶅姟绔浆閾� + 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); + } + + // 娓│ + // clientTBPid.setAdZoneId("12"); + // clientTBPid.setPid("mm_123123_123123_123213"); + + data.put("tbPidInfo", clientTBPid); + + if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 鏈夊埜锛岃烦杞埜閾炬帴 + jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), + "" + tb.getAuctionId()); + } + + // 璁剧疆璺宠浆閾炬帴 + if (convertInServer) { + if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) + jumpUrl = tb.getCouponLink(); + else + jumpUrl = tb.getAuctionUrl(); + } + + goods.put("jumpUrl", jumpUrl); + goods.put("shopInfo", redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId())); + data.put("goods", goods); + + String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); + data.put("shareUrl", shareUrl); + + out.print(JsonUtil.loadTrueResult(data)); + + final String tempUid = uid; + final TaoBaoGoodsBrief goodsInfo = tb; + ThreadUtil.run(new Runnable() { + public void run() { + // 娣诲姞娴忚璁板綍 + try { + scanHistoryV2Service.addScanHistory( + StringUtil.isNullOrEmpty(tempUid) ? null : Long.parseLong(tempUid), acceptData.getDevice(), + goodsInfo); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (CommonGoodsException e) { + e.printStackTrace(); + } catch (ScanHistoryException e) { + e.printStackTrace(); + } + } + }); + } + + /** + * 娣樺疂杞摼 + * + * @param acceptData + * @param uid + * @param id + * @param out + */ + @RequestMapping(value = "gettaobaolink") + public void getTaobaoLink(AcceptData acceptData, String uid, String id, PrintWriter out) { + ClientTBPid clientTBPid = null; + // 鐢ㄦ埛宸茬粡鐧诲綍 + if (!StringUtil.isNullOrEmpty(uid)) { + if (acceptData.getPlatform().equalsIgnoreCase("android")) { + clientTBPid = tbPidService.getAndroidDefault(); + } else { + clientTBPid = tbPidService.getIOSDefault(); + } + + } else { + if (acceptData.getPlatform().equalsIgnoreCase("android")) + clientTBPid = tbPidService.getAndroidDefault(); + else + clientTBPid = tbPidService.getIOSDefault(); + } + + JSONObject data = new JSONObject(); + + // 鏄惁鍦ㄦ湇鍔$杩涜杞摼 + boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); + TaoBaoGoodsBrief tb = null; + JSONObject ticket = new JSONObject(); + if (convertInServer) { + String appId = clientTBPid.getPid().split("_")[2]; + TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); + TaoKeAppInfo app = new TaoKeAppInfo(); + app.setAdzoneId(clientTBPid.getPid().split("_")[3]); + app.setAppKey(config.getAppKey()); + app.setAppSecret(config.getAppSecret()); + app.setPid(clientTBPid.getPid()); + try { + tb = TaoKeApiUtil.searchGoodsDetail(id, app); + if (tb != null) { + ticket.put("clickUrl", tb.getAuctionUrl()); + ticket.put("couponUrl", tb.getCouponLink()); + data.put("ticket", ticket); + } + + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + } + + data.put("pidInfo", clientTBPid); + out.print(JsonUtil.loadTrueResult(data)); + } + + // 鏍规嵁鍟嗗搧鑾峰彇鎺ㄨ崘 + @RequestMapping(value = "getgoodsrecommend", method = RequestMethod.POST) + public void getGoodsRecommend(final AcceptData acceptData, String id, PrintWriter out) { + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 6); + if (goodsList == null) + goodsList = new ArrayList<>(); + + if (goodsList == null || goodsList.size() == 0)// 閲嶆柊鍋氭帹鑽� + { + TaoBaoGoodsBrief goods = null; + try { + goods = redisManager.getTaoBaoGoodsBrief(id); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + if (goods == null)// 鍟嗗搧涓嬬嚎 + { + // 浠庢垜浠殑鍟嗗搧搴撴悳绱� + CommonGoods cgoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(id, + CommonGoods.GOODS_TYPE_TB); + + if (cgoods != null) {// 鍟嗗搧鏈夋湰鍦扮紦瀛� + // 鎸夊悕瀛楁悳绱㈠晢鍝� + SearchFilter sf = new SearchFilter(); + sf.setKey(cgoods.getTitle().substring(0, cgoods.getTitle().length() / 2)); + TaoBaoSearchResult result = TaoBaoUtil.search(sf, null, null); + if (result != null && result.getTaoBaoGoodsBriefs() != null + && result.getTaoBaoGoodsBriefs().size() > 0) + for (TaoBaoGoodsBrief gds : result.getTaoBaoGoodsBriefs()) { + if (goodsList.size() < 6) + goodsList.add(gds); + } + } + } + } + + final List<TaoBaoGoodsBrief> recommendGoodsList = new ArrayList<>(); + + goodsList.parallelStream().forEach(goods -> { + // 鑾峰彇璇︽儏 + TaoBaoGoodsBrief taoBaoGoodsBrief = null; + try { + taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(goods.getAuctionId()); + } catch (Exception e) { + e.printStackTrace(); + } + if (taoBaoGoodsBrief != null) + recommendGoodsList.add(taoBaoGoodsBrief); + }); + + // 鍙栧伓鏁颁釜鏁版嵁 + if (recommendGoodsList.size() % 2 != 0) { + recommendGoodsList.remove(recommendGoodsList.size() - 1); + } + + List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); + + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + if (recommendGoodsList != null) + for (TaoBaoGoodsBrief taoBaoGoodsBrief : recommendGoodsList) { + if (taoBaoGoodsBrief == null) + continue; + + re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); + } + out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(re))); + } + + // 涓婁紶璁㈠崟 + @RequestMapping(value = "reportorder", method = RequestMethod.POST) + public void reportOrder(AcceptData acceptData, String order, String auctionUrl, String money, long uid, + PrintWriter out, HttpServletRequest request) { + LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "],涓婁紶鐨勬窐瀹濊鍗旾D锛�" + order + ",鐢ㄦ埛ID:" + uid + ",璁㈠崟閲戦:" + + money + ",鍟嗗搧閾炬帴:" + auctionUrl); + if (StringUtil.isNullOrEmpty(order)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爋rder")); + LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 涓婁紶鐨勮鍗曚负绌猴紒涓婁紶璁㈠崟澶辫触锛�"); + return; + } + + UserInfo user = userInfoService.getUserById(uid); + if (user == null) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爑id")); + LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 鐢ㄦ埛涓嶅瓨鍦�!涓婁紶璁㈠崟澶辫触锛�"); + return; + } + order = order.replace("[", "").replace("]", ""); + String[] orderArr = order.split(","); + for (String tbOrder : orderArr) { + Order or = new Order(); + or.setBeizhu("鎺ュ彛娣诲姞"); + or.setCreatetime(java.lang.System.currentTimeMillis()); + or.setDrawbackTime(0L); + or.setOrderId(tbOrder.trim()); + or.setOrderType(1); + or.setState(1); + or.setUserInfo(new UserInfo(uid)); + or.setVersion(2); + boolean b; + try { + b = orderService.addOrder(or); + } catch (Exception e) { + e.printStackTrace(); + b = false; + } + if (b) { + LogHelper.userOrder("鐢ㄦ埛ID" + uid + "涓嬪崟鎴愬姛锛佽鍗旾D[" + or.getOrderId() + "]"); + } else { + LogHelper.userOrder("鐢ㄦ埛ID" + uid + "涓嬪崟澶辫触锛佽鍗旾D[" + or.getOrderId() + "]"); + } + } + out.print(JsonUtil.loadTrueResult("涓婃姤鎴愬姛")); + return; + } + + // 鑾峰彇娴忚璁板綍 + @RequestMapping(value = "getscanhistory", method = RequestMethod.POST) + public void getScanHistory(AcceptData acceptData, String uid, int page, PrintWriter out) { + + if (page < 0) { + out.print(JsonUtil.loadFalseResult(1, "page涓嶅皬浜�0")); + return; + } + page = page + 1; + BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + if (sys == null) { + out.print(JsonUtil.loadFalseResult(1, "涓嶅瓨鍦ㄨ绯荤粺")); + return; + } + try { + + List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid( + StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20, + Constant.SOURCE_TYPE_TAOBAO, true); + long count = scanHistoryV2Service.getCountByDeviceOrUid( + StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), + Constant.SOURCE_TYPE_TAOBAO, true); + + JSONObject data = new JSONObject(); + data.put("count", count); + JSONArray array = new JSONArray(); + + GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); + gsonBuilder.excludeFieldsWithoutExposeAnnotation(); + gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { + @Override + public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { + if (value == null) { + return new JsonPrimitive(""); + } else { + return new JsonPrimitive(value.getTime() + ""); + } + } + }); + + Gson gson = gsonBuilder.create(); + + if (list != null) { + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + for (ScanHistoryV2 sh : list) { + TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods()); + goods.setId(sh.getId()); + TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), ""); + extra.setCreatetime(sh.getCreateTime()); + array.add(gson.toJson(extra)); + } + } + data.put("data", array); + out.print(JsonUtil.loadTrueResult(data)); + return; + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + JSONObject data = new JSONObject(); + data.put("data", new JSONArray()); + data.put("count", 0); + out.print(JsonUtil.loadTrueResult(data)); + } + + } + + @RequestMapping(value = "deletescanhistory", method = RequestMethod.POST) + public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) { + BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + if (sys == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + if ("0".equals(type)) { + String[] idStr = ids.split(","); + for (String auctionIdStr : idStr) { + scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid( + StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), + auctionIdStr); + } + } else { + scanHistoryV2Service.deleteByDeviceOrUid(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), + acceptData.getDevice()); + } + out.print(JsonUtil.loadTrueResult("")); + + return; + } + + // 鏍规嵁鍘熼摼鎺ヨ幏鍙栨帹骞块摼鎺� + + @RequestMapping(value = "getTaoBaoLink", method = RequestMethod.POST) + public void getTaoBaoLink(AcceptData acceptData, String url, PrintWriter out) { + if (!url.contains("//detail.m.tmall.com/item.htm") && !url.contains("h5.m.taobao.com/awp/core/detail.htm") + && !url.contains("item.taobao.com/item.htm")) { + out.print(JsonUtil.loadFalseResult(1, "閾炬帴閿欒")); + return; + } + + String params = url.split("\\?")[1]; + String[] ps = params.split("&"); + String id = ""; + for (String st : ps) { + if (st.contains("id=")) { + id = st.replace("id=", ""); + break; + } + } + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadFalseResult(1, "鍟嗗搧ID閿欒")); + return; + } + + /** + * 闃叉璇锋眰棰戠巼杩囬珮 + * + */ + // if (Constant.IS_OUTNET) { + String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaolinkParse, acceptData.getDevice() + "-" + id); + String value = redisManager.getCommonString(key); + if (!StringUtil.isNullOrEmpty(value)) { + out.print(JsonUtil.loadFalseResult(11, "璇锋眰棰戠巼闄愬埗")); + return; + } + redisManager.cacheCommonString(key, "1", 5);// 5s闂撮殧 + // } + TaoBaoGoodsBrief goods = null; + try { + goods = redisManager.getTaoBaoGoodsBrief(id); + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + if (goods == null) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧")); + return; + } + + JSONObject data = new JSONObject(); + data.put("id", id); + out.print(JsonUtil.loadTrueResult(data)); + return; + } + + /** + * 鏍规嵁璁惧淇℃伅鑾峰彇鐚滀綘鍠滄鐨勫唴瀹� + * + * @param acceptData + * @param imei -Android鐨処MEI淇℃伅 + * @param idfa -IOS鐨刬dfa骞垮憡鏍囪瘑淇℃伅 + */ + @RequestMapping(value = "guessLikeByDevice") + public void guessUserLikeByDevice(AcceptData acceptData, String imei, String idfa, int page, + HttpServletRequest request, PrintWriter out) { + int pageSize = Constant.PAGE_SIZE; + JSONArray array = new JSONArray(); + + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); + if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) { + List<TaoBaoGoodsBrief> goodsList = homeRecommendGoodsService.listGoodsByPage(null, acceptData.getDevice(), + imei, idfa, page); + + if (page < 4) {// 鍓嶄笁椤靛姞鍏ユ洿鏂� + try { + taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); + } catch (Exception e) { + } + } + + BigDecimal rate = hongBaoManageService.getFanLiRate(acceptData.getSystem()); + for (TaoBaoGoodsBrief goods : goodsList) { + TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null); + if (page < 3) + extra.setRecommend(true); + + try { + array.add(gson.toJson(extra)); + } catch (Exception e) { + e.printStackTrace(); + System.out.println(new Gson().toJson(goods)); + } + } + + if (page == 1) { + List<TLJBuyGoods> list = null; + try { + list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); + } catch (Exception e) { + } + if (list != null && list.size() > 0) + for (int i = list.size() - 1; i >= 0; i--) { + TLJBuyGoods goods = list.get(i); + TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods.getGoods(), + TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE + "", null); + String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(goods.getGoods(), + TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE, false); + TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); + vo.setLeft(goods.getLeftHongBaoCount()); + vo.setMoney(hongBao); + vo.setTagName("浠樻绔嬪噺 " + hongBao); + vo.setTip(""); + vo.setTotal(goods.getTotalHongBaoCount()); + extra.setTljBuyHongBao(vo); + extra.setPictureTag(new ClientTextStyleVO("绔嬪噺TOP" + (i + 1), "#E5005C", "#FCE431", null)); + extra.setRecommend(true); + extra.setSpreadMoney(vo.getTagName()); + array.add(0, gson.toJson(extra)); + } + } + + JSONObject data = new JSONObject(); + data.put("data", array); + data.put("count", 1000); + out.print(JsonUtil.loadTrueResult(data)); + return; + } + + // 浠庢帹鑽愭潵 + if (page <= 1) { + array.clear(); + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) { + long startTime = java.lang.System.currentTimeMillis(); + + TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa, ""); + + if (result != null && result.getTaoBaoGoodsBriefs() != null) { + // 绛涢�� + List<TaoBaoGoodsBriefExtra> goodsList = new ArrayList<>(); + + List<TaoBaoGoodsBrief> gList = recommendGoodsDeleteHistoryService + .filterGoods(acceptData.getDevice(), result.getTaoBaoGoodsBriefs()); + + // filter + try { + + gList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(gList); + } catch (Exception e) { + } + + // 璁惧鎺ㄨ崘 + if (gList != null) + for (TaoBaoGoodsBrief goods : gList) { + if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null + && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0 + && goods.getBiz30day() > 1000 + && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { + + TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, + proportion.toString(), ""); + + extra.setRecommend(true); + goodsList.add(extra); + } + } + try { + monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, + (int) (java.lang.System.currentTimeMillis() - startTime), "鎺ㄨ崘鏁伴噺:" + goodsList.size())); + } catch (Exception e) { + e.printStackTrace(); + } + + Collections.shuffle(goodsList); + goodsList = goodsList.size() > 20 ? goodsList.subList(0, 20) : goodsList; + for (TaoBaoGoodsBriefExtra goods : goodsList) { + array.add(gson.toJson(goods)); + } + } else { + try { + monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, + (int) (java.lang.System.currentTimeMillis() - startTime), "鏃犳帹鑽�")); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + JSONArray localArray = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, + proportion.toString()); + array.addAll(localArray); + } else {// 浠庣簿閫夊簱鏉� + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString()); + if (array == null) { + out.print(JsonUtil.loadFalseResult("娌℃湁鏇村浜�")); + return; + } + } + + JSONObject data = new JSONObject(); + data.put("data", array); + data.put("count", 1000); + out.print(JsonUtil.loadTrueResult(data)); + } + + /** + * 鑾峰彇棣栭〉鎺ㄨ崘淇℃伅 + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getRecommendInfo") + public void getRecommendHomeInfo(AcceptData acceptData, PrintWriter out) { + + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + // 棣栭〉Banner + List<RecommendBannerV2> listBanner = superRecommendBannerV2Service + .getSuperRecommendBannerV2sBySystem(system.getId()); + + JSONObject root = new JSONObject(); + root.put("banner", listBanner); + + List<Special> honestList = null; + List<Special> specialList = null; + + Special miaoShaSpecial = new Special(); + + // 棣栭〉鎺ㄨ崘涓撻 + List<SuperSpecial> listSuper = superSpecialService.listBySystemAndCardCache(system.getId(), "index"); + + if (listSuper != null && listSuper.size() > 0) { + + honestList = new ArrayList<Special>(); + + specialList = new ArrayList<Special>(); + + for (int i = 0; i < listSuper.size(); i++) { + + Special special = listSuper.get(i).getSpecial(); + special.setCreatetime(null); + special.setUpdatetime(null); + + if ("闄愭椂绉掓潃".equals(special.getName())) { + miaoShaSpecial = special; + continue; + } + + if (i < 5) { + // 5澶т笓棰� + honestList.add(special); + } else { + // 鍏朵粬涓撻 + specialList.add(special); + } + + } + } + + root.put("honest", honestList); + root.put("special", specialList); + + /* 闄愭椂绉掓潃 - 鏃堕棿澶勭悊 */ + JSONObject msJSON = JSONObject.fromObject(new Gson().toJson(miaoShaSpecial)); + + // 鑾峰彇绉掓潃 + int[] hours = new int[]{0, 9, 12, 14, 16, 20, 22}; + int hour = -1; + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(Long.parseLong(acceptData.getTime())); + int nowHour = calendar.get(Calendar.HOUR_OF_DAY); + for (int i = 0; i < hours.length - 1; i++) { + if (nowHour >= hours[i] && nowHour < hours[i + 1]) { + hour = hours[i + 1]; + break; + } + } + + if (hour < 0) + hour = 24; + long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd"), + "yyyy-MM-dd") + 1000 * 60 * 60 * hour; + msJSON.put("time", time); + + root.put("miaoSha", msJSON); + + out.print(JsonUtil.loadTrueResult(root)); + } + + /** + * 鏂扮増鎺ㄨ崘涓撻绠$悊(1.4.0) + * + * @param acceptData + * @param out + */ + @Deprecated + @RequestMapping(value = "getNewRecommendInfo") + public void getNewRecommendInfo(AcceptData acceptData, Long uid, String specialCard, String swiperCard, + PrintWriter out) { + } + + /** + * 鏂扮増鎺ㄨ崘涓撻绠$悊(1.5.3) + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getRecommendIndex") + public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) { + try { + // 鑾峰彇璁惧瀹氫箟鎬у埆 + int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice(), acceptData.getSystem()); + + // 1銆佷笓棰樻ā鍧� + JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex, acceptData.getSystem()); + + // 2銆侀《閮ㄨ疆鎾浘 + List<BannerVO> topPicList = getSwiperByCard("index_top", acceptData); + if (topPicList == null) { + topPicList = new ArrayList<BannerVO>(); + } + root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList)); + + // 3銆侀個璇锋湁濂� + List<BannerVO> invitePicList = null; + if ("ios".equalsIgnoreCase(acceptData.getPlatform()) + && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { + // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥� + } else { + invitePicList = getSwiperByCard("index_invite", acceptData); + } + + if (invitePicList == null) { + invitePicList = new ArrayList<BannerVO>(); + } + root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList)); + + // 4銆両OS鐨勫簳閮ㄧ綉椤甸摼鎺� + String platform = acceptData.getPlatform(); + if ("ios".equalsIgnoreCase(platform)) { + root.put("htmlLink", configService.getValue(ConfigKeyEnum.indexHtmlLinkIos.getKey(), acceptData.getSystem())); + } + + root.put("spikeGoods", getSpikeGoodsContent(acceptData)); + + 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<BannerVO> getInvitePicList(Long uid, AcceptData acceptData) { + // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥� + if ("ios".equalsIgnoreCase(acceptData.getPlatform()) + && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { + return null; + } + + List<BannerVO> invitePicList = getSwiperByCard("index_invite", acceptData); + + return invitePicList; + } + + public List<BannerVO> getSwiperByCard(String card, AcceptData acceptData) { + List<BannerVO> swiperList = null; + try { + swiperList = swiperPictureService.getByBannerCardAndVersion(card, acceptData.getPlatform(), + Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + e.printStackTrace(); + } + return swiperList; + } + + private JSONObject getSpikeGoodsContent(AcceptData acceptData) { + // 涓嬩竴娆″�掕鏃剁殑鏃堕棿 + 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 = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsHour, acceptData.getPlatform() + "-" + acceptData.getVersion()); + String cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsList, acceptData.getPlatform() + "-" + acceptData.getVersion()); + + 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); + } + } + JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem()); + if (array == null) { + array = new JSONArray(); + + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + 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; + } + JSONObject goods = new JSONObject(); + goods.put("goods", gson + .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null))); + goods.put("jumpDetail", jumpDetail); + JSONObject params = new JSONObject(); + params.put("url", configService.getValue(ConfigKeyEnum.spikeGoodsLink.getKey(), acceptData.getSystem()) + "?id=" + taoBaoGoodsBrief.getAuctionId()); + goods.put("params", params); + + // 1.5.4鍙婁互鍚庤繑鍥� + if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { + array.add(goods); + } else { + array.add(goods.optJSONObject("goods")); + } + } + + // 缂撳瓨鍗婁釜灏忔椂 + redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30); + } + Long endTime = nextTime.getTimeInMillis() - java.lang.System.currentTimeMillis(); + + JSONObject root = new JSONObject(); + root.put("time", nextTime.getTimeInMillis()); + root.put("endTime", endTime > 0 ? endTime : 0); + root.put("listgoods", array); + + JSONObject params = new JSONObject(); + params.put("url", configService.getValue(ConfigKeyEnum.spikeGoodsLink.getKey(), acceptData.getSystem())); + + root.put("params", params); + root.put("jumpDetail", jumpDetail); + + return root; + } + + /** + * 闄愭椂绉掓潃 1.5.3 + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getSpikeGoods") + public void getSpikeGoods(AcceptData acceptData, PrintWriter out) { + JSONObject root = getSpikeGoodsContent(acceptData); + out.print(JsonUtil.loadTrueResult(root)); + } + + /** + * 鍟嗗搧鍩烘湰璇︽儏 (1.4.0) + * + * @param acceptData + * @param id + * @param uid 椤甸潰鏉ユ簮 + * @param out + */ + @RequestMapping(value = "getgoodsinfo", method = RequestMethod.POST) + public void getGoodsInfo(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) { + + if (id == null) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } + + BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), + acceptData.getPackages(), acceptData.getSystem()); + if (system == null) { + out.print(JsonUtil.loadFalseResult(1, "绯荤粺涓嶅瓨鍦�")); + return; + } + + JSONObject data = new JSONObject(); + data.put("invalid", false); + + // IOS鏄惁姝e湪涓婄嚎 + if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { + String version = acceptData.getVersion(); + data.put("iosOnling", configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); + } + + long startTime = java.lang.System.currentTimeMillis(); + + // 鑾峰彇娣樺鍙傛暟 + ClientTBPid clientTBPid = null; + + // 鐢ㄦ埛鏈櫥褰� + if (acceptData.getPlatform().equalsIgnoreCase("android")) { + clientTBPid = tbPidService.getAndroidDefault(); + } else { + clientTBPid = tbPidService.getIOSDefault(); + } + + LogHelper.test("鑾峰彇PID鑰楁椂锛�" + (java.lang.System.currentTimeMillis() - startTime)); + + final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + // 鏄惁鍦ㄦ湇鍔$杩涜杞摼 + boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); + + JSONObject ticket = new JSONObject(); + TaoBaoGoodsBrief goods = null; + + if (!convertInServer) { + try { + goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); + if (goods == null) { + TaoKeAppInfo app = new TaoKeAppInfo(); + 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(id, app); + final TaoBaoGoodsBrief finalGoods = goods; + if (goods != null) { + ThreadUtil.run(new Runnable() { + @Override + public void run() { + taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods); + } + }); + } + } + } catch (TaobaoGoodsDownException e) { + // 鍟嗗搧涓嬫灦 + ThreadUtil.run(new Runnable() { + public void run() { + taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); + } + }); + + } + + } 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(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.specialConvertCouponV2(goods.getAuctionId(), app, null, null); + 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(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) { + tb = goodsList.get(0); + } + + if (tb == null) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�")); + return; + } + + if (tb.getImgList() == null) { + tb.setImgList(new ArrayList<>()); + } + + tb.getImgList().add(0, tb.getPictUrl()); + + List<String> finalImgList = new ArrayList<>(); + for (String img : tb.getImgList()) { + finalImgList.add(TbImgUtil.getTBSizeImg(img, 600)); + } + if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) + finalImgList.add(0, tb.getPictUrlWhite()); + + // 澶ф窐瀹㈠晢鍝佽繃婊� + try { + goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods).getGoods(); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + 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", MoneyBigDecimalUtil.getWithNoZera(tb.getZkPrice()).toString()); + + // 30澶╅攢閲� + goodsJson.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); + goodsJson.put("salesCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); + + // 鍒嗕韩璧� + BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem()); + data.put("shareMoney", "楼" + shareMoney); + // 鍒嗕韩璧氫汉鎻愮ず + List<ShamUser> listShareUser = new ArrayList<ShamUser>(); + if (tb.getBiz30day() >= 1000) { + listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5); + } + + // 鍒ゆ柇鏀惰棌 + if (uid == null) { + data.put("collected", false); + } else { + CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, + Constant.SOURCE_TYPE_TAOBAO); + data.put("collected", collectionGoods != null ? true : false); + } + + // 娴嬭瘯 + SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, + "goods_detail_jump_taobao"); + if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { + data.put("native", true); + } else { + data.put("native", false); + } + + // 鑾峰彇PID + String pid = clientTBPid.getPid(); + LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); + + // 鏄惁鏈夊埜 + goodsJson.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); + + // 棰嗗埜浜哄垪琛� + List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); + + String hongBao = null; + + // 鑾峰彇鍒镐俊鎭� + if (!StringUtil.isNullOrEmpty(tb.getCouponInfo()) && tb.getCouponAmount() != null + && tb.getCouponAmount().compareTo(new BigDecimal(0)) > 0 && tb.getCouponEffectiveStartTime() != null + && tb.getCouponEffectiveEndTime() != null) { + BigDecimal quanPrice = TaoBaoUtil.getCouponPrice(tb); + JSONObject couponInfo = new JSONObject(); + couponInfo.put("couponPrice", MoneyBigDecimalUtil.getWithNoZera(quanPrice).toString()); + + if (from != null && from.equals("miandan")) { + // 鍏嶅崟鍟嗗搧 + hongBao = "楼" + quanPrice.toString(); + } + + String token = ""; + if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) + && VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) { + token = redisManager.getCommonTaoToken(tb.getAuctionId()); + if (StringUtil.isNullOrEmpty(token)) { + token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink()); + redisManager.saveCommonTaoToken(tb.getAuctionId(), token); + } + } + if (!VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) + 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", MoneyBigDecimalUtil.getWithNoZera(tb.getCouponAmount()).toString()); + couponInfo.put("couponTime", "浣跨敤鏈熼檺锛�" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-" + + tb.getCouponEffectiveEndTime().replace("-", ".")); + // 鍒哥殑鍙d护 + + if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) + couponInfo.put("couponToken", ""); + else + 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(acceptData.getSystem()); + if ("taolijin".equalsIgnoreCase(from)) + proportion = manageService.getTLJShareRate(System.currentTimeMillis(), acceptData.getSystem()); + hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion, false); + } + goodsJson.put("hongBao", hongBao); + + List<ClientTextStyleVO> labels = new ArrayList<>(); + goodsJson.put("labels", labels); + + data.put("tbPidInfo", clientTBPid); + + String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); + + if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 鏈夊埜锛岃烦杞埜閾炬帴 + jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), + "" + tb.getAuctionId()); + } + + // 璁剧疆璺宠浆閾炬帴 + if (convertInServer) { + if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) + jumpUrl = tb.getCouponLink(); + else + jumpUrl = tb.getAuctionUrl(); + } + goodsJson.put("jumpUrl", jumpUrl); + + TaoBaoShopInfo tbShopInfo = redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId()); + if (tbShopInfo != null) { + String shopType = tbShopInfo.getShopType(); + if (!StringUtil.isNullOrEmpty(shopType) && shopType.contains("tm.png")) { + tbShopInfo.setUserType("1"); + } else { + tbShopInfo.setUserType("0"); + } + + String shopLink = tbShopInfo.getShopUrl(); + if (StringUtil.isNullOrEmpty(shopLink)) { + tbShopInfo.setShopUrl(TaoBaoUtil.getShopLink(tbShopInfo.getUserId())); + } + } + + // 搴楅摵1.5.4鍙婁互鍚庣増鏈� + if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { + TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); + if (shop != null) { + String shopLink = shop.getShopLink(); + if (StringUtil.isNullOrEmpty(shopLink)) { + shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); + } + goodsJson.put("shopInfo", shop); + } + } else { + goodsJson.put("shopInfo", tbShopInfo); + } + + // 鍒嗕韩璺緞 + String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); + + // 鏄惁鍔犲叆閫夊搧搴擄細 0鏈姞鍏� 1 宸插姞鍏� + boolean storageState = false; + if (uid != null) { + storageState = userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO); + } + + data.put("storageState", storageState); + data.put("shareUrl", shareUrl); + data.put("shareUsers", listShareUser); + data.put("couponUsers", listCouponUser); + data.put("detailWebUrl", "http://apph5.banliapp.com/apppage/goods_img.html?id=" + id); + + String noRebateHelpLink = null; + + // 鍟嗗搧閾炬帴 + String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), + Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + ""); + try { + data.put("h5Url", HttpUtil.getShortLink(h5Url)); + } catch (Exception e) { + data.put("h5Url", h5Url); + } + + // 鏄惁鏈夎繑鍒� + boolean fanliValid = true; + // 璧勯噾绫诲瀷 1-杩� 2-濂� + int moneyType = 1; + + // 鎺ㄥ箍绾㈠寘 + if (from != null && from.equals("taolijin")) { + // 璁$畻鎺ㄥ箍绾㈠寘 + String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); + BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); + + // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1 + if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { + out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧涓嶅瓨鍦�")); + return; + } + + // 鏄惁涓烘柊鐢ㄦ埛 + boolean isNewUser = userInfoExtraService.isNewUser(uid); + if (isNewUser) { + // 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜�� + long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); + if (countRecord > 0) { + isNewUser = false; + } + } + + SpreadHongBao spreadHongBao = new SpreadHongBao(); + if (isNewUser) { + spreadHongBao.setMoney("1"); + } else { + spreadHongBao.setMoney(spreadMoney.toString()); + + moneyType = 2; + fanliValid = false; + ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); + textStyleVO1.setContent("鍒嗕韩"); + textStyleVO1.setColor("#666666"); + ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO(); + textStyleVO2.setContent("璧氬閲�"); + textStyleVO2.setColor("#F14242"); + ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO(); + textStyleVO3.setContent("锛屽ソ鍙�"); + textStyleVO3.setColor("#666666"); + ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO(); + textStyleVO4.setContent("棰嗙孩鍖咃紒"); + textStyleVO4.setColor("#F14242"); + + List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>(); + listText.add(textStyleVO1); + listText.add(textStyleVO2); + listText.add(textStyleVO3); + listText.add(textStyleVO4); + + data.put("listTip", listText); + } + spreadHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�"); + goodsJson.put("spreadHongBao", spreadHongBao); + + // 鐢ㄦ埛鍓╀綑鍙互娣樼ぜ閲戦獙璇� + UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); + if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) { + data.put("userHongbao", new BigDecimal(0).setScale(2).toString()); + } else { + data.put("userHongbao", userMoneyExtra.getTlj().setScale(2).toString()); + } + + noRebateHelpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", null); + + if (Constant.IS_TEST) { + fanliValid = true; + goodsJson.put("shareValid", false); + JSONObject tljNum = new JSONObject(); + tljNum.put("percent", "80"); + tljNum.put("num", "8825"); + goodsJson.put("tljNum", tljNum); + } + + } else if (from != null && from.equals("taolijin_buy")) { + noRebateHelpLink = configService.getValue(ConfigKeyEnum.zigoulijianNofanliHelp.getKey(), acceptData.getSystem()); + // 鏌ヨ鍒嗕韩搴� + TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(goods.getAuctionId(), + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); + if (buyGoods == null) { + out.print(JsonUtil.loadFalseResult(2, "鑷喘绔嬪噺绾㈠寘杩囨湡")); + return; + } + + fanliValid = true; + goodsJson.put("shareValid", false); + String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70), false).toString(); + TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); + vo.setLeft(buyGoods.getLeftHongBaoCount()); + vo.setMoney(tljHongBao); + vo.setTagName("浠樻绔嬪噺 楼" + tljHongBao); + vo.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�"); + vo.setTotal(buyGoods.getTotalHongBaoCount()); + goodsJson.put("tljBuyHongBao", vo); + moneyType = 2; + } + + goodsJson.put("moneyType", moneyType); + goodsJson.put("fanliValid", fanliValid); + data.put("goods", goodsJson); + + if (!StringUtil.isNullOrEmpty(noRebateHelpLink)) { + data.put("noRebateHelpLink", noRebateHelpLink); + } else { + data.put("noRebateHelpLink", configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem())); + } + + // 鍙栨秷鍒嗕韩娲诲姩 + // 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 TaoBaoGoodsBrief goodsInfo = tb; + ThreadUtil.run(new Runnable() { + public void run() { + // 娣诲姞娴忚璁板綍 + try { + scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * 鑾峰彇鍥炬枃璇︽儏(1.4.0) + * + * @param acceptData + * @param id + * @param out + */ + @RequestMapping(value = "getgoodsdetailimgs", method = RequestMethod.POST) + public void getgoodsdetailimgs(AcceptData acceptData, String id, PrintWriter out) { + + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼爄d")); + return; + } + + List<String> detailImgs = new ArrayList<>(); + JSONArray detailImgsSize = new JSONArray(); + + List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(id, acceptData.getSystem()); + + if (imgs != null && imgs.size() > 0) { + + for (ImageInfo imgInfo : imgs) { + detailImgs.add(imgInfo.getPicture()); + } + + for (ImageInfo imgInfo : imgs) { + + if (imgInfo.getWidth() <= 0) { + detailImgsSize.clear(); + break; + } + + JSONObject size = new JSONObject(); + size.put("w", imgInfo.getWidth()); + size.put("h", imgInfo.getHeight()); + detailImgsSize.add(size); + } + + } + + JSONObject data = new JSONObject(); + data.put("detailImgs", detailImgs); + data.put("detailImgsSize", detailImgsSize); + + out.print(JsonUtil.loadTrueResult(data)); + } + + /** + * 鍟嗗搧璇︽儏鎺ㄨ崘1.4.0 + * + * @param acceptData + * @param id + * @param out + */ + @RequestMapping(value = "getgoodsderivation", method = RequestMethod.POST) + public void getRecommendGoods(AcceptData acceptData, String id, PrintWriter out) { + + try { + + List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); + // 鍒濆鍖� + if (goodsList == null) { + goodsList = new ArrayList<TaoBaoGoodsBrief>(); + } + + BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); + + List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); + + TaoKeAppInfo app = new TaoKeAppInfo(); + app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); + app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + app.setPid(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli)); + app.setAdzoneId(app.getPid().split("_")[3]); + + List<String> ids = new ArrayList<>(); + for (TaoBaoGoodsBrief goods : goodsList) + ids.add(goods.getAuctionId()); + + try { + goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); + } catch (TaoKeApiException e1) { + e1.printStackTrace(); + } catch (TaobaoGoodsDownException e1) { + e1.printStackTrace(); + } + + if (goodsList != null && goodsList.size() > 0) + goodsList.parallelStream().forEach(goods -> { + if (goods != null) { + // 鑾峰彇璇︽儏 + TaoBaoGoodsBrief taoBaoGoodsBrief = null; + try { + taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId()); + } catch (Exception e) { + e.printStackTrace(); + } + + if (taoBaoGoodsBrief == null) { + TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCouponV2(goods.getAuctionId(), app, null, null); + 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<>(); + + // 鍙栧伓鏁颁釜鏁版嵁 + if (listExtra.size() % 2 != 0) { + listExtra.remove(listExtra.size() - 1); + } + + if (listQuality.size() % 2 != 0) { + listQuality.remove(listQuality.size() - 1); + } + + JSONObject data = new JSONObject(); + data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); + data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); + out.print(JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JSONObject data = new JSONObject(); + data.put("listQuality", new JSONArray()); + data.put("listGuess", new JSONArray()); + out.print(JsonUtil.loadTrueResult(data)); + } + } + + /** + * 娲诲姩鍒楄〃 + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getSpecialActivities") + public void getSpecialActivities(AcceptData acceptData, Long uid, PrintWriter out, String callback) { + List<SpecialVO> listSpecial = specialService.listByVersion(0, Integer.MAX_VALUE, "special_activities", + acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); + + List<SpecialVO> list = new ArrayList<SpecialVO>(); + if (listSpecial != null) { + list.addAll(listSpecial); + } + + for (int i = 0; i < list.size(); i++) { + SpecialVO special = list.get(i); + JumpDetailV2 jumpDetail = special.getJumpDetail(); + if (jumpDetail != null) { + jumpDetail.setNeedLogin(special.isJumpLogin()); + special.setJumpDetail(jumpDetail); + } + String name = special.getName(); + if (StringUtil.isNullOrEmpty(name)) { + continue; + } + } + + JSONObject root = new JSONObject(); + root.put("special", JsonUtil.getApiCommonGson().toJson(list)); + if (StringUtil.isNullOrEmpty(callback)) + out.print(JsonUtil.loadTrueResult(root)); + else + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(root)); + } +} -- Gitblit v1.8.0