分账后自动提现
This commit is contained in:
parent
b95dcce2b4
commit
bd6dee6d8c
|
|
@ -510,11 +510,28 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
pcDeptRate = MoneyUtil.lt0(pcDeptRate) ? BigDecimal.ZERO : pcDeptRate;
|
||||
BigDecimal pcDeptMoney = MoneyUtil.lt0(deptGoodsCategory.getPcDeptMoney()) ? BigDecimal.ZERO : deptGoodsCategory.getPcDeptMoney();
|
||||
|
||||
BigDecimal dtx = BigDecimal.ZERO;
|
||||
|
||||
// 追加金额分账
|
||||
addPaymentConfirm(orderDetailId, deptId, memberId, masterMemberId, teamRete, teamMoney, pcDeptRate, pcDeptMoney);
|
||||
BigDecimal dtx1 = addPaymentConfirm(orderDetailId, deptId, memberId, masterMemberId, teamRete, teamMoney, pcDeptRate, pcDeptMoney);
|
||||
dtx = dtx.add(dtx1);
|
||||
|
||||
// 改价单分账
|
||||
BigDecimal changeMoney = changePaymentConfirm(orderDetailId, orderDetail.getWorkerId(), deptId, memberId, masterMemberId, teamRete, teamMoney, deptRate, deptMoney);
|
||||
BigDecimal changeMoney = BigDecimal.ZERO;
|
||||
// 查询子订单的加价记录
|
||||
List<FinancialChangeRecord> financialChangeRecords = financialChangeRecordService.selectByDetailIds(String.valueOf(orderDetailId));
|
||||
if (CollectionUtils.isNotEmpty(financialChangeRecords)) {
|
||||
// 改价记录只会有一条 直接取出
|
||||
FinancialChangeRecord fcRecord = financialChangeRecords.get(0);
|
||||
boolean paid = PayStatus.PAID.getCode().equals(fcRecord.getPayStatus());
|
||||
boolean payedAdd = PayStatus.PAYED_ADD.getCode().equals(fcRecord.getPayStatus());
|
||||
if (paid || payedAdd) {
|
||||
changeMoney = fcRecord.getChangeMoney();
|
||||
BigDecimal dtx2 = changePaymentConfirm(fcRecord, orderDetailId, orderDetail.getWorkerId(), deptId, memberId,
|
||||
masterMemberId, teamRete, teamMoney, deptRate, deptMoney);
|
||||
dtx = dtx.add(dtx2);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------- 子财务单分账部分 start ---------------------
|
||||
// 子单的实际金额
|
||||
|
|
@ -551,6 +568,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
BigDecimal workerMoney = odMoney.subtract(fineMoney);
|
||||
if (MoneyUtil.gt0(workerMoney)) {
|
||||
divMembers.add(new DivMember(memberId, MoneyUtil.toS(workerMoney), false));
|
||||
dtx = dtx.add(workerMoney);
|
||||
}
|
||||
} else {
|
||||
// 没有罚金 自己承担手续费
|
||||
|
|
@ -565,10 +583,25 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
Assert.isTrue(status, response.toString());
|
||||
// 分账成功 把罚金状态改为已扣除
|
||||
fineIds.forEach(fineRecordId -> orderFineRecordMapper.updateFineStatus(fineRecordId, 1));
|
||||
|
||||
if (!haveFine) {
|
||||
String feeAmt = response.getString("fee_amt");
|
||||
dtx = dtx.add(odMoney).subtract(new BigDecimal(feeAmt));
|
||||
}
|
||||
}
|
||||
// --------------------- 子财务单分账部分 end ---------------------
|
||||
|
||||
// 分账后自动提现去掉了 改用定时提现 2023-07-07
|
||||
// --------------------- 自动提现流程 start ---------------------
|
||||
// 走到这里确认分账成功了 进入自动提现流程
|
||||
logger.info("子订单[code={}]开始自动提现", odCode);
|
||||
if (MoneyUtil.lte0(dtx)) {
|
||||
logger.info("子订单[code={}] 待提现金额={} 无需提现", odCode, dtx);
|
||||
} else {
|
||||
// 待提现金额
|
||||
String cashAmt = AdapayUtils.bigDecimalToString(dtx);
|
||||
executor.execute(() -> drawCash(orderDetailId, financialDetail.getDeptId(), memberId, cashAmt));
|
||||
}
|
||||
// --------------------- 自动提现流程 end ---------------------
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -586,18 +619,10 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
* @return 改价金额
|
||||
* @throws BaseAdaPayException AdaPay分账接口可能抛出的异常
|
||||
*/
|
||||
private BigDecimal changePaymentConfirm(Long orderDetailId, Long workerId, Long deptId, String memberId, String masterMemberId,
|
||||
BigDecimal teamRete, BigDecimal teamMoney, BigDecimal deptRate, BigDecimal deptMoney) throws BaseAdaPayException {
|
||||
BigDecimal changeMoney = BigDecimal.ZERO;
|
||||
// 查询子订单的加价记录
|
||||
List<FinancialChangeRecord> financialChangeRecords = financialChangeRecordService.selectByDetailIds(String.valueOf(orderDetailId));
|
||||
if (CollectionUtils.isNotEmpty(financialChangeRecords)) {
|
||||
// 改价记录只会有一条 直接取出
|
||||
FinancialChangeRecord fcRecord = financialChangeRecords.get(0);
|
||||
boolean paid = PayStatus.PAID.getCode().equals(fcRecord.getPayStatus());
|
||||
boolean payedAdd = PayStatus.PAYED_ADD.getCode().equals(fcRecord.getPayStatus());
|
||||
if (paid || payedAdd) {
|
||||
changeMoney = fcRecord.getChangeMoney();
|
||||
private BigDecimal changePaymentConfirm(FinancialChangeRecord fcRecord, Long orderDetailId, Long workerId, Long deptId,
|
||||
String memberId, String masterMemberId, BigDecimal teamRete, BigDecimal teamMoney,
|
||||
BigDecimal deptRate, BigDecimal deptMoney) throws BaseAdaPayException {
|
||||
BigDecimal changeMoney = fcRecord.getChangeMoney();
|
||||
// 平台抽成
|
||||
BigDecimal platformFee = changeMoney.multiply(deptRate).add(deptMoney).setScale(2, RoundingMode.UP);
|
||||
// 大师傅抽成
|
||||
|
|
@ -667,9 +692,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
throw new IllegalArgumentException(response.getString("error_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changeMoney;
|
||||
return workerFee;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -685,8 +708,9 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
* @param pcDeptMoney 平台抽成金额
|
||||
* @throws BaseAdaPayException AdaPay分账接口可能抛出的异常
|
||||
*/
|
||||
private void addPaymentConfirm(Long orderDetailId, Long deptId, String memberId, String masterMemberId,
|
||||
private BigDecimal addPaymentConfirm(Long orderDetailId, Long deptId, String memberId, String masterMemberId,
|
||||
BigDecimal teamRete, BigDecimal teamMoney, BigDecimal pcDeptRate, BigDecimal pcDeptMoney) throws BaseAdaPayException {
|
||||
BigDecimal dtx = BigDecimal.ZERO;
|
||||
List<OrderAddSubtract> oasList = orderAddSubtractMapper.select(new OrderAddSubtract()
|
||||
.setOrderDetailId(orderDetailId).setPayStatus(PayStatus.PAID.getCode()));
|
||||
List<OrderAddSubtract> adds = oasList.stream().filter(oas -> MoneyUtil.gt0(oas.getMoney())).collect(Collectors.toList());
|
||||
|
|
@ -717,6 +741,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
}
|
||||
if (MoneyUtil.gt0(workerFee)) {
|
||||
divMembers.add(new DivMember(memberId, MoneyUtil.toS(workerFee), !feeFlag));
|
||||
dtx = dtx.add(workerFee);
|
||||
}
|
||||
String orderNo = "OAS_" + oas.getId() + "_" + System.currentTimeMillis();
|
||||
//调用分账
|
||||
|
|
@ -725,6 +750,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
orderNo, MoneyUtil.toS(oasMoney), divMembers, null, null);
|
||||
logger.info("子订单[{}]的追加单[{}]分账结果: {}", orderDetailId, oas.getId(), response.toString());
|
||||
}
|
||||
return dtx;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue