|
|
@@ -229,51 +229,18 @@ public class OrderInfoService {
|
|
|
Package aPackage = packageRepo.findById(orderInfo.getPackageId()).orElseThrow(new BusinessException("无套餐"));
|
|
|
|
|
|
User parentUser = userRepo.findById(parent).orElseThrow(new BusinessException("无用户"));
|
|
|
- Member member = parentUser.getMember();
|
|
|
- if (Member.NORMAL.equals(member)) {
|
|
|
- return;
|
|
|
- }
|
|
|
+// Member member = parentUser.getMember();
|
|
|
+// if (Member.NORMAL.equals(member) || Member.EMPLOYEE.equals(member)) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
BigDecimal amount = orderInfo.getPrice();
|
|
|
String transactionId = orderInfo.getId().toString();
|
|
|
|
|
|
- BigDecimal ratio;
|
|
|
- // 保存流水
|
|
|
- switch (member) {
|
|
|
- case EXPERT:
|
|
|
- // 达人分销
|
|
|
- ratio = aPackage.getPersonalRatio0();
|
|
|
- // 套餐有额外分销
|
|
|
- if (ObjectUtil.isNull(ratio)) {
|
|
|
- ratio = sysConfigService.getBigDecimal("PERSONAL_RATIO_0");
|
|
|
- }
|
|
|
- break;
|
|
|
- case GENERAL:
|
|
|
- // 108将分销
|
|
|
- ratio = aPackage.getGeneralRatio();
|
|
|
- // 套餐有额外分销
|
|
|
- if (ObjectUtil.isNull(ratio)) {
|
|
|
- ratio = sysConfigService.getBigDecimal("GENERAL_RATIO");
|
|
|
- }
|
|
|
- break;
|
|
|
- case MAKER:
|
|
|
- // 创客分销
|
|
|
- ratio = aPackage.getMakerRatio();
|
|
|
- // 套餐有额外分销
|
|
|
- if (ObjectUtil.isNull(ratio)) {
|
|
|
- ratio = sysConfigService.getBigDecimal("MAKER_RATIO");
|
|
|
- }
|
|
|
- break;
|
|
|
- case GENERAL_MAKER:
|
|
|
- // 108将+创客分销
|
|
|
- ratio = aPackage.getGeneralMakerRatio();
|
|
|
- // 套餐有额外分销
|
|
|
- if (ObjectUtil.isNull(ratio)) {
|
|
|
- ratio = sysConfigService.getBigDecimal("PROMOTE_MAKER_RATIO");
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- ratio = BigDecimal.ZERO;
|
|
|
+ BigDecimal ratio = aPackage.getPersonalRatio0();
|
|
|
+ if (ObjectUtil.isNull(ratio)) {
|
|
|
+ ratio = sysConfigService.getBigDecimal("PERSONAL_RATIO_0");
|
|
|
}
|
|
|
+
|
|
|
// 钱和流水
|
|
|
if (BigDecimal.ZERO.compareTo(ratio) < 0) {
|
|
|
BigDecimal directPushAmount = amount.multiply(ratio);
|
|
|
@@ -288,7 +255,8 @@ public class OrderInfoService {
|
|
|
commissionRecordRepo.save(commissionRecord1);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // 无限级找创客/108将
|
|
|
+ this.makerGeneralDistribution(parentUser, amount, orderInfo.getId(), userId);
|
|
|
// 间推
|
|
|
this.indirect(parentUser, aPackage, userId, transactionId, amount);
|
|
|
}
|
|
|
@@ -394,30 +362,64 @@ public class OrderInfoService {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- 创客分销
|
|
|
- 创客和108将捞到二者之一就停还是两个都捞到?
|
|
|
+ 创客和108将分销
|
|
|
*/
|
|
|
- public void makerDistribution(User user, BigDecimal amount, Boolean isCache, Long orderId) {
|
|
|
+ public void makerGeneralDistribution(User parent, BigDecimal amount, Long orderId, Long userId) {
|
|
|
BigDecimal makerRatio = sysConfigService.getBigDecimal("MAKER_RATIO");
|
|
|
BigDecimal maker = amount.multiply(makerRatio);
|
|
|
|
|
|
- User parent = userRepo.findById(user.getParent()).orElse(null);
|
|
|
+ BigDecimal generalRatio = sysConfigService.getBigDecimal("GENERAL_RATIO");
|
|
|
+ BigDecimal general = amount.multiply(generalRatio);
|
|
|
+
|
|
|
+ boolean isGeneral = true;
|
|
|
+ boolean isMaker = true;
|
|
|
+
|
|
|
while (parent != null) {
|
|
|
- if (Member.MAKER.equals(parent.getMember())) {
|
|
|
- if (isCache) {
|
|
|
+ CommissionRecord record = CommissionRecord.builder()
|
|
|
+ .userId(parent.getId())
|
|
|
+ .fromUserId(userId)
|
|
|
+ .payMethod(PayMethod.YUE)
|
|
|
+ .transactionId(orderId.toString())
|
|
|
+ .amount(maker)
|
|
|
+ .build();
|
|
|
+ // 创客
|
|
|
+ if (isMaker && Member.MAKER.equals(parent.getMember())) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(maker));
|
|
|
+ userRepo.save(parent);
|
|
|
+
|
|
|
+ record.setTransactionType(TransactionType.MAKER);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isMaker = false;
|
|
|
+ }
|
|
|
+ // 108将
|
|
|
+ if (isGeneral && Member.GENERAL.equals(parent.getMember())) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(general));
|
|
|
+ userRepo.save(parent);
|
|
|
+
|
|
|
+ record.setTransactionType(TransactionType.GENERAL);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isGeneral = false;
|
|
|
+ }
|
|
|
+ // 108将+创客
|
|
|
+ if (Member.GENERAL_MAKER.equals(parent.getMember())) {
|
|
|
+ if (isMaker) {
|
|
|
parent.setCacheAmount(parent.getCacheAmount().add(maker));
|
|
|
- } else {
|
|
|
- parent.setMaker(maker.add(parent.getCacheAmount()));
|
|
|
+ userRepo.save(parent);
|
|
|
+
|
|
|
+ record.setTransactionType(TransactionType.MAKER);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isMaker = false;
|
|
|
}
|
|
|
- userRepo.save(parent);
|
|
|
- commissionRecordRepo.save(CommissionRecord.builder()
|
|
|
- .userId(parent.getId())
|
|
|
- .fromUserId(user.getId())
|
|
|
- .transactionType(TransactionType.MAKER)
|
|
|
- .payMethod(PayMethod.YUE)
|
|
|
- .transactionId(orderId.toString())
|
|
|
- .amount(maker)
|
|
|
- .build());
|
|
|
+ if (isGeneral) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(general));
|
|
|
+ userRepo.save(parent);
|
|
|
+
|
|
|
+ record.setTransactionType(TransactionType.GENERAL);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isGeneral = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isGeneral && !isMaker) {
|
|
|
return;
|
|
|
}
|
|
|
parent = userRepo.findById(parent.getParent()).orElse(null);
|