licailing 5 gadi atpakaļ
vecāks
revīzija
5abf06a652

+ 3 - 0
src/main/java/com/izouma/imt/repo/vendor/DecorationRepo.java

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.util.List;
 
 public interface DecorationRepo extends JpaRepository<Decoration, Long>, JpaSpecificationExecutor<Decoration> {
     @Query("update Decoration t set t.del = true where t.id = ?1")
@@ -15,4 +16,6 @@ public interface DecorationRepo extends JpaRepository<Decoration, Long>, JpaSpec
     void softDelete(Long id);
 
     Decoration findByVendorInfoId(Long vendorInfoId);
+
+    List<Decoration> findAllByVendorInfoIdIsNotNullAndAndCustomAreaIsNotNull();
 }

+ 44 - 6
src/main/java/com/izouma/imt/service/vendor/VendorInfoService.java

@@ -8,10 +8,7 @@ import com.github.kevinsawicki.http.HttpRequest;
 import com.izouma.imt.converter.LongArrayConverter;
 import com.izouma.imt.converter.StringArrayConverter;
 import com.izouma.imt.domain.*;
-import com.izouma.imt.domain.vendor.BranchInformation;
-import com.izouma.imt.domain.vendor.Product;
-import com.izouma.imt.domain.vendor.ProductTag;
-import com.izouma.imt.domain.vendor.VendorInfo;
+import com.izouma.imt.domain.vendor.*;
 import com.izouma.imt.dto.*;
 import com.izouma.imt.dto.excel.VendorInfoVO;
 import com.izouma.imt.enums.*;
@@ -63,6 +60,7 @@ public class VendorInfoService {
     private final BuyersInfoService        buyersInfoService;
     private final SysConfigRepo            sysConfigRepo;
     private final SearchRecordRepo         searchRecordRepo;
+    private final DecorationRepo           decorationRepo;
 
     public Page<VendorInfo> all(PageQuery pageQuery) {
         return vendorInfoRepo.findAll(JpaUtils.toSpecification(pageQuery, VendorInfo.class), JpaUtils.toPageRequest(pageQuery));
@@ -508,6 +506,11 @@ public class VendorInfoService {
                 .stream()
                 .collect(Collectors.groupingBy(BranchInformation::getUserId));
 
+        // 自定义
+        Map<Long, String> decorationMap = decorationRepo.findAllByVendorInfoIdIsNotNullAndAndCustomAreaIsNotNull()
+                .stream()
+                .collect(Collectors.toMap(Decoration::getVendorInfoId, Decoration::getCustomArea));
+
         // 所有标签
         List<ProductTag> tagList = productTagRepo.findAll();
         Map<Long, String> tagMap = tagList
@@ -608,11 +611,46 @@ public class VendorInfoService {
             }
             if (StrUtil.isNotBlank(vendorInfo.getLogo1())) {
                 HttpRequest.get(vendorInfo.getLogo1())
-                        .receive(new File(dirfile + "/logo1" + this.getSuffix(vendorInfo.getLogo())));
+                        .receive(new File(dirfile + "/logo1" + this.getSuffix(vendorInfo.getLogo1())));
             }
             if (StrUtil.isNotBlank(vendorInfo.getBusinessLicenseImg())) {
                 HttpRequest.get(vendorInfo.getBusinessLicenseImg())
-                        .receive(new File(dirfile + "/BusinessLicense" + this.getSuffix(vendorInfo.getLogo())));
+                        .receive(new File(dirfile + "/BusinessLicense" + this.getSuffix(vendorInfo.getBusinessLicenseImg())));
+            }
+            if (StrUtil.isNotBlank(vendorInfo.getIDImg())) {
+                HttpRequest.get(vendorInfo.getIDImg())
+                        .receive(new File(dirfile + "/id" + this.getSuffix(vendorInfo.getIDImg())));
+            }
+            if (StrUtil.isNotBlank(user.getCard())) {
+                HttpRequest.get(user.getCard())
+                        .receive(new File(dirfile + "/card" + this.getSuffix(user.getCard())));
+            }
+            if (StrUtil.isNotBlank(vendorInfo.getOtherFiles())) {
+                String[] split = vendorInfo.getOtherFiles().split(",");
+                for (int i = 1; i <= split.length; i++) {
+                    HttpRequest.get(split[i - 1])
+                            .receive(new File(dirfile + "/other" + i + this.getSuffix(split[i - 1])));
+                }
+            }
+            if (StrUtil.isNotBlank(vendorInfo.getImg())) {
+                String[] split = vendorInfo.getImg().split(",");
+                for (int i = 1; i <= split.length; i++) {
+                    String suffix = this.getSuffix(split[i - 1]);
+//                    if (suffix.equals(".mp4")){
+//                        continue;
+//                    }
+
+                    HttpRequest.get(split[i - 1])
+                            .receive(new File(dirfile + "/banner" + i + suffix));
+                }
+            }
+            String decoration = decorationMap.get(vendorInfo.getId());
+            if (StrUtil.isNotBlank(decoration)) {
+                String[] split = decoration.split(",");
+                for (int i = 1; i <= split.length; i++) {
+                    HttpRequest.get(split[i - 1])
+                            .receive(new File(dirfile + "/custom" + i + this.getSuffix(split[i - 1])));
+                }
             }
             vos.add(vo);
         });

+ 2 - 2
src/test/java/com/izouma/imt/service/vendor/VendorInfoServiceTest.java

@@ -257,7 +257,7 @@ public class VendorInfoServiceTest {
     @Test
     public void test14() throws IOException {
         List<VendorInfoVO> data = vendorInfoService.export();
-        ExcelUtils.export1(data,"vendor/");
-        ZipUtil.zip(new File("vendor"));
+//        ExcelUtils.export1(data,"vendor/");
+//        ZipUtil.zip(new File("vendor"));
     }
 }