zhaoxian vor 3 Jahren
Ursprung
Commit
0b29d3ccb1

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/xml/ProductMaterialMapper.xml

@@ -148,6 +148,8 @@
         WHERE video_url is not null
         and product_id = #{productId}
           and trade_name = #{tradeName}
+          and start_month >= #{startMonth}
+          and end_month <= #{endMonth}
         ORDER BY t1.create_time desc
     </select>
 

+ 12 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/ProductMaterialServiceImpl.java

@@ -92,6 +92,7 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
 
     @Override
     public Result<Object> add(JSONObject data) throws IOException {
+        String result = "添加完成";
         JSONArray list = data.getJSONArray("list");
         if (Check.isNull(list) || list.size() == 0) {
             return Result.error("缺少参数");
@@ -107,18 +108,24 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
             String videoUrl = trade.getString("videoUrl");
             String signature = trade.getString("signature");
             String uploaderId = trade.getString("uploaderId");
+            QueryWrapper<ProductMaterial> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("product_id", entity.getProductId());
+            queryWrapper.eq("trade_name", tradeName).last("limit 1");
+            ProductMaterial one1 = this.getOne(queryWrapper);
+            if (!Check.isNull(one1)) {
+                entity.setStartMonth(one1.getStartMonth());
+                entity.setEndMonth(one1.getEndMonth());
+                result = "";
+            }
             int count = 0;
             if (Check.isNull(videoUrl)) {
-                QueryWrapper<ProductMaterial> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("product_id", entity.getProductId());
-                queryWrapper.eq("trade_name", tradeName);
-                queryWrapper.isNull("video_url").last("limit 1");
+                queryWrapper.isNull("video_url");
                 ProductMaterial one = this.getOne(queryWrapper);
                 if (Check.isNull(one)) {
                     entity.setTradeName(tradeName);
                     lists.add(entity);
                 }
-            }  else {
+            } else {
                 if (Check.isNull(signature) && Check.isNull(uploaderId)) {
                     List<String> urls = Arrays.asList(videoUrl.split(","));
                     for (String url : urls) {