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