|
@@ -264,18 +264,21 @@ public class OrderInfoService {
|
|
|
// 百分比
|
|
// 百分比
|
|
|
BigDecimal percentage = sysConfigService.getBigDecimal(name);
|
|
BigDecimal percentage = sysConfigService.getBigDecimal(name);
|
|
|
BigDecimal personalAmount = amount.multiply(percentage);
|
|
BigDecimal personalAmount = amount.multiply(percentage);
|
|
|
- parentUser.setAmount(parentUser.getAmount().add(personalAmount));
|
|
|
|
|
- userRepo.save(parentUser);
|
|
|
|
|
|
|
+ if (BigDecimal.ZERO.compareTo(personalAmount) < 0) {
|
|
|
|
|
+ parentUser.setAmount(parentUser.getAmount().add(personalAmount));
|
|
|
|
|
+ userRepo.save(parentUser);
|
|
|
|
|
+
|
|
|
|
|
+ // 个人佣金流水
|
|
|
|
|
+ commissionRecordRepo.save(CommissionRecord.builder()
|
|
|
|
|
+ .userId(parentUser.getId())
|
|
|
|
|
+ .amount(personalAmount)
|
|
|
|
|
+ .payMethod(PayMethod.YUE)
|
|
|
|
|
+ .fromUserId(userId)
|
|
|
|
|
+ .transactionType(TransactionType.PROMOTE)
|
|
|
|
|
+ .transactionId(transactionId)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 个人佣金流水
|
|
|
|
|
- commissionRecordRepo.save(CommissionRecord.builder()
|
|
|
|
|
- .userId(parentUser.getId())
|
|
|
|
|
- .amount(personalAmount)
|
|
|
|
|
- .payMethod(PayMethod.YUE)
|
|
|
|
|
- .fromUserId(userId)
|
|
|
|
|
- .transactionType(TransactionType.PROMOTE)
|
|
|
|
|
- .transactionId(transactionId)
|
|
|
|
|
- .build());
|
|
|
|
|
if (ObjectUtil.isEmpty(parentUser.getParent())) {
|
|
if (ObjectUtil.isEmpty(parentUser.getParent())) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -325,25 +328,29 @@ public class OrderInfoService {
|
|
|
|
|
|
|
|
// 团长或大团长
|
|
// 团长或大团长
|
|
|
User user = null;
|
|
User user = null;
|
|
|
- // 上级为空或上级为不为普通用户停止
|
|
|
|
|
|
|
|
|
|
|
|
+ // 上级为空或上级为不为普通用户停止
|
|
|
while (ObjectUtil.isNotNull(parentUserId)) {
|
|
while (ObjectUtil.isNotNull(parentUserId)) {
|
|
|
user = userRepo.findById(parentUserId).orElseThrow(new BusinessException("无用户"));
|
|
user = userRepo.findById(parentUserId).orElseThrow(new BusinessException("无用户"));
|
|
|
// 如果是团长/大团长 拿直推钱
|
|
// 如果是团长/大团长 拿直推钱
|
|
|
if (!Member.NORMAL.equals(user.getMember())) {
|
|
if (!Member.NORMAL.equals(user.getMember())) {
|
|
|
- user.setAmount(user.getCacheAmount().add(head));
|
|
|
|
|
- userRepo.save(user);
|
|
|
|
|
|
|
+ // 钱>0 才存
|
|
|
|
|
+ if (BigDecimal.ZERO.compareTo(head) < 0) {
|
|
|
|
|
|
|
|
- // 个人佣金流水
|
|
|
|
|
- CommissionRecord commissionRecord = CommissionRecord.builder()
|
|
|
|
|
- .userId(parentUserId)
|
|
|
|
|
- .amount(head)
|
|
|
|
|
- .payMethod(PayMethod.YUE)
|
|
|
|
|
- .fromUserId(userId)
|
|
|
|
|
- .transactionType(TransactionType.PROMOTE)
|
|
|
|
|
- .transactionId(orderInfo.getTransactionId())
|
|
|
|
|
- .build();
|
|
|
|
|
- commissionRecordRepo.save(commissionRecord);
|
|
|
|
|
|
|
+ user.setAmount(user.getCacheAmount().add(head));
|
|
|
|
|
+ userRepo.save(user);
|
|
|
|
|
+
|
|
|
|
|
+ // 个人佣金流水
|
|
|
|
|
+ CommissionRecord commissionRecord = CommissionRecord.builder()
|
|
|
|
|
+ .userId(parentUserId)
|
|
|
|
|
+ .amount(head)
|
|
|
|
|
+ .payMethod(PayMethod.YUE)
|
|
|
|
|
+ .fromUserId(userId)
|
|
|
|
|
+ .transactionType(TransactionType.PROMOTE)
|
|
|
|
|
+ .transactionId(orderInfo.getTransactionId())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ commissionRecordRepo.save(commissionRecord);
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
parentUserId = user.getParent();
|
|
parentUserId = user.getParent();
|
|
@@ -365,20 +372,21 @@ public class OrderInfoService {
|
|
|
String name = "PERSONAL_RATIO_" + i;
|
|
String name = "PERSONAL_RATIO_" + i;
|
|
|
BigDecimal percentage = sysConfigService.getBigDecimal(name);
|
|
BigDecimal percentage = sysConfigService.getBigDecimal(name);
|
|
|
BigDecimal personalAmount = amount.multiply(percentage);
|
|
BigDecimal personalAmount = amount.multiply(percentage);
|
|
|
|
|
+ if (BigDecimal.ZERO.compareTo(personalAmount) < 0) {
|
|
|
|
|
+ parent.setAmount(parent.getCacheAmount().add(personalAmount));
|
|
|
|
|
+ userRepo.save(parent);
|
|
|
|
|
+ // 个人佣金流水
|
|
|
|
|
+ CommissionRecord commissionRecord = CommissionRecord.builder()
|
|
|
|
|
+ .userId(parent.getId())
|
|
|
|
|
+ .amount(personalAmount)
|
|
|
|
|
+ .payMethod(PayMethod.YUE)
|
|
|
|
|
+ .fromUserId(userId)
|
|
|
|
|
+ .transactionType(TransactionType.CHILD_PROMOTE)
|
|
|
|
|
+ .transactionId(orderInfo.getTransactionId())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ commissionRecordRepo.save(commissionRecord);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- parent.setAmount(parent.getCacheAmount().add(personalAmount));
|
|
|
|
|
- userRepo.save(parent);
|
|
|
|
|
-
|
|
|
|
|
- // 个人佣金流水
|
|
|
|
|
- CommissionRecord commissionRecord = CommissionRecord.builder()
|
|
|
|
|
- .userId(parent.getId())
|
|
|
|
|
- .amount(personalAmount)
|
|
|
|
|
- .payMethod(PayMethod.YUE)
|
|
|
|
|
- .fromUserId(userId)
|
|
|
|
|
- .transactionType(TransactionType.CHILD_PROMOTE)
|
|
|
|
|
- .transactionId(orderInfo.getTransactionId())
|
|
|
|
|
- .build();
|
|
|
|
|
- commissionRecordRepo.save(commissionRecord);
|
|
|
|
|
}
|
|
}
|
|
|
i++;
|
|
i++;
|
|
|
parent1 = parent.getParent();
|
|
parent1 = parent.getParent();
|