...
|
...
|
@@ -100,9 +100,6 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
MerchantOrderPaymentService merchantOrderPaymentService;
|
|
|
|
|
|
@Autowired
|
|
|
OrderCodeGenerator orderCodeGenerator;
|
|
|
|
|
|
@Autowired
|
|
|
WeixinPayUFORealAppService weixinPayAppService;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -171,6 +168,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
@Autowired
|
|
|
private RefundManager refundManager;
|
|
|
|
|
|
@Autowired
|
|
|
OrderCodeGenerator orderCodeGenerator;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 订单支付结果确认
|
...
|
...
|
@@ -419,6 +419,11 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
|
|
|
|
|
|
private void penaltyEarnestIfWalletSellerOrder(BiFunction penaltyEarnestFunction, SellerWalletDetail.Type swdType, SellerOrder sellerOrder) {
|
|
|
|
|
|
if (sellerOrder == null){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
Integer sellerUid = sellerOrder.getUid();
|
|
|
Long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
Integer skup = sellerOrder.getSkup();
|
...
|
...
|
@@ -462,6 +467,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
Integer targetUid = transferMoneyModel.getTargetUid();
|
|
|
int now = transferMoneyModel.getNow();
|
|
|
|
|
|
|
|
|
penaltyEarnestIfWalletSellerOrder(request.getPenaltyEarnestFunction(), request.getSwdType(), sellerOrder);
|
|
|
|
|
|
OrdersPayTransfer transfer = createTransfer(buyerOrderCode, sellerOrderCode, transferCase.getCode(), null, targetUid, BigDecimal.ZERO, now);
|
...
|
...
|
@@ -1310,54 +1316,87 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
|
|
|
public TransferMoneyModel invoke() {
|
|
|
|
|
|
buyerOrderCode = request.getBuyerOrderCode();
|
|
|
logTag = String.format("transfer money orderCode is %s", buyerOrderCode);
|
|
|
// 订单号check
|
|
|
if (buyerOrderCode < 1L) {
|
|
|
logger.warn("{}, transfer fail orderCode empty", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
// 类型检查
|
|
|
transferCase = TransferCase.getTransferCase(request.getType());
|
|
|
if (transferCase == null) {
|
|
|
logger.warn("{}, transfer fail transferType invalid", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
// 买家订单检查
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(buyerOrderCode);
|
|
|
if (buyerOrder == null) {
|
|
|
logger.warn("{}, transfer fail buyer order not exist", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
CodeMeta codeMeta = orderCodeGenerator.expId(buyerOrderCode);
|
|
|
// 买家订单号
|
|
|
if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()){
|
|
|
logTag = String.format("transfer money orderCode is %s", buyerOrderCode);
|
|
|
// 订单号check
|
|
|
if (buyerOrderCode < 1L) {
|
|
|
logger.warn("{}, transfer fail orderCode empty", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
// 类型检查
|
|
|
transferCase = TransferCase.getTransferCase(request.getType());
|
|
|
if (transferCase == null) {
|
|
|
logger.warn("{}, transfer fail transferType invalid", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrderCode);
|
|
|
if (buyerOrderGoods == null) {
|
|
|
logger.warn("{}, transfer fail buyerOrderGoods not exist", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
// 买家订单检查
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(buyerOrderCode);
|
|
|
if (buyerOrder == null) {
|
|
|
logger.warn("{}, transfer fail buyer order not exist", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrderCode);
|
|
|
if (buyerOrderGoods == null) {
|
|
|
logger.warn("{}, transfer fail buyerOrderGoods not exist", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
// 卖家订单检查
|
|
|
Integer skup = buyerOrderGoods.getSkup();
|
|
|
sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
if (sellerOrder == null) {
|
|
|
logger.warn("{}, transfer fail getOrderInfo seller order not exist, skup is {}", logTag, buyerOrderGoods.getSkup());
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
// 卖家订单检查
|
|
|
Integer skup = buyerOrderGoods.getSkup();
|
|
|
sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
if (sellerOrder == null) {
|
|
|
logger.warn("{}, transfer fail getOrderInfo seller order not exist, skup is {}", logTag, buyerOrderGoods.getSkup());
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
Integer sellerUid = sellerOrder.getUid();
|
|
|
sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
|
|
|
targetUserType = transferCase == EARNEST_MONEY_TO_BUYER ? TargetUserType.buyer : TargetUserType.seller;
|
|
|
targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid;
|
|
|
|
|
|
if (targetUid == null || targetUid < 1) {
|
|
|
logger.warn("{}, transfer fail uid {} invalid", logTag, targetUid);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]不合法");
|
|
|
}
|
|
|
now = (int) (System.currentTimeMillis() / 1000);
|
|
|
// 查看是否已经有转账记录
|
|
|
checkTransferExist(buyerOrderCode);
|
|
|
}
|
|
|
Integer sellerUid = sellerOrder.getUid();
|
|
|
sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
// 商品服务
|
|
|
else if(codeMeta.getType() == OrderCodeType.GOODS_SERVICE.getType()){
|
|
|
|
|
|
targetUserType = transferCase == EARNEST_MONEY_TO_BUYER ? TargetUserType.buyer : TargetUserType.seller;
|
|
|
targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid;
|
|
|
|
|
|
if (targetUid == null || targetUid < 1) {
|
|
|
logger.warn("{}, transfer fail uid {} invalid", logTag, targetUid);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]不合法");
|
|
|
logTag = String.format("transfer money orderCode is %s", buyerOrderCode);
|
|
|
|
|
|
// 类型检查
|
|
|
transferCase = TransferCase.getTransferCase(request.getType());
|
|
|
if (transferCase == null) {
|
|
|
logger.warn("{}, transfer fail transferType invalid", logTag);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
// 商品返利的场合,不存在 买家订单号|卖家订单号的区分
|
|
|
sellerOrderCode = buyerOrderCode;
|
|
|
targetUserType = TargetUserType.seller;
|
|
|
targetUid = request.getSellerUid();
|
|
|
|
|
|
if (targetUid == null || targetUid < 1) {
|
|
|
logger.warn("{}, transfer fail uid {} invalid", logTag, targetUid);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]不合法");
|
|
|
}
|
|
|
now = (int) (System.currentTimeMillis() / 1000);
|
|
|
|
|
|
}
|
|
|
now = (int) (System.currentTimeMillis() / 1000);
|
|
|
// 查看是否已经有转账记录
|
|
|
checkTransferExist(buyerOrderCode);
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|