From da172401669413a57b92c681740056dfd75d295e Mon Sep 17 00:00:00 2001
From: yj <Administrator@192>
Date: 星期二, 10 三月 2020 12:07:52 +0800
Subject: [PATCH] 动态商品信息更新

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |  134 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 113 insertions(+), 21 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
index c252c6d..2ca96d5 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -70,6 +70,7 @@
 import com.yeshi.fanli.util.jd.JDApiUtil;
 import com.yeshi.fanli.util.jd.JDUtil;
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
+import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
 import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -355,10 +356,8 @@
 		GoodsDetailVO goodsDetailVO = null;
 		JDGoods jdGoods = null;
 		PDDGoodsDetail pddGoods = null;
-		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
-		ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate);
+		ConfigParamsDTO params = hongBaoManageService.getShowComputeRate("android", "55");
+		params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
 		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
 			try {
 				TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
@@ -567,10 +566,8 @@
 
 	public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType) throws GoodsEvaluateException {
 		GoodsDetailVO goodsDetail = null;
-		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-		BigDecimal shareRate = hongBaoManageService.getShareRate();
-		BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
-		ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate);
+		ConfigParamsDTO params = hongBaoManageService.getShowComputeRate("android", "55");
+		params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
 		if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
 			try {
 				TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
@@ -1560,7 +1557,11 @@
 								commentInfoNew.setTagList(tagListNew);
 								commentNew.add(commentInfoNew);
 								continue;
+							} else {
+								continue;
 							}
+						} else {
+							continue;
 						}
 					}
 
@@ -1626,11 +1627,8 @@
 		try {
 			Date now = new Date();
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-			BigDecimal shareRate = hongBaoManageService.getShareRate();
-			BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
-			ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
-					vipFanLiRate);
+			ConfigParamsDTO params = hongBaoManageService.getShowComputeRate("android", "55");
+			params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
 			for (GoodsEvaluate goodsEvaluate : list) {
 				// 鏄惁2涓皬鏃朵箣鍐呭凡鏇存柊
 				Date updateTime = goodsEvaluate.getUpdateTime();
@@ -1667,7 +1665,7 @@
 
 				GoodsDetailVO goods = goodsEvaluate.getGoods();
 				if (goods != null) {
-					GoodsDetailVO goodsNew = getGoodsNewInfo(goods.getGoodsId(), goods.getGoodsType(), paramsDTO);
+					GoodsDetailVO goodsNew = getGoodsNewInfo(goods.getGoodsId(), goods.getGoodsType(), params);
 					if (goodsNew != null) {
 						goodsEvaluate.setGoods(goodsNew);
 					} else {
@@ -1689,7 +1687,7 @@
 					}
 
 					GoodsDetailVO goodsDetailVO = getGoodsNewInfo(simpleGoods.getGoodsId(), simpleGoods.getGoodsType(),
-							paramsDTO);
+							params);
 					if (goodsDetailVO != null) {
 						simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
 						simpleGoods.setState(0);
@@ -1712,7 +1710,7 @@
 						}
 					}
 				}
-
+				goodsEvaluate.setImgList(imgList);
 				goodsEvaluate.setUpdateTime(new Date());
 				goodsEvaluateDao.save(goodsEvaluate);
 			}
@@ -1892,11 +1890,9 @@
 				return false;
 			}
 
-			BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-			BigDecimal shareRate = hongBaoManageService.getShareRate();
-			BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
-			ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate);
-			GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params);
+			ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
+			paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+			GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
 			// 鍙戝竷鐢ㄦ埛
 			ActivityUser user = activityUserService.getRandomByDaTaoKeCid(daTaoKe.getCid());
 
@@ -2164,4 +2160,100 @@
 		}
 		return true;
 	}
+	
+	@Override
+	public void updateTaoBaoGoods(TaoBaoGoodsBrief goods) {
+		try {
+			if (goods == null) {
+				return;
+			}
+			List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_TAOBAO, goods.getAuctionId());
+			if (queryExist == null || queryExist.size() == 0) {
+				return;
+			}
+			
+			ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
+			paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+			GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
+			updateGoods(queryExist, goodsNew);
+		
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	@Override
+	public void updateJDGoods(JDGoods jdGoods) {
+		if (jdGoods == null) {
+			return;
+		}
+		List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_JD, jdGoods.getSkuId());
+		if (queryExist == null || queryExist.size() == 0) {
+			return;
+		}
+		
+		ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
+		paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+		GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
+		updateGoods(queryExist, goodsNew);
+	}
+	
+	@Override
+	public void updatePDDGoods(PDDGoodsDetail pddGoods) {
+		if (pddGoods == null) {
+			return;
+		}
+		List<GoodsEvaluate> queryExist = goodsEvaluateDao.queryExist(Constant.SOURCE_TYPE_PDD, pddGoods.getGoodsId());
+		if (queryExist == null || queryExist.size() == 0) {
+			return;
+		}
+		
+		ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
+		paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
+		GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
+		updateGoods(queryExist, goodsNew);
+	}
+	
+	private void updateGoods(List<GoodsEvaluate> listExist, GoodsDetailVO goodsNew) {
+		long goodsId = goodsNew.getGoodsId();
+		int goodsType = goodsNew.getGoodsType();
+		for (GoodsEvaluate goodsEvaluate: listExist) {
+			GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
+			if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null 
+				&& goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType ) {
+				goodsEvaluate.setGoods(goodsNew);
+			}
+			
+			// 鏇存柊鍟嗗搧淇℃伅
+			List<ImgInfo> imgList = goodsEvaluate.getImgList();
+			if (imgList == null || imgList.size() == 0) {
+				continue;
+			}
+
+			for (ImgInfo imgInfo : imgList) {
+				SimpleGoods simpleGoods = imgInfo.getGoods();
+				if (simpleGoods == null) {
+					continue;
+				}
+
+				simpleGoods.setState(0);
+				simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
+				CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
+				if (couponInfo == null) {
+					simpleGoods.setPrice(goodsDetailVO.getZkPrice());
+				} else {
+					simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
+					simpleGoods.setAmount(couponInfo.getAmount());
+				}
+				imgInfo.setGoods(simpleGoods);
+				imgInfo.setGoodsVO(goodsDetailVO);
+			}
+			
+			goodsEvaluate.setImgList(imgList);
+			goodsEvaluate.setUpdateTime(new Date());
+			goodsEvaluateDao.save(goodsEvaluate);
+		}
+	}
+	
+	
 }

--
Gitblit v1.8.0