|
@@ -9,13 +9,12 @@ import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.entity.*;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.mapper.IAgentNewMapper;
|
|
|
-import com.fdkankan.manage.service.IAgentIncrementService;
|
|
|
import com.fdkankan.manage.service.IAgentNewService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.manage.service.IIncrementTypeService;
|
|
|
import com.fdkankan.manage.service.ISysUserService;
|
|
|
+import com.fdkankan.manage.vo.request.AgentAddIncrementParam;
|
|
|
import com.fdkankan.manage.vo.request.AgentParam;
|
|
|
-import com.fdkankan.manage.vo.response.AgentIncrementVo;
|
|
|
import com.fdkankan.manage.vo.response.AgentVo;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -40,8 +39,6 @@ public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew>
|
|
|
@Autowired
|
|
|
ISysUserService sysUserService;
|
|
|
@Autowired
|
|
|
- IAgentIncrementService agentIncrementService;
|
|
|
- @Autowired
|
|
|
IIncrementTypeService incrementTypeService;
|
|
|
|
|
|
@Override
|
|
@@ -53,7 +50,6 @@ public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew>
|
|
|
wrapper.orderByDesc(AgentNew::getCreateTime);
|
|
|
Page<AgentNew> page = this.page(new Page<>(agentParam.getPageNum(), agentParam.getPageSize()), wrapper);
|
|
|
List<AgentVo> voList = new ArrayList<>();
|
|
|
- HashMap<Integer,IncrementType> map = incrementTypeService.getIdMap();
|
|
|
for (AgentNew record : page.getRecords()) {
|
|
|
AgentVo vo = new AgentVo();
|
|
|
BeanUtils.copyProperties(record,vo);
|
|
@@ -61,18 +57,6 @@ public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew>
|
|
|
if(sysUser != null){
|
|
|
vo.setSysUserName(sysUser.getNickName());
|
|
|
}
|
|
|
- List<AgentIncrement> agentIncrements = agentIncrementService.getByAgentId(record.getId());
|
|
|
- List<AgentIncrementVo> agentIncrementVos = new ArrayList<>();
|
|
|
- for (AgentIncrement agentIncrement : agentIncrements) {
|
|
|
- if(map.get(agentIncrement.getIncrementTypeId()) == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- AgentIncrementVo agentVo = new AgentIncrementVo();
|
|
|
- BeanUtils.copyProperties(agentIncrement,agentVo);
|
|
|
- agentVo.setIncrementTypeName(map.get(agentIncrement.getIncrementTypeId()).getName());
|
|
|
- agentIncrementVos.add(agentVo);
|
|
|
- }
|
|
|
- vo.setAgentIncrements(agentIncrementVos );
|
|
|
voList.add(vo);
|
|
|
}
|
|
|
|
|
@@ -83,19 +67,27 @@ public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void addIncrementNum(AgentVo param) {
|
|
|
+ public void addIncrementNum(AgentAddIncrementParam param) {
|
|
|
if(param.getId() == null ){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
- if(param.getDownTotalNum()!=null){
|
|
|
- LambdaUpdateWrapper<AgentNew> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.eq(AgentNew::getId,param.getId());
|
|
|
- wrapper.set(AgentNew::getDownTotalNum, param.getDownTotalNum());
|
|
|
- this.update(wrapper);
|
|
|
+ AgentNew agentNew = this.getById(param.getId());
|
|
|
+ if(agentNew == null){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<AgentNew> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(AgentNew::getId,param.getId());
|
|
|
+ if(param.getDownAddNum()!=null && param.getDownAddNum() >0){
|
|
|
+ wrapper.set(AgentNew::getDownTotalNum,agentNew.getDownTotalNum() + param.getDownAddNum());
|
|
|
+ }
|
|
|
+ if(param.getHighAddNum()!=null && param.getDownAddNum() >0){
|
|
|
+ wrapper.set(AgentNew::getDownTotalNum,agentNew.getHighTotalNum() + param.getHighAddNum());
|
|
|
}
|
|
|
- if(param.getAgentIncrements() != null && param.getAgentIncrements().size() >0){
|
|
|
- agentIncrementService.addNum(param.getAgentIncrements());
|
|
|
+ if(param.getMajorAddNum()!=null && param.getDownAddNum() >0){
|
|
|
+ wrapper.set(AgentNew::getDownTotalNum,agentNew.getMajorTotalNum() + param.getMajorAddNum());
|
|
|
}
|
|
|
+ this.update(wrapper);
|
|
|
|
|
|
}
|
|
|
}
|