123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package com.fdkankan.agent.service.impl;
- import java.util.Date;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
- import com.fdkankan.agent.entity.AgentNew;
- import com.fdkankan.agent.entity.AgentNewLog;
- import com.fdkankan.agent.entity.IncrementType;
- import com.fdkankan.agent.mapper.IAgentNewMapper;
- import com.fdkankan.agent.response.AgentNewVo;
- import com.fdkankan.agent.service.IAgentNewLogService;
- import com.fdkankan.agent.service.IAgentNewService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author
- * @since 2022-11-09
- */
- @Service
- public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew> implements IAgentNewService {
- @Autowired
- IAgentNewLogService agentNewLogService;
- @Override
- public AgentNewVo getByUserName(String phoneNum) {
- LambdaQueryWrapper<AgentNew> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(AgentNew::getUserName,phoneNum);
- List<AgentNew> list = this.list(wrapper);
- if(list == null || list.size() <=0){
- return null;
- }
- List<AgentNewVo> listVo = new ArrayList<>();
- for (AgentNew agentNew : list) {
- AgentNewVo vo = new AgentNewVo();
- BeanUtils.copyProperties(agentNew,vo);
- vo.setDownSubNum(vo.getDownTotalNum() - vo.getDownUseNum());
- vo.setHighSubNum(vo.getHighTotalNum() - vo.getHighUseNum());
- vo.setMajorSubNum(vo.getMajorTotalNum() - vo.getMajorUseNum());
- listVo.add(vo);
- }
- return listVo.get(0);
- }
- @Override
- public void subNum(AgentNewVo agentNewVo, Long userId,IncrementType incrementType, Integer count,Integer addType) {
- if(count == null || count <=0){
- return;
- }
- AgentNewLog agentNewLog = new AgentNewLog();
- agentNewLog.setAgentId(agentNewVo.getId());
- agentNewLog.setUserId(userId);
- agentNewLog.setCount(count);
- agentNewLog.setGiveType(addType);
- LambdaUpdateWrapper<AgentNew> wrapper = new LambdaUpdateWrapper<>();
- wrapper.eq(AgentNew::getId,agentNewVo.getId());
- if(incrementType != null && incrementType.getValidTimeType() == 0){
- agentNewLog.setType(0);
- wrapper.set(AgentNew::getMajorUseNum,agentNewVo.getMajorUseNum() + count);
- }
- if(incrementType != null && incrementType.getValidTimeType() == 1){
- agentNewLog.setType(1);
- wrapper.set(AgentNew::getHighUseNum,agentNewVo.getHighUseNum() + count);
- }
- if(incrementType == null){
- agentNewLog.setType(2);
- wrapper.set(AgentNew::getDownUseNum,agentNewVo.getDownUseNum() + count);
- }
- this.update(wrapper);
- agentNewLogService.save(agentNewLog);
- }
- }
|