admin
2024-01-23 81da61b828e29b7745e1382dfbbaeb685dc083ef
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
@@ -99,7 +99,7 @@
    @Transactional
    @Override
    public void deleteTaoBaoGoods(Long auctionId) {
    public void deleteTaoBaoGoods(String auctionId) {
        // 删除精选库相关的数据
        qualityFactoryGoodsUpdateService.deleteByTaoBaoGoodsId(auctionId);
@@ -109,7 +109,7 @@
    @Transactional
    @Override
    public void offlineTaoBaoGoods(Long auctionId) {
    public void offlineTaoBaoGoods(String auctionId) {
        // 更新动态数据
        activityGoodsUpdateService.downTaoBaoGoods(auctionId);
@@ -134,7 +134,7 @@
        if (goods == null)
            throw new TaobaoGoodsUpdateException(1, "商品为空");
        if (goods.getAuctionId() == null || goods.getAuctionId() == 0)
        if (StringUtil.isNullOrEmpty( goods.getAuctionId()))
            throw new TaobaoGoodsUpdateException(2, "商品ID为空");
        // 设置商品正常上线
@@ -146,7 +146,7 @@
            e.printStackTrace();
        }
        TaoBaoGoodsBrief tb = taoBaoGoodsBriefMapper.selectByPrimaryKey(goods.getAuctionId());
        TaoBaoGoodsBrief tb = taoBaoGoodsBriefMapper.selectOneByAuctionId(goods.getAuctionId());
        if (tb != null) {
            goods.setId(tb.getId());
            TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods);
@@ -174,9 +174,9 @@
    @Override
    public void deleteOutOfDate() {
        List<Long> list = taoBaoGoodsBriefMapper
        List<String> list = taoBaoGoodsBriefMapper
                .queryCanDeleteGoods(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 2), 0, 2000);
        for (Long auctionId : list) {
        for (String auctionId : list) {
            deleteTaoBaoGoods(auctionId);
        }
    }
@@ -259,25 +259,25 @@
    }
    @Override
    public List<Long> listNeedUpdateGoodsId(long start, int count, int hour) {
    public List<String> listNeedUpdateGoodsId(long start, int count, int hour) {
        return taoBaoGoodsBriefMapper.listNeedUpdateGoodsId(start, count, hour);
    }
    @Override
    public void updateByTaoKeGoodsDetail(Long id) {
    public void updateByTaoKeGoodsDetail(String goodsId) {
        try {
            TaoBaoGoodsBrief oldGoods = taoBaoGoodsBriefMapper.selectByPrimaryKey(id);
            TaoBaoGoodsBrief oldGoods = taoBaoGoodsBriefMapper.selectOneByAuctionId(goodsId);
            if (oldGoods == null) {
                return;
            }
            TaoBaoGoodsBrief newGoods = TaoKeApiUtil.searchGoodsDetail(id);
            TaoBaoGoodsBrief newGoods = TaoKeApiUtil.searchGoodsDetail(oldGoods.getAuctionId());
            if (newGoods == null) {
                return;
            }
            // 更新精选商品
            newGoods.setId(id);
            newGoods.setId(oldGoods.getId());
            TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(newGoods);
            taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(updateGoods);
@@ -292,7 +292,7 @@
            }
        } catch (TaobaoGoodsDownException e) {
            offlineTaoBaoGoods(id);
            offlineTaoBaoGoods(goodsId);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
@@ -310,15 +310,14 @@
            return;
        }
        goods.setUpdatetime(new Date());
        if (goods.getId() == null)
            goods.setId(goods.getAuctionId());
        goods.setMid(goods.getAuctionId());
        taoBaoGoodsUpdateDao.save(goods);
        taoBaoGoodsCacheUtil.addUpdateHistory(goods.getAuctionId());
    }
    @Async
    @Override
    public void addUpdateQueueAsync(Long auctionId) {
    public void addUpdateQueueAsync(String auctionId) {
        addUpdateQueueSync(auctionId);
    }
@@ -327,7 +326,7 @@
     *
     * @param auctionId
     */
    private void addUpdateQueueSync(Long auctionId) {
    private void addUpdateQueueSync(String auctionId) {
        try {
            if (taoBaoGoodsCacheUtil.canAddToUpdateQueue(auctionId)) {
                // 添加到更新队列
@@ -354,7 +353,7 @@
        // 商品过滤不允许出错
        try {
            Map<Long, TaoBaoGoodsBrief> finalMap = new HashMap<>();
            Map<String, TaoBaoGoodsBrief> finalMap = new HashMap<>();
            // 原始数据全覆盖
            for (TaoBaoGoodsBrief goods : goodsList) {
                finalMap.put(goods.getAuctionId(), goods);
@@ -373,11 +372,15 @@
            }
            // 再从mongodb中取覆盖
            List<Long> auctionIds = new ArrayList<>();
            List<String> auctionIds = new ArrayList<>();
            for (TaoBaoGoodsBrief goods : tempGoodsList) {
                auctionIds.add(goods.getAuctionId());
            }
            List<TaoBaoGoodsBrief> mList = taoBaoGoodsUpdateDao.listByAuctionIds(auctionIds);
            List<TaoBaoGoodsBrief> mList =null;
            try {
                mList = taoBaoGoodsUpdateDao.listByAuctionIds(auctionIds);
            }catch(Exception e){
            }
            if (mList != null)
                for (TaoBaoGoodsBrief goods : mList) {
                    if (goods.getUpdatetime().getTime() > System.currentTimeMillis() - 1000 * 60 * 60 * 24L)// 在1天内更新的数据才参与过滤
@@ -412,7 +415,7 @@
        // 商品过滤不允许出错
        try {
            Map<Long, CommonGoods> finalMap = new HashMap<>();
            Map<String, CommonGoods> finalMap = new HashMap<>();
            // 原始数据全覆盖
            List<CommonGoods> tempGoodsList = new ArrayList<>();
            for (CommonGoods goods : goodsList) {
@@ -433,7 +436,7 @@
            }
            // 再从mongodb中取覆盖
            List<Long> auctionIds = new ArrayList<>();
            List<String> auctionIds = new ArrayList<>();
            for (CommonGoods goods : tempGoodsList) {
                auctionIds.add(goods.getGoodsId());
            }