Authored by wujiexiang

Merge branch 'test6.9.9' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.9

... ... @@ -80,7 +80,8 @@ public class CacheKeyBuilder {
BUYER_ORDER_FEE("ufo:order:buyer:order:fee",""),
BUYER_ORDER_CUT_POLICY("ufo:buyer:order:cut:policy:","type:{}"),
LARGE_SETTLEMENT_SUPER_NOTICE_WALLET_NOT_ENOUGH("ufo:seller:largeSettlement:walletNotEnough:notice:","uid:{}:funcLevel:{}:cnt"),
DEPOSIT_PLATFORM_FEE("ufo:order:deposit:platform:fee", "")
DEPOSIT_PLATFORM_FEE("ufo:order:deposit:platform:fee", ""),
SELLER_SALE_PRICE_LIMIT("ufo:order:seller:salePrice:limit:config","")
;
private String fix;
... ...
... ... @@ -5,6 +5,7 @@ import com.alibaba.fastjson.TypeReference;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yohobuy.ufo.model.order.bo.AmountCutPolicy;
import com.yohobuy.ufo.model.order.bo.DepositFee;
import com.yohobuy.ufo.model.order.bo.SellerSalePriceLimit;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.MetaConfigKey;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
... ... @@ -353,4 +354,19 @@ public class MetaConfigService {
}
return pfMap;
}
public Map<String, SellerSalePriceLimit> getSellerGoodsPriceLimit(){
CacheKeyBuilder.KeyTemp kt = CacheKeyBuilder.KeyTemp.SELLER_SALE_PRICE_LIMIT;
RedisKeyBuilder rkb = kt.builderKeyOnlyFixed();
final String key = MetaConfigKey.SELLER_GOODS_PRICE_LIMIT;
String configVal = new DataProcesser(rkb, key, ExpiredTime.ORDER_BASE_CONFIG).getConfigVal();
Map<String, SellerSalePriceLimit> pfMap = null;
try{
pfMap = JSONObject.parseObject(configVal, new TypeReference<Map<String, SellerSalePriceLimit>>(){});
}catch (Exception ex){
logger.warn("in getSellerGoodsPriceLimit parseObject fail, metaVal {}", configVal, ex);
}
return pfMap;
}
}
... ...
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);
}
}
... ...