Authored by chenchao

add business client

... ... @@ -61,6 +61,9 @@ public class BuyerOrder {
@Getter@Setter
private Integer activityType;//活动类型:0:普通,18:砍价
@Getter@Setter
private Integer businessClient;
public Integer getOriginalStatus() {
return originalStatus;
}
... ...
... ... @@ -24,11 +24,12 @@
<result column="seller_delivery_deal" jdbcType="INTEGER" property="sellerDeliveryDeal" />
<result column="seller_delivery_deal_again" jdbcType="INTEGER" property="sellerDeliveryDealAgain" />
<result column="activity_type" jdbcType="INTEGER" property="activityType" />
<result column="business_client" jdbcType="INTEGER" property="businessClient" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount,
ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status,
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again,activity_type
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again,activity_type, business_client
</sql>
... ... @@ -143,7 +144,7 @@
is_cancel, amount, ship_fee,
status, create_time, update_time,
buyer_order_status, seller_order_status, channel_no, attributes,platform_delivery_status,
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again,activity_type)
seller_delivery_status,seller_delivery_deal,seller_delivery_deal_again,activity_type,business_client)
values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER},
#{clientType,jdbcType=INTEGER}, #{payment,jdbcType=INTEGER}, #{paymentType,jdbcType=TINYINT},
#{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL},
... ... @@ -151,7 +152,8 @@
#{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR},
#{attributes,jdbcType=INTEGER},#{platformDeliveryStatus,jdbcType=INTEGER},
#{sellerDeliveryStatus,jdbcType=INTEGER},#{sellerDeliveryDeal,jdbcType=INTEGER},
#{sellerDeliveryDealAgain,jdbcType=INTEGER},#{activityType,jdbcType=INTEGER})
#{sellerDeliveryDealAgain,jdbcType=INTEGER},#{activityType,jdbcType=INTEGER},
#{businessClient,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
insert into buyer_order
... ...
... ... @@ -140,7 +140,8 @@ public class ShoppingController {
@RequestParam(name = "activity_type", required = false, defaultValue = "0") int activityType,
@RequestParam(name="depositRequirement", required = false, defaultValue = OrderConstant.N_STR)String depositRequirement,
@RequestParam(name="promotionId", required = false)Integer promotionId,
@RequestParam(name = "client_type", required = false) String clientType){
@RequestParam(name = "client_type", required = false) String clientType,
@RequestParam(name="business_client", required = false, defaultValue = "ufo")String businessClient){
if(StringUtils.isBlank(channelNo)){
channelNo = "2919";
}
... ... @@ -154,6 +155,7 @@ public class ShoppingController {
.userActivityId(userActivityId).activityType(activityTypeEnum)
.depositRequirement(depositRequirement)
.promotionId(promotionId)
.businessClient(businessClient)
.build();
logger.info("in ufo.order.submit, req {}", request);
OrderSubmitResponse submitResponse = buyerOrderService.submit(request);
... ...
package com.yohoufo.order.model;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.BusinessClientEnum;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.charge.ChargeContext;
import com.yohoufo.order.charge.model.ChargeGoods;
import com.yohoufo.order.charge.model.ChargeResult;
import com.yohoufo.order.charge.model.SingleFeeDetail;
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.OrderBuilder;
import com.yohoufo.order.service.impl.ShoppingServiceImpl;
import org.apache.commons.lang3.StringUtils;
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,
Function<SkupType, Integer> deliveryWayFunc,
SellerOrderGoods psog,
ChargeContext chargeContext,
String businessClient) {
//算费结果
ChargeResult chargeResult = chargeContext.getChargeResult();
ChargeGoods chargeGoods = chargeContext.getChargeGoods();
SkupType skupType = chargeGoods.getSkupType();
Integer businessClientCode = null;
if (StringUtils.isNotBlank(businessClient)){
if(OrderConstant.BusinessClient.TAOBAO_FLEAMARKET.equalsIgnoreCase(businessClient)) {
businessClientCode = BusinessClientEnum.TAOBAO_FLEAMARKET_CLIENT.getCode();
}
}
return OrderBuilder.builder()
.uid(uid)
.skup(psog.getId())
.depositCode(goodsPrepareData.getDepositCode())
.orderCode(orderCode)
.productId(psog.getProductId())
.paymentType(OrderConstant.PAYMENT_ONLINE)
.deliverWay(deliveryWayFunc.apply(skupType))
.channelNo(channelNo)
.amount(BigDecimal.valueOf(chargeResult.getFinalAmount()))
.shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount()))
.couponBoList(buildOrderCouponBoList(chargeResult))
.hiddenAddressInfo(userAddressPair.getRight())
.addressInfo(userAddressPair.getLeft())
.clientType(clientType)
.attributes(buildOrderAttribute(psog, chargeGoods.isDepositRequirement()).getCode())
.originalAttributes(psog.getAttributes())
.sellerOrderGoods(psog)
.activityBo(buildOrderActivityBo(chargeResult))
.amountDetailBo(buildOrderAmountDetailBo(chargeResult))
.tariffFee(chargeResult.getTariffFee())
.depositFee(buildDepositFee(chargeGoods))
.promotionCutAmount(chargeResult.getPromotionCutAmount())
.useableFullPromotionList(chargeGoods.getUseableFullPromotionList())
.businessClient(businessClientCode)
.build();
}
/**
* 获取订单attribute属性
*
* @return
*/
protected OrderAttributes buildOrderAttribute(SellerOrderGoods skup, boolean isDepositRequirement) {
if (isDepositRequirement) {
return OrderAttributes.DEPOSITE;
}
OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(skup.getAttributes());
return orderAttributes;
}
/**
* 活动优惠
*
* @param chargeResult
* @return
*/
protected ActivityBo buildOrderActivityBo(ChargeResult chargeResult) {
return ActivityBo.builder().activityType(chargeResult.getActivityCutResult().getActivityType())
.userActivityId(chargeResult.getActivityCutResult().getUserActivityId())
//以计算结果为准
.activityCutAmount(BigDecimal.valueOf(chargeResult.getActivityCutResult().getActivityCutAmount()))
.build();
}
/**
* 优惠券支付结果
*
* @param chargeResult
* @return
*/
protected CouponBoList buildOrderCouponBoList(ChargeResult chargeResult) {
return CouponBoList.builder().couponBos(chargeResult.getCouponPayResultList().getCouponPayResults().stream()
.map(couponPayResult -> CouponBo.builder()
.couponCode(couponPayResult.getCouponCode())
.couponType(couponPayResult.getCouponType())
.couponAmount(BigDecimal.valueOf(couponPayResult.getCouponAmount()))
.build()
)
.collect(Collectors.toList())
).build();
}
/**
* 订单金额明细
* @param chargeResult
* @return
*/
protected AmountDetailBo buildOrderAmountDetailBo(ChargeResult chargeResult) {
//订单金额明细
final AmountDetailBo amountDetailBo = new AmountDetailBo();
//商品金额
amountDetailBo.setGoodsAmount(chargeResult.getGoodsAmount());
//运费原价
amountDetailBo.setShippingAmount(chargeResult.getShippingAmount());
//活动金额
amountDetailBo.setActivityCutAmount(chargeResult.getActivityCutResult().getActivityCutAmount());
//税费
SingleFeeDetail tariffFee;
if (Objects.nonNull(tariffFee = chargeResult.getTariffFee())) {
amountDetailBo.setTariffRate(tariffFee.getRate());
amountDetailBo.setTariffAmount(tariffFee.getAmount());
amountDetailBo.setTariffCutAmount(tariffFee.getCutAmount());
}
SingleFeeDetail shipFeeDetail;
if (Objects.nonNull(shipFeeDetail = chargeResult.getShipFeeDetail())){
amountDetailBo.setShippingActivityCutAmount(shipFeeDetail.getCutAmount());
}
SingleFeeDetail depositFee;
if (Objects.nonNull(depositFee=chargeResult.getDepositFee())){
amountDetailBo.setDepositAmount(depositFee.getAmount());
}
SingleFeeDetail quickDeliveFee = chargeResult.getQuickDeliverServiceFee();
if (Objects.nonNull(quickDeliveFee)){
amountDetailBo.setQuickDeliveServiceAmount(quickDeliveFee.getAmount());
}
//活动券减免金额
chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode()).
ifPresent(tempPayResult -> amountDetailBo.setCouponCutAmount(tempPayResult.getCouponAmount()));
//运费券减免金额
chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.SHIPPING_COUPON.getCode()).
ifPresent(tempPayResult -> amountDetailBo.setShippingCouponCutAmount(tempPayResult.getCouponAmount()));
amountDetailBo.setPromotionCutAmount(chargeResult.getPromotionCutAmount());
return amountDetailBo;
}
private SingleFeeDetail buildDepositFee(ChargeGoods chargeGoods){
BigDecimal qdsf = chargeGoods.getQuickDeliverServiceFee();
BigDecimal smf = chargeGoods.getStorageManagementFee();
double amount = 0D;
if (Objects.nonNull(qdsf)){
amount = qdsf.doubleValue();
}
if (Objects.nonNull(smf)){
amount = smf.doubleValue();
}
SingleFeeDetail sfd = SingleFeeDetail.builder().amount(amount).build();
return sfd;
}
}
... ...
... ... @@ -29,7 +29,7 @@ public class OrderBuilder {
int paymentType;
int deliverWay;
String channelNo;
Integer businessClient;
/**
* 实付金额
*/
... ...
... ... @@ -76,4 +76,9 @@ public class ShoppingRequest {
* 促销
*/
private Integer promotionId;
/**
* business_client: 'h5/xianyu',
*/
private String businessClient;
}
... ...
... ... @@ -31,6 +31,7 @@ import com.yohoufo.order.constants.CouponConstants;
import com.yohoufo.order.event.BuyerCancelEvent;
import com.yohoufo.order.event.ErpBuyerOrderEvent;
import com.yohoufo.order.event.NotPaidNoticeEvent;
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;
... ... @@ -620,31 +621,14 @@ public class ShoppingServiceImpl implements IShoppingService {
// 减库存,skup更新成不可售,入库
//BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost);
orderBuilder = OrderBuilder.builder()
.uid(uid)
.skup(shoppingRequest.getSkup())
.depositCode(goodsPrepareData.getDepositCode())
.orderCode(orderCode)
.productId(psog.getProductId())
.paymentType(OrderConstant.PAYMENT_ONLINE)
.deliverWay(buildDeliveryWay(skupType))
.channelNo(shoppingRequest.getChannelNo())
.amount(BigDecimal.valueOf(chargeResult.getFinalAmount()))
.shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount()))
.couponBoList(buildOrderCouponBoList(chargeResult))
.hiddenAddressInfo(userAddressPair.getRight())
.addressInfo(userAddressPair.getLeft())
.clientType(shoppingRequest.getClientType())
.attributes(buildOrderAttribute(psog, chargeGoods.isDepositRequirement()).getCode())
.originalAttributes(psog.getAttributes())
.sellerOrderGoods(psog)
.activityBo(buildOrderActivityBo(chargeResult))
.amountDetailBo(buildOrderAmountDetailBo(chargeResult))
.tariffFee(chargeResult.getTariffFee())
.depositFee(buildDepositFee(chargeGoods))
.promotionCutAmount(chargeResult.getPromotionCutAmount())
.useableFullPromotionList(chargeGoods.getUseableFullPromotionList())
.build();
orderBuilder = getOrderBuilderFactory().create(uid, orderCode, shoppingRequest.getChannelNo(),
shoppingRequest.getClientType(),
userAddressPair,
goodsPrepareData,
DeliveryWayUtils::findDeliveryWayCodeBySkupType,
psog, chargeContext,
shoppingRequest.getBusinessClient());
submitResult = ordeCreationService.doSubmitOrder(orderBuilder);
}finally {
... ... @@ -901,32 +885,10 @@ public class ShoppingServiceImpl implements IShoppingService {
}
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();
return DeliveryWayUtils.findDeliveryWayCodeBySkupType(skupType);
}
protected OrderBuilderFactory getOrderBuilderFactory() {
return new OrderBuilderFactory();
}
}
... ...
... ... @@ -313,6 +313,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService {
buyerOrder.setSellerDeliveryDealAgain(0);
//活动类型
buyerOrder.setActivityType(orderBuilder.getActivityBo().getActivityType());
buyerOrder.setBusinessClient(orderBuilder.getBusinessClient());
buyerOrderMapper.insert(buyerOrder);
return buyerOrder;
}
... ...
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();
}
}
... ...