Authored by wujiexiang

Merge branch 'dev_bid' into test6.9.13

... ... @@ -16,7 +16,6 @@ import com.yohoufo.order.constants.CouponConstants;
import com.yohoufo.order.model.request.ShoppingRequest;
import com.yohoufo.order.service.impl.MetaConfigService;
import com.yohoufo.order.service.proxy.CouponProxyService;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.tuple.Pair;
... ... @@ -44,7 +43,9 @@ public class ChargeContextFactory {
SellerOrderGoods skupInfo,
ActivityPrice activityPrice,
int chargeStage,
Function<ShoppingRequest, Pair<AddressInfo, AddressInfo>> userAddressFunc) {
Function<SkupType, Integer> deliveryWayFunc,
Function<ShoppingRequest, Pair<AddressInfo, AddressInfo>> userAddressFunc
) {
Integer promotionId;
boolean promotionSelected = Objects.nonNull(promotionId=request.getPromotionId());
//优惠券
... ... @@ -105,7 +106,7 @@ public class ChargeContextFactory {
ChargeParam chargeParam = ChargeParam.builder().uid(request.getUid())
.chargeStage(chargeStage)
.apiVersion(request.getApiVersion())
.deliveryWay(buildDeliveryWay(skupType))
.deliveryWay(deliveryWayFunc.apply(skupType))
.shipFee(shipFee)
.couponCodes(couponCodes)
.tariffCutPolicy(acpMap.get(BuyOrderFeeName.TARIFF_AMOUNT))
... ... @@ -177,34 +178,7 @@ public class ChargeContextFactory {
return tcpMap;
}
protected int buildDeliveryWay(SkupType skupType) {
DeliveryWayEnum deliveryWay ;
if (skupType==null){
deliveryWay = DeliveryWayEnum.SF;
}else{
SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupType.getCode());
RegionEnum regionEnum = RegionEnum.getByCode(codeNode.getRegion());
if (regionEnum == null){
deliveryWay = DeliveryWayEnum.SF;
}else{
switch (regionEnum){
case HONGKONG:
deliveryWay = DeliveryWayEnum.OVERSEAS_HONGHONG;
break;
case MAINLAND:
default:
deliveryWay = DeliveryWayEnum.SF;
break;
}
}
}
return deliveryWay.getCode();
}
private FeeNRate getFeeNRate(SkupType skupType){
if (skupType == null){
... ...
... ... @@ -2,10 +2,28 @@ package com.yohoufo.order.model;
import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.charge.ChargeContext;
import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.service.impl.ShoppingServiceImpl;
import org.apache.commons.lang3.tuple.Pair;
import java.util.function.Function;
public class OfflineOrderBuilderFactory extends OrderBuilderFactory {
@Override
protected int buildDeliveryWay(SkupType skupType) {
public OrderBuilder create(int uid, long orderCode, String channelNo, String clientType,
Pair<AddressInfo, AddressInfo> userAddressPair,
ShoppingServiceImpl.GoodsPrepareData goodsPrepareData,
Function<SkupType, Integer> deliveryWayFunc,
SellerOrderGoods psog,
ChargeContext chargeContext) {
return super.create(uid, orderCode, channelNo, clientType, userAddressPair, goodsPrepareData, this::getDeliveryWayCode, psog, chargeContext);
}
public int getDeliveryWayCode(SkupType skupType) {
return DeliveryWayEnum.SELF_FETCH.getCode();
}
}
... ...
package com.yohoufo.order.model;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
... ... @@ -18,16 +16,21 @@ import com.yohoufo.order.model.bo.CouponBo;
import com.yohoufo.order.model.bo.CouponBoList;
import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.service.impl.ShoppingServiceImpl;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
import org.apache.commons.lang3.tuple.Pair;
import java.math.BigDecimal;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public class OrderBuilderFactory {
public OrderBuilder create(int uid, long orderCode, String channelNo, String clientType, Pair<AddressInfo, AddressInfo> userAddressPair, ShoppingServiceImpl.GoodsPrepareData goodsPrepareData, SellerOrderGoods psog, ChargeContext chargeContext) {
public OrderBuilder create(int uid, long orderCode, String channelNo, String clientType,
Pair<AddressInfo, AddressInfo> userAddressPair,
ShoppingServiceImpl.GoodsPrepareData goodsPrepareData,
Function<SkupType, Integer> deliveryWayFunc,
SellerOrderGoods psog,
ChargeContext chargeContext) {
//算费结果
ChargeResult chargeResult = chargeContext.getChargeResult();
ChargeGoods chargeGoods = chargeContext.getChargeGoods();
... ... @@ -40,7 +43,7 @@ public class OrderBuilderFactory {
.orderCode(orderCode)
.productId(psog.getProductId())
.paymentType(OrderConstant.PAYMENT_ONLINE)
.deliverWay(buildDeliveryWay(skupType))
.deliverWay(deliveryWayFunc.apply(skupType))
.channelNo(channelNo)
.amount(BigDecimal.valueOf(chargeResult.getFinalAmount()))
.shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount()))
... ... @@ -60,35 +63,6 @@ public class OrderBuilderFactory {
.build();
}
protected int buildDeliveryWay(SkupType skupType) {
DeliveryWayEnum deliveryWay ;
if (skupType==null){
deliveryWay = DeliveryWayEnum.SF;
}else{
SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupType.getCode());
RegionEnum regionEnum = RegionEnum.getByCode(codeNode.getRegion());
if (regionEnum == null){
deliveryWay = DeliveryWayEnum.SF;
}else{
switch (regionEnum){
case HONGKONG:
deliveryWay = DeliveryWayEnum.OVERSEAS_HONGHONG;
break;
case MAINLAND:
default:
deliveryWay = DeliveryWayEnum.SF;
break;
}
}
}
return deliveryWay.getCode();
}
/**
* 获取订单attribute属性
*
... ...
... ... @@ -36,6 +36,7 @@ import com.yohoufo.order.service.seller.SkupService;
import com.yohoufo.order.service.seller.processor.PriceComputePrepareProcessor;
import com.yohoufo.order.service.support.ShoppingSupport;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.utils.DeliveryWayUtils;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.MathUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -169,6 +170,7 @@ public class BuyerBidPublishService {
newSellerOrderGoods(0, 0, bidPrice.getPrice()),
ActivityPrice.NON_ACTIVITY_PRICE,
ChargeParam.COMPUTE,
DeliveryWayUtils::findDeliveryWayCodeBySkupType,
(shoppingRequest) -> {
if (StringUtils.isNoneBlank(shoppingRequest.getAddressId())) {
return shoppingSupport.getAndCheckAddressInfo(request.getUid(), request.getAddressId());
... ... @@ -248,6 +250,7 @@ public class BuyerBidPublishService {
request.getChannelNo(), request.getClientType(),
getAndCheckAddressInfo(request),
new ShoppingServiceImpl.GoodsPrepareData(),
DeliveryWayUtils::findDeliveryWayCodeBySkupType,
newSellerOrderGoods(skup, goodsInfo.getProductId(), bidPrice.getPrice()),
chargeContext);
//求购 定金
... ...
... ... @@ -2,6 +2,8 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.response.store.StoreInfoBo;
import com.yohoufo.common.ApiResponse;
... ...
... ... @@ -9,7 +9,6 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.*;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.lock.RedisLock;
... ... @@ -29,12 +28,7 @@ import com.yohoufo.order.constants.ActivityTypeEnum;
import com.yohoufo.order.event.BuyerCancelEvent;
import com.yohoufo.order.event.ErpBuyerOrderEvent;
import com.yohoufo.order.event.NotPaidNoticeEvent;
import com.yohoufo.order.model.OfflineOrderBuilderFactory;
import com.yohoufo.order.model.OrderBuilderFactory;
import com.yohoufo.order.model.bo.ActivityBo;
import com.yohoufo.order.model.bo.AmountDetailBo;
import com.yohoufo.order.model.bo.CouponBo;
import com.yohoufo.order.model.bo.CouponBoList;
import com.yohoufo.order.model.dto.BuyerOrderSubmitResult;
import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.model.request.ShoppingRequest;
... ... @@ -51,7 +45,6 @@ import com.yohoufo.order.service.proxy.CouponProxyService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.seller.orderMeta.SellerFeeService;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
import com.yohoufo.order.service.support.CouponSupport;
import com.yohoufo.order.service.support.PromotionSupport;
import com.yohoufo.order.service.support.ShoppingSupport;
... ... @@ -132,15 +125,9 @@ public class ShoppingServiceImpl implements IShoppingService {
private AppraiseAddressService appraiseAddressService;
@Autowired
private MetaConfigService metaConfigService;
@Autowired
private StorageDepositMapper storageDepositMapper;
@Autowired
private CouponProxyService couponProxyService;
@Autowired
private RedisLockFactory redisLockFactory;
@Autowired
... ... @@ -311,7 +298,9 @@ public class ShoppingServiceImpl implements IShoppingService {
SellerOrderGoods skupInfo,
ActivityPrice activityPrice,
int chargeStage) {
return chargeContextFactory.buildChargeContext(request, skupInfo, activityPrice, chargeStage, this::getAndCheckAddressInfo);
return chargeContextFactory.buildChargeContext(request, skupInfo, activityPrice, chargeStage,
DeliveryWayUtils::findDeliveryWayCodeBySkupType,
this::getAndCheckAddressInfo);
}
@Override
... ... @@ -454,11 +443,12 @@ public class ShoppingServiceImpl implements IShoppingService {
logger.info("generate new orderCode:{}", orderCode);
orderBuilder = getOrderBuilderFactory().create(uid,orderCode,shoppingRequest.getChannelNo(),
orderBuilder = getOrderBuilderFactory().create(uid, orderCode, shoppingRequest.getChannelNo(),
shoppingRequest.getClientType(),
userAddressPair,
goodsPrepareData,
psog,chargeContext);
DeliveryWayUtils::findDeliveryWayCodeBySkupType,
psog, chargeContext);
submitResult = ordeCreationService.doSubmitOrder(orderBuilder);
}finally {
... ...
package com.yohoufo.order.utils;
import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
public class DeliveryWayUtils {
public static int findDeliveryWayCodeBySkupType(SkupType skupType) {
DeliveryWayEnum deliveryWay;
if (skupType == null) {
deliveryWay = DeliveryWayEnum.SF;
} else {
SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupType.getCode());
RegionEnum regionEnum = RegionEnum.getByCode(codeNode.getRegion());
if (regionEnum == null) {
deliveryWay = DeliveryWayEnum.SF;
} else {
switch (regionEnum) {
case HONGKONG:
deliveryWay = DeliveryWayEnum.OVERSEAS_HONGHONG;
break;
case MAINLAND:
default:
deliveryWay = DeliveryWayEnum.SF;
break;
}
}
}
return deliveryWay.getCode();
}
}
... ...