Authored by chenchao

merge and optimized

Showing 23 changed files with 166 additions and 187 deletions
... ... @@ -11,10 +11,8 @@ import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.SellerGoodsListRequest;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.service.seller.changePrice.ChangePriceService;
import com.yohoufo.order.service.seller.changePrice.NotEntryGoodsChangePriceService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -147,7 +145,7 @@ public class SellerGoodsController {
@RequestParam(name = "skup") int skup,
@RequestParam(name="price", required = true)String price) throws GatewayException {
SingleGoodsChangePriceReq req = SingleGoodsChangePriceReq.builder()
.uid(uid).skup(skup).price(price).build();
.uid(uid).skup(skup).num(1).price(price).build();
logger.info("in ufo.notEntrySeller.changePrice, req {}", req);
try {
OrderSubmitResp result = changePriceService.changePrice(req);
... ...
... ... @@ -138,7 +138,7 @@ public class SellerOrderController {
if(!result){
msg = "批量取消失败";
}
return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).buildSellerBo();
return new ApiResponse.ApiResponseBuilder().data(result).code(200).message(msg).build();
*/
}
... ...
... ... @@ -7,7 +7,7 @@ import lombok.Data;
* Created by chao.chen on 2019/3/22.
*/
@Data
public class NEGCPOrderContext extends SellerOrderContext{
public class ChangePriceOrderContext extends SellerOrderContext{
private SellerOrder sellerOrder;
}
... ...
package com.yohoufo.order.model;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.model.SellerOrderGoods;
... ... @@ -55,7 +56,7 @@ public class SellerOrderContext {
*/
private SkupType skupType;
private SellerTypeNode sellerTypeNode;
private SellerBo sellerBo;
}
... ...
package com.yohoufo.order.model.dto;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.service.proxy.ProductProxyService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
... ... @@ -37,15 +36,13 @@ public class ChangePricePrepareDTO {
SellerOrderComputeResult computeResult;
BigDecimal preSalePrice;
BigDecimal preEarnestMoney;
private String tips;
private boolean isSuper;
SkupType skupType;
private SellerBo sellerBo;
}
... ...
package com.yohoufo.order.model.dto;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
... ... @@ -32,5 +33,7 @@ public class SingleChangePricePrepareDTO {
private SkupType skupType;
private SellerBo sellerBo;
private String priceOverFlowTips;
}
... ...
... ... @@ -27,7 +27,7 @@ import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.impl.SkupService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.seller.changePrice.NotEntryGoodsChangePriceService;
import com.yohoufo.order.service.seller.changePrice.SingleGoodsChangePriceService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -63,7 +63,7 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
private CacheCleaner cacheCleaner;
@Autowired
private NotEntryGoodsChangePriceService notEntryGoodsChangePriceService;
private SingleGoodsChangePriceService singleGoodsChangePriceService;
/**
* 更新订单状态
* @param orderInfo
... ... @@ -100,7 +100,7 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
//
int sellerUid = orderInfo.getUid();
Long orderCode = orderInfo.getOrderCode();
notEntryGoodsChangePriceService.processAfterChangePriceOrderPaid(sellerUid, orderCode);
singleGoodsChangePriceService.processAfterChangePriceOrderPaid(sellerUid, orderCode);
String prdName = null;
String sizeName = null;
Integer productId = null;
... ...
... ... @@ -62,7 +62,7 @@ public class SellerDecrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
private void changeEarnest(int uid, long taskId, SellerTaskResult result, List<SellerOrder> successOrders,ChangePricePrepareDTO cppDto) {
try {
if (!cppDto.isSuper()) {
if (!cppDto.getSellerBo().isSuper()) {
BigDecimal preSalePrice = cppDto.getPreSalePrice(),
salePrice = cppDto.getSalePrice();
SellerOrderComputeResult computeResult = cppDto.getComputeResult();
... ...
... ... @@ -51,8 +51,8 @@ public class SellerIncrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
.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.isSuper());
SellerWallet sellerWallet = cppDto.isSuper() ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
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);
result.sellerWallet = sellerWallet;
log.info("[{}-{}] pre use total earnest result:{}", uid, taskId, sellerWallet);
return Objects.nonNull(sellerWallet);
... ... @@ -63,7 +63,7 @@ public class SellerIncrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
ChangePricePrepareDTO cppDto = taskDto.getProcessData();
int uid = taskDto.getUid();
long taskId = taskDto.getTaskId();
if (result.failCnt > 0 && !cppDto.isSuper()) {
if (result.failCnt > 0 && !cppDto.getSellerBo().isSuper()) {
BigDecimal totalDiffMoney = cppDto.getDiffEarnestMoney().multiply(BigDecimal.valueOf(-1 * result.failCnt));
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
.afterProductPrice(cppDto.getSalePrice())
... ... @@ -94,7 +94,7 @@ public class SellerIncrPriceTaskHandler extends AbstractSellerAdjustPriceTaskHan
log.info("[{}-{}] has {} skup success,need to add wallet detail", uid, taskId, result.successCnt);
try {
if (!cppDto.isSuper()) {
if (!cppDto.getSellerBo().isSuper()) {
//4 划账记录
List<OrderInfo> orderList = successOrders.parallelStream().map(
so -> OrderInfo.builder().orderCode(so.getOrderCode()).amount(cppDto.getDiffEarnestMoney()).build())
... ...
... ... @@ -41,7 +41,7 @@ import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.seller.changePrice.NotEntryGoodsChangePriceService;
import com.yohoufo.order.service.seller.changePrice.SingleGoodsChangePriceService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -117,7 +117,7 @@ public class SellerOrderCancelService {
MerchantOrderPaymentService merchantOrderPaymentService;
@Autowired
private NotEntryGoodsChangePriceService notEntryGoodsChangePriceService;
private SingleGoodsChangePriceService singleGoodsChangePriceService;
@Autowired
private CacheCleaner cacheCleaner;
... ... @@ -291,7 +291,7 @@ public class SellerOrderCancelService {
//seller order code
if (OrderCodeType.SELLER_TYPE.equals(codeType)){
//普通卖家主动取消时
notEntryGoodsChangePriceService.recordSelfCancelIfPresent(uid, orderCode);
singleGoodsChangePriceService.recordSelfCancelIfPresent(uid, orderCode);
result = cancelSellerOrder(uid, orderCode);
}
//buyer order code
... ... @@ -308,7 +308,7 @@ public class SellerOrderCancelService {
long orderCode = orderRequest.getOrderCode();
int result = 0;
notEntryGoodsChangePriceService.recordAutoCancelIfPresent(uid, orderCode);
singleGoodsChangePriceService.recordAutoCancelIfPresent(uid, orderCode);
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(sellerOrder)){
... ...
... ... @@ -525,15 +525,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
}
/**
* 批量调价
* @param req
* @return
*/
@Deprecated
public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req) throws GatewayException {
ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req);
BigDecimal preSalePrice = cppDto.getPreSalePrice(),
... ...
package com.yohoufo.order.service.seller.changePrice;
import com.alibaba.fastjson.JSON;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.dto.LifeCycleSellerGoods;
import com.yohoufo.order.model.dto.SellerTaskDTO;
import com.yohoufo.order.model.dto.SellerTaskResult;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.handler.SellerDecrPriceTaskHandler;
import com.yohoufo.order.service.handler.SellerIncrPriceTaskHandler;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.seller.imperfect.ImperfectGoodsService;
import com.yohoufo.order.service.seller.processor.SellerTaskProcessor;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -23,14 +30,25 @@ public class ChangePriceService {
private Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private NotEntryGoodsChangePriceService notEntryGoodsChangePriceService;
private SingleGoodsChangePriceService singleGoodsChangePriceService;
@Autowired
private SellerOrderService sellerOrderService;
@Autowired
private SingleGoodsChangePricePrepareProcessor singleGoodsChangePricePrepareProcessor;
@Autowired
private ImperfectGoodsService imperfectGoodsService;
SellerTaskProcessor sellerTaskProcessor;
@Autowired
private SellerIncrPriceTaskHandler sellerIncrPriceTaskHandler;
@Autowired
private SellerDecrPriceTaskHandler sellerDecrPriceTaskHandler;
private LifeCycleSellerGoods getLifeCycleSellerGoods(int skup){
if (skup <=0){
... ... @@ -45,26 +63,14 @@ public class ChangePriceService {
LifeCycleSellerGoods lcsg = getLifeCycleSellerGoods(req.getSkup());
final SkupType skupType = lcsg.getSkupType();
final Payment payment = lcsg.getPayment();
logger.info("in computeChangePrice 4 single goods, req {} LifeCycleSellerGoods {}", req, lcsg);
SoldPrdComputeBo spcb = null;
switch (skupType){
case IN_STOCK:
case ADVANCE:
if (payment == Payment.WALLET){
//TODO 之前钱包变价计算只有批量,没有针对skup单个计算的
}else{
spcb = notEntryGoodsChangePriceService.computeChangePrice(req);
}
break;
case FLAW:
case SECOND_HAND:
SellerOrderComputeReq socr = SellerOrderComputeReq.builder()
.uid(req.getUid()).skupType(skupType.getCode())
.num(1)
.price(req.getPrice()).build();
spcb = sellerOrderService.computePublishPrd(socr);
spcb = singleGoodsChangePriceService.computeChangePrice(req);
break;
}
... ... @@ -72,6 +78,35 @@ public class ChangePriceService {
}
private OrderSubmitResp changePriceOfEntryGoods(SingleGoodsChangePriceReq req){
ChangePricePrepareDTO cppDto = singleGoodsChangePricePrepareProcessor.checkAndAcquire(req);
SellerTaskDTO<ChangePricePrepareDTO> taskDTO = null;
if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) > 0) {
//涨价
taskDTO = new SellerTaskDTO(req.getUid(),
SellerWalletDetail.Type.ADD_PRICE.getValue(),
sellerIncrPriceTaskHandler,
JSON.toJSONString(req),
cppDto);
} else if (cppDto.getSalePrice().compareTo(cppDto.getPreSalePrice()) < 0) {
//降价
taskDTO = new SellerTaskDTO(req.getUid(),
SellerWalletDetail.Type.SUBTRACT_PRICE.getValue(),
sellerDecrPriceTaskHandler,
JSON.toJSONString(req),
cppDto);
}
SellerTaskResult result = sellerTaskProcessor.process(taskDTO);
//返还结果
OrderSubmitResp resp = OrderSubmitResp.builder()
.tips(cppDto.getTips()).build();
return resp;
}
public OrderSubmitResp changePrice(SingleGoodsChangePriceReq req){
LifeCycleSellerGoods lcsg = getLifeCycleSellerGoods(req.getSkup());
final Payment payment = lcsg.getPayment();
... ... @@ -84,9 +119,10 @@ public class ChangePriceService {
case SECOND_HAND:
if (payment == Payment.WALLET){
//TODO 支持入驻后上架的商品变价,通过钱包支付
resp = changePriceOfEntryGoods(req);
}else{
//TODO 现有逻辑只支持 非入驻时上架的现货和预售,不支持瑕疵or二手
resp = notEntryGoodsChangePriceService.changePrice(req);
resp = singleGoodsChangePriceService.changePrice(req);
}
break;
}
... ...
package com.yohoufo.order.service.seller.changePrice;
import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;
import com.yohoufo.order.model.dto.SingleChangePricePrepareDTO;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by chao.chen on 2019/4/15.
*/
@Service
public class EntryGoodsChangePricePrepardProcessor {
private final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private SingleGoodsChangePricePrepareProcessor singleGoodsChangePricePrepareProcessor;
public SingleChangePricePrepareDTO checkAndAcquire(SingleGoodsChangePriceReq req){
SingleChangePricePrepareDTO scppdto = singleGoodsChangePricePrepareProcessor.checkAndAcquire(req);
return scppdto;
}
}
package com.yohoufo.order.service.seller.changePrice;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.dto.SingleChangePricePrepareDTO;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.model.request.PrdQueryReq;
import com.yohoufo.order.service.seller.OrderComputeHandler;
import com.yohoufo.order.service.seller.OrderComputeProvider;
import com.yohoufo.order.service.seller.processor.ChangePriceCommonPrepareProcessor;
import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.OrderAssist;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* NES -> not entry seller paid
* 非入驻时支付的商品
* Created by chao.chen on 2019/3/21.
*/
@Service
public class NEGChangePricePrepareProcessor {
protected final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
SingleGoodsChangePricePrepareProcessor singleGoodsChangePricePrepareProcessor;
public SingleChangePricePrepareDTO checkAndAcquire(SingleGoodsChangePriceReq req){
return singleGoodsChangePricePrepareProcessor.checkAndAcquire(req);
}
}
package com.yohoufo.order.service.seller.changePrice;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.order.model.NEGCPOrderContext;
import com.yohoufo.order.model.ChangePriceOrderContext;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.seller.PublishExcutor;
... ... @@ -12,14 +12,14 @@ import org.springframework.stereotype.Service;
* Created by chao.chen on 2019/3/22.
*/
@Service
public class NEGChangePricePublishExcutor implements PublishExcutor<NEGCPOrderContext, OrderSubmitResp> {
public class NEGChangePricePublishExcutor implements PublishExcutor<ChangePriceOrderContext, OrderSubmitResp> {
@Autowired
SellerOrderService sellerOrderService;
@Override
public OrderSubmitResp publish(NEGCPOrderContext ctx) {
public OrderSubmitResp publish(ChangePriceOrderContext ctx) {
SellerOrderSubmitReq req = SellerOrderSubmitReq.builder()
.uid(ctx.getUid())
... ...
... ... @@ -9,10 +9,11 @@ import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.NEGCPOrderContext;
import com.yohoufo.order.model.ChangePriceOrderContext;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.dto.SingleChangePricePrepareDTO;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.service.impl.SellerAddressService;
import com.yohoufo.order.service.impl.SkupService;
import com.yohoufo.order.service.seller.PublishProcessor;
... ... @@ -41,23 +42,23 @@ public class NEGChangePricePublishProcessor
private SkupService skupService;
@Autowired
private NEGChangePricePrepareProcessor NEGChangePricePrepareProcessor;
private SingleGoodsChangePricePrepareProcessor singleGoodsChangePricePrepareProcessor;
@Override
public NEGCPOrderContext buildPublishCtx(SingleGoodsChangePriceReq im) {
public ChangePriceOrderContext buildPublishCtx(SingleGoodsChangePriceReq im) {
return buildSellerOrderContext(im);
}
private NEGCPOrderContext buildSellerOrderContext(SingleGoodsChangePriceReq req) {
private ChangePriceOrderContext buildSellerOrderContext(SingleGoodsChangePriceReq req) {
int uid = req.getUid();
int skup = req.getSkup();
SingleChangePricePrepareDTO scppDto = NEGChangePricePrepareProcessor.checkAndAcquire(req);
ChangePricePrepareDTO scppDto = singleGoodsChangePricePrepareProcessor.checkAndAcquire(req);
SkupType skupType = scppDto.getSkupType();
SellerOrderGoods psog = scppDto.getPsog();
SkupDto skupDto = scppDto.getSkupMap().get(skup);
SellerOrderGoods psog = skupDto.getSellerOrderGoods();
int storageId = psog.getStorageId();
SellerOrder sellerOrder = scppDto.getSellerOrder();
SellerOrder sellerOrder = skupDto.getSellerOrder();
BigDecimal salePrice = scppDto.getSalePrice();
//step 1: rpc get product detail by storage id
//ufo.product.storage.data
... ... @@ -69,14 +70,14 @@ public class NEGChangePricePublishProcessor
}
goodsInfo.setTargetSkupStatus(SkupStatus.CAN_NOT_SELL);
SellerOrderComputeResult computeResult = scppDto.getComputeResult();
String tips = scppDto.getPriceOverFlowTips();
String tips = scppDto.getTips();
//the address of send back 2 seller
AddressInfo hiddenBackAddress = sellerAddressService.getHiddenAddressInfo(uid, skup);
AddressInfo noHiddenBackAddress = sellerAddressService.getNoHiddenAddressInfo(uid, skup);
//
NEGCPOrderContext context = new NEGCPOrderContext();
ChangePriceOrderContext context = new ChangePriceOrderContext();
context.setUid(uid);
context.setStorageId(storageId);
context.setSalePrice(salePrice);
... ...
... ... @@ -2,11 +2,14 @@ package com.yohoufo.order.service.seller.changePrice;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SingleGoodsChangePriceReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
... ... @@ -16,12 +19,15 @@ import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.dto.SingleChangePricePrepareDTO;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.model.request.PrdQueryReq;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.impl.SellerWrapper;
import com.yohoufo.order.service.seller.OrderComputeHandler;
import com.yohoufo.order.service.seller.OrderComputeProvider;
import com.yohoufo.order.service.seller.SellerAuthCheckService;
import com.yohoufo.order.service.seller.processor.ChangePriceCommonPrepareProcessor;
import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -33,9 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
... ... @@ -63,6 +67,12 @@ public class SingleGoodsChangePricePrepareProcessor {
OrderComputeProvider orderComputeProvider;
@Autowired
private SellerAuthCheckService sellerAuthCheckService;
@Autowired
private SellerService sellerService;
@Autowired
private ChangePriceCommonPrepareProcessor changePriceCommonPrepareProcessor;
public void checkGoodsStatus(SellerOrderGoods psog){
... ... @@ -78,7 +88,7 @@ public class SingleGoodsChangePricePrepareProcessor {
}
}
public SingleChangePricePrepareDTO checkAndAcquire(SingleGoodsChangePriceReq req){
public ChangePricePrepareDTO checkAndAcquire(SingleGoodsChangePriceReq req){
int uid = req.getUid();
if (uid <= 0){
logger.warn("SingleGoodsChangePricePrepareProcessor checkAndAcquire uid illegal , req {}", req);
... ... @@ -130,15 +140,38 @@ public class SingleGoodsChangePricePrepareProcessor {
SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc);
//check income
priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome());
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
SellerFuncEnum sellerFuncEnum = SellerFuncEnum.SINGLE_CHANGE_PRICE;
if (sellerBo.isNormalSuper()){
sellerAuthCheckService.checkAuth(sellerBo, sellerFuncEnum);
}
int num = req.getNum();
//作为入驻商户 检查钱包
BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
BigDecimal preEarnestMoney = sellerOrder.getEarnestMoney();
BigDecimal diffEarnestMoney = BigDecimalHelper.calDiff(preEarnestMoney,targetEM);
if (sellerBo.isCommonEntry()){
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney,
num, salePrice, false);
}
//buildSellerBo one skup Map
return SingleChangePricePrepareDTO.builder()
.sellerOrder(sellerOrder)
.psog(psog)
Map<Integer, SkupDto> skupMap = new HashMap<>(1);
SkupDto skupDto = SkupDto.builder().skup(skup).batchNo(psog.getBatchNo()).sellerOrderGoods(psog)
.sellerOrder(sellerOrder).build();
skupMap.put(skup, skupDto);
return ChangePricePrepareDTO.builder()
.baseSellerOrderGoods(psog)
.skupMap(skupMap)
.prdPrice(prdPrice)
.preEarnestMoney(preEarnestMoney)
.diffEarnestMoney(diffEarnestMoney)
.preSalePrice(preSalePrice)
.salePrice(salePrice)
.computeResult(computeResult)
.skupType(skupType)
.priceOverFlowTips(tips)
.tips(tips)
.sellerBo(sellerBo)
.build();
}
... ...
... ... @@ -15,8 +15,8 @@ import com.yohoufo.dal.order.model.SellerChangePriceRecord;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.NEGCPOrderContext;
import com.yohoufo.order.model.dto.SingleChangePricePrepareDTO;
import com.yohoufo.order.model.ChangePriceOrderContext;
import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
import com.yohoufo.order.service.proxy.ProductProxyService;
... ... @@ -52,14 +52,14 @@ import java.util.stream.Collectors;
* Created by chao.chen on 2019/3/21.
*/
@Service
public class NotEntryGoodsChangePriceService {
public class SingleGoodsChangePriceService {
private final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private SellerChangePriceRecordMapper sellerChangePriceRecordMapper;
@Autowired
private NEGChangePricePrepareProcessor negChangePricePrepareProcessor;
private SingleGoodsChangePricePrepareProcessor singleGoodsChangePricePrepareProcessor;
@Autowired
private NEGChangePricePublishProcessor negChangePricePublishProcessor;
... ... @@ -90,10 +90,9 @@ public class NotEntryGoodsChangePriceService {
*/
public SoldPrdComputeBo computeChangePrice(SingleGoodsChangePriceReq req){
logger.info("in NotEntryGoodsChangePriceService.computeChangePrice, req {}", req);
SingleChangePricePrepareDTO cppDto = negChangePricePrepareProcessor.checkAndAcquire(req);
ChangePricePrepareDTO cppDto = singleGoodsChangePricePrepareProcessor.checkAndAcquire(req);
Map<String,String> tipsConfig = resourcesProxyService.getServiceTipsConfig();
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(cppDto.getComputeResult(), tipsConfig);
return computeBo;
}
... ... @@ -113,7 +112,7 @@ public class NotEntryGoodsChangePriceService {
*/
public OrderSubmitResp changePrice(SingleGoodsChangePriceReq req){
logger.info("in NotEntryGoodsChangePriceService.changePrice, req {}", req);
NEGCPOrderContext ctx = negChangePricePublishProcessor.buildPublishCtx(req);
ChangePriceOrderContext ctx = negChangePricePublishProcessor.buildPublishCtx(req);
SellerOrderGoods psog = ctx.getSellerOrderGoods();
int preSkup = psog.getId();
SellerOrder sellerOrder = ctx.getSellerOrder();
... ...
... ... @@ -2,10 +2,7 @@ package com.yohoufo.order.service.seller.imperfect;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsImage;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsInfo;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.bo.*;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.request.StoragePriceBo;
... ... @@ -18,7 +15,6 @@ import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.model.ImperfectOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohobuy.ufo.model.order.bo.SellerTypeNode;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
... ... @@ -71,14 +67,14 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
logger.info("in ImperfectGoodsPublishExcutor.publish, uid {} storageId {} salePrice {}",
uid, storageId, salePrice);
OrderSubmitResp resp = null;
SellerTypeNode sellerTypeNode = ctx.getSellerTypeNode();
if (sellerTypeNode.isNotEntry()){
SellerBo sellerBo = ctx.getSellerBo();
if (sellerBo.isNotEntry()){
resp = publishByNotEntry(ctx);
}
if (sellerTypeNode.isCommonEntry()){
if (sellerBo.isCommonEntry()){
resp = publishByCommonEntry(ctx);
}
if (sellerTypeNode.isSuper()){
if (sellerBo.isSuper()){
resp = publishBySuper(ctx);
}
return resp;
... ...
... ... @@ -4,10 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsImage;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsInfo;
import com.yohobuy.ufo.model.order.bo.*;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.OrderDetailDesc;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.ImperfectOrderSubmitReq;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
... ... @@ -16,7 +15,6 @@ import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.order.model.ImperfectOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohobuy.ufo.model.order.bo.SellerTypeNode;
import com.yohoufo.order.service.impl.SkupService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.seller.PublishProcessor;
... ... @@ -101,9 +99,9 @@ public class ImperfectPublishProcessor implements PublishProcessor<ImperfectOrde
logger.info("in buildSellerBo Seller imperfect OrderContext , uid {}, storageId {}, price {}, computeResult {}", uid, storageId,
goodsInfo.getPrice(), computeResult);
SellerTypeNode sellerTypeNode = icpNode.getSellerTypeNode();
SellerBo sellerBo = icpNode.getSellerBo();
boolean isEntryShop = sellerTypeNode.isCommonEntry() || sellerTypeNode.isSuper();
boolean isEntryShop = sellerBo.isCommonEntry() || sellerBo.isSuper();
SkupStatus tss;
if (isEntryShop){
tss = SkupStatus.CAN_SELL;
... ... @@ -125,7 +123,7 @@ public class ImperfectPublishProcessor implements PublishProcessor<ImperfectOrde
context.setSoldProduct(goodsInfo);
context.setSellerOrderComputeResult(computeResult);
context.setImperfectGoodsInfo(imperfectGoodsInfo);
context.setSellerTypeNode(sellerTypeNode);
context.setSellerBo(sellerBo);
context.setEntryShop(isEntryShop);
return context;
}
... ...
package com.yohoufo.order.service.seller.processor;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SellerBaseChangeReq;
... ... @@ -19,6 +20,7 @@ import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.model.request.PrdQueryReq;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.impl.SellerWrapper;
import com.yohoufo.order.service.seller.OrderComputeHandler;
import com.yohoufo.order.service.seller.OrderComputeProvider;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -110,9 +112,9 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh
//作为入驻商户 检查钱包
BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
BigDecimal diffEarnestMoney = BigDecimalHelper.calDiff(sourceEM,targetEM);
boolean isSuper = sellerService.isSuperEntrySeller(uid);
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
if (diffEarnestMoney.compareTo(BigDecimal.ZERO)>0){
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice, isSuper);
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice, sellerBo.isSuper());
}
priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome());
... ... @@ -125,7 +127,8 @@ public abstract class AbsEntryChangePricePrepareProcessor<T extends SellerBaseCh
.computeResult(computeResult)
.preEarnestMoney(sourceEM)
.preSalePrice(preSalePrice)
.tips(tips).isSuper(isSuper)
.tips(tips)
.sellerBo(sellerBo)
.skupType(skupType)
.build();
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.seller.processor;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.common.SellerFuncEnum;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.constants.SkupType;
... ... @@ -70,7 +71,7 @@ public class PriceComputePrepareProcessor {
SkupType skupType;
String priceOverFlowTips;
SellerOrderComputeResult computeResult;
SellerTypeNode sellerTypeNode;
SellerBo sellerBo;
}
/**
... ... @@ -150,18 +151,14 @@ public class PriceComputePrepareProcessor {
SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc);
//check seller type and wallet
SellerFuncEnum sellerFuncEnum = SellerFuncEnum.BATCH_PUBLISH;
SellerWrapper sellerWrapper = sellerService.getBaseSellerWrapper(uid);
SellerTypeNode stNode = SellerHelper.convertSellerTypeNode(sellerWrapper.buildSellerBo());
if (stNode.isNormalSuper()){
sellerAuthCheckService.checkAuth(sellerWrapper.buildSellerBo(), sellerFuncEnum);
SellerBo sellerBo = sellerService.getSellerWithAuth(uid);
if (sellerBo.isNormalSuper()){
sellerAuthCheckService.checkAuth(sellerBo, sellerFuncEnum);
}
if (stNode.isCommonEntry()){
if (sellerBo.isCommonEntry()){
checkNGetMergeEarnestMoney(uid, computeResult.getEarnestMoney().getEarnestMoney(),
num, salePrice, false);
}
return PriceComputeNode.builder()
.uid(uid)
.num(num)
... ... @@ -170,7 +167,7 @@ public class PriceComputePrepareProcessor {
.prdPrice(prdPrice)
.skupType(skupType)
.priceOverFlowTips(tips)
.sellerTypeNode(stNode)
.sellerBo(sellerBo)
.computeResult(computeResult)
.build();
}
... ...
... ... @@ -23,6 +23,9 @@ public class SellerTaskProcessor {
private SellerTaskMapper sellerTaskMapper;
public SellerTaskResult process(SellerTaskDTO taskDto) {
if (taskDto == null){
return null;
}
int uid = taskDto.getUid();
log.info("[{}] begin to process", taskDto.getUid());
//记录操作记录
... ...