| | |
| | | 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 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.SuperRecommendBannerV2;
|
| | | 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.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | |
| | | if (!"1".equals(version) && "android".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | jumpDetail = jumpDetailService.getlastJumpDetailCache();
|
| | | }
|
| | | List<RecommendSpecial> recommendSpecialList = null;
|
| | |
|
| | | List<SuperRecommendSpecial> superRecommendSpecialList = superRecommendSpecialService
|
| | | .getSuperRecommendSpecialBySystemId(system.getId());
|
| | | if (superRecommendSpecialList != null && superRecommendSpecialList.size() > 0) {
|
| | |
|
| | | List<RecommendSpecial> recommendSpecialList = null;
|
| | | for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) {
|
| | | if (recommendSpecialList == null) {
|
| | | recommendSpecialList = new ArrayList<RecommendSpecial>();
|
| | | recommendSpecialList = new ArrayList<RecommendSpecial>();
|
| | |
|
| | | for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) {
|
| | | RecommendSpecial recommendSpecial = superRecommendSpecial.getRecommendSpecial();
|
| | | if (jumpDetail != null) {
|
| | | recommendSpecial.setJumpDetail(jumpDetail);
|
| | | }
|
| | | recommendSpecialList.add(recommendSpecial);
|
| | | }
|
| | | RecommendSpecial recommendSpecial = superRecommendSpecial.getRecommendSpecial();
|
| | | if (jumpDetail != null) {
|
| | | recommendSpecial.setJumpDetail(jumpDetail);
|
| | | }
|
| | | recommendSpecialList.add(recommendSpecial);
|
| | | }
|
| | |
|
| | | if (recommendSpecialList == null || recommendSpecialList.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", recommendSpecialList.size());
|
| | | Gson gson = new Gson();
|
| | |
| | | // 获取淘客参数
|
| | | ClientTBPid clientTBPid = null;
|
| | | if (simpleGoods.getMaterialLibType() != null && simpleGoods.getMaterialLibType() == 1) {
|
| | | String pid = Constant.TAOBAO_SPECIAL_PID_DEFAULT;
|
| | | clientTBPid = new ClientTBPid(Constant.TAOBAO_AUTH_APPKEY, Constant.TAOBAO_AUTH_APPSECRET,
|
| | | 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")) {
|
| | |
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
|
| | | && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0
|
| | | && goods.getBiz30day() > 1000)
|
| | | && goods.getBiz30day() > 1000 && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite()))
|
| | | goodsList.add(goods);
|
| | | }
|
| | | try {
|
| | |
| | | }
|
| | |
|
| | | // 首页Banner
|
| | | List<RecommendBannerV2> listBanner = null;
|
| | |
|
| | | List<SuperRecommendBannerV2> listRecommendBanner = superRecommendBannerV2Service
|
| | | .getSuperRecommendBannerV2sBySystem(system);
|
| | |
|
| | | if (listRecommendBanner != null && listRecommendBanner.size() > 0) {
|
| | |
|
| | | listBanner = new ArrayList<RecommendBannerV2>();
|
| | |
|
| | | for (SuperRecommendBannerV2 superRecommendBanner : listRecommendBanner) {
|
| | | RecommendBannerV2 recommendBanner = superRecommendBanner.getRecommendBanner();
|
| | | // 淘特价暂时修改
|
| | | if (system.getId() == 7) {
|
| | | recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity()
|
| | | .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial"));
|
| | | }
|
| | |
|
| | | listBanner.add(recommendBanner);
|
| | | }
|
| | | }
|
| | | List<RecommendBannerV2> listBanner = superRecommendBannerV2Service
|
| | | .getSuperRecommendBannerV2sBySystem(system.getId());
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("banner", listBanner);
|
| | |
| | | // 获取淘客参数
|
| | | ClientTBPid clientTBPid = null;
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(uid)) {
|
| | | // 用户未登录
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | clientTBPid = tbPidService.getAndroidDefault();
|
| | | } else {
|
| | | clientTBPid = tbPidService.getIOSDefault();
|
| | | }
|
| | |
|
| | | // 用户未登录
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | clientTBPid = tbPidService.getAndroidDefault();
|
| | | } else {
|
| | | // 用户已经登录
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | clientTBPid = tbPidService.getAndroidDefault();
|
| | | } else {
|
| | | clientTBPid = tbPidService.getIOSDefault();
|
| | | }
|
| | | clientTBPid = tbPidService.getIOSDefault();
|
| | | }
|
| | |
|
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime));
|
| | |
| | |
|
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id));
|
| | | if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) {
|
| | | 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);
|
| | | TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
|
| | | if (linkInfo != null) {
|
| | | goods.setAuctionUrl(linkInfo.getAuctionUrl());
|
| | | goods.setCouponLink(linkInfo.getCouponLink());
|
| | | goods.setTkRate(linkInfo.getTkRate());
|
| | | }
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 商品下架
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
| | | // 测试使用
|
| | | 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) {
|
| | |
| | |
|
| | | String token = "";
|
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) {
|
| | | token = redisManager.getCommonTaoToken(tb.getAuctionId());
|
| | | token = redisManager.getCommonTaoToken(tb.getAuctionId());
|
| | | if (StringUtil.isNullOrEmpty(token)) {
|
| | | token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink());
|
| | | redisManager.saveCommonTaoToken(tb.getAuctionId(), token);
|
| | |
| | | tb.setCouponLinkTaoToken(token);
|
| | |
|
| | | // 服务端转链
|
| | | if (convertInServer && !StringUtil.isNullOrEmpty(tb.getCouponLink())) {
|
| | | // if (convertInServer && !StringUtil.isNullOrEmpty(tb.getCouponLink())) {
|
| | | couponInfo.put("couponUrl", tb.getCouponLink());
|
| | | } else {
|
| | | couponInfo.put("couponUrl",
|
| | | TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid, tb.getAuctionId() + ""));
|
| | | }
|
| | | // } 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("-", ".") + "-"
|
| | |
| | | data.put("couponUsers", listCouponUser);
|
| | | data.put("detailWebUrl", "http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
|
| | | // 商品链接
|
| | | data.put("h5Url", String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + ""));
|
| | | String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + "");
|
| | | try {
|
| | | data.put("h5Url", HttpUtil.getShortLink(h5Url));
|
| | | } catch (Exception e) {
|
| | | data.put("h5Url", h5Url);
|
| | | }
|
| | |
|
| | | // 取消分享活动
|
| | | // if (!StringUtil.isNullOrEmpty(uid)
|
| | |
| | | });
|
| | |
|
| | | List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>();
|
| | | //删除推荐
|
| | | //
|
| | | // try {
|
| | | // List<QualityFactory> listRecommend = qualityGoodsService.recommendByAuctionId(id);
|
| | | //
|
| | | // if (listRecommend != null && listRecommend.size() > 1) {
|
| | | // for (QualityFactory quality : listRecommend) {
|
| | | //
|
| | | // TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
|
| | | // if (taoBaoGoodsBrief == null) {
|
| | | // continue;
|
| | | // }
|
| | | //
|
| | | // int biz30day = taoBaoGoodsBrief.getBiz30day();
|
| | | // if (biz30day >= 10000) {
|
| | | // double sales = biz30day;
|
| | | // String salesCountMidea = String.format("%.1f", sales / 10000);
|
| | | // taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
|
| | | // } else {
|
| | | // taoBaoGoodsBrief.setSalesCount(biz30day + "");
|
| | | // }
|
| | | //
|
| | | // // 改变图片尺寸
|
| | | // String pictUrl = taoBaoGoodsBrief.getPictUrl();
|
| | | // if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | // taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | // }
|
| | | //
|
| | | // listQuality.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null));
|
| | | // }
|
| | | // }
|
| | | // } catch (Exception e2) {
|
| | | // e2.printStackTrace();
|
| | | // }
|
| | | // 删除推荐
|
| | | //
|
| | | // try {
|
| | | // List<QualityFactory> listRecommend =
|
| | | // qualityGoodsService.recommendByAuctionId(id);
|
| | | //
|
| | | // if (listRecommend != null && listRecommend.size() > 1) {
|
| | | // for (QualityFactory quality : listRecommend) {
|
| | | //
|
| | | // TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
|
| | | // if (taoBaoGoodsBrief == null) {
|
| | | // continue;
|
| | | // }
|
| | | //
|
| | | // int biz30day = taoBaoGoodsBrief.getBiz30day();
|
| | | // if (biz30day >= 10000) {
|
| | | // double sales = biz30day;
|
| | | // String salesCountMidea = String.format("%.1f", sales / 10000);
|
| | | // taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
|
| | | // } else {
|
| | | // taoBaoGoodsBrief.setSalesCount(biz30day + "");
|
| | | // }
|
| | | //
|
| | | // // 改变图片尺寸
|
| | | // String pictUrl = taoBaoGoodsBrief.getPictUrl();
|
| | | // if (!StringUtil.isNullOrEmpty(pictUrl) &&
|
| | | // !pictUrl.contains("320x320")) {
|
| | | // taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | // }
|
| | | //
|
| | | // listQuality.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
|
| | | // proportion.toString(), null));
|
| | | // }
|
| | | // }
|
| | | // } catch (Exception e2) {
|
| | | // e2.printStackTrace();
|
| | | // }
|
| | |
|
| | | // 取偶数个数据
|
| | | if (listExtra.size() % 2 != 0) {
|
| | |
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listExtra));
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listQuality));
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|