Authored by tanling

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

... ... @@ -319,7 +319,7 @@ public class SellerOrderController {
@RequestParam(name = "product_id") int product_id,
@RequestParam(name = "num") int num,
@RequestParam(name="skupType", defaultValue = DEFAULT_SKUP_TYPE, required = false) Integer skupType
) throws GatewayException {
) {
SellerBatchChangeReq req = new SellerBatchChangeReq();
req.setStorageId(storage_id);
req.setUid(uid);
... ... @@ -395,7 +395,7 @@ public class SellerOrderController {
@RequestParam(name = "old_price") BigDecimal old_price,
@RequestParam(name = "num") int num,
@RequestParam(name="skupType", defaultValue = DEFAULT_SKUP_TYPE, required = false) Integer skupType
) throws GatewayException {
) {
SellerBatchChangeReq req = new SellerBatchChangeReq();
req.setStorageId(storage_id);
req.setUid(uid);
... ...
package com.yohoufo.order.model.dto;
import com.yohobuy.ufo.model.order.constants.SkupType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SkupDownShelfPrepareDto {
private Map<Integer, SkupDto> idSkupMap;
private SkupType skupType;
}
... ...
... ... @@ -3,11 +3,13 @@ package com.yohoufo.order.service.handler;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.model.dto.*;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
... ... @@ -62,7 +64,9 @@ public class SellerDecrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
private void changeEarnest(int uid, long taskId, SellerTaskResult result, List<SellerOrder> successOrders,ChangePricePrepareDTO cppDto) {
try {
if (!cppDto.getSellerBo().isSuper()) {
final SkupType skupType ;
boolean noChangeMoney = (SellerGoodsHelper.isQuickDeliver(skupType=cppDto.getSkupType()) || cppDto.getSellerBo().isSuper());
if (!noChangeMoney) {
BigDecimal preSalePrice = cppDto.getPreSalePrice(),
salePrice = cppDto.getSalePrice();
SellerOrderComputeResult computeResult = cppDto.getComputeResult();
... ... @@ -78,7 +82,8 @@ public class SellerDecrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
.seriNo(String.valueOf(taskId))
.type(SellerWalletDetail.Type.SUBTRACT_PRICE.getValue()).build();
log.info("[{}-{}] post use total earnest:{},diff earnest:{},num:{}", uid, taskId, totalDiffMoney, diffEarnestMoney, result.successCnt);
log.info("[{}-{}] post use total earnest:{},diff earnest:{},num:{}",
uid, taskId, totalDiffMoney, diffEarnestMoney, result.successCnt);
SellerWallet sellerWallet = merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
log.info("[{}-{}] post use total earnest result:{}", uid, taskId, sellerWallet);
... ...
... ... @@ -15,12 +15,14 @@ import com.yohoufo.dal.order.SellerTaskDetailMapper;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.model.dto.SellerTaskDTO;
import com.yohoufo.order.model.dto.SellerTaskResult;
import com.yohoufo.order.model.dto.SkupDownShelfPrepareDto;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.seller.setting.SellerService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.seller.SellerGoodsStatusFlowService;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -36,7 +38,7 @@ import java.util.stream.Collectors;
* Created by jiexiang.wu on 2018/12/21.
*/
@Component
public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<Map<Integer, SkupDto>> {
public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<SkupDownShelfPrepareDto> {
@Autowired
private SellerOrderMapper sellerOrderMapper;
... ... @@ -54,8 +56,9 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<Map<In
private MerchantOrderPaymentService merchantOrderPaymentService;
@Override
protected boolean preHandle(SellerTaskResult result, SellerTaskDTO<Map<Integer, SkupDto>> taskDto) {
Map<Integer, SkupDto> skupDtoMap = taskDto.getProcessData();
protected boolean preHandle(SellerTaskResult result, SellerTaskDTO<SkupDownShelfPrepareDto> taskDto) {
SkupDownShelfPrepareDto sdspDto = taskDto.getProcessData();
Map<Integer, SkupDto> skupDtoMap = sdspDto.getIdSkupMap();
Set<Integer> skupSets = skupDtoMap.keySet();
List<SellerOrder> soList = sellerOrderMapper.selectBySkups(skupSets);
for (SellerOrder so : soList) {
... ... @@ -69,8 +72,9 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<Map<In
}
@Override
protected List<FutureTask> getFutureTasks(SellerTaskResult result, SellerTaskDTO<Map<Integer, SkupDto>> taskDto) {
Map<Integer, SkupDto> skupDtoMap = taskDto.getProcessData();
protected List<FutureTask> getFutureTasks(SellerTaskResult result, SellerTaskDTO<SkupDownShelfPrepareDto> taskDto) {
SkupDownShelfPrepareDto sdspDto = taskDto.getProcessData();
Map<Integer, SkupDto> skupDtoMap = sdspDto.getIdSkupMap();
List<FutureTask> futureTasks = Lists.newArrayList();
for (Map.Entry<Integer, SkupDto> entry : skupDtoMap.entrySet()) {
FutureTask<Integer> futureTask = new FutureTask<>(new DownShelfTask(taskDto.getUid(), taskDto.getTaskId(), entry.getValue()));
... ... @@ -80,11 +84,12 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<Map<In
}
@Override
public void postHandle(SellerTaskResult result, SellerTaskDTO<Map<Integer, SkupDto>> taskDto) {
public void postHandle(SellerTaskResult result, SellerTaskDTO<SkupDownShelfPrepareDto> taskDto) {
if (result.successCnt > 0) {
SkupDownShelfPrepareDto sdspDto = taskDto.getProcessData();
Map<Integer, SkupDto> skupDtoMap = sdspDto.getIdSkupMap();
int uid = taskDto.getUid();
long taskId = taskDto.getTaskId();
Map<Integer, SkupDto> skupDtoMap = taskDto.getProcessData();
//下架成功的订单
List<SellerOrder> successOrders = Lists.newArrayList();
for (Integer skup : result.successSkups) {
... ... @@ -92,10 +97,13 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<Map<In
}
try {
boolean isSuper = sellerService.isSuperEntrySeller(uid);
//退保证金
SellerWallet sellerWallet = postRefundEarnest(uid, taskId, isSuper, result, successOrders);
//明细
addWalletDetail(uid, taskId, isSuper, sellerWallet, successOrders);
boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(sdspDto.getSkupType());
if (!isQuickDeliver) {
//退保证金
SellerWallet sellerWallet = postRefundEarnest(uid, taskId, isSuper, result, successOrders);
//明细
addWalletDetail(uid, taskId, isSuper, sellerWallet, successOrders);
}
//消息盒子
inboxNotify(uid, skupDtoMap);
... ...
... ... @@ -3,11 +3,13 @@ package com.yohoufo.order.service.handler;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.model.dto.*;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
... ... @@ -50,9 +52,12 @@ public class SellerIncrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
.earnestMoney(totalDiffMoney).productCount(skupDtoMap.size())
.seriNo(String.valueOf(taskId))
.type(swdType.getValue()).build();
log.info("[{}-{}] pre use total earnest:{},diff earnest:{},num:{},super:{}", uid, taskId, totalDiffMoney, diffEarnestMoney, skupDtoMap.size(), cppDto.getSellerBo().isSuper());
SellerWallet sellerWallet = cppDto.getSellerBo().isSuper() ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
final SkupType skupType = cppDto.getSkupType();
final boolean isSuper = cppDto.getSellerBo().isSuper();
log.info("[{}-{}] pre use total earnest:{},diff earnest:{},num:{},super:{} skupType {}",
uid, taskId, totalDiffMoney, diffEarnestMoney, skupDtoMap.size(), isSuper, skupType);
boolean noChangeMoney = SellerGoodsHelper.isQuickDeliver(skupType) || isSuper;
SellerWallet sellerWallet = noChangeMoney ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
result.sellerWallet = sellerWallet;
log.info("[{}-{}] pre use total earnest result:{}", uid, taskId, sellerWallet);
return Objects.nonNull(sellerWallet);
... ... @@ -63,7 +68,9 @@ public class SellerIncrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
ChangePricePrepareDTO cppDto = taskDto.getProcessData();
int uid = taskDto.getUid();
long taskId = taskDto.getTaskId();
if (result.failCnt > 0 && !cppDto.getSellerBo().isSuper()) {
final boolean isSuper = cppDto.getSellerBo().isSuper();
final boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(cppDto.getSkupType());
if (!isQuickDeliver && result.failCnt > 0 && !isSuper) {
BigDecimal totalDiffMoney = cppDto.getDiffEarnestMoney().multiply(BigDecimal.valueOf(-1 * result.failCnt));
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
.afterProductPrice(cppDto.getSalePrice())
... ... @@ -94,7 +101,7 @@ public class SellerIncrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
log.info("[{}-{}] has {} skup success,need to add wallet detail", uid, taskId, result.successCnt);
try {
if (!cppDto.getSellerBo().isSuper()) {
if (!isQuickDeliver && !isSuper) {
//4 划账记录
List<OrderInfo> orderList = successOrders.parallelStream().map(
so -> OrderInfo.builder().orderCode(so.getOrderCode()).amount(cppDto.getDiffEarnestMoney()).build())
... ...
... ... @@ -329,12 +329,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
//扣减保证金
final int num = req.getNum();
int uid = req.getUid();
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, SellerFuncEnum.BATCH_PUBLISH);
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, ctx.getSkupType(), SellerFuncEnum.BATCH_PUBLISH);
Boolean isSuper = sellerBo.isSuper();
SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult();
BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney();
BigDecimal mEarestMoney = priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney,
num, ctx.getSalePrice(), isSuper);
num, ctx.getSalePrice(), isSuper, ctx.getSkupType());
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.PUBLISH;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
.storageId(ctx.getStorageId()).earnestMoney(mEarestMoney)
... ... @@ -413,7 +413,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
}
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
int uid = req.getUid();
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, SellerFuncEnum.BATCH_OFFSHELVE);
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, null, SellerFuncEnum.BATCH_OFFSHELVE);
Boolean isSuper = sellerBo.isSuper();
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
.earnestMoney(totalRefundEM).productCount(needCancelSkups.size())
... ... @@ -590,7 +590,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req);
BigDecimal preSalePrice = cppDto.getPreSalePrice(),
salePrice = cppDto.getSalePrice();
SellerBo sellerBo = sellerAuthCheckService.checkAuth(req.getUid(), SellerFuncEnum.BATCH_CHANGEPRICE);
SellerBo sellerBo = sellerAuthCheckService.checkAuth(req.getUid(), null, SellerFuncEnum.BATCH_CHANGEPRICE);
boolean isSuper = sellerBo.isSuper();
int uid = req.getUid();
Map<Integer, SkupDto> skupMap = cppDto.getSkupMap();
... ... @@ -690,10 +690,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
* @param req
* @return
*/
public BatchChangePriceResp batchAdjustPrice(SellerBatchChangeReq req) throws GatewayException {
public BatchChangePriceResp batchAdjustPrice(SellerBatchChangeReq req) {
//校验及计算金额
ChangePricePrepareDTO cppDto = adjustPricePrepareProcessor.checkAndAcquire(req);
SellerBo sellerBo = sellerAuthCheckService.checkAuth(req.getUid(), SellerFuncEnum.BATCH_CHANGEPRICE);
final SkupType skupType = cppDto.getSkupType();
SellerBo sellerBo = sellerAuthCheckService.checkAuth(req.getUid(), skupType, SellerFuncEnum.BATCH_CHANGEPRICE);
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
//涨价
... ... @@ -725,8 +726,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
}
public boolean batchDownShelf(SellerBatchChangeReq req) {
Map<Integer, SkupDto> skupDtoMap = sellerDownShelfPrepareProcessor.checkAndAcquire(req);
SellerTaskDTO<Map<Integer, SkupDto>> taskDTO = new SellerTaskDTO(req.getUid(),
SkupDownShelfPrepareDto skupDtoMap = sellerDownShelfPrepareProcessor.checkAndAcquire(req);
SellerTaskDTO<SkupDownShelfPrepareDto> taskDTO = new SellerTaskDTO(req.getUid(),
SellerWalletDetail.Type.SELLER_OFF.getValue(),
sellerDownShelfTaskHandler,
JSON.toJSONString(req),
... ...
... ... @@ -207,14 +207,14 @@ public class BuyerOrderChangeBusinessPostProcessor {
logger.info("[{}] notify resource to clear user cache", uid);
try {
String url = baseServiceCaller.getYohoGatewayUrl() + "?method=app.resources.clearUserCache&client_type=h5&uid=" + uid;
String url = baseServiceCaller.getErpGatewayUrl() + "/erp/resources/user/clearCache/?uid=" + uid;
baseServiceCaller.proxyPost("app.resources.clearUserCache", url, null);
} catch (Exception ex) {
logger.error("clear user cache for resource,uid:{}", uid, ex);
}
//2.
logger.info("[{}] notify fofp to consume buyer order", uid);
logger.info("[{}] notify fofp to consume buyer order", buyerOrder.getOrderCode());
JSONObject jsonObject = new JSONObject();
jsonObject.put("uid", uid);
jsonObject.put("orderCode", buyerOrder.getOrderCode());
... ...
... ... @@ -29,17 +29,10 @@ public class BaseServiceCaller {
@Value("${erp-gateway.url}")
private String erpGatewayUrl;
@Value("${yoho.gateway.url:http://service.yoho.yohoops.org}")
private String yohoGatewayUrl;
public String getErpGatewayUrl() {
return erpGatewayUrl;
}
public String getYohoGatewayUrl() {
return yohoGatewayUrl;
}
public ApiResponse proxyPost(String serviceName, String url, Object object) {
return doPost(serviceName, url, object);
}
... ...
... ... @@ -68,7 +68,7 @@ public class ImportPublishExcutor implements PublishExcutor<BatchImportPrdReq, S
return null;
}
sellerWrapper = sellerWrapper.attachSellerLevelFunc((sw)->sellerFuncService.getSellerLevelFunc(sw));
sellerAuthCheckService.checkAuth(sellerBo, SellerFuncEnum.BATCH_PUBLISH);
sellerAuthCheckService.checkAuth(sellerBo, null, SellerFuncEnum.BATCH_PUBLISH);
//TODO check left in wallet
for(ProductImportTranItemBo importPrd : importPrds){
Integer storageId = importPrd.getStorageId();
... ...
... ... @@ -5,11 +5,13 @@ import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohobuy.ufo.model.order.common.SellerWalletType;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerWalletMapper;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.order.service.seller.setting.SellerService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* Created by chao.chen on 2019/1/15.
... ... @@ -32,12 +35,13 @@ public class SellerAuthCheckService {
@Autowired
private SellerWalletMapper sellerWalletMapper;
public void checkAuth(SellerBo sellerBo, SellerFuncEnum sellerFunc){
public void checkAuth(SellerBo sellerBo, SkupType skupType, SellerFuncEnum sellerFunc){
int uid = sellerBo.getUid();
EntrySellerType est = sellerBo.getEntrySellerType();
boolean needCheck = sellerBo.isNormalSuper() || sellerBo.isLargeSettlementSuper();
boolean excludeSkupType = SellerGoodsHelper.isQuickDeliver(skupType);
boolean includeSellerType = sellerBo.isNormalSuper() || sellerBo.isLargeSettlementSuper();
if (needCheck){
if (!excludeSkupType && includeSellerType){
SellerLevelFuncBo slfb = sellerBo.getSellerLevelFunc();
List<Integer> funcIdList = slfb.getFuncIdList();
Integer level = slfb.getLevel();
... ... @@ -53,9 +57,9 @@ public class SellerAuthCheckService {
}
}
public SellerBo checkAuth(Integer uid, SellerFuncEnum sellerFunc){
public SellerBo checkAuth(Integer uid, SkupType skupType, SellerFuncEnum sellerFunc){
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
checkAuth(sellerBo, sellerFunc);
checkAuth(sellerBo, skupType, sellerFunc);
return sellerBo;
}
... ...
... ... @@ -139,7 +139,7 @@ public class SingleGoodsChangePricePrepareProcessor {
priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome());
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
SellerFuncEnum sellerFuncEnum = SellerFuncEnum.SINGLE_CHANGE_PRICE;
sellerAuthCheckService.checkAuth(sellerBo, sellerFuncEnum);
sellerAuthCheckService.checkAuth(sellerBo, skupType, sellerFuncEnum);
int num = req.getNum();
//作为入驻商户 检查钱包
BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
... ... @@ -147,7 +147,7 @@ public class SingleGoodsChangePricePrepareProcessor {
BigDecimal diffEarnestMoney = BigDecimalHelper.calDiff(preEarnestMoney,targetEM);
if (sellerBo.isCommonEntry()){
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney,
num, salePrice, false);
num, salePrice, false, skupType);
}
//buildSellerBo one skup Map
Map<Integer, SkupDto> skupMap = new HashMap<>(1);
... ...
... ... @@ -88,7 +88,6 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh
BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(req.getPrice(), skupType);
//若needChangePriceSkupList中有skup出现不存在于skupOfSalingMap keys中,说明该skup走到了其他状态中
Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(getExpectedSkups(req), req.getOldPrice(), salePrice, skupOfSalingMap);
// //
SkupDto sampleSkupDto = skupMap.values().iterator().next();
int sampleSkup = sampleSkupDto.getSkup();
SellerOrderGoods sampleSog = sampleSkupDto.getSellerOrderGoods();
... ... @@ -113,7 +112,8 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh
BigDecimal diffEarnestMoney = BigDecimalHelper.calDiff(sourceEM,targetEM);
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
if (diffEarnestMoney.compareTo(BigDecimal.ZERO)>0){
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice, sellerBo.isSuper());
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num,
salePrice, sellerBo.isSuper(), skupType);
}
priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome());
... ... @@ -182,7 +182,8 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh
throw new UfoServiceException(400, "部分商品正在等待买家支付");
}
return sellerOrderGoodList.parallelStream().collect(Collectors.toMap(SellerOrderGoods::getId,
(sog)-> SkupDto.builder().skup(sog.getId()).sellerOrderGoods(sog).batchNo(sog.getBatchNo()).build()));
(sog)-> SkupDto.builder().skup(sog.getId()).sellerOrderGoods(sog)
.batchNo(sog.getBatchNo()).build()));
}
... ...
... ... @@ -149,10 +149,10 @@ public class PriceComputePrepareProcessor {
//check seller type and wallet
SellerFuncEnum sellerFuncEnum = SellerFuncEnum.BATCH_PUBLISH;
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
sellerAuthCheckService.checkAuth(sellerBo, sellerFuncEnum);
sellerAuthCheckService.checkAuth(sellerBo, skupType, sellerFuncEnum);
if (sellerBo.isCommonEntry()){
checkNGetMergeEarnestMoney(uid, computeResult.getEarnestMoney().getEarnestMoney(),
num, salePrice, false);
num, salePrice, false, skupType);
}
return PriceComputeNode.builder()
.uid(uid)
... ... @@ -212,15 +212,17 @@ public class PriceComputePrepareProcessor {
if (prdPrice.subtract(minPrice).doubleValue() < 0D){
log.warn("in computePublishPrd,uid {} minPrice {}, storageId {}",
uid, minPrice, storageId);
if (isShowError)
if (isShowError){
throw new UfoServiceException(501, "您的出价过低");
}
}
if (prdPrice.subtract(maxPrice).doubleValue() > 0D){
log.warn("in computePublishPrd,uid {} maxPrice {}, storageId {}",
uid, maxPrice, storageId);
if (isShowError)
if (isShowError){
throw new UfoServiceException(501, "您的出价过高");
}
}
}
... ... @@ -246,9 +248,13 @@ public class PriceComputePrepareProcessor {
}
public BigDecimal checkNGetMergeEarnestMoney(int uid, BigDecimal singleEarestMoney,
int num, BigDecimal prdPrice, boolean isSuper){
BigDecimal mEarestMoney;
mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
int num, BigDecimal prdPrice,
boolean isSuper, SkupType skupType){
BigDecimal mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
if (SellerGoodsHelper.isQuickDeliver(skupType)){
return mEarestMoney;
}
if(!isSuper) {
boolean isEnough = sellerAuthCheckService.isEnough(uid, mEarestMoney);
if (!isEnough) {
... ...
package com.yohoufo.order.service.seller.processor;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SellerBatchChangeReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.model.dto.SkupDownShelfPrepareDto;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -35,12 +37,19 @@ public class SellerDownShelfPrepareProcessor {
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
public Map<Integer, SkupDto> checkAndAcquire(SellerBatchChangeReq req) {
public SkupDownShelfPrepareDto checkAndAcquire(SellerBatchChangeReq req) {
int uid = req.getUid();
if (uid <= 0) {
logger.warn("batch off shelve checkAndAcquire uid illegal , req {}", req);
throw new UfoServiceException(400, "参数[uid]错误");
}
Integer skupTypeCode = req.getSkupType();
SkupType skupType;
if (Objects.isNull(skupTypeCode) || Objects.isNull(skupType=SkupType.getSkupType(skupTypeCode))){
logger.warn("batch off shelve checkAndAcquire skupTypeCode illegal , req {}", req);
throw new UfoServiceException(400, "参数[skupType]错误");
}
int num = req.getNum();
if (num <= 0) {
logger.warn("batch off shelve checkAndAcquire num is illegal, req {}", req);
... ... @@ -59,7 +68,12 @@ public class SellerDownShelfPrepareProcessor {
}
//检查
Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(req);
return skupMap;
SkupDownShelfPrepareDto sdspDto = SkupDownShelfPrepareDto.builder()
.idSkupMap(skupMap)
.skupType(skupType)
.build();
return sdspDto;
}
private Map<Integer, SkupDto> checkNeedProcessSkups(SellerBatchChangeReq req) {
... ...
... ... @@ -67,4 +67,9 @@ public final class SellerGoodsHelper {
}
return result;
}
public static boolean isQuickDeliver(SkupType skupType){
return skupType != null && SkupType.QUICK_DELIVER.equals(skupType);
}
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.seller.setting;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.service.seller.SellerAuthCheckService;
import org.junit.Test;
... ... @@ -17,7 +18,8 @@ public class SellerAuthCheckServiceTest extends BaseWebTest {
public void testCheckAuth(){
Integer uid = 500031424;
SellerFuncEnum sellerFunc = SellerFuncEnum.BATCH_CHANGEPRICE;
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, sellerFunc);
SkupType skupType = SkupType.IN_STOCK;
SellerBo sellerBo = sellerAuthCheckService.checkAuth(uid, skupType, sellerFunc);
System.out.println("testCheckAuth BATCH_CHANGEPRICE "+ JSONObject.toJSONString(sellerBo));
}
}
... ...