| | |
| | | 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.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.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
|
| | | 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.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
|
| | | import com.yeshi.fanli.service.inter.tlj.DeviceTaoLiJinRecordService;
|
| | | 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.service.inter.user.UserMoneyExtraService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | 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 DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | |
|
| | | @Resource
|
| | | private ConfigTaoLiJinService configTaoLiJinService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTaoLiJinRecordService deviceTaoLiJinRecordService;
|
| | |
|
| | | @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, "请上传id"));
|
| | | 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 (simpleGoods.getMaterialLibType() != null && simpleGoods.getMaterialLibType() == 1) {
|
| | | String pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
|
| | | clientTBPid = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | pid.split("_")[2], pid.split("_")[3]);
|
| | | } else {
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | 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());// 销量(和salesCount一致,此处处理兼容)
|
| | | if (taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null)
|
| | | taobaoJson.put("coupon", true);
|
| | | else
|
| | | taobaoJson.put("coupon", false);
|
| | |
|
| | | // taoBaoGoodsBriefExtra.setAuctionUrl(null);
|
| | | data.put("taobao", taobaoJson);
|
| | | String info = configService.get("detail_prompt");
|
| | | data.put("info", info);
|
| | | String onlyInfo = configService.get("only_info");
|
| | | data.put("only", onlyInfo);
|
| | | data.put("helpUrl", configService.get("old_goods_detail_help_url"));
|
| | |
|
| | | 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("downAPP");
|
| | | 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, "请上传id"));
|
| | | 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是否正在上线
|
| | | 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.getRelationGoodsRecommend(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) + "],上传的淘宝订单ID:" + order + ",用户ID:" + uid + ",订单金额:"
|
| | | + money + ",商品链接:" + auctionUrl);
|
| | | if (StringUtil.isNullOrEmpty(order)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传order"));
|
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 上传的订单为空!上传订单失败!");
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传uid"));
|
| | | 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 + "下单成功!订单ID[" + or.getOrderId() + "]");
|
| | | } else {
|
| | | LogHelper.userOrder("用户ID" + uid + "下单失败!订单ID[" + 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 = "linkParse-" + 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的IMEI信息
|
| | | * @param idfa
|
| | | * -IOS的idfa广告标识信息
|
| | | */
|
| | | @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 = daTaoKeGoodsDetailService.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.getByBannerCard(swiperCard);
|
| | |
|
| | | 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("home_invite_banner"));
|
| | |
|
| | | 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");
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | | root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList));
|
| | |
|
| | | // 3、邀请有奖
|
| | | List<SwiperPicture> invitePicList = null;
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | } else {
|
| | | invitePicList = getSwiperByCard("index_invite");
|
| | | }
|
| | |
|
| | | if (invitePicList == null) {
|
| | | invitePicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | | root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList));
|
| | |
|
| | | // 4、IOS的底部网页链接
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("ios".equalsIgnoreCase(platform)) {
|
| | | root.put("htmlLink", configService.get("index_html_link_ios"));
|
| | | }
|
| | |
|
| | | 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");
|
| | |
|
| | | return invitePicList;
|
| | | }
|
| | |
|
| | | public List<SwiperPicture> getSwiperByCard(String card) {
|
| | | List<SwiperPicture> swiperList = null;
|
| | | try {
|
| | | swiperList = swiperPictureService.getByBannerCard(card);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | e.printStackTrace();
|
| | | }
|
| | | return swiperList;
|
| | | }
|
| | |
|
| | | 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 = String.format("spikeGoods_hour-%s-%s", acceptData.getPlatform(), acceptData.getVersion());
|
| | | String cachekey = String.format("spikeGoodsList-%s-%s", 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("spike_goods_link") + "?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("spike_goods_link"));
|
| | |
|
| | | 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, "请上传id"));
|
| | | 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是否正在上线
|
| | | 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 = daTaoKeGoodsDetailService.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("-", "."));
|
| | | // 券的口令
|
| | |
|
| | | 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.yeshitv.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("zigoulijian_nofanli_help");
|
| | | // 查询分享库
|
| | | 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("no_rebate_help_link"));
|
| | | }
|
| | |
|
| | | // 取消分享活动
|
| | | // 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, "请上传id"));
|
| | | 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.getRelationGoodsRecommend(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) {
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | | List<Special> listSpecial = specialService.listByVersion(0, Integer.MAX_VALUE, "special_activities",
|
| | | platformCode, 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;
|
| | | }
|
| | |
|
| | | // 是否需要弹出框
|
| | | if (name.equals("账户等级特权")) {
|
| | | if (!VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | } else {
|
| | | if (uid != null) {
|
| | | special.setElastic(userTaoLiJinOriginService.hasRankHongBao(uid));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("special", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(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 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; |
| | | |
| | | @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()),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, "请上传id")); |
| | | 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(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),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), |
| | | 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());// 销量(和salesCount一致,此处处理兼容) |
| | | 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.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.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, "请上传id")); |
| | | 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是否正在上线 |
| | | 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(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),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), |
| | | 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.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, 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(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, long 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) + "],上传的淘宝订单ID:" + order + ",用户ID:" + uid + ",订单金额:" |
| | | + money + ",商品链接:" + auctionUrl); |
| | | if (StringUtil.isNullOrEmpty(order)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传order")); |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 上传的订单为空!上传订单失败!"); |
| | | return; |
| | | } |
| | | |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传uid")); |
| | | 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 + "下单成功!订单ID[" + or.getOrderId() + "]"); |
| | | } else { |
| | | LogHelper.userOrder("用户ID" + uid + "下单失败!订单ID[" + 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(), |
| | | 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的IMEI信息 |
| | | * @param idfa |
| | | * -IOS的idfa广告标识信息 |
| | | */ |
| | | @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、IOS的底部网页链接 |
| | | 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"); |
| | | 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, Long id, Long uid, String from, PrintWriter out) { |
| | | |
| | | if (id == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | 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是否正在上线 |
| | | 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.specialConvertCoupon(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("-", ".")); |
| | | // 券的口令 |
| | | |
| | | 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, "请上传id")); |
| | | return; |
| | | } |
| | | |
| | | List<String> detailImgs = new ArrayList<>(); |
| | | JSONArray detailImgsSize = new JSONArray(); |
| | | |
| | | List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(Long.parseLong(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, long 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.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,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<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<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)); |
| | | } |
| | | } |