|
|
@@ -244,6 +244,8 @@ public class OrderInfoService {
|
|
|
// 钱和流水
|
|
|
if (BigDecimal.ZERO.compareTo(ratio) < 0) {
|
|
|
BigDecimal directPushAmount = amount.multiply(ratio);
|
|
|
+ parentUser.setCacheAmount(directPushAmount.add(parentUser.getCacheAmount()));
|
|
|
+ userRepo.save(parentUser);
|
|
|
CommissionRecord commissionRecord1 = CommissionRecord.builder()
|
|
|
.userId(parent)
|
|
|
.amount(directPushAmount)
|
|
|
@@ -374,50 +376,64 @@ public class OrderInfoService {
|
|
|
boolean isGeneral = true;
|
|
|
boolean isMaker = true;
|
|
|
|
|
|
+ CommissionRecord record = CommissionRecord.builder()
|
|
|
+ .userId(parent.getId())
|
|
|
+ .fromUserId(userId)
|
|
|
+ .payMethod(PayMethod.YUE)
|
|
|
+ .transactionId(orderId.toString())
|
|
|
+ .build();
|
|
|
+
|
|
|
while (parent != null) {
|
|
|
- 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));
|
|
|
- userRepo.save(parent);
|
|
|
-
|
|
|
- record.setTransactionType(TransactionType.MAKER);
|
|
|
- commissionRecordRepo.save(record);
|
|
|
- isMaker = false;
|
|
|
- }
|
|
|
- if (isGeneral) {
|
|
|
- parent.setCacheAmount(parent.getCacheAmount().add(general));
|
|
|
- userRepo.save(parent);
|
|
|
-
|
|
|
- record.setTransactionType(TransactionType.GENERAL);
|
|
|
- commissionRecordRepo.save(record);
|
|
|
- isGeneral = false;
|
|
|
- }
|
|
|
+ switch (parent.getMember()) {
|
|
|
+ case MAKER:
|
|
|
+ if (isMaker) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(maker));
|
|
|
+ userRepo.save(parent);
|
|
|
+ // 流水
|
|
|
+ record.setAmount(maker);
|
|
|
+ record.setTransactionType(TransactionType.MAKER);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isMaker = false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case GENERAL:
|
|
|
+ if (isGeneral) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(general));
|
|
|
+ userRepo.save(parent);
|
|
|
+ // 流水
|
|
|
+ record.setAmount(general);
|
|
|
+ record.setTransactionType(TransactionType.GENERAL);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isGeneral = false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case GENERAL_MAKER:
|
|
|
+ if (isMaker) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(maker));
|
|
|
+ userRepo.save(parent);
|
|
|
+ // 流水
|
|
|
+ record.setAmount(maker);
|
|
|
+ record.setTransactionType(TransactionType.MAKER);
|
|
|
+ commissionRecordRepo.save(record);
|
|
|
+ isMaker = false;
|
|
|
+ }
|
|
|
+ if (isGeneral) {
|
|
|
+ parent.setCacheAmount(parent.getCacheAmount().add(general));
|
|
|
+ userRepo.save(parent);
|
|
|
+ // 流水
|
|
|
+ commissionRecordRepo.save(CommissionRecord.builder()
|
|
|
+ .userId(parent.getId())
|
|
|
+ .fromUserId(userId)
|
|
|
+ .payMethod(PayMethod.YUE)
|
|
|
+ .transactionId(orderId.toString())
|
|
|
+ .amount(general)
|
|
|
+ .transactionType(TransactionType.GENERAL)
|
|
|
+ .build());
|
|
|
+ isGeneral = false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
if (!isGeneral && !isMaker) {
|
|
|
return;
|