|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.BidStoragePriceVo;
|
|
|
import com.yohobuy.ufo.model.order.bo.PrdPrice;
|
|
|
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
|
|
|
import com.yohobuy.ufo.model.order.common.CancelType;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
...
|
...
|
@@ -20,6 +20,7 @@ import com.yohoufo.order.model.bo.Account; |
|
|
import com.yohoufo.order.model.bo.AccountPayResult;
|
|
|
import com.yohoufo.order.model.bo.SubmitSellerOrder;
|
|
|
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
|
|
|
import com.yohoufo.order.model.dto.ServiceFeeRate;
|
|
|
import com.yohoufo.order.model.request.PrdQueryReq;
|
|
|
import com.yohoufo.order.model.request.SellerBidPublishRequest;
|
|
|
import com.yohoufo.order.model.response.OrderSubmitResp;
|
...
|
...
|
@@ -30,17 +31,16 @@ import com.yohoufo.order.service.proxy.ResourcesProxyService; |
|
|
import com.yohoufo.order.service.proxy.UserProxyService;
|
|
|
import com.yohoufo.order.service.seller.OrderComputeHandler;
|
|
|
import com.yohoufo.order.service.seller.OrderComputeProvider;
|
|
|
import com.yohoufo.order.service.seller.fee.GoodsAmountService;
|
|
|
import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
|
|
import com.yohoufo.order.utils.AddressHelper;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import com.yohoufo.order.utils.SellerGoodsHelper;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.function.Supplier;
|
|
|
|
...
|
...
|
@@ -56,9 +56,6 @@ public class SellerBidPublishService { |
|
|
private BidProductProxyService bidProductProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private GoodsAmountService goodsAmountService;
|
|
|
|
|
|
@Autowired
|
|
|
private OrderComputeProvider orderComputeProvider;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -80,6 +77,9 @@ public class SellerBidPublishService { |
|
|
private SellerBidOrderBindService sellerBidOrderBindService;
|
|
|
|
|
|
@Autowired
|
|
|
private MetaConfigService metaConfigService;
|
|
|
|
|
|
@Autowired
|
|
|
private CacheCleaner cacheCleaner;
|
|
|
|
|
|
|
...
|
...
|
@@ -101,7 +101,7 @@ public class SellerBidPublishService { |
|
|
|
|
|
//3.检测入驻用户账户保证金
|
|
|
Account account = accountFactory.get(uid);
|
|
|
account.checkBalanceEnough(computeResult.getEarnestMoney().getEarnestMoney());
|
|
|
account.checkBalanceEnough(computeResult.getEarnestMoney().getEarnestMoney(), SkupType.getSkupType(saleableBidSkup.getAttribute()));
|
|
|
//4.返回结果
|
|
|
Supplier<Map<String, String>> tipsConfigSupplier = () -> resourcesProxyService.getServiceTipsConfig();
|
|
|
return SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult, tipsConfigSupplier);
|
...
|
...
|
@@ -120,11 +120,11 @@ public class SellerBidPublishService { |
|
|
int storageId = saleableBidSkup.getStorageId();
|
|
|
SkupType skupType = SkupType.getSkupType(saleableBidSkup.getAttribute());
|
|
|
logger.info("[{}] compute seller bid skup fee,skup:{},storageId:{},skupType:{}", uid, saleableBidSkup.getSkup(), storageId, skupType);
|
|
|
boolean isImperfect = SellerGoodsHelper.isImperfectGoods(skupType);
|
|
|
PrdQueryReq pqr = PrdQueryReq.builder().uid(uid)
|
|
|
.storageId(storageId).prdPrice(saleableBidSkup.getPrice()).build();
|
|
|
PrdPrice prdPrice = isImperfect ? priceComputePrepareProcessor.checkPriceRange(pqr, true) : priceComputePrepareProcessor.checkPulishAuthNPriceRange(pqr, true);
|
|
|
SellerOrderComputeResult pcc = goodsAmountService.getGoodsServiceFeeRate(uid, storageId, prdPrice, skupType);
|
|
|
priceComputePrepareProcessor.checkPulishAuthNPriceRange(pqr, true);
|
|
|
|
|
|
SellerOrderComputeResult pcc = getSellerBidGoodsFeeRate(uid, skupType);
|
|
|
|
|
|
OrderComputeHandler computeHandler = orderComputeProvider.findBySkupType(skupType);
|
|
|
SellerOrderComputeResult computeResult = computeHandler.compute(saleableBidSkup.getPrice(), pcc);
|
...
|
...
|
@@ -147,7 +147,7 @@ public class SellerBidPublishService { |
|
|
|
|
|
//3.检测入驻用户账户保证金
|
|
|
Account account = accountFactory.get(uid);
|
|
|
account.checkBalanceEnough(computeResult.getEarnestMoney().getEarnestMoney());
|
|
|
account.checkBalanceEnough(computeResult.getEarnestMoney().getEarnestMoney(), SkupType.getSkupType(saleableBidSkup.getAttribute()));
|
|
|
|
|
|
int skup = saleableBidSkup.getSkup();
|
|
|
//先占库存
|
...
|
...
|
@@ -212,4 +212,23 @@ public class SellerBidPublishService { |
|
|
|
|
|
return Pair.of(noHiddenBackAddress, hiddenBackAddress);
|
|
|
}
|
|
|
|
|
|
public SellerOrderComputeResult getSellerBidGoodsFeeRate(int uid, SkupType skupType) {
|
|
|
logger.info("in getSellerBidGoodsFeeRate uid {}, skupType {}",
|
|
|
uid, skupType);
|
|
|
ServiceFeeRate rate = getSellerBidGoodsFeeRate(skupType);
|
|
|
List<ServiceFeeRate> allConfig = Lists.newArrayList(rate);
|
|
|
SellerOrderComputeResult socr = new SellerOrderComputeResult();
|
|
|
socr.setServiceFeeRates(allConfig);
|
|
|
return socr;
|
|
|
}
|
|
|
|
|
|
public ServiceFeeRate getSellerBidGoodsFeeRate(SkupType skupType) {
|
|
|
Map<String, ServiceFeeRate> sfrMap = metaConfigService.getSellerBidGoodsFeeRate();
|
|
|
|
|
|
String key = skupType.getLocalCacheKey();
|
|
|
ServiceFeeRate sft = sfrMap.get(key);
|
|
|
logger.info("getBidGoodsServiceFeeRate from local cache, skupType {} ServiceFeeRate {}", skupType, sft);
|
|
|
return sft;
|
|
|
}
|
|
|
} |
...
|
...
|
|