|
@@ -108,46 +108,52 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
|
String signature = trade.getString("signature");
|
|
|
String uploaderId = trade.getString("uploaderId");
|
|
|
int count = 0;
|
|
|
- if (Check.isNull(signature) && Check.isNull(uploaderId)) {
|
|
|
- List<String> urls = Arrays.asList(videoUrl.split(","));
|
|
|
- for (String url : urls) {
|
|
|
- ProductMaterial material = new ProductMaterial();
|
|
|
- count++;
|
|
|
- //获取MD5
|
|
|
- String localPath = LoadFileUtil.downLoadFromUrl(url, downloadPath);
|
|
|
- String md5 = MD5Util.getMd5(localPath);
|
|
|
- if (checkVideo(entity.getProductId(), tradeName, md5)) {
|
|
|
- BeanUtils.copyProperties(entity, material);
|
|
|
- material.setTradeName(tradeName);
|
|
|
- MaterialInfo info = materialInfoService.getMaterialInfoByCode(md5);
|
|
|
- if (!Check.isNull(info)) {
|
|
|
- material.setUploaderId(uploaderId);
|
|
|
+ if (Check.isNull(videoUrl)) {
|
|
|
+ ProductMaterial material = new ProductMaterial();
|
|
|
+ material.setTradeName(tradeName);
|
|
|
+ lists.add(material);
|
|
|
+ } else {
|
|
|
+ if (Check.isNull(signature) && Check.isNull(uploaderId)) {
|
|
|
+ List<String> urls = Arrays.asList(videoUrl.split(","));
|
|
|
+ for (String url : urls) {
|
|
|
+ ProductMaterial material = new ProductMaterial();
|
|
|
+ count++;
|
|
|
+ //获取MD5
|
|
|
+ String localPath = LoadFileUtil.downLoadFromUrl(url, downloadPath);
|
|
|
+ String md5 = MD5Util.getMd5(localPath);
|
|
|
+ if (checkVideo(entity.getProductId(), tradeName, md5)) {
|
|
|
+ BeanUtils.copyProperties(entity, material);
|
|
|
+ material.setTradeName(tradeName);
|
|
|
+ MaterialInfo info = materialInfoService.getMaterialInfoByCode(md5);
|
|
|
+ if (!Check.isNull(info)) {
|
|
|
+ material.setUploaderId(uploaderId);
|
|
|
+ } else {
|
|
|
+ material.setUploaderId(material.getUserId());
|
|
|
+ }
|
|
|
+ material.setSignature(md5);
|
|
|
+ String cosUrl = getCosUrl(url);
|
|
|
+ material.setVideoUrl(cosUrl);
|
|
|
+ lists.add(material);
|
|
|
} else {
|
|
|
- material.setUploaderId(material.getUserId());
|
|
|
+ flag = true;
|
|
|
+ if (msg.contains(tradeName)) {
|
|
|
+ msg += "第" + count + "条视频已存在,";
|
|
|
+ } else {
|
|
|
+ msg += "商品(" + tradeName + ")下的第" + count + "条视频已存在,";
|
|
|
+ }
|
|
|
}
|
|
|
- material.setSignature(md5);
|
|
|
- String cosUrl = getCosUrl(url);
|
|
|
- material.setVideoUrl(cosUrl);
|
|
|
+ LoadFileUtil.delFile(localPath);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ProductMaterial material = new ProductMaterial();
|
|
|
+ BeanUtils.copyProperties(entity, material);
|
|
|
+ material.setTradeName(tradeName);
|
|
|
+ material.setVideoUrl(videoUrl);
|
|
|
+ material.setSignature(signature);
|
|
|
+ material.setUploaderId(uploaderId);
|
|
|
+ if (checkVideo(entity.getProductId(), tradeName, signature)) {
|
|
|
lists.add(material);
|
|
|
- } else {
|
|
|
- flag = true;
|
|
|
- if (msg.contains(tradeName)) {
|
|
|
- msg += "第" + count + "条视频已存在,";
|
|
|
- } else {
|
|
|
- msg += "商品(" + tradeName + ")下的第" + count + "条视频已存在,";
|
|
|
- }
|
|
|
}
|
|
|
- LoadFileUtil.delFile(localPath);
|
|
|
- }
|
|
|
- } else {
|
|
|
- ProductMaterial material = new ProductMaterial();
|
|
|
- BeanUtils.copyProperties(entity, material);
|
|
|
- material.setTradeName(tradeName);
|
|
|
- material.setVideoUrl(videoUrl);
|
|
|
- material.setSignature(signature);
|
|
|
- material.setUploaderId(uploaderId);
|
|
|
- if (checkVideo(entity.getProductId(), tradeName, signature)) {
|
|
|
- lists.add(material);
|
|
|
}
|
|
|
}
|
|
|
}
|