Authored by LUOXC

Merge branch 'dev6.8.6' into test6.8.6

... ... @@ -8,9 +8,7 @@ import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohobuy.ufo.model.order.req.ManualDealRequest;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
... ... @@ -19,7 +17,6 @@ import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.TimeUtils;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.RefundContant;
... ... @@ -38,8 +35,6 @@ import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.SellerOrderPaymentService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.service.handler.BuyerOrderPayDiffTimeHandler;
import com.yohoufo.order.service.handler.penalty.PenaltyResult;
import com.yohoufo.order.service.handler.penalty.SellerEarnestMoney2BuyerPenaltyCalculator;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.pay.alipay.AlipayOuyinService;
import com.yohoufo.order.service.pay.wallet.WalletPayService;
... ... @@ -476,7 +471,7 @@ public class PaymentServiceImpl implements IPaymentService {
}
private void punishEarnest(BiFunction penaltyEarnestFunction, SellerWalletDetail.Type swdType, SellerOrder sellerOrder){
private void penaltyEarnestIfWalletSellerOrder(BiFunction penaltyEarnestFunction, SellerWalletDetail.Type swdType, SellerOrder sellerOrder){
Integer sellerUid = sellerOrder.getUid();
Long sellerOrderCode = sellerOrder.getOrderCode();
Integer skup = sellerOrder.getSkup();
... ... @@ -485,9 +480,13 @@ public class PaymentServiceImpl implements IPaymentService {
penaltyEarnestFunction.apply(sellerOrder,swdType);
}else {
// 处罚所有金额
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
.orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue()).build();
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder()
.uid(sellerUid)
.orderCode(sellerOrderCode)
.skup(skup)
.earnestMoney(sellerOrder.getEarnestMoney())
.type(swdType.getValue())
.build();
merchantOrderPaymentService.punishEarnest( moai, swdType);
}
}
... ... @@ -544,7 +543,7 @@ public class PaymentServiceImpl implements IPaymentService {
}
Integer sellerUid = sellerOrder.getUid();
long sellerOrderCode = sellerOrder.getOrderCode();
punishEarnest(request.getPenaltyEarnestFunction(), request.getSwdType(), sellerOrder);
penaltyEarnestIfWalletSellerOrder(request.getPenaltyEarnestFunction(), request.getSwdType(), sellerOrder);
val targetUserType = transferCase == EARNEST_MONEY_TO_BUYER ? TargetUserType.buyer : TargetUserType.seller;
val targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid;
... ...
... ... @@ -535,20 +535,31 @@ public class SellerOrderCancelService {
.swdType(SellerWalletDetail.Type.SELLER_CANCEL)
.alarmConfig(AlarmConfig.SELLER_PLAY_BUYER)
.build();
// 如果有剩余保证金,则为部分扣保证金
// 如果有剩余保证金,则为部分扣保证金。需要退还剩余保证金
if (penaltyResult.getLeftAmount().compareTo(BigDecimal.ZERO) > 0) {
BiFunction<SellerOrder, SellerWalletDetail.Type, SellerWallet> penaltyEarnestFunction = (order, type) -> {
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder()
.uid(sellerUid)
.orderCode(sellerOrderCode)
.skup(skup)
.earnestMoney(sellerOrder.getEarnestMoney())
.penaltyEarnestMoney(penaltyResult.getPenaltyAmount())
.type(type.getValue())
.build();
return merchantOrderPaymentService.punishEarnest(moai, type);
};
tmReq.setPenaltyEarnestFunction(penaltyEarnestFunction);
// 如果使用钱包支付保证金,在分账给买家中退还剩余保证金
if(PaymentHelper.isWallet(sellerOrder.getPayment())){
BiFunction<SellerOrder, SellerWalletDetail.Type, SellerWallet> penaltyEarnestFunction = (order, type) -> {
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder()
.uid(sellerUid)
.orderCode(sellerOrderCode)
.skup(skup)
.earnestMoney(sellerOrder.getEarnestMoney())
.penaltyEarnestMoney(penaltyResult.getPenaltyAmount())
.type(type.getValue())
.build();
return merchantOrderPaymentService.punishEarnest(moai, type);
};
tmReq.setPenaltyEarnestFunction(penaltyEarnestFunction);
}
// 如果不是使用钱包支付保证金,退剩余保证金给卖家
else {
try {
refundEarnestMoney(sellerOrder, targetSOStatus, penaltyResult.getLeftAmount());
} catch (Exception e) {
logger.warn("返回剩余保证金失败, sellerUid is {}, skup is {}, err is {}", sellerUid, skup, e.getMessage());
}
}
}
transferService.transfer(tmReq);
} else {
... ...