Authored by chenchao

clean datail cache

... ... @@ -205,6 +205,7 @@ public class SellerOrderController {
) throws GatewayException {
BatchChangePriceReq req = BatchChangePriceReq.builder()
.uid(uid).price(price)
.isShowPriceError(true)
.batchNo(batchNo).skupList(skupList)
.build();
logger.info("in ufo.sellerOrder.batchChangePrice, req {}", req);
... ... @@ -225,6 +226,7 @@ public class SellerOrderController {
.storageId(storage_id)
.uid(uid).price(price)
.batchNo(batchNo).skupList(skupList)
.isShowPriceError(false)
.build();
logger.info("in ufo.sellerOrder.computeChangePrice, req {}", req);
SoldPrdComputeBo computeBo = sellerOrderService.computeChangePrice(req);
... ...
... ... @@ -61,8 +61,10 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
private UserProxyService userProxyService;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
private ProductProxyService productProxyService;
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
@Override
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
... ... @@ -154,11 +156,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
}
@Autowired
private ProductProxyService productProxyService;
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
private String overFlowPriceKey(Integer storageId, BigDecimal salePrice){
... ...
package com.yohoufo.order.service.impl;
import com.google.common.collect.Sets;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
... ... @@ -151,7 +152,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
int num = pcn.getNum();
BigDecimal salePrice = pcn.getPrdPrice();
String tips = null;
ProductProxyService.PrdPrice prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice);
ProductProxyService.PrdPrice prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice, true);
try {
sellerOrderPrepareProcessor.checkSuggestPrice(prdPrice, salePrice);
}catch (UfoServiceException ex){
... ... @@ -166,11 +167,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
public SoldPrdComputeBo computeChangePrice(BatchChangePriceReq req) throws GatewayException {
log.info("in computeChangePrice, req {}", req);
ChangePricePrepareDTO pcn = changePricePrepareProcessor.checkAndAcquire(req);
/*
if (pcn.getTips() != null){
throw new UfoServiceException(SellerOrderPrepareProcessor.TIPS_ERROR_CODE, pcn.getTips() );
}
*/
SellerOrderComputeResult computeResult = pcn.getComputeResult();
SoldPrdComputeBo spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
spc.setTips(pcn.getTips());
return spc;
}
... ... @@ -578,7 +582,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
int failCnt = 0;
if(Objects.nonNull(sellerWallet)) {
//1.1 划账成功后
//TODO 2 商品变价(同步价格到商品)
//2 商品变价(同步价格到商品)
Set<Integer> skupSet = skupMap.keySet();
productProxyService.batchUpdatePrice(skupSet, salePrice);
... ... @@ -601,12 +605,10 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
so-> OrderInfo.builder().orderCode(so.getOrderCode()).amount(diffEarnestMoney).build())
.collect(Collectors.toList());
merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList );
successCnt = skupMap.size();
SkupDto skupDto = skupMap.values().iterator().next();
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(skupDto.getSellerOrderGoods())
));
List<RedisKeyBuilder> skupDetailRKBs = getSkupDetailRKBs(skupMap);
skupDetailRKBs.add(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue()));
cacheCleaner.delete(skupDetailRKBs);
}else {
//1.2 划账失败后
failCnt = skupMap.size();
... ... @@ -620,6 +622,20 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
return resp;
}
private List<RedisKeyBuilder> getSkupDetailRKBs(Map<Integer, SkupDto> skupMap){
Set<String> keys = new HashSet<>(skupMap.size());
List<RedisKeyBuilder> skupDetailRKBs = new ArrayList<>(skupMap.size());
for(Map.Entry<Integer, SkupDto> entry : skupMap.entrySet()){
SellerOrderGoods sog = entry.getValue().getSellerOrderGoods();
String key = new StringBuilder().append(sog.getBatchNo()).append(sog.getGoodsPrice())
.append(sog.getStatus()).toString();
if (keys.contains(key)){
continue;
}
skupDetailRKBs.add(CacheKeyBuilder.sellerOrderDetailKey(sog));
}
return skupDetailRKBs;
}
private static final int MAX_DEAL = 10;
... ...
... ... @@ -292,7 +292,7 @@ public class ShoppingServiceImpl implements IShoppingService {
//inBoxFacade.buyerOrderNotPayed(shoppingRequest.getUid(), orderCode);
if (submitResult != null){
//clean cache
//TODO merge clean key
// merge clean key
cacheCleaner.cleanList(uid, TabType.BUY.getValue());
SellerOrderGoods psog = submitResult.getSellerOrderGoods();
Integer sellerUid = submitResult.getSellerOrder().getUid();
... ...
... ... @@ -104,7 +104,7 @@ public class ChangePricePrepareProcessor {
String tips = null;
ProductProxyService.PrdPrice prdPrice;
prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice);
prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice, req.isShowPriceError());
try {
sellerOrderPrepareProcessor.checkSuggestPrice(prdPrice, salePrice);
}catch (UfoServiceException ex){
... ...
... ... @@ -5,7 +5,6 @@ import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.req.SellerOrderBatchCancelReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.dto.SkupDto;
import lombok.Data;
... ...
... ... @@ -130,7 +130,7 @@ public class SellerOrderPrepareProcessor {
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
context.setSoldProduct(goodsInfo);
ProductProxyService.PrdPrice prdPrice = checkPrice(storageId, salePrice);;
ProductProxyService.PrdPrice prdPrice = checkPrice(storageId, salePrice, true);
try {
checkSuggestPrice(prdPrice, salePrice);
... ... @@ -184,18 +184,20 @@ public class SellerOrderPrepareProcessor {
public static final int TIPS_ERROR_CODE = 505;
public ProductProxyService.PrdPrice checkPrice(int storageId, BigDecimal prdPrice) {
public ProductProxyService.PrdPrice checkPrice(int storageId, BigDecimal prdPrice, boolean isShowError) {
ProductProxyService.PrdPrice prdPriceRange = productProxyService.getPrdPriceRange(storageId);
log.info("in checkPrice, prdPrice {}, storageId {} prdPriceRange {}", prdPrice, storageId, prdPriceRange);
BigDecimal minPrice = prdPriceRange.getMinPrice();
BigDecimal maxPrice = prdPriceRange.getMaxPrice();
if (prdPrice.subtract(minPrice).doubleValue() < 0D){
log.warn("in computePublishPrd,minPrice {}, storageId {}", minPrice, storageId);
if (isShowError)
throw new UfoServiceException(501, "您的出价过低");
}
if (prdPrice.subtract(maxPrice).doubleValue() > 0D){
log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);
if (isShowError)
throw new UfoServiceException(501, "您的出价过高");
}
return prdPriceRange;
... ...