...
|
...
|
@@ -6,8 +6,7 @@ import com.yoho.core.rest.client.ServiceCaller; |
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.order.common.*;
|
|
|
import com.yohobuy.ufo.model.order.constants.ChangePriceStatus;
|
|
|
import com.yohobuy.ufo.model.order.constants.SkupType;
|
|
|
import com.yohobuy.ufo.model.order.constants.*;
|
|
|
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
...
|
...
|
@@ -20,7 +19,6 @@ import com.yohoufo.dal.order.model.BuyerOrder; |
|
|
import com.yohoufo.dal.order.model.SellerChangePriceRecord;
|
|
|
import com.yohoufo.dal.order.model.SellerOrder;
|
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
import com.yohobuy.ufo.model.order.constants.OrderConstant;
|
|
|
import com.yohoufo.order.charge.ChargeContext;
|
|
|
import com.yohoufo.order.charge.ChargeService;
|
|
|
import com.yohoufo.order.charge.model.*;
|
...
|
...
|
@@ -46,6 +44,7 @@ import com.yohoufo.order.service.listener.OrderChangeListenerContainer; |
|
|
import com.yohoufo.order.service.proxy.BargainProxyService;
|
|
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
|
|
import com.yohoufo.order.service.proxy.UserProxyService;
|
|
|
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
|
|
|
import com.yohoufo.order.service.support.CouponSupport;
|
|
|
import com.yohoufo.order.service.support.ShoppingSupport;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
...
|
...
|
@@ -61,6 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
...
|
...
|
@@ -125,7 +125,10 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
private ConfigReader configReader;
|
|
|
|
|
|
@Autowired
|
|
|
AppraiseAddressService appraiseAddressService;
|
|
|
private AppraiseAddressService appraiseAddressService;
|
|
|
|
|
|
@Autowired
|
|
|
private MetaConfigService metaConfigService;
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -133,6 +136,7 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public PaymentResponse payment(ShoppingRequest request){
|
|
|
int skup;
|
|
|
int uid;
|
...
|
...
|
@@ -237,17 +241,34 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
.activityTypeEnum(activityTypeEnum).build();
|
|
|
}
|
|
|
|
|
|
private ChargeContext buildChargeContext(ShoppingRequest request, SellerOrderGoods skupInfo, ActivityPrice activityPrice,int chargeStage) {
|
|
|
private ChargeContext buildChargeContext(ShoppingRequest request,
|
|
|
SellerOrderGoods skupInfo,
|
|
|
ActivityPrice activityPrice,
|
|
|
int chargeStage) {
|
|
|
Integer skupAttr = skupInfo.getAttributes();
|
|
|
SkupType skupType = SkupType.getSkupType(skupAttr);
|
|
|
FeeNRate feeNRate = getFeeNRate(skupType);
|
|
|
BigDecimal tariffRate = null;
|
|
|
if (feeNRate != null){
|
|
|
tariffRate = feeNRate.getTariffRate();
|
|
|
}
|
|
|
ChargeParam chargeParam = ChargeParam.builder().uid(request.getUid())
|
|
|
.chargeStage(chargeStage)
|
|
|
.apiVersion(request.getApiVersion())
|
|
|
.deliveryWay(buildDeliveryWay())
|
|
|
.deliveryWay(buildDeliveryWay(skupType))
|
|
|
.couponCodes(request.getCouponCodes()).build();
|
|
|
|
|
|
ChargeGoods chargeGoods = ChargeGoods.builder()
|
|
|
.goodsPrice(skupInfo.getGoodsPrice())
|
|
|
.productId(skupInfo.getProductId())
|
|
|
.attributes(skupAttr)
|
|
|
.skup(skupInfo.getId())
|
|
|
.activityCutPrice(BigDecimal.ZERO)
|
|
|
.skupType(skupType)
|
|
|
.tariffRate(tariffRate)
|
|
|
.build();
|
|
|
return ChargeContext.builder()
|
|
|
.chargeParam(chargeParam)
|
|
|
.chargeGoods(ChargeGoods.builder().goodsPrice(skupInfo.getGoodsPrice()).productId(skupInfo.getProductId())
|
|
|
.attributes(skupInfo.getAttributes()).skup(skupInfo.getId()).activityCutPrice(BigDecimal.ZERO).build())
|
|
|
.chargeGoods(chargeGoods)
|
|
|
.activityPrice(activityPrice)
|
|
|
.build();
|
|
|
|
...
|
...
|
@@ -325,6 +346,32 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
return response;
|
|
|
}
|
|
|
|
|
|
private FeeNRate buildDefaultFeeNRate(SkupType skupType){
|
|
|
FeeNRate feeNRate = null;
|
|
|
switch (skupType){
|
|
|
case HK_IN_STOCK:
|
|
|
feeNRate = new FeeNRate();
|
|
|
feeNRate.setShipFee(new BigDecimal(55));
|
|
|
feeNRate.setShipFee(new BigDecimal(0.091));
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
return feeNRate;
|
|
|
}
|
|
|
|
|
|
|
|
|
private FeeNRate getFeeNRate(SkupType skupType){
|
|
|
if (skupType == null){
|
|
|
return null;
|
|
|
}
|
|
|
Map<String,FeeNRate> config = metaConfigService.getBuyerOrderFeeNRate();
|
|
|
if (config == null){
|
|
|
// set default
|
|
|
return buildDefaultFeeNRate(skupType);
|
|
|
}
|
|
|
return config.get(skupType.getLocalCacheKey());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提交订单
|
|
|
* @param shoppingRequest
|
...
|
...
|
@@ -366,6 +413,8 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
|
|
|
logger.info("generate new orderCode:{}",orderCode);
|
|
|
|
|
|
SkupType skupType = chargeContext.getChargeGoods().getSkupType();
|
|
|
|
|
|
// 减库存,skup更新成不可售,入库
|
|
|
//BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost);
|
|
|
OrderBuilder orderBuilder = OrderBuilder.builder()
|
...
|
...
|
@@ -374,7 +423,7 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
.orderCode(orderCode)
|
|
|
.productId(psog.getProductId())
|
|
|
.paymentType(OrderConstant.PAYMENT_ONLINE)
|
|
|
.deliverWay(buildDeliveryWay())
|
|
|
.deliverWay(buildDeliveryWay(skupType))
|
|
|
.channelNo(shoppingRequest.getChannelNo())
|
|
|
.amount(BigDecimal.valueOf(chargeResult.getFinalAmount()))
|
|
|
.shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount()))
|
...
|
...
|
@@ -425,7 +474,7 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
//
|
|
|
inBoxFacade.sellerSkupCreateOrderByBuyer(sellerUid, psog);
|
|
|
}else{
|
|
|
logger.warn("buyer submit order ");
|
|
|
logger.warn("buyer submit order ordeCreationService.doSubmitOrder fail shoppingRequest {}", shoppingRequest);
|
|
|
}
|
|
|
// 返回结果
|
|
|
return OrderSubmitResponse.builder().orderCode(orderCode).productId(psog.getProductId())
|
...
|
...
|
@@ -548,6 +597,8 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
//活动金额
|
|
|
amountDetailBo.setActivityCutAmount(chargeResult.getActivityCutResult().getActivityCutAmount());
|
|
|
|
|
|
//税费
|
|
|
amountDetailBo.setTariffAmount(chargeResult.getTariffAmount());
|
|
|
//活动券减免金额
|
|
|
chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode()).
|
|
|
ifPresent(tempPayResult -> amountDetailBo.setCouponCutAmount(tempPayResult.getCouponAmount()));
|
...
|
...
|
@@ -559,8 +610,33 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
return amountDetailBo;
|
|
|
}
|
|
|
|
|
|
protected int buildDeliveryWay() {
|
|
|
return OrderConstant.DELIVERY_WAY_SF;
|
|
|
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();
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|