| | |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void deleteTaoBaoGoods(Long auctionId) { |
| | | public void deleteTaoBaoGoods(String auctionId) { |
| | | // 删除精选库相关的数据 |
| | | qualityFactoryGoodsUpdateService.deleteByTaoBaoGoodsId(auctionId); |
| | | |
| | |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void offlineTaoBaoGoods(Long auctionId) { |
| | | public void offlineTaoBaoGoods(String auctionId) { |
| | | // 更新动态数据 |
| | | activityGoodsUpdateService.downTaoBaoGoods(auctionId); |
| | | |
| | |
| | | if (goods == null) |
| | | throw new TaobaoGoodsUpdateException(1, "商品为空"); |
| | | |
| | | if (goods.getAuctionId() == null || goods.getAuctionId() == 0) |
| | | if (StringUtil.isNullOrEmpty( goods.getAuctionId())) |
| | | throw new TaobaoGoodsUpdateException(2, "商品ID为空"); |
| | | |
| | | // 设置商品正常上线 |
| | |
| | | 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); |
| | |
| | | |
| | | @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); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @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); |
| | | |
| | |
| | | } |
| | | |
| | | } catch (TaobaoGoodsDownException e) { |
| | | offlineTaoBaoGoods(id); |
| | | offlineTaoBaoGoods(goodsId); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param auctionId |
| | | */ |
| | | private void addUpdateQueueSync(Long auctionId) { |
| | | private void addUpdateQueueSync(String auctionId) { |
| | | try { |
| | | if (taoBaoGoodsCacheUtil.canAddToUpdateQueue(auctionId)) { |
| | | // 添加到更新队列 |
| | |
| | | |
| | | // 商品过滤不允许出错 |
| | | try { |
| | | Map<Long, TaoBaoGoodsBrief> finalMap = new HashMap<>(); |
| | | Map<String, TaoBaoGoodsBrief> finalMap = new HashMap<>(); |
| | | // 原始数据全覆盖 |
| | | for (TaoBaoGoodsBrief goods : goodsList) { |
| | | finalMap.put(goods.getAuctionId(), goods); |
| | |
| | | } |
| | | |
| | | // 再从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天内更新的数据才参与过滤 |
| | |
| | | |
| | | // 商品过滤不允许出错 |
| | | try { |
| | | Map<Long, CommonGoods> finalMap = new HashMap<>(); |
| | | Map<String, CommonGoods> finalMap = new HashMap<>(); |
| | | // 原始数据全覆盖 |
| | | List<CommonGoods> tempGoodsList = new ArrayList<>(); |
| | | for (CommonGoods goods : goodsList) { |
| | |
| | | } |
| | | |
| | | // 再从mongodb中取覆盖 |
| | | List<Long> auctionIds = new ArrayList<>(); |
| | | List<String> auctionIds = new ArrayList<>(); |
| | | for (CommonGoods goods : tempGoodsList) { |
| | | auctionIds.add(goods.getGoodsId()); |
| | | } |