Browse Source

导入商品

wanglang 1 month ago
parent
commit
3a6c33b18c

+ 13 - 2
trade-client/src/main/java/com/trade/client/trade/salescontract/service/impl/SalesServiceImpl.java

@@ -6,6 +6,7 @@ import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -362,10 +363,20 @@ public class SalesServiceImpl implements SalesService {
                 List<SalesCommodityDto> salesCommodityDtos = salesCommodityService.getXiaoTuCommodityList(
                         salesCommodityDto.getHsCode(), customerUser.getXtUid(), customerUser.getId(), false);
                 if (salesCommodityDtos != null && salesCommodityDtos.size() > 0) {
-                    SalesCommodityDto salesCommodityTemp = salesCommodityDtos.get(0);
-                    if (StringUtils.isNotEmpty(salesCommodityTemp.getErrors())) {
+                    SalesCommodityDto salesCommodityTemp = salesCommodityDtos.stream()
+                            .filter(s -> salesCommodityDto.getHsCode().equals(s.getHsCode())).findAny().get();
+                    if (salesCommodityTemp == null) {
+                        stringBuffer.append("商品不存在,");
+                    } else if (salesCommodityTemp != null && StringUtils.isNotEmpty(salesCommodityTemp.getErrors())) {
                         stringBuffer.append(salesCommodityTemp.getErrors() + ",");
                     }
+                    List<SalesCommodityDto> salesCommodityDtosTemp = salesCommodityDtos.stream()
+                            .filter(s -> !salesCommodityDto.getHsCode().equals(s.getHsCode()))
+                            .collect(Collectors.toList());
+                    for (SalesCommodityDto commodityDto : salesCommodityDtosTemp) {
+                        pass.add(commodityDto);
+                        continue;
+                    }
                 } else {
                     stringBuffer.append("商品不存在,");
                 }