|
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.jar.JarFile;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -90,12 +91,14 @@ public class InviteReceiptsService {
|
|
|
firstCancel(vipUserRecord, ruler);
|
|
|
}else {
|
|
|
VipUserRecord currentRecord = vipUserRecordDao.findTop1ByCpIdOrderByOperateTime(vipUserRecord.getCpId());
|
|
|
- WalletReceipts currentWalletReceipts = walletReceiptsDao.findTop1ByVipUserRecord_Id(currentRecord.getId());
|
|
|
- if (ObjectUtils.isNotEmpty(currentWalletReceipts) && Math.abs(vipUserRecord.getOperateTime() - currentRecord.getOperateTime()) < 24L *60*60*1000*currentWalletReceipts.getRuler().getFirstPurchaseDay()){
|
|
|
- currentWalletReceipts.setStatus(ReceiptsStatus.CANCEL);
|
|
|
- walletReceiptsDao.save(currentWalletReceipts);
|
|
|
- Wallet wallet = walletService.getWalletByUserId(currentWalletReceipts.getInviteUserId());
|
|
|
- walletDao.updateIncWaitAmount(wallet.getId(), ruler.getBaseTotal().negate());
|
|
|
+ if (ObjectUtils.isNotEmpty(currentRecord)){
|
|
|
+ WalletReceipts currentWalletReceipts = walletReceiptsDao.findTop1ByVipUserRecord_Id(currentRecord.getId());
|
|
|
+ if (ObjectUtils.isNotEmpty(currentWalletReceipts) && Math.abs(vipUserRecord.getOperateTime() - currentWalletReceipts.getCreateTime()) < 24L *60*60*1000*currentWalletReceipts.getRuler().getFirstPurchaseDay()){
|
|
|
+ currentWalletReceipts.setStatus(ReceiptsStatus.CANCEL);
|
|
|
+ walletReceiptsDao.save(currentWalletReceipts);
|
|
|
+ Wallet wallet = walletService.getWalletByUserId(currentWalletReceipts.getInviteUserId());
|
|
|
+ walletDao.updateIncWaitAmount(wallet.getId(), ruler.getBaseTotal().negate());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -339,7 +342,11 @@ public class InviteReceiptsService {
|
|
|
//上月无消息,生成入账
|
|
|
insertReceipts(ruler, walletReceipts);
|
|
|
}else if (topOne.getSuc().equals(1) || topOne.getSuc().equals(4)){
|
|
|
- //上月最后消息为订购,生成入账
|
|
|
+ //上月最后消息为订购,生成入账(若本月已生成持续返利则不自动生成)
|
|
|
+ WalletReceipts noCancelByCreateTime = walletReceiptsDao.findNoCancelByCreateTime(walletReceipts.getUserId(), DateUtils.getCurrentMonthStartTime(), new Date().getTime());
|
|
|
+ if (ObjectUtils.isEmpty(noCancelByCreateTime)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
insertReceipts(ruler, walletReceipts);
|
|
|
}
|
|
|
}
|
|
@@ -397,7 +404,7 @@ public class InviteReceiptsService {
|
|
|
walletReceipts.setOutTradeNo(ruler.getSetMealCode());
|
|
|
walletReceipts.setRuler(ruler);
|
|
|
VipUserRecord vipUserRecord = it.getVipUserRecord();
|
|
|
- vipUserRecord.setId(null);
|
|
|
+// vipUserRecord.setId(null);
|
|
|
vipUserRecord.setFirst(false);
|
|
|
vipUserRecord.setPlanningId(ruler.getSetMealCode());
|
|
|
walletReceipts.setVipUserRecord(vipUserRecord);
|