| | |
| | | package com.yeshi.fanli.controller.web;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSection;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSectionGoods;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendSection;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.entity.taobao.ScanHistory;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendSectionService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.ScanHistoryService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/web/v1/webRecommend")
|
| | | public class WebRecommendController {
|
| | |
|
| | | @Resource
|
| | | private WebControllerUtil webControllerUtil;
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendBannerService superRecommendBannerService;
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendSectionService superRecommendSectionService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private RecommendSectionGoodsService recommendSectionGoodsService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private SystemService systemService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private SystemConfigService systemConfigService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private ScanHistoryService scanHistoryService;
|
| | |
|
| | | @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) {
|
| | |
|
| | | System system = systemService.getSystem("WEB", Constant.systemCommonConfig.getH5PackageName());
|
| | | 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);
|
| | | }
|
| | |
|
| | | 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:26:03
|
| | | * @param acceptData
|
| | | * @param index
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRecommendSection", method = RequestMethod.GET)
|
| | | public void getRecommendSection(AcceptData acceptData, String callback, PrintWriter out) {
|
| | |
|
| | | System system = systemService.getSystem("WEB", Constant.systemCommonConfig.getH5PackageName());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM));
|
| | | return;
|
| | | }
|
| | | List<SuperRecommendSection> superRecommendSectionList = superRecommendSectionService
|
| | | .getSuperRecommendSectionBySystemId(system.getId());
|
| | | List<RecommendSection> recommendSectionList = null;
|
| | | for (SuperRecommendSection superRecommendSection : superRecommendSectionList) {
|
| | | if (recommendSectionList == null) {
|
| | | recommendSectionList = new ArrayList<RecommendSection>();
|
| | | }
|
| | | RecommendSection recommendSection = superRecommendSection.getRecommendSection();
|
| | |
|
| | | // 暂时改变淘特价的跳转地址
|
| | | if (system.getId() == 7) {
|
| | | recommendSection.setJumpUrl(recommendSection.getJumpUrl().replace("column.html", "column_ttj.html"));
|
| | | }
|
| | |
|
| | | recommendSectionList.add(recommendSection);
|
| | | }
|
| | | if (recommendSectionList == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NODATA));
|
| | | return;
|
| | | }
|
| | | Utils.sort(recommendSectionList);
|
| | | int size = recommendSectionList.size();
|
| | |
|
| | | List<RecommendSectionGoods> recommendSectionGoodsList = null;
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", size);
|
| | | JSONArray dataArr = new JSONArray();
|
| | | JSONObject validData = null;
|
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | Map<String, String> convertMap = hongBaoManageService.convertMap();
|
| | | String proportion = convertMap.get("hongbao_goods_proportion");
|
| | | String fcRate = convertMap.get("hongbao_fc_ratio");
|
| | |
|
| | | Map<Long, List<RecommendSectionGoods>> map = recommendSectionGoodsService.getAllSectionGoodsMap();
|
| | | for (int i = 0; i < size; i++) {
|
| | | validData = new JSONObject();
|
| | | RecommendSection recommendSection = recommendSectionList.get(i);
|
| | | recommendSectionGoodsList = map.get(recommendSection.getId());
|
| | | if (recommendSectionGoodsList == null) {
|
| | | continue;
|
| | | }
|
| | | Utils.sort(recommendSectionGoodsList);
|
| | | if (recommendSection.getCounts() < recommendSectionGoodsList.size()) {
|
| | | recommendSectionGoodsList = recommendSectionGoodsList.subList(0, recommendSection.getCounts());
|
| | | }
|
| | | validData.put("count", recommendSectionGoodsList.size());
|
| | | validData.put("recommendSection", gson.toJson(recommendSection));
|
| | |
|
| | | // 替换TaoBaoGoodsBrief
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson2 = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
| | | for (RecommendSectionGoods rss : recommendSectionGoodsList) {
|
| | | JSONObject obj = JSONObject.fromObject(gson2.toJson(rss));
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(
|
| | | gson2.fromJson(obj.optJSONObject("taoBaoGoodsBrief").toString(), TaoBaoGoodsBrief.class),
|
| | | proportion, fcRate, ""));
|
| | | obj.put("taoBaoGoodsBrief", json);
|
| | | array.add(obj);
|
| | | }
|
| | |
|
| | | validData.put("recommendSectionGoodsList", array);
|
| | | dataArr.add(validData);
|
| | | }
|
| | | data.put("data", dataArr);
|
| | |
|
| | | String result = JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data));
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.cacheCommonString("client-api-getRecommendSection", result, 3 * 60);
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(result)));
|
| | | return;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 方法说明: 获取商品详情
|
| | | * |
| | | * @author mawurui createTime 2018年5月11日 上午11:37:02
|
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | |
|
| | | @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET)
|
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, String callback,
|
| | | PrintWriter out) {
|
| | | long begin = java.lang.System.currentTimeMillis();
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | | return;
|
| | | }
|
| | | System system = webControllerUtil.getSystem(acceptData);
|
| | | // 淘特价
|
| | | if (system.getId() == 7) {
|
| | | system = systemService.getSystem("ANDROID", Constant.systemCommonConfig.getAndroidPackageName());
|
| | | }
|
| | |
|
| | | 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();
|
| | | }
|
| | |
|
| | | if (tb != null) {
|
| | | tb.setAuctionUrl(null);
|
| | | tb.setId(null);
|
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | // 获取默认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));
|
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null)
|
| | | taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink());
|
| | |
|
| | | if (uid != null && !"".equals(uid.trim())) {
|
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid),
|
| | | Long.parseLong(id));
|
| | | data.put("collection", collectionGoods != null ? true : false);
|
| | | }
|
| | | taoBaoGoodsBriefExtra.setAuctionUrl(null);
|
| | | data.put("taobao", gson.toJson(taoBaoGoodsBriefExtra));
|
| | | String info = configService.get("detail_prompt");
|
| | | data.put("info", info);
|
| | | String onlyInfo = configService.get("only_info");
|
| | | 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.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) + "元");
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | |
|
| | | final TaoBaoGoodsBrief tbb=tb;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 添加浏览记录
|
| | | ScanHistory sh = TaoBaoUtil.getScanHistory(tbb);
|
| | | sh.setDevice(acceptData.getDevice());
|
| | | sh.setSystem(systemService.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
|
| | | sh.setCreatetime(new Date());
|
| | | if (uid != null && !uid.equals("")) {
|
| | | sh.setUid(Long.parseLong(uid));
|
| | | }
|
| | | try {
|
| | | scanHistoryService.addScanHistory(sh);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | recommendSectionGoodsService.deleteRecommendSectionGoodsByTbAuctionId(Long.parseLong(id));
|
| | | ;
|
| | | }
|
| | | });
|
| | | }
|
| | | long end = java.lang.System.currentTimeMillis();
|
| | | java.lang.System.out.println("耗时:" + (end - begin));
|
| | | return;
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.controller.web; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.config.SystemConfigKeyEnum; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner; |
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner; |
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2; |
| | | import com.yeshi.fanli.entity.system.BusinessSystem; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService; |
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; |
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService; |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/web/v1/webRecommend") |
| | | public class WebRecommendController { |
| | | |
| | | @Resource |
| | | private WebControllerUtil webControllerUtil; |
| | | |
| | | @Resource |
| | | private SuperRecommendBannerService superRecommendBannerService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | |
| | | /** |
| | | * 方法说明: 推荐轮播商品信息 |
| | | * |
| | | * @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", |
| | | 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); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 方法说明: 获取商品详情 |
| | | * |
| | | * @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); |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | if (tb != null) { |
| | | tb.setAuctionUrl(null); |
| | | tb.setId(null); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | // 获取默认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 (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); |
| | | |
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem()) + "元"); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); |
| | | |
| | | final TaoBaoGoodsBrief tbb = tb; |
| | | |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | } |
| | | long end = java.lang.System.currentTimeMillis(); |
| | | java.lang.System.out.println("耗时:" + (end - begin)); |
| | | return; |
| | | } |
| | | } |