From 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 11 七月 2019 16:34:13 +0800
Subject: [PATCH] 订单bug,分享爆款自购修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java |   81 ++++++++++++++++++++++++++++++++++------
 1 files changed, 68 insertions(+), 13 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
index a8bea9e..8c86f1f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
@@ -17,9 +17,12 @@
 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.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;
@@ -40,6 +43,12 @@
 
 	@Resource
 	private CommonGoodsService commonGoodsService;
+
+	@Resource
+	private ShareHotGoodsService shareHotGoodsService;
+
+	@Resource
+	private TLJBuyGoodsService tljBuyGoodsService;
 
 	@Override
 	public void startUpdate() {
@@ -69,7 +78,7 @@
 	@Override
 	public void deleteTaoBaoGoods(Long auctionId) {
 		// 鍒犻櫎绮鹃�夊簱鐩稿叧鐨勬暟鎹�
-		qualityFactoryService.deleteByTbAuctionId(auctionId);
+		qualityFactoryService.deleteByTaoBaoGoodsId(auctionId);
 
 		// 鍒犻櫎鍟嗗搧鏈韩鏁版嵁
 		taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
@@ -82,13 +91,17 @@
 		activityService.downTaoBaoGoods(auctionId);
 
 		// 鍒犻櫎绮鹃�夊簱鐩稿叧鐨勬暟鎹�
-		qualityFactoryService.deleteByTbAuctionId(auctionId);
+		qualityFactoryService.deleteByTaoBaoGoodsId(auctionId);
 
 		// 鍒犻櫎鍟嗗搧鏈韩鏁版嵁
 		taoBaoGoodsBriefMapper.deleteByAuctionId(auctionId);
 
 		// 鏇存柊绠�鐗堝晢鍝佺姸鎬佷负涓嬫灦
 		commonGoodsService.offlineCommonGoods(auctionId, CommonGoods.GOODS_TYPE_TB);
+
+		// 鍒嗕韩鐖嗘鏁版嵁鍒犻櫎
+		shareHotGoodsService.deleteByGoodsId(auctionId);
+
 	}
 
 	@Transactional
@@ -107,18 +120,22 @@
 			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
@@ -195,18 +212,56 @@
 		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);
+		}
+	}
 }

--
Gitblit v1.8.0