| | |
| | | import com.yeshi.fanli.exception.goods.CommonGoodsException;
|
| | | 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.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | |
|
| | | @Service
|
| | | public class TaoBaoGoodsUpdateServiceImpl implements TaoBaoGoodsUpdateService {
|
| | | @Resource
|
| | | private RecommendSectionGoodsService recommendSectionGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ActivityService activityService;
|
| | |
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | @Override
|
| | | public void startUpdate() {
|
| | |
| | | }
|
| | |
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | offlineTaoBaoGoods(goods.getAuctionId());
|
| | | offlineTaoBaoGoods(goods.getAuctionId());
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
| | | @Transactional
|
| | | @Override
|
| | | public void deleteTaoBaoGoods(Long auctionId) {
|
| | | // 删除首页推荐数据
|
| | | recommendSectionGoodsService.deleteRecommendSectionGoodsByTbAuctionId(auctionId);
|
| | |
|
| | | // 删除精选库相关的数据
|
| | | qualityFactoryService.deleteByTbAuctionId(auctionId);
|
| | | qualityFactoryService.deleteByTaoBaoGoodsId(auctionId);
|
| | |
|
| | | // 删除商品本身数据
|
| | | taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void offlineTaoBaoGoods(Long auctionId) {
|
| | | // 删除首页推荐数据
|
| | | recommendSectionGoodsService.deleteRecommendSectionGoodsByTbAuctionId(auctionId);
|
| | | public void offlineTaoBaoGoods(Long auctionId) {
|
| | | // 更新动态数据
|
| | | activityService.downTaoBaoGoods(auctionId);
|
| | |
|
| | | // 删除精选库相关的数据
|
| | | qualityFactoryService.deleteByTbAuctionId(auctionId);
|
| | | qualityFactoryService.deleteByTaoBaoGoodsId(auctionId);
|
| | |
|
| | | // 删除商品本身数据
|
| | | taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
|
| | |
|
| | | // 更新简版商品状态为下架
|
| | | commonGoodsService.offlineCommonGoods(auctionId, CommonGoods.GOODS_TYPE_TB);
|
| | |
|
| | | // 分享爆款数据删除
|
| | | shareHotGoodsService.deleteByGoodsId(auctionId);
|
| | |
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | if (goods.getAuctionId() == null || goods.getAuctionId() == 0)
|
| | | throw new TaobaoGoodsUpdateException(2, "商品ID为空");
|
| | |
|
| | | // 设置商品正常上线
|
| | | goods.setState(0);
|
| | | // 更新收藏信息
|
| | | try {
|
| | | commonGoodsService.updateCommonGoods(CommonGoodsFactory.create(goods));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsBriefMapper.queryByAuctionId(goods.getAuctionId());
|
| | | if (goodsList != null)
|
| | | for (TaoBaoGoodsBrief tb : goodsList) {
|
| | | goods.setId(tb.getId());
|
| | | TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods);
|
| | | System.out.println("更细信息:" + new Gson().toJson(updateGoods));
|
| | | taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(updateGoods);
|
| | | TaoBaoGoodsBrief tb = taoBaoGoodsBriefMapper.selectByPrimaryKey(goods.getAuctionId());
|
| | | if (tb != null) {
|
| | | goods.setId(tb.getId());
|
| | | TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods);
|
| | | System.out.println("更细信息:" + new Gson().toJson(updateGoods));
|
| | | taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(updateGoods);
|
| | | }
|
| | |
|
| | | }
|
| | | // 更新动态商品
|
| | | activityService.updateRecommendActivityGoods(goods);
|
| | |
|
| | | // 更新分享库的商品
|
| | | shareHotGoodsService.updateShareGoods(goods);
|
| | |
|
| | | // 更新自购立减库商品
|
| | | tljBuyGoodsService.updateGoods(goods);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteOutOfDate() {
|
| | | TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper = BeanUtil.getBean(TaoBaoGoodsBriefMapper.class);
|
| | | List<Long> list = taoBaoGoodsBriefMapper
|
| | | .queryCanDeleteGoods(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 2), 0, 2000);
|
| | | for (Long auctionId : list) {
|
| | |
| | | // 更新标题,商品图片,销量,价格,券信息,返利信息,店铺信息,分类信息
|
| | | updateGoods.setTitle(goods.getTitle());
|
| | | updateGoods.setPictUrl(goods.getPictUrl());
|
| | | updateGoods.setPictUrlWhite(goods.getPictUrlWhite());
|
| | | updateGoods.setImgList(goods.getImgList());
|
| | | updateGoods.setBiz30day(goods.getBiz30day());
|
| | | updateGoods.setZkPrice(goods.getZkPrice());
|
| | |
| | | updateGoods.setRootCategoryName(goods.getRootCategoryName());
|
| | | updateGoods.setLeafCatId(goods.getLeafCatId());
|
| | | updateGoods.setLeafName(goods.getLeafName());
|
| | | updateGoods.setMaterialLibType(goods.getMaterialLibType());
|
| | |
|
| | | return updateGoods;
|
| | | }
|
| | |
| | | List<TaoBaoGoodsBrief> updateList = new ArrayList<>();
|
| | |
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | |
|
| | | if (goods.getId() == null || goods.getId() == 0L) {
|
| | | throw new TaobaoGoodsUpdateException(1, "商品主键ID为空");
|
| | | }
|
| | |
|
| | | // 需要更新的信息
|
| | | TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods);
|
| | | updateGoods.setCreatetime(goods.getCreatetime());
|
| | |
|
| | | updateList.add(updateGoods);
|
| | | }
|
| | |
|
| | | taoBaoGoodsBriefMapper.updateBatchSelective(updateList);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> listNeedUpdateGoodsId(long start, int count, int hour) {
|
| | | return taoBaoGoodsBriefMapper.listNeedUpdateGoodsId(start, count, hour);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateByTaoKeGoodsDetail(Long id) {
|
| | | try {
|
| | | TaoBaoGoodsBrief oldGoods = taoBaoGoodsBriefMapper.selectByPrimaryKey(id);
|
| | | if (oldGoods == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief newGoods = TaoKeApiUtil.searchGoodsDetail(id);
|
| | | if (newGoods == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // 更新精选商品
|
| | | newGoods.setId(id);
|
| | | TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(newGoods);
|
| | | taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(updateGoods);
|
| | |
|
| | | // 更新动态商品
|
| | | activityService.updateRecommendActivityGoods(newGoods);
|
| | |
|
| | | // 更新收藏信息
|
| | | try {
|
| | | commonGoodsService.updateCommonGoods(CommonGoodsFactory.create(newGoods));
|
| | | } catch (CommonGoodsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | offlineTaoBaoGoods(id);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|