| | |
| | | + type; |
| | | return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); |
| | | } |
| | | |
| | | private String uploadPicture(File file,String contentType) throws Exception { |
| | | |
| | | private ImgInfo uploadVideoPicture(MultipartFile filevideo) { |
| | | try { |
| | | File tempFile = new File(FileUtil.getCacheDir() + "/" + filevideo.getOriginalFilename()); |
| | | if (tempFile.exists()) |
| | | tempFile.delete(); |
| | | tempFile.createNewFile(); |
| | | filevideo.transferTo(tempFile); |
| | | File destFile = new File(FileUtil.getCacheDir() + "/temp_" + filevideo.getOriginalFilename()); |
| | | // 裁剪视频封面,宽高比为2:1 |
| | | ImageCropUtil.centerCrop(tempFile, destFile, 2.0f); |
| | | BufferedImage sourceImg = ImageIO.read(new FileInputStream(destFile)); |
| | | ImgInfo info = new ImgInfo(); |
| | | int width = sourceImg.getWidth(); |
| | | int height = sourceImg.getHeight(); |
| | | String picLink = uploadPicture(destFile, filevideo.getContentType()); |
| | | info.setH(height); |
| | | info.setW(width); |
| | | info.setUrl(picLink); |
| | | return info; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String uploadPicture(File file, String contentType) throws Exception { |
| | | InputStream inputStream = new FileInputStream(file); |
| | | String type = contentType.substring(contentType.indexOf("/") + 1); |
| | | String filePath = FilePathEnum.goodsEvaluate.getPath() + UUID.randomUUID().toString().replace("-", "") + "." |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveSingleGoods(String pid, Long goodsId, Integer goodsType, String videoUrl, Integer picNum, |
| | | public String saveSingleGoods(String pid, Long goodsId, Integer goodsType, String videoUrl, Integer picNum, |
| | | String picUrls, MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | |
| | | if (StringUtil.isNullOrEmpty(videoUrl)) { |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | File destFile = new File(FileUtil.getCacheDir() + "/temp_" + filevideo.getName()); |
| | | // 裁剪视频封面,宽高比为2:1 |
| | | ImageCropUtil.centerCrop(inputStream, destFile, 2.0f); |
| | | |
| | | BufferedImage sourceImg = ImageIO.read(new FileInputStream(destFile)); |
| | | |
| | | int width = sourceImg.getWidth(); |
| | | int height = sourceImg.getHeight(); |
| | | |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | ImgInfo info = uploadVideoPicture(filevideo); |
| | | if (info == null) |
| | | throw new GoodsEvaluateException(2, "视频图片上传失败"); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setUrl(info.getUrl()); |
| | | imgVideo.setUrlHD(info.getUrl()); |
| | | } else { |
| | | imgVideo = new ImgInfo(); |
| | | imgVideo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgVideo.setLarge(true); |
| | | imgVideo.setPid(pid); |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setUrl(info.getUrl()); |
| | | imgVideo.setUrlHD(info.getUrl()); |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | imgVideo.setType(ImgEnum.video); |
| | | } |
| | | imgVideo.setW(width); |
| | | imgVideo.setH(height); |
| | | imgVideo.setW(info.getW()); |
| | | imgVideo.setH(info.getH()); |
| | | } |
| | | } |
| | | |
| | |
| | | * = false; } |
| | | */ |
| | | |
| | | String commentText = ""; |
| | | if (addComment) { |
| | | String commentText = ""; |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(1L, goodsId, "0"); |
| | | String template = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | return commentText; |
| | | } |
| | | |
| | | private String createTokenAndLink(GoodsDetailVO goodsDetailVO) throws Exception { |
| | |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | File destFile = new File(FileUtil.getCacheDir() + "/temp_" + filevideo.getName()); |
| | | // 裁剪视频封面,宽高比为2:1 |
| | | ImageCropUtil.centerCrop(inputStream, destFile, 2.0f); |
| | | ImgInfo info = uploadVideoPicture(filevideo); |
| | | if (info == null) |
| | | throw new GoodsEvaluateException(2, "视频图片上传失败"); |
| | | |
| | | BufferedImage sourceImg = ImageIO.read(new FileInputStream(destFile)); |
| | | int width = sourceImg.getWidth(); |
| | | int height = sourceImg.getHeight(); |
| | | |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setUrl(info.getUrl()); |
| | | imgVideo.setUrlHD(info.getUrl()); |
| | | } else { |
| | | imgVideo = new ImgInfo(); |
| | | imgVideo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgVideo.setLarge(true); |
| | | imgVideo.setPid(pid); |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setUrl(info.getUrl()); |
| | | imgVideo.setUrlHD(info.getUrl()); |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | imgVideo.setType(ImgEnum.video); |
| | | } |
| | | imgVideo.setW(width); |
| | | imgVideo.setH(height); |
| | | imgVideo.setW(info.getW()); |
| | | imgVideo.setH(info.getH()); |
| | | } |
| | | } |
| | | |
| | |
| | | if (filevideo != null) { |
| | | removePicture(videoPic); |
| | | |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | File destFile = new File(FileUtil.getCacheDir() + "/temp_" + filevideo.getName()); |
| | | // 裁剪视频封面,宽高比为2:1 |
| | | ImageCropUtil.centerCrop(inputStream, destFile, 2.0f); |
| | | |
| | | BufferedImage sourceImg = ImageIO.read(new FileInputStream(destFile)); |
| | | |
| | | width = sourceImg.getWidth(); |
| | | height = sourceImg.getHeight(); |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | videoPic = picLink; |
| | | ImgInfo info = uploadVideoPicture(filevideo); |
| | | if (info == null) |
| | | throw new GoodsEvaluateException(2, "视频图片上传失败"); |
| | | videoPic = info.getUrl(); |
| | | width=info.getW(); |
| | | height=info.getH(); |
| | | } |
| | | |
| | | MultipartFile activityfile = fileRequest.getFile("activityfile"); |
| | |
| | | listImg.add(imgVideo); |
| | | } |
| | | |
| | | int totalImg = 0; |
| | | if (!StringUtil.isNullOrEmpty(activityPic) || !StringUtil.isNullOrEmpty(imgInfo.getActivityUrl())) { |
| | | if (imgactivity != null) { |
| | | imgactivity.setUrl(activityPic); |
| | |
| | | imgactivity.setH(imgactivity.getH()); |
| | | } |
| | | listImg.add(imgactivity); |
| | | totalImg ++; |
| | | } |
| | | resultObj.setLineNum(1); |
| | | |
| | | int lineNum = 0; |
| | | if (totalImg > 0) { |
| | | if (totalImg == 1) { |
| | | lineNum = 1; |
| | | } else if (totalImg <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | | lineNum = 3; |
| | | } |
| | | } |
| | | |
| | | resultObj.setLineNum(lineNum); |
| | | resultObj.setImgList(listImg); |
| | | goodsEvaluateDao.save(resultObj); |
| | | } |
| | |
| | | if (filevideo != null) { |
| | | if (StringUtil.isNullOrEmpty(videoUrl)) { |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | File destFile = new File(FileUtil.getCacheDir() + "/temp_" + filevideo.getName()); |
| | | // 裁剪视频封面,宽高比为2:1 |
| | | ImageCropUtil.centerCrop(inputStream, destFile, 2.0f); |
| | | |
| | | BufferedImage sourceImg = ImageIO.read(new FileInputStream(destFile)); |
| | | |
| | | int width = sourceImg.getWidth(); |
| | | int height = sourceImg.getHeight(); |
| | | |
| | | |
| | | |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | } |
| | | ImgInfo info = uploadVideoPicture(filevideo); |
| | | if (info == null) |
| | | throw new GoodsEvaluateException(2, "视频图片上传失败"); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | | listDel.add(url); |
| | | } |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setUrl(info.getUrl()); |
| | | imgVideo.setUrlHD(info.getUrl()); |
| | | } else { |
| | | imgVideo = new ImgInfo(); |
| | | imgVideo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | imgVideo.setLarge(true); |
| | | imgVideo.setPid(pid); |
| | | imgVideo.setUrl(picLink); |
| | | imgVideo.setUrlHD(picLink); |
| | | imgVideo.setUrl(info.getUrl()); |
| | | imgVideo.setUrlHD(info.getUrl()); |
| | | imgVideo.setVideoUrl(videoUrl); |
| | | imgVideo.setType(ImgEnum.video); |
| | | } |
| | | imgVideo.setW(width); |
| | | imgVideo.setH(height); |
| | | imgVideo.setW(info.getW()); |
| | | imgVideo.setH(info.getH()); |
| | | } |
| | | |
| | | activityFile = fileRequest.getFile("activityFile"); |
| | |
| | | listImg.add(imgActivity); |
| | | } |
| | | |
| | | int totalImg = 0; |
| | | // 编辑图片 |
| | | if (!StringUtil.isNullOrEmpty(picUrls)) { |
| | | String[] pics = picUrls.split(","); |
| | |
| | | imgInfo0.setUrl(picLink); |
| | | imgInfo0.setUrlHD(picLink); |
| | | imgInfo0.setType(ImgEnum.img); |
| | | imgVideo.setW(1); |
| | | imgVideo.setH(1); |
| | | imgInfo0.setW(1); |
| | | imgInfo0.setH(1); |
| | | listImg.add(imgInfo0); |
| | | totalImg ++; |
| | | continue; |
| | | } |
| | | } |
| | |
| | | String url = imgInfo.getUrl(); |
| | | if (picLink.equals(url)) { |
| | | listImg.add(imgInfo); |
| | | totalImg ++; |
| | | break; |
| | | } |
| | | } |
| | |
| | | listDel.add(listOld.get(j)); |
| | | } |
| | | } |
| | | resultObj.setLineNum(1); |
| | | |
| | | int lineNum = 0; |
| | | if (totalImg > 0) { |
| | | if (totalImg == 1) { |
| | | lineNum = 1; |
| | | } else if (totalImg <= 4) { |
| | | lineNum = 2; |
| | | } else { |
| | | lineNum = 3; |
| | | } |
| | | } |
| | | |
| | | resultObj.setLineNum(lineNum); |
| | | resultObj.setImgList(listImg); |
| | | goodsEvaluateDao.save(resultObj); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | // @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") |
| | | @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type") |
| | | public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type) throws Exception { |
| | | List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type); |
| | | if (list == null) { |
| | | list = new ArrayList<>(); |
| | | } |
| | | Date now = new Date(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | List<GoodsEvaluate> listNew = new ArrayList<>(); |
| | | for (GoodsEvaluate goodsEvaluate : list) { |
| | | |
| | | |
| | | GoodsEvaluate evaluateNew = new GoodsEvaluate(); |
| | | try { |
| | | PropertyUtils.copyProperties(evaluateNew, goodsEvaluate); |
| | |
| | | e.printStackTrace(); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | int comment = 0; |
| | | List<CommentInfo> comments = evaluateNew.getComments(); |
| | | if (comments != null && comments.size() > 0) { |
| | |
| | | List<CommentInfo> commentNew = new ArrayList<>(); |
| | | |
| | | for (CommentInfo commentInfo : comments) { |
| | | if (StringUtil.isNullOrEmpty(commentInfo.getContent()) && |
| | | StringUtil.isNullOrEmpty(commentInfo.getCoupon())) { |
| | | continue; |
| | | } |
| | | |
| | | CommentInfo commentInfoNew = new CommentInfo(); |
| | | try { |
| | | PropertyUtils.copyProperties(commentInfoNew, commentInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | continue; |
| | | } |
| | | |
| | | comment++; |
| | | CommentInfoEnum typeComment = commentInfo.getTypeEnum(); |
| | | CommentInfoEnum typeComment = commentInfoNew.getTypeEnum(); |
| | | if (typeComment != null && typeComment == CommentInfoEnum.goodsCoupon) { |
| | | GoodsDetailVO goods = evaluateNew.getGoods(); |
| | | if (goods.isHasCoupon()) { |
| | | commentNew.add(commentInfo); |
| | | if (goods != null && goods.isHasCoupon()) { |
| | | commentNew.add(commentInfoNew); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | String coupon = commentInfo.getCoupon(); |
| | | String endTime = commentInfo.getEndTime(); |
| | | String coupon = commentInfoNew.getCoupon(); |
| | | String endTime = commentInfoNew.getEndTime(); |
| | | if (!StringUtil.isNullOrEmpty(coupon) && !StringUtil.isNullOrEmpty(endTime)) { |
| | | Date endDay = sdf.parse(endTime); |
| | | if (endDay.getTime() > now.getTime()) { |
| | | int daysBetween = DateUtil.daysBetween(now, endDay); |
| | | if (daysBetween > 0) { |
| | | String daysBetween = DateUtil.dateDiff5(now, endDay); |
| | | if (!StringUtil.isNullOrEmpty(daysBetween)) { |
| | | ClientTextStyleVO styleVO = new ClientTextStyleVO(); |
| | | styleVO.setColor("#E5005C"); |
| | | styleVO.setContent(daysBetween + "天后过期"); |
| | | styleVO.setContent(daysBetween + "后过期"); |
| | | |
| | | List<ClientTextStyleVO> tagList = commentInfo.getTagList(); |
| | | List<ClientTextStyleVO> tagList = commentInfoNew.getTagList(); |
| | | tagList.add(styleVO); |
| | | commentInfo.setTagList(tagList); |
| | | commentInfoNew.setTagList(tagList); |
| | | |
| | | commentNew.add(commentInfo); |
| | | commentNew.add(commentInfoNew); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | listNew.add(evaluateNew); |
| | | } |
| | | |
| | |
| | | updateGoodInfo(listOBJ); |
| | | } |
| | | }); |
| | | |
| | | |
| | | return listNew; |
| | | } |
| | | |