|
@@ -1,9 +1,13 @@
|
|
|
package cn.newfeifan.mall.module.distri.service.integral;
|
|
|
|
|
|
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO;
|
|
|
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
|
|
|
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
|
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog.PtProfitLogDO;
|
|
|
import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlog.PtProfitLogMapper;
|
|
|
import cn.newfeifan.mall.module.distri.enums.CaclEnum;
|
|
|
+import cn.newfeifan.mall.module.distri.service.ptprofit.PtProfitService;
|
|
|
import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
|
|
|
import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -25,7 +29,9 @@ import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
|
import cn.newfeifan.mall.module.distri.dal.mysql.integral.IntegralMapper;
|
|
|
|
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.newfeifan.mall.module.distri.constant.DistriConstants.PT_ID;
|
|
|
import static cn.newfeifan.mall.module.distri.enums.CaclEnum.DIRECT_REFERRAL_QUOTA;
|
|
|
+import static cn.newfeifan.mall.module.distri.enums.CaclEnum.MANUAL_RETURN_INTEGRAL;
|
|
|
import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -50,6 +56,9 @@ public class IntegralServiceImpl implements IntegralService {
|
|
|
@Resource
|
|
|
private PtProfitLogService ptProfitLogService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PtProfitService ptProfitService;
|
|
|
+
|
|
|
@Override
|
|
|
public Long createIntegral(IntegralSaveReqVO createReqVO) {
|
|
|
// 插入
|
|
@@ -198,4 +207,56 @@ public class IntegralServiceImpl implements IntegralService {
|
|
|
ptProfitLogService.addMessage(userId,userId,caclEnum,payIntegral,integralDO.getCurrentQuota(),0L,0L,null,tradeOrderId,orderNum);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void calcIntegral() {
|
|
|
+ List<PtProfitLogDO> ptProfitLogDOS = ptProfitLogService.calcIntegral();
|
|
|
+ for (PtProfitLogDO ptProfitLogDO : ptProfitLogDOS) {
|
|
|
+ IntegralDO integralDO = integralMapper.selectOne(new LambdaQueryWrapper<IntegralDO>().eq(IntegralDO::getUserId, ptProfitLogDO.getUserId()));
|
|
|
+ //加积分余额
|
|
|
+ integralDO.setCurrentQuota(integralDO.getCurrentQuota() + ptProfitLogDO.getAccumulatedQuotaAmount());
|
|
|
+ //加累计积分余额
|
|
|
+ integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + ptProfitLogDO.getAccumulatedQuotaAmount());
|
|
|
+ //减可用峰值
|
|
|
+ integralDO.setHighQuota(integralDO.getHighQuota() - ptProfitLogDO.getAccumulatedQuotaAmount());
|
|
|
+
|
|
|
+ integralMapper.updateById(integralDO);
|
|
|
+
|
|
|
+ PtProfitDO ptProfit = ptProfitService.getPtProfit();
|
|
|
+ IntegralDO ptIntegralDO = selectByUser(PT_ID);
|
|
|
+
|
|
|
+ //平台用户扣除积分
|
|
|
+ ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - ptProfitLogDO.getAccumulatedQuotaAmount());
|
|
|
+ ptIntegralDO.setCurrentQuota(ptIntegralDO.getCurrentQuota() - ptProfitLogDO.getAccumulatedQuotaAmount());
|
|
|
+ // 平台扣除积分
|
|
|
+ ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - ptProfitLogDO.getAccumulatedQuotaAmount());
|
|
|
+
|
|
|
+ integralMapper.updateById(ptIntegralDO);
|
|
|
+ ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId())
|
|
|
+ .ptAdd(ptProfit.getPtAdd())
|
|
|
+ .ptGrossAdd(ptProfit.getPtGrossAdd())
|
|
|
+ .ptTotalAdd(ptProfit.getPtTotalAdd()).build());
|
|
|
+
|
|
|
+ //这条记录是用户看的
|
|
|
+ PtProfitLogSaveReqVO ProfitLog = PtProfitLogSaveReqVO.builder()
|
|
|
+ .amount(ptProfitLogDO.getAccumulatedQuotaAmount())
|
|
|
+ .afterAmount(integralDO.getCurrentQuota())
|
|
|
+ .userId(ptProfitLogDO.getUserId())
|
|
|
+ .generateUserId(ptProfitLogDO.getGenerateUserId())
|
|
|
+ .profitStatus(MANUAL_RETURN_INTEGRAL.getType())
|
|
|
+ .maxAvailablePointsAmount(-ptProfitLogDO.getAccumulatedQuotaAmount())
|
|
|
+ .afterMaxAvailablePointsAmount(integralDO.getHighQuota())
|
|
|
+ .build();
|
|
|
+ ptProfitLogMapper.insert(BeanUtils.toBean(ProfitLog, PtProfitLogDO.class));
|
|
|
+
|
|
|
+ //这条是pt看的
|
|
|
+ PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
|
|
|
+ .amount(ptProfitLogDO.getAccumulatedQuotaAmount())
|
|
|
+ .afterAmount(ptProfit.getPtGrossAdd())
|
|
|
+ .generateUserId(ptProfitLogDO.getGenerateUserId())
|
|
|
+ .profitStatus(MANUAL_RETURN_INTEGRAL.getType())
|
|
|
+ .build();
|
|
|
+ ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|