yujian
2019-09-05 ad233381a240dce92cd5d9626d67a9dd25cf6473
品牌
4个文件已修改
454 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandClassShopService.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
@@ -15,7 +15,9 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.entity.brand.TaoBaoShopHistory;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
@@ -23,8 +25,11 @@
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.brand.BrandClassService;
import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
import com.yeshi.fanli.service.inter.brand.BrandInfoRecordService;
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
import com.yeshi.fanli.service.inter.brand.TaoBaoShopHistoryService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
@@ -35,7 +40,9 @@
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.BrandInfoVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -67,6 +74,16 @@
    @Resource
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private BrandInfoService brandInfoService;
    @Resource
    private SwiperPictureService swiperPictureService;
    @Resource
    private BrandInfoRecordService brandInfoRecordService;
    /**
     * 店铺列表
@@ -310,4 +327,280 @@
        taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
    }
    /**
     * 品牌列表列表
     *
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getList", method = RequestMethod.POST)
    public void getList(AcceptData acceptData, Integer page, Long cid, Long uid, PrintWriter out) {
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult("页码不正确"));
            return;
        }
        if (cid != null && cid == 0) {
            cid = null;
        }
        JSONObject data = new JSONObject();
        if (page == 1 && cid != null) {
            List<BrandInfo> brandlist = brandInfoService.listValidBrandInfoCache(cid);
            if(brandlist == null)
                brandlist = new ArrayList<BrandInfo>();
            data.put("brandlist", JsonUtil.getApiCommonGson().toJson(brandlist));
        }
        long count = brandInfoService.countBrandInfo(cid);
        List<BrandInfoVO> list = brandInfoService.listBrandInfoCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid);
        if (list == null)
            list = new ArrayList<BrandInfoVO>();
        GsonBuilder gb = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
        gb.excludeFieldsWithoutExposeAnnotation();
        Gson gson = gb.create();
        data.put("count", count);
        data.put("list", gson.toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 店铺详情过渡页
     *
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
    public void getShopInfoV2(AcceptData acceptData, Integer page, Long id, Long uid, PrintWriter out) {
        if (id == null) {
            out.print(JsonUtil.loadFalseResult("缺失店铺id"));
            return;
        }
        List<TaoBaoShop> shopList = new ArrayList<TaoBaoShop>();
        List<SwiperPicture> topPicList = new ArrayList<>();
        JSONObject data = new JSONObject();
        if (page == 1) {
            // 2、顶部轮播图
            List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("index_top");
            if (oldtopPicList != null && oldtopPicList.size() > 0)
                topPicList.addAll(oldtopPicList);
            TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(id);
            if (taoBaoShop == null) {
                out.print(JsonUtil.loadFalseResult("店铺信息获取失败"));
                return;
            }
            String shopLink = taoBaoShop.getShopLink();
            if (StringUtil.isNullOrEmpty(shopLink)) {
                taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
            }
            String shopNameCustom = taoBaoShop.getShopNameCustom();
            if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
                taoBaoShop.setShopName(shopNameCustom);
            }
            String shopIconCustom = taoBaoShop.getShopIconCustom();
            if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
                taoBaoShop.setShopIcon(shopIconCustom);
            }
            Integer userType = taoBaoShop.getUserType();
            if (userType == null || userType == 0) {
                taoBaoShop.setUserType(10);
            } else {
                taoBaoShop.setUserType(11);
            }
            shopList.add(taoBaoShop);
            ThreadUtil.run(new Runnable() {
                public void run() {
                    // 添加足迹
                    taoBaoShopHistoryService.addHistory(id, uid, acceptData.getDevice());
                }
            });
        }
        data.put("picList", JsonUtil.getApiCommonGson().toJson(topPicList));
        data.put("shopList", JsonUtil.getApiCommonGson().toJson(shopList));
        // 商品列表信息
        int pageSize = 50;
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        // 先查询大淘客数据
        List<DaTaoKeDetail> listDaTaoKe = daTaoKeGoodsService.listBySellerId(0, pageSize, id);
        if (listDaTaoKe != null && listDaTaoKe.size() > 0) {
            for (DaTaoKeDetail daTaoKe : listDaTaoKe) {
                listGoodsBrief.add(TaoBaoUtil.convert(daTaoKe));
            }
        }
        // 不足50条数据、查询精选库
        if (listGoodsBrief.size() < pageSize) {
            int needCount = pageSize - listGoodsBrief.size();
            List<TaoBaoGoodsBrief> listGoods = taoBaoGoodsBriefService.listByShopId(0, needCount, id);
            if (listGoods != null && listGoods.size() > 0) {
                if (listGoodsBrief.size() > 0) {
                    for (int i = 0; i < listGoods.size(); i++) {
                        long aid = listGoods.get(i).getAuctionId();
                        boolean isRepeat = false;
                        for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) {
                            long auctionId = goodsBrief.getAuctionId();
                            if (auctionId == aid) {
                                isRepeat = true;
                                break;
                            }
                        }
                        if (isRepeat) {
                            listGoods.remove(i);
                            i--;
                        }
                    }
                }
                listGoodsBrief.addAll(listGoods);
            }
        }
        JSONArray array = new JSONArray();
        if (listGoodsBrief.size() > 0) {
            List<Long> listGid = new ArrayList<Long>();
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
                listGid.add(taoBaoGoodsBrief.getAuctionId());
            }
            // API网络接口验证是否在售
            List<TaoBaoGoodsBrief> listTaoKeGoods = null;
            try {
                listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
            } catch (TaoKeApiException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            // 商品信息过滤
            listGoodsBrief = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(listGoodsBrief);
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
                if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                    boolean stateSale = false; // 默认停售
                    Long goodsId = taoBaoGoodsBrief.getAuctionId();
                    for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                        Long auctionId = taoKeGoods.getAuctionId();
                        if (goodsId == auctionId || goodsId.equals(auctionId)) {
                            stateSale = true; // 在售
                            break;
                        }
                    }
                    if (!stateSale) {
                        continue;
                    }
                }
                GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate,
                        shareRate);
                array.add(gson.toJson(goodsDetailVO));
            }
        }
        data.put("count", array.size());
        data.put("list", array);
        out.print(JsonUtil.loadTrueResult(data));
        // 添加到更新列表
        taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
    }
    /**
     * 店铺足迹
     *
     * @param acceptData
     * @param type
     *            精选1, 足迹列表2
     * @param out
     */
    @RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
    public void getHistoryV2(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
        if (type == null) {
            out.print(JsonUtil.loadFalseResult("类型不正确"));
            return;
        }
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult("页码不正确"));
            return;
        }
        int pageSize;
        if (type == 1) {
            pageSize = 4;
        } else {
            pageSize = Constant.PAGE_SIZE;
        }
        long count = 0;
        List<TaoBaoShopHistory> listHistory = null;
        if (uid == null || uid == 0) {
            String device = acceptData.getDevice();
            count = taoBaoShopHistoryService.countByDevice(device);
            if (count > 0) {
                listHistory = taoBaoShopHistoryService.listByDevice((page - 1) * pageSize, pageSize, device);
            }
        } else {
            count = taoBaoShopHistoryService.countByUid(uid);
            if (count > 0) {
                listHistory = taoBaoShopHistoryService.listByUid((page - 1) * pageSize, pageSize, uid);
            }
        }
        List<BrandInfo> list = new ArrayList<BrandInfo>();
        if (listHistory != null && listHistory.size() > 0) {
            for (TaoBaoShopHistory history : listHistory) {
                TaoBaoShop taoBaoShop = history.getTaoBaoShop();
                if (taoBaoShop == null)
                    continue;
                String shopNameCustom = taoBaoShop.getShopNameCustom();
                if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
                    taoBaoShop.setShopName(shopNameCustom);
                }
                String shopIconCustom = taoBaoShop.getShopIconCustom();
                if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
                    taoBaoShop.setShopIcon(shopIconCustom);
                }
                BrandInfo brandInfo = new BrandInfo();
                brandInfo.setId(taoBaoShop.getShopId());
                brandInfo.setName(taoBaoShop.getShopName());
                brandInfo.setIcon(taoBaoShop.getShopIcon());
                list.add(brandInfo);
            }
        }
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("list", JsonUtil.getApiCommonGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -59,6 +59,7 @@
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.OtherInfo;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.search.SearchKeyVO;
import com.yeshi.fanli.vo.tlj.ReduceHongBao;
import net.sf.json.JSONArray;
@@ -166,6 +167,7 @@
            if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion()))
                root.put("scoreExchange", getScoreExchangeInfo(acceptData));
            root.put("searchDiscovery", getSearchDiscoveryInfo(acceptData));
            out.print(JsonUtil.loadTrueResult(root));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "获取数据失败"));
@@ -339,6 +341,46 @@
        root.put("tagImg", "http://img.flqapp.com/resource/score_exchange_tag.png");
        return root;
    }
    /**
     * 金币兑换信息
     *
     * @param acceptData
     * @return
     */
    private JSONObject getSearchDiscoveryInfo(AcceptData acceptData) {
        JSONArray array = new JSONArray();
        String keys = configService.get("search_discovery_keys");
        if (!StringUtil.isNullOrEmpty(keys)) {
            JSONArray arrayKeys = JSONArray.fromObject(keys);
            for (int i = 0; i < arrayKeys.size(); i++) {
                String name = arrayKeys.get(i).toString();
                JSONObject params = new JSONObject();
                params.put("searchKey", name);
                SearchKeyVO keyVO = new SearchKeyVO();
                keyVO.setName(name);
                keyVO.setParams(params.toString());
                array.add(keyVO);
            }
        }
        JSONObject params = new JSONObject();
        params.put("url", "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=204");
        JSONObject root = new JSONObject();
        root.put("picture", "http://img.flqapp.com/resource/home_search_found.png");
        root.put("params", params);
        root.put("jumpDetail", jumpDetailV2Service.getByTypeCache("integralExchange",
                Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion())));
        root.put("jumpResult", jumpDetailV2Service.getByTypeCache("web",
                Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion())));
        root.put("keyList", array);
        return root;
    }
    /**
     * 首页底部商品推荐
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandClassShopServiceImpl.java
@@ -524,4 +524,99 @@
    }
    @Override
    public List<TaoBaoShopVO> listEffectiveShop(long start, int count, Long cid) {
        if (cid != null && cid <= 0) {
            cid = null;
        }
        List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo(start, count, cid);
        if (listInfo == null || listInfo.size() == 0)
            return listInfo;
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        // 淘宝商品信息过滤
        Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
        for (TaoBaoShopVO taoBaoShopVO : listInfo) {
            String shopNameCustom = taoBaoShopVO.getShopNameCustom();
            if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
                taoBaoShopVO.setShopName(shopNameCustom);
            }
            String shopIconCustom = taoBaoShopVO.getShopIconCustom();
            if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
                taoBaoShopVO.setShopIcon(shopIconCustom);
            }
            List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>();
            List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
            // 商品添加到更新队列
            taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
            for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
                GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory
                        .convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), null, fanLiRate, shareRate);
                listGoods.add(goodsDetailVO);
            }
            taoBaoShopVO.setListGoodsVO(listGoods);
        }
        return listInfo;
    }
    @Override
    public long countBrandShopinfo(Long cid) {
        if (cid != null && cid <= 0) {
            cid = null;
        }
        return taoBaoShopService.countBrandShopinfo(cid);
    }
    @Override
    public List<TaoBaoShop> listEffectiveClassShop(Long cid) {
        if (cid == null && cid <= 0)
            return null;
        List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
        if (list == null || list.size() == 0)
            return null;
        List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
        for (BrandClassShop brandClassShop : list) {
            TaoBaoShop shop = brandClassShop.getShop();
            if (shop != null) {
                Integer userType = shop.getUserType();
                if (userType == null || userType == 0) {
                    shop.setUserType(10);
                } else {
                    shop.setUserType(11);
                }
                String shopLink = shop.getShopLink();
                if (StringUtil.isNullOrEmpty(shopLink)) {
                    shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
                }
                String shopNameCustom = shop.getShopNameCustom();
                if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
                    shop.setShopName(shopNameCustom);
                }
                String shopIconCustom = shop.getShopIconCustom();
                if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
                    shop.setShopIcon(shopIconCustom);
                }
                listShop.add(shop);
            }
        }
        return listShop;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandClassShopService.java
@@ -5,7 +5,9 @@
import org.springframework.web.multipart.MultipartFile;
import com.yeshi.fanli.entity.brand.BrandClassShop;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.exception.brand.BrandClassShopException;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
import net.sf.json.JSONObject;
@@ -104,5 +106,27 @@
     * @return
     */
    public JSONObject listEffectiveCacheV2(int page, Long cid);
    /**
     *  兼容2.0
     * @param start
     * @param count
     * @param cid
     * @return
     */
    public List<TaoBaoShopVO> listEffectiveShop(long start, int count, Long cid);
    public long countBrandShopinfo(Long cid);
    /**
     * 分类下店铺
     * @param cid
     * @return
     */
    public List<TaoBaoShop> listEffectiveClassShop(Long cid);
    
}