|
@@ -2,8 +2,11 @@ package cn.newfeifan.mall.module.distri.service.ptprofitlog;
|
|
|
|
|
|
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
import cn.newfeifan.mall.module.distri.enums.CaclEnum;
|
|
|
+import cn.newfeifan.mall.module.distri.enums.IntegralEnum;
|
|
|
import cn.newfeifan.mall.module.member.service.user.MemberUserService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.actuate.web.mappings.MappingsEndpoint;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -23,6 +26,7 @@ import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlog.PtProfitLogMapper;
|
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.newfeifan.mall.module.distri.enums.CaclEnum.*;
|
|
|
import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
|
|
|
+import static cn.newfeifan.mall.module.distri.enums.IntegralEnum.*;
|
|
|
|
|
|
/**
|
|
|
* 平台利润记录 Service 实现类
|
|
@@ -37,8 +41,8 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
private PtProfitLogMapper ptProfitLogMapper;
|
|
|
@Resource
|
|
|
private MemberUserService memberUserService;
|
|
|
-
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private MappingsEndpoint mappingsEndpoint;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -82,14 +86,10 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
public PageResult<PtProfitLogRespVO> getPtProfitLogPage(PtProfitLogPageReqVO pageReqVO) {
|
|
|
PageResult<PtProfitLogRespVO> result = BeanUtils.toBean(ptProfitLogMapper.selectPage(pageReqVO), PtProfitLogRespVO.class);
|
|
|
for (PtProfitLogRespVO ptProfitLogRespVO : result.getList()) {
|
|
|
- ptProfitLogRespVO.setProfitStatusName(Objects.requireNonNull(CaclEnum.getCaclEnumByValue(ptProfitLogRespVO.getProfitStatus())).getName());
|
|
|
-
|
|
|
- if (ptProfitLogRespVO.getProfitStatus().equals(RECOMMENDED_PERSON_QUOTA.getType()) ||
|
|
|
- ptProfitLogRespVO.getProfitStatus().equals(CaclEnum.ORDER_PAY_INTEGRAL_ANCESTER.getType()) ||
|
|
|
- ptProfitLogRespVO.getProfitStatus().equals(CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER.getType()) ||
|
|
|
- ptProfitLogRespVO.getProfitStatus().equals(CaclEnum.MANUAL_RETURN_INTEGRAL.getType()) ||
|
|
|
- ptProfitLogRespVO.getProfitStatus().equals(CaclEnum.SMALL_QUOTA_CRASH_SETTLE.getType()) ||
|
|
|
- ptProfitLogRespVO.getProfitStatus().equals(SMALL_QUOTA_CRASH.getType())) {
|
|
|
+ ptProfitLogRespVO.setProfitStatusName(Objects.requireNonNull(IntegralEnum.getName(ptProfitLogRespVO.getProfitStatus())));
|
|
|
+
|
|
|
+ if (ptProfitLogRespVO.getProfitStatus().equals(BUY_ORDER.getType()) ||
|
|
|
+ ptProfitLogRespVO.getProfitStatus().equals(TEAM_BONUS.getType())) {
|
|
|
ptProfitLogRespVO.setUsername(memberUserService.getUser(ptProfitLogRespVO.getGenerateUserId()).getUsername());
|
|
|
}
|
|
|
}
|
|
@@ -109,14 +109,8 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
.amount(amount)
|
|
|
.percentTemplate(percentTemplate)
|
|
|
.profitStatus(caclEnum.getType())
|
|
|
- .accumulatedQuotaAmount(accumulatedQuotAmount)
|
|
|
- .maxAvailablePointsAmount(maxAvailablePointsAmount)
|
|
|
- .afterMaxAvailablePointsAmount(afterMaxAvailablePointsAmount)
|
|
|
.generateUserId(userId)
|
|
|
.build();
|
|
|
- if(caclEnum.getType().equals(SMALL_QUOTA_CRASH.getType())){
|
|
|
- ptProfitLog.setUserId(userId);
|
|
|
- }
|
|
|
ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
|
|
|
// todo 发送通知
|
|
|
// todo 发短信
|
|
@@ -125,15 +119,9 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
@Override
|
|
|
public Long addMessageFreeze(Long userId,Long ancestorId, CaclEnum caclEnum, Long amount, Long afterAmount, String percentTemplate,Long accumulatedQuotAmount, Long maxAvailablePointsAmount ,Long afterMaxAvailablePointsAmount) {
|
|
|
PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
|
|
|
- .afterFreezeAmount(afterAmount)
|
|
|
- .freezeAmount(amount)
|
|
|
.percentTemplate(percentTemplate)
|
|
|
.profitStatus(caclEnum.getType())
|
|
|
- .accumulatedQuotaAmount(accumulatedQuotAmount)
|
|
|
- .maxAvailablePointsAmount(maxAvailablePointsAmount)
|
|
|
- .afterMaxAvailablePointsAmount(afterMaxAvailablePointsAmount)
|
|
|
.generateUserId(ancestorId)
|
|
|
- .userId(userId)
|
|
|
.build();
|
|
|
PtProfitLogDO bean = BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class);
|
|
|
ptProfitLogMapper.insert(bean);
|
|
@@ -170,7 +158,7 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
.betweenIfPresent(PtProfitLogDO::getCreateTime, yesterdayThreeAM, todayThreeAM)
|
|
|
.eqIfPresent(PtProfitLogDO::getProfitStatus, CaclEnum.DIRECT_REFERRAL_QUOTA.getType())
|
|
|
.or().eq(PtProfitLogDO::getProfitStatus, CaclEnum.TOGETHER_AWARD.getType())
|
|
|
- .in(PtProfitLogDO::getUserId, sonsId));
|
|
|
+ .in(PtProfitLogDO::getGenerateUserId, sonsId));
|
|
|
Long sum = ptProfitLogDOS.stream().mapToLong(PtProfitLogDO::getAmount).sum();
|
|
|
|
|
|
return sum + "";
|
|
@@ -181,7 +169,7 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
List<PtProfitLogDO> ptProfitLogDOS = ptProfitLogMapper.selectList(new LambdaQueryWrapperX<PtProfitLogDO>()
|
|
|
.eqIfPresent(PtProfitLogDO::getProfitStatus, CaclEnum.DIRECT_REFERRAL_QUOTA.getType())
|
|
|
.or().eq(PtProfitLogDO::getProfitStatus, CaclEnum.TOGETHER_AWARD.getType())
|
|
|
- .in(PtProfitLogDO::getUserId, sonsId));
|
|
|
+ .in(PtProfitLogDO::getGenerateUserId, sonsId));
|
|
|
Long sum = ptProfitLogDOS.stream().mapToLong(PtProfitLogDO::getAmount).sum();
|
|
|
|
|
|
return sum + "";
|
|
@@ -200,10 +188,8 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
.afterAmount(afterAmount)
|
|
|
.amount(amount)
|
|
|
.percentTemplate(percentTemplate)
|
|
|
- .userId(userId)
|
|
|
.generateUserId(generateUserId)
|
|
|
.profitStatus(caclEnum.getType()).orderId(tradeOrderId).orderNo(OrderNum)
|
|
|
- .freezeAmount(freezeAmount).afterFreezeAmount(afterFreezeAmount)
|
|
|
.build();
|
|
|
ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
|
|
|
|
|
@@ -213,9 +199,23 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
|
|
|
public List<PtProfitLogDO> calcIntegral() {
|
|
|
return ptProfitLogMapper.selectList(new LambdaQueryWrapper<PtProfitLogDO>()
|
|
|
.eq(PtProfitLogDO::getProfitStatus, SMALL_QUOTA_CRASH.getType())
|
|
|
- .ne(PtProfitLogDO::getAccumulatedQuotaAmount, 0)
|
|
|
.lt(PtProfitLogDO::getCreateTime, LocalDateTime.now().minusDays(5))
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Long createPtProfitLog(Long userId, Long amount, Long afterAmount, String percentTemplate, IntegralEnum integralEnum, Integer profitType) {
|
|
|
+ PtProfitLogDO log = PtProfitLogDO.builder()
|
|
|
+ .generateUserId(userId)
|
|
|
+ .amount(amount)
|
|
|
+ .afterAmount(afterAmount)
|
|
|
+ .percentTemplate(percentTemplate)
|
|
|
+ .profitType(profitType)
|
|
|
+ .profitStatus(integralEnum.getType())
|
|
|
+ .build();
|
|
|
+ ptProfitLogMapper.insert(log);
|
|
|
+
|
|
|
+ return log.getId();
|
|
|
+ }
|
|
|
+
|
|
|
}
|