Authored by LUOXC

fix nullpointer exception

@@ -22,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.stereotype.Component; 22 import org.springframework.stereotype.Component;
23 23
24 import java.util.List; 24 import java.util.List;
  25 +import java.util.Objects;
  26 +import java.util.Optional;
25 import java.util.stream.Collectors; 27 import java.util.stream.Collectors;
26 28
27 /** 29 /**
@@ -64,12 +66,18 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv @@ -64,12 +66,18 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv
64 productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList()); 66 productProxyService.batchCreateSkup(fjr.getSellerOrderGoodsList());
65 List<Integer> skups; 67 List<Integer> skups;
66 productProxyService.sellerBatchUpdateStatus(skups=fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on); 68 productProxyService.sellerBatchUpdateStatus(skups=fjr.getSkupIds(), ProductProxyService.PrdShelvelStatus.on);
67 - SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupType.getCode());  
68 - if (codeNode.getRegion() == RegionEnum.MAINLAND.getCode()) { 69 + Optional.ofNullable(skupType)
  70 + .map(SkupType::getCode)
  71 + .map(SkupTypeCodeSupport::explain)
  72 + .map(SkupTypeCodeSupport.CodeNode::getRegion)
  73 + .filter(region -> region == RegionEnum.MAINLAND.getCode())
  74 + .ifPresent(e->{
69 //通知其他卖家价格 75 //通知其他卖家价格
70 SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder() 76 SellerOrderPriceChangeEvent sopcEvent = SellerOrderPriceChangeEvent.builder()
71 - .sellerUid(sellerUid).skup(skups.get(0)).build(); 77 + .sellerUid(sellerUid)
  78 + .skup(skups.get(0))
  79 + .build();
72 EventBusPublisher.publishEvent(sopcEvent); 80 EventBusPublisher.publishEvent(sopcEvent);
73 - } 81 + });
74 } 82 }
75 } 83 }