|
@@ -1,20 +1,19 @@
|
|
-package cn.newfeifan.mall.module.distri.service.consumptiontopuplog;
|
|
|
|
|
|
+package cn.newfeifan.mall.module.distri.service.integraltopuplog;
|
|
|
|
|
|
import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
import cn.newfeifan.mall.module.distri.constant.DistriConstants;
|
|
import cn.newfeifan.mall.module.distri.constant.DistriConstants;
|
|
-import cn.newfeifan.mall.module.distri.controller.admin.consumptionchangelog.vo.ConsumptionChangeLogSaveReqVO;
|
|
|
|
|
|
+import cn.newfeifan.mall.module.distri.controller.admin.integralchangelog.vo.IntegralChangeLogSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
|
|
-import cn.newfeifan.mall.module.distri.enums.ConsumptionEnum;
|
|
|
|
-import cn.newfeifan.mall.module.distri.service.consumptionchangelog.ConsumptionChangeLogService;
|
|
|
|
|
|
+import cn.newfeifan.mall.module.distri.enums.IntegralEnum;
|
|
|
|
+import cn.newfeifan.mall.module.distri.enums.IntegralTypeEnum;
|
|
|
|
+import cn.newfeifan.mall.module.distri.service.integralchangelog.IntegralChangeLogService;
|
|
import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
|
|
import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
|
|
import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
|
|
import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
|
|
-import cn.newfeifan.mall.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
|
|
|
import cn.newfeifan.mall.module.member.dal.dataobject.user.MemberUserDO;
|
|
import cn.newfeifan.mall.module.member.dal.dataobject.user.MemberUserDO;
|
|
import cn.newfeifan.mall.module.member.service.user.MemberUserService;
|
|
import cn.newfeifan.mall.module.member.service.user.MemberUserService;
|
|
import cn.newfeifan.mall.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
|
|
import cn.newfeifan.mall.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
|
|
-import cn.newfeifan.mall.module.system.controller.admin.auth.vo.AuthSmsSendReqVO;
|
|
|
|
import cn.newfeifan.mall.module.system.enums.sms.SmsSceneEnum;
|
|
import cn.newfeifan.mall.module.system.enums.sms.SmsSceneEnum;
|
|
import cn.newfeifan.mall.module.system.service.sms.SmsCodeService;
|
|
import cn.newfeifan.mall.module.system.service.sms.SmsCodeService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -24,8 +23,8 @@ import javax.annotation.Resource;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
-import cn.newfeifan.mall.module.distri.controller.admin.consumptiontopuplog.vo.*;
|
|
|
|
-import cn.newfeifan.mall.module.distri.dal.dataobject.consumptiontopuplog.ConsumptionTopUpLogDO;
|
|
|
|
|
|
+import cn.newfeifan.mall.module.distri.controller.admin.integraltopuplog.vo.*;
|
|
|
|
+import cn.newfeifan.mall.module.distri.dal.dataobject.integraltopuplog.IntegralTopUpLogDO;
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
@@ -45,7 +44,7 @@ import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@Validated
|
|
@Validated
|
|
-public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogService {
|
|
|
|
|
|
+public class IntegralTopUpLogServiceImpl implements IntegralTopUpLogService {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ConsumptionTopUpLogMapper consumptionTopUpLogMapper;
|
|
private ConsumptionTopUpLogMapper consumptionTopUpLogMapper;
|
|
@@ -57,68 +56,67 @@ public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogServic
|
|
private IntegralService integralService;
|
|
private IntegralService integralService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private ConsumptionChangeLogService consumptionChangeLogService;
|
|
|
|
|
|
+ private IntegralChangeLogService integralChangeLogService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private SmsCodeService smsCodeService;
|
|
private SmsCodeService smsCodeService;
|
|
- @Resource
|
|
|
|
- private MemberUserService memberUserService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public Long createConsumptionTopUpLog(ConsumptionTopUpLogSaveReqVO createReqVO) {
|
|
|
|
|
|
+ public Long createConsumptionTopUpLog(IntegralTopUpLogSaveReqVO createReqVO) {
|
|
// 充值的额度
|
|
// 充值的额度
|
|
- Long agentQuota = createReqVO.getConsumptionPoints();
|
|
|
|
|
|
+ Long agentQuota = createReqVO.getIntegralPoints();
|
|
OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
// 充值额度校验
|
|
// 充值额度校验
|
|
- quotaVerify(createReqVO.getUserId(), createReqVO.getConsumptionPoints(), orderPercentageDO);
|
|
|
|
|
|
+ quotaVerify(createReqVO.getUserId(), createReqVO.getIntegralPoints(), orderPercentageDO);
|
|
|
|
|
|
// 短信验证码校验
|
|
// 短信验证码校验
|
|
smsCodeService.useSmsCode(createReqVO.getSmsCodeUseReqDTO().setUsedIp(getClientIP()));
|
|
smsCodeService.useSmsCode(createReqVO.getSmsCodeUseReqDTO().setUsedIp(getClientIP()));
|
|
|
|
|
|
// 额度放大百万倍,存储需要(方便换算),和积分一样
|
|
// 额度放大百万倍,存储需要(方便换算),和积分一样
|
|
- createReqVO.setConsumptionPoints(createReqVO.getConsumptionPoints() * DistriConstants.MILLION);
|
|
|
|
|
|
+ createReqVO.setIntegralPoints(createReqVO.getIntegralPoints() * DistriConstants.MILLION);
|
|
|
|
|
|
// 充值倍率
|
|
// 充值倍率
|
|
- if (createReqVO.getConsumptionPoints() >= Long.parseLong(orderPercentageDO.getTriggerMagnificationPoints()) * DistriConstants.MILLION) {
|
|
|
|
- createReqVO.setPracticalConsumptionPoints((long) (createReqVO.getConsumptionPoints() * Double.parseDouble(orderPercentageDO.getConsumptionMagnification())));
|
|
|
|
|
|
+ if (createReqVO.getIntegralPoints() >= Long.parseLong(orderPercentageDO.getTriggerMagnificationPoints()) * DistriConstants.MILLION) {
|
|
|
|
+ createReqVO.setPracticalIntegralPoints((long) (createReqVO.getIntegralPoints() * Double.parseDouble(orderPercentageDO.getIntegralMagnification())));
|
|
} else {
|
|
} else {
|
|
- createReqVO.setPracticalConsumptionPoints(createReqVO.getConsumptionPoints());
|
|
|
|
|
|
+ createReqVO.setPracticalIntegralPoints(createReqVO.getIntegralPoints());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// 插入
|
|
// 插入
|
|
- ConsumptionTopUpLogDO consumptionTopUpLog = BeanUtils.toBean(createReqVO, ConsumptionTopUpLogDO.class);
|
|
|
|
|
|
+ IntegralTopUpLogDO consumptionTopUpLog = BeanUtils.toBean(createReqVO, IntegralTopUpLogDO.class);
|
|
consumptionTopUpLogMapper.insert(consumptionTopUpLog);
|
|
consumptionTopUpLogMapper.insert(consumptionTopUpLog);
|
|
|
|
|
|
// 修改用户钱包
|
|
// 修改用户钱包
|
|
IntegralDO integralDO = integralService.selectByUser(consumptionTopUpLog.getUserId());
|
|
IntegralDO integralDO = integralService.selectByUser(consumptionTopUpLog.getUserId());
|
|
- integralDO.setConsumptionPoints(integralDO.getConsumptionPoints() + consumptionTopUpLog.getPracticalConsumptionPoints());
|
|
|
|
|
|
+ integralDO.setRedCurrentQuota(integralDO.getRedCurrentQuota() + consumptionTopUpLog.getPracticalIntegralPoints());
|
|
integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
|
|
|
|
|
|
// 记录用户消费分变动日志
|
|
// 记录用户消费分变动日志
|
|
- consumptionChangeLogService.createConsumptionChangeLog(ConsumptionChangeLogSaveReqVO.builder()
|
|
|
|
|
|
+ integralChangeLogService.createConsumptionChangeLog(IntegralChangeLogSaveReqVO.builder()
|
|
.userId(consumptionTopUpLog.getUserId())
|
|
.userId(consumptionTopUpLog.getUserId())
|
|
- .consumptionPoints(consumptionTopUpLog.getPracticalConsumptionPoints())
|
|
|
|
- .afterConsumptionPoints(integralDO.getConsumptionPoints())
|
|
|
|
- .consumptionStatus(ConsumptionEnum.PT_TOP_TUP.getType())
|
|
|
|
- .practicalConsumptionPoints(consumptionTopUpLog.getConsumptionPoints())
|
|
|
|
|
|
+ .integralPoints(consumptionTopUpLog.getPracticalIntegralPoints())
|
|
|
|
+ .afterIntegralPoints(integralDO.getRedCurrentQuota())
|
|
|
|
+ .integralStatus(IntegralEnum.PT_TOP_TUP.getType())
|
|
|
|
+ .integralType(IntegralTypeEnum.RED_INTEGRAL.getType())
|
|
|
|
+ .practicalIntegralPoints(consumptionTopUpLog.getIntegralPoints())
|
|
.generateUserId(getLoginUserId())
|
|
.generateUserId(getLoginUserId())
|
|
.build());
|
|
.build());
|
|
|
|
|
|
// 发送短信通知用户充值成功
|
|
// 发送短信通知用户充值成功
|
|
- MemberUserDO user = memberUserService.getUser(consumptionTopUpLog.getUserId());
|
|
|
|
- smsCodeService.sendSmsCode(SmsCodeSendReqDTO.builder()
|
|
|
|
- .mobile(user.getMobile())
|
|
|
|
- .scene(SmsSceneEnum.CONSUMPTION_POINTS_TOP_UP.getScene())
|
|
|
|
- .createIp(getClientIP())
|
|
|
|
- .build());
|
|
|
|
-
|
|
|
|
- // 当单笔充值大于设定金额时,将用户设置为代理商
|
|
|
|
- if(agentQuota >= Long.parseLong(orderPercentageDO.getAgentQuota()) && !user.getAgent()){
|
|
|
|
- user.setAgent(true);
|
|
|
|
- memberUserService.updateUser(BeanUtils.toBean(user, MemberUserUpdateReqVO.class));
|
|
|
|
- }
|
|
|
|
|
|
+// MemberUserDO user = memberUserService.getUser(consumptionTopUpLog.getUserId());
|
|
|
|
+// smsCodeService.sendSmsCode(SmsCodeSendReqDTO.builder()
|
|
|
|
+// .mobile(user.getMobile())
|
|
|
|
+// .scene(SmsSceneEnum.CONSUMPTION_POINTS_TOP_UP.getScene())
|
|
|
|
+// .createIp(getClientIP())
|
|
|
|
+// .build());
|
|
|
|
+
|
|
|
|
+// // 当单笔充值大于设定金额时,将用户设置为代理商
|
|
|
|
+// if(agentQuota >= Long.parseLong(orderPercentageDO.getAgentQuota()) && !user.getAgent()){
|
|
|
|
+// user.setAgent(true);
|
|
|
|
+// memberUserService.updateUser(BeanUtils.toBean(user, MemberUserUpdateReqVO.class));
|
|
|
|
+// }
|
|
|
|
|
|
// 返回
|
|
// 返回
|
|
return consumptionTopUpLog.getId();
|
|
return consumptionTopUpLog.getId();
|
|
@@ -150,11 +148,11 @@ public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogServic
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void updateConsumptionTopUpLog(ConsumptionTopUpLogSaveReqVO updateReqVO) {
|
|
|
|
|
|
+ public void updateConsumptionTopUpLog(IntegralTopUpLogSaveReqVO updateReqVO) {
|
|
// 校验存在
|
|
// 校验存在
|
|
validateConsumptionTopUpLogExists(updateReqVO.getId());
|
|
validateConsumptionTopUpLogExists(updateReqVO.getId());
|
|
// 更新
|
|
// 更新
|
|
- ConsumptionTopUpLogDO updateObj = BeanUtils.toBean(updateReqVO, ConsumptionTopUpLogDO.class);
|
|
|
|
|
|
+ IntegralTopUpLogDO updateObj = BeanUtils.toBean(updateReqVO, IntegralTopUpLogDO.class);
|
|
consumptionTopUpLogMapper.updateById(updateObj);
|
|
consumptionTopUpLogMapper.updateById(updateObj);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -165,35 +163,35 @@ public class ConsumptionTopUpLogServiceImpl implements ConsumptionTopUpLogServic
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ConsumptionTopUpLogDO getConsumptionTopUpLog(Long id) {
|
|
|
|
|
|
+ public IntegralTopUpLogDO getConsumptionTopUpLog(Long id) {
|
|
return consumptionTopUpLogMapper.selectById(id);
|
|
return consumptionTopUpLogMapper.selectById(id);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PageResult<ConsumptionTopUpLogDO> getConsumptionTopUpLogPage(ConsumptionTopUpLogPageReqVO pageReqVO) {
|
|
|
|
|
|
+ public PageResult<IntegralTopUpLogDO> getConsumptionTopUpLogPage(IntegralTopUpLogPageReqVO pageReqVO) {
|
|
return consumptionTopUpLogMapper.selectPage(pageReqVO);
|
|
return consumptionTopUpLogMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ConsumptionInfoVO isFirstConsumption(Long userId) {
|
|
|
|
- List<ConsumptionTopUpLogDO> consumptionTopUpLogDOS = consumptionTopUpLogMapper.selectList(ConsumptionTopUpLogDO::getUserId, userId);
|
|
|
|
|
|
+ public IntegralInfoVO isFirstConsumption(Long userId) {
|
|
|
|
+ List<IntegralTopUpLogDO> integralTopUpLogDOS = consumptionTopUpLogMapper.selectList(IntegralTopUpLogDO::getUserId, userId);
|
|
|
|
|
|
- ConsumptionInfoVO build = ConsumptionInfoVO.builder().build();
|
|
|
|
|
|
+ IntegralInfoVO build = IntegralInfoVO.builder().build();
|
|
OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
- if (consumptionTopUpLogDOS.isEmpty()) {
|
|
|
|
- build.setIsFirstConsumption(true);
|
|
|
|
- build.setMinimumConsumptionPoints(Long.valueOf(orderPercentageDO.getFirstTopUpConsumption()));
|
|
|
|
- } else {
|
|
|
|
- build.setIsFirstConsumption(false);
|
|
|
|
- build.setMinimumConsumptionPoints(Long.valueOf(orderPercentageDO.getFollowUpConsumption()));
|
|
|
|
- }
|
|
|
|
- build.setConsumptionMagnification(orderPercentageDO.getConsumptionMagnification());
|
|
|
|
|
|
+// if (consumptionTopUpLogDOS.isEmpty()) {
|
|
|
|
+// build.setIsFirstConsumption(true);
|
|
|
|
+// build.setMinimumConsumptionPoints(Long.valueOf(orderPercentageDO.getFirstTopUpConsumption()));
|
|
|
|
+// } else {
|
|
|
|
+// build.setIsFirstConsumption(false);
|
|
|
|
+// build.setMinimumConsumptionPoints(Long.valueOf(orderPercentageDO.getFollowUpConsumption()));
|
|
|
|
+// }
|
|
|
|
+ build.setConsumptionMagnification(orderPercentageDO.getIntegralMagnification());
|
|
build.setTriggerMagnificationPoints(orderPercentageDO.getTriggerMagnificationPoints());
|
|
build.setTriggerMagnificationPoints(orderPercentageDO.getTriggerMagnificationPoints());
|
|
return build;
|
|
return build;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ConsumptionTopUpLogDO> selectList() {
|
|
|
|
|
|
+ public List<IntegralTopUpLogDO> selectList() {
|
|
return consumptionTopUpLogMapper.selectList();
|
|
return consumptionTopUpLogMapper.selectList();
|
|
}
|
|
}
|
|
|
|
|