| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | 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.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.su.recommend.SuperRecommendSpecial;
|
| | | import com.yeshi.fanli.entity.bus.user.CollectionGoods;
|
| | | 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.common.ImageInfo;
|
| | | import com.yeshi.fanli.entity.common.JumpDetail;
|
| | |
| | | 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.TaoBaoShopInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.ScanHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.ShareManageService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | |
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import org.yeshi.utils.IPUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v1/user")
|
| | |
| | |
|
| | | @Resource
|
| | | private SuperRecommendBannerV2Service superRecommendBannerV2Service;
|
| | | |
| | | @Resource
|
| | | private ShamUserService shamUserService;
|
| | | |
| | |
|
| | | @RequestMapping(value = "getrecommendsection")
|
| | | public void getRecommendSection(AcceptData acceptData, int index, PrintWriter out) {
|
| | |
| | | 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) {
|
| | |
| | | + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent);
|
| | |
|
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb) + "元");
|
| | |
|
| | | data.put("shareHongBao", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb));
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | final TaoBaoGoodsBrief tbb = tb;
|
| | |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : recommendGoodsList) {
|
| | | if (taoBaoGoodsBrief == null)
|
| | | continue;
|
| | | if (taoBaoGoodsBrief.getBiz30day() != null)
|
| | | taoBaoGoodsBrief.setSalesCount(0 + "");
|
| | | else
|
| | | taoBaoGoodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(taoBaoGoodsBrief.getBiz30day()));
|
| | | |
| | | re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, ""));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(re)));
|
| | |
| | | RecommendBannerV2 recommendBanner = superRecommendBanner.getRecommendBanner();
|
| | | // 淘特价暂时修改
|
| | | if (system.getId() == 7) {
|
| | | recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity()
|
| | | .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial"));
|
| | | recommendBanner.getJumpDetail().setActivity(
|
| | | recommendBanner.getJumpDetail().getActivity()
|
| | | .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial"));
|
| | | }
|
| | |
|
| | | listBanner.add(recommendBanner);
|
| | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 商品基本详情 (1.4.0)
|
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getgoodsinfo", method = RequestMethod.POST)
|
| | | public void getGoodsInfo(AcceptData acceptData, String id, String uid, PrintWriter out) {
|
| | | |
| | | if ("0".equalsIgnoreCase(uid)){
|
| | | uid = "";
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | | return;
|
| | | }
|
| | | |
| | | System system = systemService.getSystemCache(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 (StringUtil.isNullOrEmpty(uid)) {
|
| | | // 用户未登录
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | clientTBPid = tbPidService.getAndroidDefault();
|
| | | } else {
|
| | | clientTBPid = tbPidService.getIOSDefault();
|
| | | }
|
| | | |
| | | } else {
|
| | | |
| | | // 用户已经登录
|
| | | TBPid tbPid = null;
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | |
| | | tbPid = tbPidService.getTBPid(Long.parseLong(uid),PidUser.TYPE_FANLI_ANDROID);
|
| | | |
| | | if (tbPid == null) {
|
| | | clientTBPid = tbPidService.getAndroidDefault();
|
| | | } else {
|
| | | String siteId = tbPid.getPid().split("_")[2];
|
| | | String adzoneId = tbPid.getPid().split("_")[3];
|
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
|
| | | clientTBPid = new ClientTBPid(config.getAppKey(),tbPid.getPid(), siteId, adzoneId);
|
| | | }
|
| | |
|
| | | } else {
|
| | | |
| | | tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_IOS);
|
| | | |
| | | if (tbPid == null) {
|
| | | clientTBPid = tbPidService.getIOSDefault();
|
| | | } else {
|
| | | String siteId = tbPid.getPid().split("_")[2];
|
| | | String adzoneId = tbPid.getPid().split("_")[3];
|
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
|
| | | clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime));
|
| | |
|
| | | |
| | | final String clientPid = clientTBPid.getPid();
|
| | | final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | // 是否在服务端进行转链
|
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer();
|
| | | |
| | | List<String> taskList = new ArrayList<>();
|
| | | // 获取商品基本信息
|
| | | taskList.add("goods");
|
| | | |
| | | taskList.stream().parallel().forEach(task -> {
|
| | | if (task.equalsIgnoreCase("goods")) {
|
| | | JSONObject ticket = new JSONObject();
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | |
| | | if (!convertInServer) {
|
| | | |
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id));
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 商品下架
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | taoBaoGoodsUpdateService.deleteTaoBaoGoods(Long.parseLong(id));
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | | |
| | | } else {
|
| | | 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) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | 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(img);
|
| | | }
|
| | | |
| | | |
| | | JSONObject goods = new JSONObject();
|
| | | goods.put("auctionId", tb.getAuctionId());
|
| | | goods.put("imgList", finalImgList);
|
| | | goods.put("title", tb.getTitle());
|
| | | goods.put("userType", tb.getUserType() == 1 ? 2 : 1);
|
| | | goods.put("price", tb.getReservePrice().toString());
|
| | | goods.put("zkPrice", tb.getZkPrice().toString());
|
| | |
|
| | | |
| | | // 红包
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, new BigDecimal(rateStr));
|
| | | goods.put("hongBao", hongBao);
|
| | | // 30天销量
|
| | | goods.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day()));
|
| | | |
| | | // 分享赚
|
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | data.put("shareMoney","¥" + shareMoney);
|
| | | // 分享赚人提示
|
| | | List<ShamUser> listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5);
|
| | |
|
| | | // 判断收藏
|
| | | if (StringUtil.isNullOrEmpty(uid)) {
|
| | | data.put("collected", false);
|
| | | } else {
|
| | | CollectionGoods collectionGoods = |
| | | collectionGoodsService.findByUidAndAuctionId(Long.parseLong(uid), Long.parseLong(id));
|
| | | 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));
|
| | | |
| | | // 是否有券
|
| | | goods.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true);
|
| | | |
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = null;
|
| | | |
| | | // 获取券信息
|
| | | 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);
|
| | | |
| | | // 领券人列表
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | |
|
| | | 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();
|
| | | }
|
| | | goods.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");
|
| | | }
|
| | | }
|
| | | // 店铺
|
| | | goods.put("shopInfo", tbShopInfo);
|
| | | |
| | | // 分享路径
|
| | | String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl());
|
| | | |
| | | data.put("shareUrl", shareUrl);
|
| | | data.put("goods", goods);
|
| | | data.put("shareUsers", listShareUser);
|
| | | data.put("couponUsers", listCouponUser);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final String tempUid = uid;
|
| | | final TaoBaoGoodsBrief goodsInfo = tb;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 添加浏览记录
|
| | | ScanHistory sh = TaoBaoUtil.getScanHistory(goodsInfo);
|
| | | sh.setId(0);
|
| | | sh.setDevice(acceptData.getDevice());
|
| | | sh.setSystem(systemService.getSystem(acceptData.getPlatform(),
|
| | | acceptData.getPackages()));
|
| | | sh.setCreatetime(new Date());
|
| | | if (!StringUtil.isNullOrEmpty(tempUid)) {
|
| | | sh.setUid(Long.parseLong(tempUid));
|
| | | }
|
| | | try {
|
| | | scanHistoryService.addScanHistory(sh);
|
| | | } 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) {
|
| | |
|
| | | System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
|
| | | |
| | | // 重新做推荐
|
| | | if (goodsList == null || goodsList.size() == 0) {
|
| | | |
| | | goodsList = new ArrayList<>();
|
| | | |
| | | TaoBaoGoodsBrief goods = null;
|
| | | |
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(id);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | if (goods == null){
|
| | | // 从我们的商品库搜索
|
| | | CollectionGoods cgoods = collectionGoodsService.findByAuctionId(id);
|
| | | |
| | | // 商品有本地缓存
|
| | | 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() == 10) {
|
| | | break;
|
| | | }
|
| | | goodsList.add(gds);
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | | // 需要另做推荐
|
| | | if (goodsList.size() < 2) {
|
| | | try {
|
| | | List<RecommendSectionGoods> list = recommendSectionGoodsService.getSectionGoods(10);
|
| | | if (list != null) {
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (i == 10) {
|
| | | break;
|
| | | }
|
| | | goodsList.add(list.get(i).getTaoBaoGoodsBrief());
|
| | | }
|
| | | }
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | | Map<String, String> map = hongBaoManageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | |
| | | List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | | |
| | | goodsList.parallelStream().forEach(goods -> {
|
| | | // 获取详情
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | try {
|
| | | taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(goods.getAuctionId());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | if (taoBaoGoodsBrief != null) {
|
| | | listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, ""));
|
| | | }
|
| | | |
| | | });
|
| | |
|
| | | |
| | | List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | | try {
|
| | | List<QualityFactory> listRecommend = qualityGoodsService.recommendByAuctionId(id);
|
| | | |
| | | if (listRecommend != null && listRecommend.size() > 1) {
|
| | | for (QualityFactory quality : listRecommend) {
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | int biz30day = taoBaoGoodsBrief.getBiz30day();
|
| | | if (biz30day >= 10000) {
|
| | | double sales = biz30day;
|
| | | String salesCountMidea = String.format("%.1f", sales / 10000);
|
| | | taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万");
|
| | | } else {
|
| | | taoBaoGoodsBrief.setSalesCount(biz30day + "");
|
| | | }
|
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = taoBaoGoodsBrief.getPictUrl();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | listQuality.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null));
|
| | | }
|
| | | }
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | |
| | | |
| | | // 取偶数个数据
|
| | | 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("listGuess", JsonUtil.getApiCommonGson().toJson(listExtra));
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listQuality));
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|