...
|
...
|
@@ -21,6 +21,7 @@ import com.yohoufo.dal.order.*; |
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.common.BillTradeStatus;
|
|
|
import com.yohoufo.order.common.HbfqEnum;
|
|
|
import com.yohoufo.order.common.TradeType;
|
|
|
import com.yohoufo.order.common.TransferCase;
|
|
|
import com.yohoufo.order.constants.RefundContant;
|
|
|
import com.yohoufo.order.model.PayQueryBo;
|
...
|
...
|
@@ -100,9 +101,6 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
MerchantOrderPaymentService merchantOrderPaymentService;
|
|
|
|
|
|
@Autowired
|
|
|
OrderCodeGenerator orderCodeGenerator;
|
|
|
|
|
|
@Autowired
|
|
|
WeixinPayUFORealAppService weixinPayAppService;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -171,6 +169,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
@Autowired
|
|
|
private RefundManager refundManager;
|
|
|
|
|
|
@Autowired
|
|
|
OrderCodeGenerator orderCodeGenerator;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 订单支付结果确认
|
...
|
...
|
@@ -419,6 +420,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 +468,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 +1317,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);
|
|
|
}
|
|
|
|
|
|
// 卖家订单检查
|
|
|
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);
|
|
|
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 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;
|
|
|
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);
|
|
|
|
|
|
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);
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -1370,7 +1410,11 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
record.setUserType(targetUserType.getCode());
|
|
|
record.setPayType(1);
|
|
|
// 如果[全部货款->卖家],否则[补偿款->卖家或买家] 2:货款;3:补偿款
|
|
|
record.setTradeType(transferCase == TransferCase.ALL_GOODS_MONEY_TO_SELLER ? 2 : 3);
|
|
|
if (transferCase == TransferCase.DEPOSIT_REBATE_TO_USER){
|
|
|
record.setTradeType(TradeType.deposit_rebate.getCode()); // 返利
|
|
|
}else{
|
|
|
record.setTradeType(transferCase == TransferCase.ALL_GOODS_MONEY_TO_SELLER ? TradeType.goods_income.getCode() : TradeType.compensateIncome.getCode());
|
|
|
}
|
|
|
record.setIncomeOutcome(1);
|
|
|
record.setTradeStatus(BillTradeStatus.NEW.getCode());
|
|
|
record.setCreateTime(now);
|
...
|
...
|
|