| | |
| | | package com.yeshi.fanli.service.impl.dynamic; |
| | | |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.yeshi.utils.DateUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.ImageCropUtil; |
| | | import org.yeshi.utils.tencentcloud.COSManager; |
| | | |
| | | import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao; |
| | |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.FilePathEnum; |
| | | import com.yeshi.fanli.util.FileUtil; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; |
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.jd.JDApiUtil; |
| | | import com.yeshi.fanli.util.jd.JDUtil; |
| | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | |
| | | @Resource |
| | | private JDGoodsCacheUtil jdGoodsCacheUtil; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private ConvertLinkManager convertLinkManager; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException { |
| | |
| | | return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); |
| | | } |
| | | |
| | | 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("-", "") + "." |
| | | + type; |
| | | return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); |
| | | } |
| | | |
| | | /** |
| | | * 删除图片 |
| | | * |
| | |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | BufferedImage sourceImg = ImageIO.read(inputStream); |
| | | 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(filevideo); |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | |
| | | } |
| | | |
| | | /* |
| | | * // 无券不能自动 生成评论 CouponInfoVO couponInfo1 = goodsDetailVO.getCouponInfo(); if |
| | | * (couponInfo1 == null) { addComment = false; } |
| | | * // 无券不能自动 生成评论 CouponInfoVO couponInfo1 = |
| | | * goodsDetailVO.getCouponInfo(); if (couponInfo1 == null) { addComment |
| | | * = false; } |
| | | */ |
| | | |
| | | |
| | | if (addComment) { |
| | | String commentText = ""; |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "","1"); |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, |
| | | JDApiUtil.POSITION_SHARE + "", "1"); |
| | | String template = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | |
| | | commentText = commentText.replace("[券后价]", goodsDetailVO.getCouponPrice().toString()); |
| | | } |
| | | |
| | | commentText =commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | | |
| | | commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", |
| | | "\r\n"); |
| | | |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | commentInfo.setId(UUID.randomUUID().toString().replace("-", "")); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private String createTokenAndLink(GoodsDetailVO goodsDetailVO) throws Exception { |
| | | String commentText = ""; |
| | | if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsDetailVO.getGoodsId() + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "","1"); |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | "1"); |
| | | String template = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } else if (goodsDetailVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetailVO.getGoodsId(), PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsDetailVO.getGoodsId(), |
| | | PinDuoDuoApiUtil.PID_SHARE + "", "1"); |
| | | String template = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); |
| | | commentText = template.replace("[链接]", jumpLink); |
| | | } |
| | |
| | | } |
| | | |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | BufferedImage sourceImg = ImageIO.read(inputStream); |
| | | 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(filevideo); |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveGoodsComment(String id, int kind, List<CommentInfo> comments) throws GoodsEvaluateException, Exception { |
| | | public void saveGoodsComment(String id, int kind, List<CommentInfo> comments) |
| | | throws GoodsEvaluateException, Exception { |
| | | if (comments == null || comments.size() == 0 ) { |
| | | throw new GoodsEvaluateException(1, "内容不能为空"); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveCurrencyCoupon(String pid, int kind, CommentInfo commentInfo) throws GoodsEvaluateException, Exception { |
| | | public void saveCurrencyCoupon(String pid, int kind, CommentInfo commentInfo) |
| | | throws GoodsEvaluateException, Exception { |
| | | if (StringUtil.isNullOrEmpty(pid)) { |
| | | throw new GoodsEvaluateException(1, "请保存第一部分信息"); |
| | | } |
| | |
| | | removePicture(videoPic); |
| | | |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | BufferedImage sourceImg = ImageIO.read(inputStream); |
| | | 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(filevideo); |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | videoPic = picLink; |
| | | } |
| | | |
| | |
| | | throw new GoodsEvaluateException(1, "视频链接不能为空"); |
| | | } |
| | | InputStream inputStream = filevideo.getInputStream(); |
| | | BufferedImage sourceImg = ImageIO.read(inputStream); |
| | | 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(filevideo); |
| | | |
| | | |
| | | String picLink = uploadPicture(destFile,filevideo.getContentType()); |
| | | if (imgVideo != null) { |
| | | String url = imgVideo.getUrl(); |
| | | if (!StringUtil.isNullOrEmpty(url)) { |
| | |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", goodsVO.getCouponPrice().toString()); |
| | | } |
| | | commentText =commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | | |
| | | commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n") |
| | | .replace("\r\n\r\n", "\r\n"); |
| | | |
| | | CommentInfo commentInfo = new CommentInfo(); |
| | | commentInfo.setId(UUID.randomUUID().toString().replace("-", "")); |