|
|
package com.yohoufo.order.service.seller;
|
|
|
|
|
|
import com.yohobuy.ufo.model.order.bo.SellerSalePriceLimit;
|
|
|
import com.yohobuy.ufo.model.order.constants.SkupType;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.order.service.impl.MetaConfigService;
|
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -9,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -18,6 +21,9 @@ public class SellerOrderRiskWatchDog { |
|
|
@Autowired
|
|
|
private ProductProxyService productProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private MetaConfigService metaConfigService;
|
|
|
|
|
|
public void checkPublishPriceLimit(int uid, int storageId,
|
|
|
SkupType skupType, BigDecimal salePrice){
|
|
|
|
...
|
...
|
@@ -27,12 +33,20 @@ public class SellerOrderRiskWatchDog { |
|
|
if (skupType == null){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
switch (skupType){
|
|
|
case IN_STOCK:
|
|
|
BigDecimal avg = productProxyService.getAveragePriceOfMonthly(uid, storageId);
|
|
|
if (Objects.nonNull(avg) && avg.compareTo(BigDecimal.ZERO) > 0){
|
|
|
//TODO use persistent media save config data
|
|
|
BigDecimal leastRateLimit = new BigDecimal(0.35D);
|
|
|
SellerSalePriceLimit sspl = getSellerSalePriceLimit(skupType.getLocalCacheKey());
|
|
|
Double leastRate=null;
|
|
|
if (sspl==null || (leastRate=sspl.getLeastRate()) == null || leastRate.doubleValue() <0D){
|
|
|
logger.warn("in checkPublishPriceLimit leastRate illegal ,uid {}, storageId {}, skupType {}, salePrice {} leastRate {}",
|
|
|
uid, storageId, skupType, salePrice, leastRate);
|
|
|
leastRate = 0.35D;
|
|
|
}
|
|
|
BigDecimal leastRateLimit = new BigDecimal(leastRate);
|
|
|
if (avg.multiply(leastRateLimit).compareTo(salePrice) > 0){
|
|
|
throw new UfoServiceException(400, "您的出价过低,请重新出价");
|
|
|
}
|
...
|
...
|
@@ -40,4 +54,9 @@ public class SellerOrderRiskWatchDog { |
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private SellerSalePriceLimit getSellerSalePriceLimit(String key){
|
|
|
Map<String, SellerSalePriceLimit> configDataMap = metaConfigService.getSellerGoodsPriceLimit();
|
|
|
return configDataMap.get(key);
|
|
|
}
|
|
|
} |
...
|
...
|
|