Authored by tanling

退款接口有条件限制

... ... @@ -82,7 +82,9 @@ public class ActionStatusHold {
SellerOrderStatus.FINISH.getCode(),
SellerOrderStatus.PLAY_SELF.getCode(),
SellerOrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode(),
SellerOrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode());
SellerOrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(),
// 支付成功回调超时,但已经超时取消了,这种场景可以退款
SellerOrderStatus.TIMEOUT_CANCEL.getCode());
}
//
static List<Integer> CanCancelStatus;
... ...
... ... @@ -160,7 +160,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
final static List<Integer> canRefundStatusList = Arrays.asList(OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(), OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode());
OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode(),
// 支付成功回调超时,但已经被超时取消,这种场景是可以退款的
OrderStatus.BUYER_CANCEL_TIMEOUT.getCode());
@Override
public boolean canRefund(OrderInfo orderInfo) {
... ...
... ... @@ -280,7 +280,8 @@ public class PaymentServiceImpl implements IPaymentService {
// 如果状态是已取消,则需要需要把钱退给用户
if (abstractOrderService.isTimeoutCancelStatus(orderInfo)){
logger.info("paySuccess but need refund order is {}, amount is {} waring", orderCode, orderInfo.getAmount());
logger.info("paySuccess but has canceled. need refund order is {}, amount is {} waring", orderCode, orderInfo.getAmount());
saveOrdersPay(paymentData, codeMeta.getType(), orderInfo);
PaymentRequest request = PaymentRequest.builder().orderCode(orderCode).refundAmount(orderInfo.getAmount().doubleValue()).build();
refund(request);
return;
... ... @@ -297,22 +298,7 @@ public class PaymentServiceImpl implements IPaymentService {
}
// 记录支付成功记录
OrdersPay ordersPay = new OrdersPay();
ordersPay.setOrderCode(orderCode);
ordersPay.setUid(orderInfo.getUid());
ordersPay.setPayment(orderInfo.getPayment() == null ? 0 : orderInfo.getPayment().intValue());
ordersPay.setAmount(new BigDecimal(paymentData.getTotalFee()));
ordersPay.setPayOrderCode(String.valueOf(orderCode));
ordersPay.setSerialNo(paymentData.getTradeNo());
ordersPay.setCreateTime(TimeUtils.getTimeStampSecond());
// attach: 买家userId; 卖家seller_id 订单类表
JSONObject attach = new JSONObject();
attach.put("buyer_id", paymentData.getBuyerId());
attach.put("seller_id", paymentData.getMchId());
attach.put("order_type", codeMeta.getType());
ordersPay.setAttach(attach.toJSONString());
ordersPayDao.insertSelective(ordersPay);
saveOrdersPay(paymentData, codeMeta.getType(), orderInfo);
// 流水记录表支付方式适配
Integer recordPayment = orderInfo.getPayment();
... ... @@ -330,18 +316,41 @@ public class PaymentServiceImpl implements IPaymentService {
return;
}
addPayBuyRecord(orderInfo.getUid(), orderInfo.getSellerUid(), goods.getSkup(), orderCode, recordPayment,
ordersPay.getAmount());
new BigDecimal(paymentData.getTotalFee()));
} else if (codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()) {
addPayEnsureRecord(orderInfo.getUid(), orderInfo.getSkup(), orderCode, recordPayment,
ordersPay.getAmount());
new BigDecimal(paymentData.getTotalFee()));
} else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) {
addPayRechargeEnsureRecord(orderInfo.getUid(), orderInfo.getSkup(), orderCode, recordPayment,
ordersPay.getAmount());
new BigDecimal(paymentData.getTotalFee()));
}
logger.info("paySuccess finished. orderCode is {}", orderCode);
abstractOrderService.processAfterPay(orderInfo);
}
private OrdersPay saveOrdersPay(PaymentData paymentData, long orderType, OrderInfo orderInfo) {
long orderCode = Long.valueOf(paymentData.getOrderCode());
OrdersPay ordersPay = new OrdersPay();
ordersPay.setOrderCode(orderCode);
ordersPay.setUid(orderInfo.getUid());
ordersPay.setPayment(orderInfo.getPayment() == null ? 0 : orderInfo.getPayment().intValue());
ordersPay.setAmount(new BigDecimal(paymentData.getTotalFee()));
ordersPay.setPayOrderCode(String.valueOf(orderCode));
ordersPay.setSerialNo(paymentData.getTradeNo());
ordersPay.setCreateTime(TimeUtils.getTimeStampSecond());
// attach: 买家userId; 卖家seller_id 订单类表
JSONObject attach = new JSONObject();
attach.put("buyer_id", paymentData.getBuyerId());
attach.put("seller_id", paymentData.getMchId());
attach.put("order_type", orderType);
ordersPay.setAttach(attach.toJSONString());
ordersPayDao.insertSelective(ordersPay);
return ordersPay;
}
private PaymentData convertQueryPaymentData(PayQueryBo payQueryBo) {
PaymentData paymentData = new PaymentData();
... ...