| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefMapper;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | 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.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsService;
|
| | | 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.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | |
| | | private TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsService collectionGoodsService;
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Override
|
| | | public void startUpdate() {
|
| | |
| | | }
|
| | |
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | downTaoBaoGoods(goods.getAuctionId());
|
| | | offlineTaoBaoGoods(goods.getAuctionId());
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void downTaoBaoGoods(Long auctionId) {
|
| | | public void offlineTaoBaoGoods(Long auctionId) {
|
| | | // 删除首页推荐数据
|
| | | recommendSectionGoodsService.deleteRecommendSectionGoodsByTbAuctionId(auctionId);
|
| | | // 更新动态数据
|
| | |
| | |
|
| | | // 删除商品本身数据
|
| | | taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
|
| | |
|
| | | // 更新简版商品状态为下架
|
| | | commonGoodsService.offlineCommonGoods(auctionId, CommonGoods.GOODS_TYPE_TB);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | if (goods.getAuctionId() == null || goods.getAuctionId() == 0)
|
| | | throw new TaobaoGoodsUpdateException(2, "商品ID为空");
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsBriefMapper.queryByAuctionId(goods.getAuctionId());
|
| | | if (goodsList == null || goodsList.size() == 0)
|
| | | throw new TaobaoGoodsUpdateException(3, "商品不在商品库中");
|
| | |
|
| | | for (TaoBaoGoodsBrief tb : goodsList) {
|
| | | goods.setId(tb.getId());
|
| | | TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods);
|
| | | System.out.println("更细信息:" + new Gson().toJson(updateGoods));
|
| | | taoBaoGoodsBriefMapper.updateByPrimaryKeySelective(updateGoods);
|
| | | // 更新收藏信息
|
| | | collectionGoodsService.updateCollectionGoods(goods);
|
| | | // 更新收藏信息
|
| | | try {
|
| | | commonGoodsService.updateCommonGoods(CommonGoodsFactory.create(goods));
|
| | | } catch (CommonGoodsException e) {
|
| | | 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);
|
| | |
|
| | | }
|
| | |
|
| | | // 更新动态商品
|
| | | activityService.updateRecommendActivityGoods(goods);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | @Override
|
| | | public void updateTaoBaoGoods(List<TaoBaoGoodsBrief> goodsList) throws TaobaoGoodsUpdateException {
|
| | | if (goodsList == null)
|
| | | return;
|
| | | if (goodsList == null || goodsList.size() == 0)
|
| | | throw new TaobaoGoodsUpdateException(1, "商品列表为空");
|
| | |
|
| | | List<TaoBaoGoodsBrief> updateList = new ArrayList<>();
|
| | |
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | | if (goods.getId() == null || goods.getId() == 0L)
|
| | |
|
| | | if (goods.getId() == null || goods.getId() == 0L) {
|
| | | throw new TaobaoGoodsUpdateException(1, "商品主键ID为空");
|
| | | updateList.add(goods);
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief updateGoods = getUpdateTaoBaoGoodsBrief(goods);
|
| | | updateGoods.setCreatetime(goods.getCreatetime());
|
| | |
|
| | | updateList.add(updateGoods);
|
| | | }
|
| | |
|
| | | taoBaoGoodsBriefMapper.updateBatchSelective(updateList);
|
| | | }
|
| | |
|