| | |
| | | @RequestMapping("api/web/v1/webRecommend") |
| | | public class WebRecommendController { |
| | | |
| | | @Resource |
| | | private WebControllerUtil webControllerUtil; |
| | | @Resource |
| | | private WebControllerUtil webControllerUtil; |
| | | |
| | | @Resource |
| | | private SuperRecommendBannerService superRecommendBannerService; |
| | | @Resource |
| | | private SuperRecommendBannerService superRecommendBannerService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | |
| | | /** |
| | | * |
| | | * 方法说明: 推荐轮播商品信息 |
| | | * |
| | | * @author mawurui createTime 2018年5月11日 上午11:13:47 |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRecommenBanner", method = RequestMethod.GET) |
| | | public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) { |
| | | /** |
| | | * 方法说明: 推荐轮播商品信息 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | * @author mawurui createTime 2018年5月11日 上午11:13:47 |
| | | */ |
| | | @RequestMapping(value = "getRecommenBanner", method = RequestMethod.GET) |
| | | public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) { |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystem("WEB", |
| | | Constant.systemCommonConfig.getH5PackageName(),acceptData.getSystem()); |
| | | JSONObject json = new JSONObject(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM)); |
| | | 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")); |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystem("WEB", |
| | | systemConfigService.getValueCache(SystemConfigKeyEnum.h5PackageName, acceptData.getSystem()), acceptData.getSystem()); |
| | | JSONObject json = new JSONObject(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM)); |
| | | 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); |
| | | } |
| | | list.add(recommendBanner); |
| | | } |
| | | |
| | | if (list == null) { |
| | | json.put("code", "1"); |
| | | json.put("msg", WebControllerUtil.NODATA); |
| | | 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); |
| | | // jsonp方式返回 |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json))); |
| | | return; |
| | | } |
| | | if (list == null) { |
| | | json.put("code", "1"); |
| | | json.put("msg", WebControllerUtil.NODATA); |
| | | 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); |
| | | // jsonp方式返回 |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json))); |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 方法说明: 获取商品详情 |
| | | * |
| | | * @author mawurui createTime 2018年5月11日 上午11:37:02 |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | /** |
| | | * 方法说明: 获取商品详情 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param out |
| | | * @author mawurui createTime 2018年5月11日 上午11:37:02 |
| | | */ |
| | | |
| | | @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET) |
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, Integer goodsType, |
| | | String callback, PrintWriter out) { |
| | | |
| | | long begin = java.lang.System.currentTimeMillis(); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | BusinessSystem system = webControllerUtil.getSystem(acceptData); |
| | | @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET) |
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, Integer goodsType, |
| | | String callback, PrintWriter out) { |
| | | |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM)); |
| | | return; |
| | | } |
| | | TaoBaoGoodsBrief tb = null; |
| | | try { |
| | | tb = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id)); |
| | | } catch (NumberFormatException e1) { |
| | | e1.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | long begin = java.lang.System.currentTimeMillis(); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | BusinessSystem system = webControllerUtil.getSystem(acceptData); |
| | | |
| | | if (tb != null) { |
| | | tb.setAuctionUrl(null); |
| | | tb.setId(null); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | JSONObject data = new JSONObject(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM)); |
| | | return; |
| | | } |
| | | TaoBaoGoodsBrief tb = null; |
| | | try { |
| | | tb = redisManager.getTaoBaoGoodsBrief(id); |
| | | } catch (NumberFormatException e1) { |
| | | e1.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | |
| | | // 获取默认PID信息 |
| | | int type = 0; |
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) |
| | | type = 1; |
| | | else |
| | | type = 2; |
| | | List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(type); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, config.get(0),acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) |
| | | taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink()); |
| | | if (tb != null) { |
| | | tb.setAuctionUrl(null); |
| | | tb.setId(null); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | if (uid != null && !"".equals(uid.trim())) { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), |
| | | Long.parseLong(id), goodsType); |
| | | data.put("collection", collectionGoods != null ? true : false); |
| | | } |
| | | taoBaoGoodsBriefExtra.setAuctionUrl(null); |
| | | data.put("taobao", gson.toJson(taoBaoGoodsBriefExtra)); |
| | | 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); |
| | | int showType = taoBaoGoodsBriefExtra.getShowType(); |
| | | String price = ""; |
| | | if (showType == 1 || showType == 3) { |
| | | price = taoBaoGoodsBriefExtra.getQuanPrice() + ""; |
| | | } else { |
| | | price = taoBaoGoodsBriefExtra.getZkPrice() + ""; |
| | | } |
| | | String appName = systemConfigService.getValueCache(SystemConfigKeyEnum.appName, acceptData.getSystem()); |
| | | data.put("sharePrice", "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 "); |
| | | data.put("shareTitle", taoBaoGoodsBriefExtra.getTitle()); |
| | | data.put("shareContent", "¥" + price + "元"); |
| | | data.put("shareImg", taoBaoGoodsBriefExtra.getPictUrl()); |
| | | String html = configService.getValue(ConfigKeyEnum.downAPP.getKey(), acceptData.getSystem()); |
| | | data.put("downAPP", html); |
| | | String shareSinaContent = configService.getValue("shareSinaContent", acceptData.getSystem()); |
| | | data.put("shareSina", |
| | | "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 " |
| | | + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent); |
| | | // 获取默认PID信息 |
| | | int type = 0; |
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) |
| | | type = 1; |
| | | else |
| | | type = 2; |
| | | List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(type); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, config.get(0), acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) |
| | | taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink()); |
| | | |
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()) + "元"); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); |
| | | if (uid != null && !"".equals(uid.trim())) { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), |
| | | id, goodsType); |
| | | data.put("collection", collectionGoods != null ? true : false); |
| | | } |
| | | taoBaoGoodsBriefExtra.setAuctionUrl(null); |
| | | data.put("taobao", gson.toJson(taoBaoGoodsBriefExtra)); |
| | | 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); |
| | | int showType = taoBaoGoodsBriefExtra.getShowType(); |
| | | String price = ""; |
| | | if (showType == 1 || showType == 3) { |
| | | price = taoBaoGoodsBriefExtra.getQuanPrice() + ""; |
| | | } else { |
| | | price = taoBaoGoodsBriefExtra.getZkPrice() + ""; |
| | | } |
| | | String appName = systemConfigService.getValueCache(SystemConfigKeyEnum.appName, acceptData.getSystem()); |
| | | data.put("sharePrice", "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 "); |
| | | data.put("shareTitle", taoBaoGoodsBriefExtra.getTitle()); |
| | | data.put("shareContent", "¥" + price + "元"); |
| | | data.put("shareImg", taoBaoGoodsBriefExtra.getPictUrl()); |
| | | String html = configService.getValue(ConfigKeyEnum.downAPP.getKey(), acceptData.getSystem()); |
| | | data.put("downAPP", html); |
| | | String shareSinaContent = configService.getValue("shareSinaContent", acceptData.getSystem()); |
| | | data.put("shareSina", |
| | | "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 " |
| | | + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent); |
| | | |
| | | final TaoBaoGoodsBrief tbb = tb; |
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem()) + "元"); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); |
| | | |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | } |
| | | long end = java.lang.System.currentTimeMillis(); |
| | | java.lang.System.out.println("耗时:" + (end - begin)); |
| | | return; |
| | | } |
| | | final TaoBaoGoodsBrief tbb = tb; |
| | | |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | } |
| | | long end = java.lang.System.currentTimeMillis(); |
| | | java.lang.System.out.println("耗时:" + (end - begin)); |
| | | return; |
| | | } |
| | | } |