|
@@ -18,6 +18,7 @@ import com.zswl.cloud.bdb.client.service.InviteReceiptsRoleFeignService;
|
|
|
import com.zswl.cloud.bdb.client.vo.InviteReceiptsRoleVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.bson.types.ObjectId;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -76,7 +77,7 @@ public class InviteReceiptsService {
|
|
|
|
|
|
if (vipUserRecord.getSuc().equals(1) || vipUserRecord.getSuc().equals(4)){//订阅
|
|
|
|
|
|
- if (isFirstSuc(ruler, vipUserRecord.getCpId(), vipUserRecord.getOperateTime(), inviteRecord.getRegisterTime())){ //首次订购,且时间小于48小时
|
|
|
+ if (isFirstSuc(ruler, vipUserRecord.getCpId(), vipUserRecord.getOperateTime(), inviteRecord.getRegisterTime(), vipUserRecord.getId())){ //首次订购,且时间小于48小时
|
|
|
|
|
|
sucToReceipts(ruler, vipUserRecord, inviteRecord.getInviteUserId());
|
|
|
vipUserRecord.setFirst(true);
|
|
@@ -128,8 +129,8 @@ public class InviteReceiptsService {
|
|
|
return ObjectUtils.isNotEmpty(topVipUserRecord) && topVipUserRecord.isFirst();
|
|
|
}
|
|
|
|
|
|
- private boolean isFirstSuc(InviteReceiptsRoleVo rulerVo, String userId, Long operateTime, Long registerTime){
|
|
|
- return rulerVo.getFirstPurchaseDay()!=null && !vipUserRecordDao.existsByCpIdAndSucIn(userId, List.of(1)) && Math.abs(operateTime - registerTime) <= 48L*60*60*1000;
|
|
|
+ private boolean isFirstSuc(InviteReceiptsRoleVo rulerVo, String userId, Long operateTime, Long registerTime, String vipUserRecordId){
|
|
|
+ return rulerVo.getFirstPurchaseDay()!=null && !vipUserRecordDao.existsByCpIdAndSucInAndIdNot(userId, List.of(1), vipUserRecordId) && Math.abs(operateTime - registerTime) <= 48L*60*60*1000;
|
|
|
}
|
|
|
|
|
|
private boolean isSucLastMonth(String userId){
|
|
@@ -221,7 +222,9 @@ public class InviteReceiptsService {
|
|
|
walletReceipts.setOutTradeNo(vipUserRecord.getPlanningId());
|
|
|
walletReceipts.setTotal(rulerVo.getBaseTotal());
|
|
|
walletReceipts.setEstimatedTime(DateUtils.nextMonthDayStartTime(rulerVo.getDay()));
|
|
|
- vipUserRecord.setId(new ObjectId().toHexString());
|
|
|
+ if (StringUtils.isEmpty(vipUserRecord.getId())){
|
|
|
+ vipUserRecord.setId(new ObjectId().toHexString());
|
|
|
+ }
|
|
|
walletReceipts.setVipUserRecord(vipUserRecord);
|
|
|
walletReceipts.setRuler(rulerVo);
|
|
|
//邀请人钱包
|
|
@@ -344,7 +347,7 @@ public class InviteReceiptsService {
|
|
|
}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)){
|
|
|
+ if (ObjectUtils.isNotEmpty(noCancelByCreateTime)){
|
|
|
return;
|
|
|
}
|
|
|
insertReceipts(ruler, walletReceipts);
|