From 9b5fa0ca42546a8ad1cdb19957612f2c9ab3a3b2 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 24 三月 2020 11:41:07 +0800
Subject: [PATCH] 单品上传图片

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java |   90 +++++++++++++++++++++++++++++---------------
 1 files changed, 59 insertions(+), 31 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 40a472d..8b4e77d 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
@@ -329,21 +329,29 @@
 		}
 
 		// 缂栬緫鍥剧墖
-		List<String> listpic = null;
+		List<String> listpic = new ArrayList<>();
 		if (!StringUtil.isNullOrEmpty(picUrls)) {
 			String[] pics = picUrls.split(",");
 			if (pics != null) {
-				listpic = new ArrayList<>();
 				for (int i = 0; i < pics.length; i++) {
 					String picLink = pics[i];
-					if (fileRequest != null) {
-						MultipartFile file = fileRequest.getFile("file" + i);
-						if (file != null) {
-							picLink = uploadPicture(file);
-						}
-
-					}
 					if (picLink.startsWith("http")) {
+						listpic.add(picLink);
+					}
+				}
+			}
+		}
+		
+		
+		// 涓婁紶鏂囦欢鏇挎崲
+		if (fileRequest != null) {
+			for (int i = 0; i < 9; i++) {
+				MultipartFile file = fileRequest.getFile("file" + i);
+				if (file != null) {
+					String picLink = uploadPicture(file);
+					if (i < listpic.size()) {
+						listpic.set(i, picLink);
+					} else {
 						listpic.add(picLink);
 					}
 				}
@@ -490,9 +498,15 @@
 				String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl,
 						JDApiUtil.POSITION_SHARE + "", "1");
 				String template = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey());
+				if (jumpLink == null) {
+					throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�");
+				}
 				commentText = template.replace("[閾炬帴]", jumpLink);
 			} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
 				String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", "1");
+				if (jumpLink == null) {
+					throw new GoodsEvaluateException(1, "璇ュ晢鍝佽浆閾惧け璐�");
+				}
 				String template = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey());
 				commentText = template.replace("[閾炬帴]", jumpLink);
 			}
@@ -1517,7 +1531,11 @@
 		executor.execute(new Runnable() {
 			@Override
 			public void run() {
+				// 鏇存柊淇℃伅
 				updateGoodInfo(list);
+				
+				// 鍒犻櫎宸茶繃鏈�
+				removeOverdue();
 			}
 		});
 
@@ -1664,6 +1682,9 @@
 			@Override
 			public void run() {
 				updateGoodInfo(listOBJ);
+				
+				// 鍒犻櫎宸茶繃鏈�
+				removeOverdue();
 			}
 		});
 
@@ -2286,13 +2307,8 @@
 		for (GoodsEvaluate goodsEvaluate: listExist) {
 			GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
 			if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null 
-				&& goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType ) {
-				if (goodsDetailVO.getTitle().equalsIgnoreCase(goodsNew.getTitle())) {
-					goodsEvaluate.setGoods(goodsNew);
-				} else {
-					goodsEvaluate.setState(1);
-					goodsEvaluate.setRemarks("鍟嗗搧鏍囬鍙戠敓鍙樺寲涓嬫灦锛�" + goodsDetailVO.getTitle() +" / 鏂帮細" + goodsNew.getTitle());
-				}
+				&& goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType) {
+				goodsEvaluate.setGoods(goodsNew);
 			}
 			
 			// 鏇存柊鍟嗗搧淇℃伅
@@ -2308,26 +2324,19 @@
 					continue;
 				}
 
-				GoodsDetailVO goodsVO = imgInfo.getGoodsVO();
-				if (goodsVO != null) {
-					if (goodsVO.getTitle().equalsIgnoreCase(goodsNew.getTitle())) {
-						simpleGoods.setState(0);
-					} else {
-						simpleGoods.setState(1);
-						simpleGoods.setRemarks("鍟嗗搧鏍囬鍙戠敓鍙樺寲涓嬫灦锛�" + goodsVO.getTitle() +" / 鏂帮細" + goodsNew.getTitle());
-					}
-				}
 				
-				simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
-				CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
+				simpleGoods.setState(0);
+				simpleGoods.setPrice(goodsNew.getCouponPrice());
+				CouponInfoVO couponInfo = goodsNew.getCouponInfo();
 				if (couponInfo == null) {
-					simpleGoods.setPrice(goodsDetailVO.getZkPrice());
+					simpleGoods.setPrice(goodsNew.getZkPrice());
 				} else {
-					simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
+					simpleGoods.setPrice(goodsNew.getCouponPrice());
 					simpleGoods.setAmount(couponInfo.getAmount());
 				}
+				
 				imgInfo.setGoods(simpleGoods);
-				imgInfo.setGoodsVO(goodsDetailVO);
+				imgInfo.setGoodsVO(goodsNew);
 			}
 			
 			goodsEvaluate.setImgList(imgList);
@@ -2336,5 +2345,24 @@
 		}
 	}
 	
-	
+	private void removeOverdue() {
+		List<GoodsEvaluate> list = goodsEvaluateDao.queryOverdue();
+		if (list == null || list.size() == 0) {
+			return;
+		}
+		long nm = 1000 * 60;// 涓�鍒嗛挓鐨勬绉掓暟
+		long nh = 1000 * 60 * 60;// 涓�灏忔椂鐨勬绉掓暟
+		long nd = 1000 * 24 * 60 * 60;// 涓�澶╃殑姣鏁�
+		
+		long time = java.lang.System.currentTimeMillis();
+		for (GoodsEvaluate goodsEvaluate: list) {
+			long diff = time - goodsEvaluate.getEndTime().getTime();
+			long min = diff % nd % nh / nm; 
+			
+			// 杩囨湡瓒呰繃10鍒嗛挓灏卞垹闄�
+			if (min > 10) {
+				goodsEvaluateDao.remove(goodsEvaluate);
+			}
+		}
+	}
 }

--
Gitblit v1.8.0