mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
update
This commit is contained in:
@@ -1398,67 +1398,67 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public OrderSplitResult doBalancePaymentWithDelay(OrderBasicInfo orderBasicInfo, List<DivMember> divMemberList, String wechatAppId) throws BaseAdaPayException {
|
||||
// 订单结算金额
|
||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
// 订单编号
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
|
||||
BigDecimal confirmAmt = BigDecimal.ZERO; // 消费金额
|
||||
BigDecimal feeAmt = BigDecimal.ZERO; // 手续费金额
|
||||
String status = null; // 状态
|
||||
|
||||
// 获取余额支付扣除金额 也许存在一笔不够扣,需要扣多笔的情况
|
||||
List<BalanceDeductionAmountVO> list = calculateSplitTheBillAmount(orderBasicInfo.getMemberId(), settleAmount);
|
||||
// List<String> collect = list.stream().map(BalanceDeductionAmountVO::getPaymentId).collect(Collectors.toList());
|
||||
|
||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderBasicInfo.getOrderCode());
|
||||
List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
||||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||
String deductionRecord = orderPayRecord.getDeductionRecord();
|
||||
paymentInfos.addAll(orderPayRecordService.parseDeductionRecord(deductionRecord));
|
||||
}
|
||||
List<String> collect = paymentInfos.stream().map(PaymentInfo::getPaymentId).collect(Collectors.toList());
|
||||
|
||||
// 校验是否分账
|
||||
OrderSplitResult result = verifyOrderConfirmAmount(collect, orderCode, settleAmount, wechatAppId);
|
||||
if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(result.getStatus())) {
|
||||
// 没有分账,执行分账逻辑
|
||||
for (BalanceDeductionAmountVO vo : list) {
|
||||
String paymentId = vo.getPaymentId();
|
||||
BigDecimal deductionAmount = vo.getDeductionAmount();
|
||||
|
||||
PaymentConfirmParam param = PaymentConfirmParam.builder()
|
||||
.paymentId(paymentId)
|
||||
.divMemberList(divMemberList)
|
||||
.confirmAmt(deductionAmount)
|
||||
.orderCode(orderCode)
|
||||
.wechatAppId(wechatAppId)
|
||||
.build();
|
||||
|
||||
// 延时分账,使用确认交易API
|
||||
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId,
|
||||
// adapayMemberAccount, deductionAmount, orderCode, wechatAppId);
|
||||
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(param);
|
||||
|
||||
if (paymentConfirmResponse != null && paymentConfirmResponse.isNotFailed()) {
|
||||
confirmAmt = confirmAmt.add(new BigDecimal(paymentConfirmResponse.getConfirm_amt()));
|
||||
feeAmt = feeAmt.add(new BigDecimal(paymentConfirmResponse.getFee_amt()));
|
||||
status = paymentConfirmResponse.getStatus();
|
||||
memberAdapayRecordService.unfreezeAmountAndUpdateSpendAmount(paymentId, confirmAmt, confirmAmt);
|
||||
}
|
||||
}
|
||||
|
||||
// 分账接口返回的信息
|
||||
result = new OrderSplitResult();
|
||||
result.setConfirmAmt(confirmAmt.toString());
|
||||
result.setStatus(status);
|
||||
result.setFeeAmt(feeAmt.toString());
|
||||
result.setOrderCode(orderCode);
|
||||
result.setSettleAmt(settleAmount.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// public OrderSplitResult doBalancePaymentWithDelay(OrderBasicInfo orderBasicInfo, List<DivMember> divMemberList, String wechatAppId) throws BaseAdaPayException {
|
||||
// // 订单结算金额
|
||||
// BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
// // 订单编号
|
||||
// String orderCode = orderBasicInfo.getOrderCode();
|
||||
//
|
||||
// BigDecimal confirmAmt = BigDecimal.ZERO; // 消费金额
|
||||
// BigDecimal feeAmt = BigDecimal.ZERO; // 手续费金额
|
||||
// String status = null; // 状态
|
||||
//
|
||||
// // 获取余额支付扣除金额 也许存在一笔不够扣,需要扣多笔的情况
|
||||
// List<BalanceDeductionAmountVO> list = calculateSplitTheBillAmount(orderBasicInfo.getMemberId(), settleAmount);
|
||||
// // List<String> collect = list.stream().map(BalanceDeductionAmountVO::getPaymentId).collect(Collectors.toList());
|
||||
//
|
||||
// List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderBasicInfo.getOrderCode());
|
||||
// List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
||||
// for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||
// String deductionRecord = orderPayRecord.getDeductionRecord();
|
||||
// paymentInfos.addAll(orderPayRecordService.parseDeductionRecord(deductionRecord));
|
||||
// }
|
||||
// List<String> collect = paymentInfos.stream().map(PaymentInfo::getPaymentId).collect(Collectors.toList());
|
||||
//
|
||||
// // 校验是否分账
|
||||
// OrderSplitResult result = verifyOrderConfirmAmount(collect, orderCode, settleAmount, wechatAppId);
|
||||
// if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(result.getStatus())) {
|
||||
// // 没有分账,执行分账逻辑
|
||||
// for (BalanceDeductionAmountVO vo : list) {
|
||||
// String paymentId = vo.getPaymentId();
|
||||
// BigDecimal deductionAmount = vo.getDeductionAmount();
|
||||
//
|
||||
// PaymentConfirmParam param = PaymentConfirmParam.builder()
|
||||
// .paymentId(paymentId)
|
||||
// .divMemberList(divMemberList)
|
||||
// .confirmAmt(deductionAmount)
|
||||
// .orderCode(orderCode)
|
||||
// .wechatAppId(wechatAppId)
|
||||
// .build();
|
||||
//
|
||||
// // 延时分账,使用确认交易API
|
||||
// // PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(paymentId,
|
||||
// // adapayMemberAccount, deductionAmount, orderCode, wechatAppId);
|
||||
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(param);
|
||||
//
|
||||
// if (paymentConfirmResponse != null && paymentConfirmResponse.isNotFailed()) {
|
||||
// confirmAmt = confirmAmt.add(new BigDecimal(paymentConfirmResponse.getConfirm_amt()));
|
||||
// feeAmt = feeAmt.add(new BigDecimal(paymentConfirmResponse.getFee_amt()));
|
||||
// status = paymentConfirmResponse.getStatus();
|
||||
// memberAdapayRecordService.unfreezeAmountAndUpdateSpendAmount(paymentId, confirmAmt, confirmAmt);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 分账接口返回的信息
|
||||
// result = new OrderSplitResult();
|
||||
// result.setConfirmAmt(confirmAmt.toString());
|
||||
// result.setStatus(status);
|
||||
// result.setFeeAmt(feeAmt.toString());
|
||||
// result.setOrderCode(orderCode);
|
||||
// result.setSettleAmt(settleAmount.toString());
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 计算分账扣除金额
|
||||
@@ -1609,57 +1609,50 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
* @return
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
public OrderSplitResult doPaymentConfirmWithDelay(OrderBasicInfo orderBasicInfo, List<DivMember> divMemberList, String wechatAppId) throws BaseAdaPayException {
|
||||
// 订单编号
|
||||
String orderCode = orderBasicInfo.getOrderCode();
|
||||
// 订单结算金额
|
||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
|
||||
// 查询订单支付记录
|
||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
||||
|
||||
// 选出需要分账的支付id
|
||||
List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
||||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||
BigDecimal payAmount = orderPayRecord.getPayAmount();
|
||||
BigDecimal refundAmount = orderPayRecord.getRefundAmount() == null ? BigDecimal.ZERO : orderPayRecord.getRefundAmount();
|
||||
// 如果相减等于0,说明这笔支付单退完了,就不用分账了
|
||||
BigDecimal subtract = payAmount.subtract(refundAmount);
|
||||
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
||||
paymentInfos.addAll(orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord()));
|
||||
}
|
||||
}
|
||||
|
||||
List<String> paymentIds = paymentInfos.stream().map(PaymentInfo::getPaymentId).collect(Collectors.toList());
|
||||
|
||||
// 支付id
|
||||
String paymentId = paymentInfos.get(0).getPaymentId();
|
||||
|
||||
// 校验订单分账金额
|
||||
OrderSplitResult result = verifyOrderConfirmAmount(paymentIds, orderCode, settleAmount, wechatAppId);
|
||||
|
||||
// 校验订单是否分账 状态为非交易完成的时候,进行分账处理
|
||||
if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(result.getStatus())) {
|
||||
PaymentConfirmParam param = PaymentConfirmParam.builder()
|
||||
.paymentId(paymentId)
|
||||
.divMemberList(divMemberList)
|
||||
.confirmAmt(settleAmount)
|
||||
.orderCode(orderCode)
|
||||
.wechatAppId(wechatAppId)
|
||||
.build();
|
||||
// 调汇付的分账接口 确认交易
|
||||
PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(param);
|
||||
|
||||
// 分账接口返回的信息
|
||||
result = new OrderSplitResult();
|
||||
result.setConfirmAmt(paymentConfirmResponse.getConfirm_amt());
|
||||
result.setStatus(paymentConfirmResponse.getStatus());
|
||||
result.setFeeAmt(paymentConfirmResponse.getFee_amt());
|
||||
result.setOrderCode(orderCode);
|
||||
result.setSettleAmt(settleAmount.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// public OrderSplitResult doPaymentConfirmWithDelay(OrderBasicInfo orderBasicInfo, List<DivMember> divMemberList, String wechatAppId) throws BaseAdaPayException {
|
||||
// // 订单编号
|
||||
// String orderCode = orderBasicInfo.getOrderCode();
|
||||
// // 订单结算金额
|
||||
// BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||
// // 查询订单支付记录
|
||||
// List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderCode);
|
||||
// // 选出需要分账的支付id
|
||||
// List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
||||
// for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||
// BigDecimal payAmount = orderPayRecord.getPayAmount();
|
||||
// BigDecimal refundAmount = orderPayRecord.getRefundAmount() == null ? BigDecimal.ZERO : orderPayRecord.getRefundAmount();
|
||||
// // 如果相减等于0,说明这笔支付单退完了,就不用分账了
|
||||
// BigDecimal subtract = payAmount.subtract(refundAmount);
|
||||
// if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// paymentInfos.addAll(orderPayRecordService.parseDeductionRecord(orderPayRecord.getDeductionRecord()));
|
||||
// }
|
||||
// }
|
||||
// List<String> paymentIds = paymentInfos.stream().map(PaymentInfo::getPaymentId).collect(Collectors.toList());
|
||||
// // 支付id
|
||||
// String paymentId = paymentInfos.get(0).getPaymentId();
|
||||
// // 校验订单分账金额
|
||||
// OrderSplitResult result = verifyOrderConfirmAmount(paymentIds, orderCode, settleAmount, wechatAppId);
|
||||
// // 校验订单是否分账 状态为非交易完成的时候,进行分账处理
|
||||
// if (!AdapayStatusEnum.SUCCEEDED.getValue().equals(result.getStatus())) {
|
||||
// PaymentConfirmParam param = PaymentConfirmParam.builder()
|
||||
// .paymentId(paymentId)
|
||||
// .divMemberList(divMemberList)
|
||||
// .confirmAmt(settleAmount)
|
||||
// .orderCode(orderCode)
|
||||
// .wechatAppId(wechatAppId)
|
||||
// .build();
|
||||
// // 调汇付的分账接口 确认交易
|
||||
// PaymentConfirmResponse paymentConfirmResponse = adapayService.createPaymentConfirmRequest(param);
|
||||
// // 分账接口返回的信息
|
||||
// result = new OrderSplitResult();
|
||||
// result.setConfirmAmt(paymentConfirmResponse.getConfirm_amt());
|
||||
// result.setStatus(paymentConfirmResponse.getStatus());
|
||||
// result.setFeeAmt(paymentConfirmResponse.getFee_amt());
|
||||
// result.setOrderCode(orderCode);
|
||||
// result.setSettleAmt(settleAmount.toString());
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 订单实时分账方法
|
||||
|
||||
Reference in New Issue
Block a user