lyhzzz 1 rok temu
rodzic
commit
e7d10ddff2

+ 3 - 31
src/main/java/com/cdf/service/impl/ExcelService.java

@@ -17,6 +17,7 @@ import com.cdf.httpClient.client.CdfHKClient;
 import com.cdf.httpClient.response.cdf.CdfProduct;
 import com.cdf.httpClient.response.cdf.CdfProductListByIdsRequest;
 import com.cdf.httpClient.response.cdf.CdfProductListByIdsVo;
+import com.cdf.httpClient.response.cdf.CdfProductVo;
 import com.cdf.request.UploadHotsParam;
 import com.cdf.response.*;
 import com.cdf.exception.BusinessException;
@@ -237,35 +238,10 @@ public class ExcelService {
     private void checkUploadProduct(File file, List<String> errorList){
         List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
         Integer colum = 1;
-        HashMap<String, List<String>> productSourceProductMap = new HashMap<>();
-        HashMap<String, List<String>> resultPMap = new HashMap<>();
         HashMap<String, List<String>> numMap = new HashMap<>();
         HashMap<String,ProductSource> productMap = new HashMap<>();
 
         for (HashMap<Integer, String> map : excelRowList) {
-            String sourceId = map.get(3);
-            String pid = map.get(4);
-            if(StringUtils.isNotBlank(pid)){
-                List<String> pidList = productSourceProductMap.computeIfAbsent(sourceId, k -> new ArrayList<>());
-                pidList.add(pid);
-            }
-        }
-        for (String mchId : productSourceProductMap.keySet()) {
-            ProductSource productSource = productSourceService.getByMchId(mchId);
-            if(productSource !=null){
-                JSONArray ids = new JSONArray();
-                ids.addAll(productSourceProductMap.get(mchId));
-                CdfProductListByIdsRequest idsRequest = new CdfProductListByIdsRequest(ids);
-                CdfProductListByIdsVo vos = cdfHKClient.getProductListByIds(productSource.getCdfHost(), productSource.getCdfMchId(), idsRequest);
-                if(vos.getProductCardList()!=null && vos.getProductCardList().size() >0){
-                    for (CdfProduct cdfProduct : vos.getProductCardList()) {
-                        List<String> pidList = resultPMap.computeIfAbsent(mchId, k -> new ArrayList<>());
-                        pidList.add(cdfProduct.getId());
-                    }
-                }
-            }
-        }
-        for (HashMap<Integer, String> map : excelRowList) {
             colum ++;
             String sceneNum = map.get(0);
             String sid = map.get(1);
@@ -299,12 +275,8 @@ public class ExcelService {
                 errorList.add(colum.toString());
                 continue;
             }
-            List<String> cdfProductList = resultPMap.get(mchId);
-            if(cdfProductList.isEmpty()){
-                errorList.add(colum.toString());
-                continue;
-            }
-            if(!cdfProductList.contains(pid)){
+            CdfProductVo productById = cdfHKClient.getProductById(productSource.getCdfHost(),productSource.getCdfMchId(),pid);
+            if(productById == null || productById.getId() == null || !productById.getId().equals(pid)){
                 errorList.add(colum.toString());
             }