|
|
@ -6,11 +6,13 @@ import com.qs.serve.common.model.dto.SimpleKeyValue; |
|
|
|
import com.qs.serve.common.util.Assert; |
|
|
|
import com.qs.serve.common.util.AuthContextUtils; |
|
|
|
import com.qs.serve.common.util.CodeGenUtil; |
|
|
|
import com.qs.serve.common.util.CollectionUtil; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
|
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
|
|
|
import com.qs.serve.modules.bms.service.BmsSupplierAddressService; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsCategoryRule; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsImminentBatch; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsSku; |
|
|
|
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto; |
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsCategoryRuleMapper; |
|
|
@ -32,8 +34,10 @@ import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author YenHex |
|
|
@ -122,7 +126,27 @@ public class OmsOrderPart1ServiceImpl implements OmsOrderPart1Service { |
|
|
|
@Override |
|
|
|
public List<SimpleKeyValue> verifySku(OmsVerifySkuParam param) { |
|
|
|
|
|
|
|
List<SimpleKeyValue> errorImminentIds = new ArrayList<>(); |
|
|
|
|
|
|
|
LocalDate nowDate = LocalDate.now(); |
|
|
|
boolean isImminentCheck = CollectionUtil.isNotEmpty(param.getImminentItemIds()); |
|
|
|
List<GoodsImminentBatch> goodsImminentBatches = null; |
|
|
|
if(isImminentCheck){ |
|
|
|
if(CollectionUtil.isEmpty(param.getImminentItemIds())){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
goodsImminentBatches = goodsImminentBatchService.listByIds(param.getImminentItemIds()); |
|
|
|
for (GoodsImminentBatch batch : goodsImminentBatches) { |
|
|
|
if(batch.getEndDate().isBefore(nowDate)){ |
|
|
|
errorImminentIds.add(new SimpleKeyValue("临期品已过期",batch.getId())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> skuIds = param.getSkuIds(); |
|
|
|
if(isImminentCheck){ |
|
|
|
skuIds = goodsImminentBatches.stream().map(a->Long.parseLong(a.getSkuId())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
GoodsCategoryRule categoryRule = goodsCategoryRuleMapper.selectById(param.getRuleId()); |
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectById(param.getSupplierId()); |
|
|
@ -156,6 +180,19 @@ public class OmsOrderPart1ServiceImpl implements OmsOrderPart1Service { |
|
|
|
//拦截品类下单规则
|
|
|
|
errorSkuIds.addAll(omsOrderService.handleCategoryRule(skuIds,categoryRule)); |
|
|
|
|
|
|
|
if(isImminentCheck){ |
|
|
|
if(CollectionUtil.isEmpty(errorSkuIds)){ |
|
|
|
for (SimpleKeyValue errorSkuId : errorSkuIds) { |
|
|
|
for (GoodsImminentBatch batch : goodsImminentBatches) { |
|
|
|
if(batch.getSkuId().equals(errorSkuId.getValue())){ |
|
|
|
errorImminentIds.add(new SimpleKeyValue(errorSkuId.getLabel(),batch.getId())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return errorImminentIds; |
|
|
|
} |
|
|
|
|
|
|
|
return errorSkuIds; |
|
|
|
} |
|
|
|
|
|
|
|