| | |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | |
| | | public class TaoBaoGoodsUpdateServiceImpl implements TaoBaoGoodsUpdateService {
|
| | |
|
| | | @Resource
|
| | | private ActivityService activityService;
|
| | | private ActivityGoodsUpdateService activityGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private QualityFactoryGoodsUpdateService qualityFactoryGoodsUpdateService;
|
| | |
| | | @Override
|
| | | public void offlineTaoBaoGoods(Long auctionId) {
|
| | | // 更新动态数据
|
| | | activityService.downTaoBaoGoods(auctionId);
|
| | | activityGoodsUpdateService.downTaoBaoGoods(auctionId);
|
| | |
|
| | | // 删除精选库相关的数据
|
| | | qualityFactoryGoodsUpdateService.deleteByTaoBaoGoodsId(auctionId);
|
| | |
| | | }
|
| | |
|
| | | // 更新动态商品
|
| | | activityService.updateRecommendActivityGoods(goods);
|
| | | activityGoodsUpdateService.updateRecommendActivityGoods(goods);
|
| | |
|
| | | // 更新分享库的商品
|
| | | shareHotGoodsService.updateShareGoods(goods);
|
| | |
| | | taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(updateGoods);
|
| | |
|
| | | // 更新动态商品
|
| | | activityService.updateRecommendActivityGoods(newGoods);
|
| | | activityGoodsUpdateService.updateRecommendActivityGoods(newGoods);
|
| | |
|
| | | // 更新收藏信息
|
| | | try {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TaoBaoGoodsBrief> filterTaoBaoGoods(List<TaoBaoGoodsBrief> goodsList) {
|
| | | Map<Long, TaoBaoGoodsBrief> finalMap = new HashMap<>();
|
| | | // 原始数据全覆盖
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | | finalMap.put(goods.getAuctionId(), goods);
|
| | | }
|
| | | public List<TaoBaoGoodsBrief> filterImportantTaoBaoGoods(List<TaoBaoGoodsBrief> goodsList) {
|
| | |
|
| | | List<TaoBaoGoodsBrief> tempGoodsList = new ArrayList<>();
|
| | | tempGoodsList.addAll(goodsList);
|
| | | // 先从redis里面取覆盖
|
| | | for (int i = 0; i < tempGoodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(tempGoodsList.get(i).getAuctionId());
|
| | | if (goods != null) {
|
| | | finalMap.put(goods.getAuctionId(), goods);
|
| | | tempGoodsList.remove(i--);
|
| | | }
|
| | | }
|
| | |
|
| | | // 再从mongodb中取覆盖
|
| | | List<Long> auctionIds = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief goods : tempGoodsList) {
|
| | | auctionIds.add(goods.getAuctionId());
|
| | | }
|
| | | List<TaoBaoGoodsBrief> mList = taoBaoGoodsUpdateDao.listByAuctionIds(auctionIds);
|
| | | if (mList != null)
|
| | | for (TaoBaoGoodsBrief goods : mList) {
|
| | | // 商品过滤不允许出错
|
| | | try {
|
| | | Map<Long, TaoBaoGoodsBrief> finalMap = new HashMap<>();
|
| | | // 原始数据全覆盖
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | | finalMap.put(goods.getAuctionId(), goods);
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> finalList = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief goods : goodsList)
|
| | | finalList.add(finalMap.get(goods.getAuctionId()));
|
| | | List<TaoBaoGoodsBrief> tempGoodsList = new ArrayList<>();
|
| | | tempGoodsList.addAll(goodsList);
|
| | | // 先从redis里面取覆盖
|
| | | for (int i = 0; i < tempGoodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil
|
| | | .getCommonTaoBaoGoodsInfo(tempGoodsList.get(i).getAuctionId());
|
| | | if (goods != null) {
|
| | | finalMap.put(goods.getAuctionId(), goods);
|
| | | tempGoodsList.remove(i--);
|
| | | }
|
| | | }
|
| | |
|
| | | return finalList;
|
| | | // 再从mongodb中取覆盖
|
| | | List<Long> auctionIds = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief goods : tempGoodsList) {
|
| | | auctionIds.add(goods.getAuctionId());
|
| | | }
|
| | | List<TaoBaoGoodsBrief> mList = taoBaoGoodsUpdateDao.listByAuctionIds(auctionIds);
|
| | | if (mList != null)
|
| | | for (TaoBaoGoodsBrief goods : mList) {
|
| | | if (goods.getUpdatetime().getTime() > System.currentTimeMillis() - 1000 * 60 * 60 * 24L)// 在1天内更新的数据才参与过滤
|
| | | finalMap.put(goods.getAuctionId(), goods);
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> finalList = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | | TaoBaoGoodsBrief newGoods = finalMap.get(goods.getAuctionId());
|
| | | // 过滤价格,返利比例,券信息
|
| | | goods.setZkPrice(newGoods.getZkPrice());
|
| | | goods.setTkRate(newGoods.getTkRate());
|
| | | goods.setCouponAmount(newGoods.getCouponAmount());
|
| | | goods.setCouponActivityId(newGoods.getCouponActivityId());
|
| | | goods.setCouponEffectiveEndTime(newGoods.getCouponEffectiveEndTime());
|
| | | goods.setCouponEffectiveStartTime(newGoods.getCouponEffectiveStartTime());
|
| | | goods.setCouponStartFee(newGoods.getCouponStartFee());
|
| | | goods.setCouponTotalCount(newGoods.getCouponTotalCount());
|
| | | goods.setCouponLeftCount(newGoods.getCouponLeftCount());
|
| | |
|
| | | finalList.add(goods);
|
| | | }
|
| | | return finalList;
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int listAndRemoveByMaxUpdateTime(Date maxTime, int page, int pageSize) {
|
| | | return taoBaoGoodsUpdateDao.listAndRemoveByMaxUpdateTime(maxTime, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByMaxUpdateTime(Date maxTime) {
|
| | | return taoBaoGoodsUpdateDao.countByMaxUpdateTime(maxTime);
|
| | |
|
| | | }
|
| | |
|
| | | }
|