123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package com.fdkankan.manage.service.impl;
- import com.alibaba.excel.EasyExcel;
- import com.alibaba.excel.ExcelWriter;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.fdkankan.manage.common.PageInfo;
- import com.fdkankan.manage.common.CacheUtil;
- 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.*;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.fdkankan.manage.vo.request.AgentAddIncrementParam;
- import com.fdkankan.manage.vo.request.AgentNewLogParam;
- import com.fdkankan.manage.vo.request.AgentParam;
- import com.fdkankan.manage.vo.request.OrderParam;
- import com.fdkankan.manage.vo.response.AgentNewLogVo;
- import com.fdkankan.manage.vo.response.AgentVo;
- import com.fdkankan.manage.vo.response.OrderVo;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author
- * @since 2022-11-08
- */
- @Service
- public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew> implements IAgentNewService {
- @Autowired
- ISysUserService sysUserService;
- @Autowired
- IIncrementTypeService incrementTypeService;
- @Autowired
- IAgentNewLogService agentNewLogService;
- @Autowired
- IExcelService excelService;
- @Override
- public Object pageList(AgentParam agentParam) {
- LambdaQueryWrapper<AgentNew> wrapper = new LambdaQueryWrapper<>();
- if(StringUtils.isNotBlank(agentParam.getName())){
- wrapper.like(AgentNew::getName,agentParam.getName());
- }
- wrapper.orderByDesc(AgentNew::getCreateTime);
- Page<AgentNew> page = this.page(new Page<>(agentParam.getPageNum(), agentParam.getPageSize()), wrapper);
- List<AgentVo> voList = new ArrayList<>();
- for (AgentNew record : page.getRecords()) {
- AgentVo vo = new AgentVo();
- BeanUtils.copyProperties(record,vo);
- SysUser sysUser = sysUserService.getById(vo.getSysUserId());
- if(sysUser != null){
- vo.setSysUserName(sysUser.getNickName());
- }
- voList.add(vo);
- }
- Page<AgentVo> voPage = new Page<>(agentParam.getPageNum(), agentParam.getPageSize());
- voPage.setTotal(page.getTotal());
- voPage.setRecords(voList);
- return PageInfo.PageInfo(voPage);
- }
- @Override
- public void addIncrementNum(AgentAddIncrementParam param) {
- if(param.getId() == null ){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- AgentNew agentNew = this.getById(param.getId());
- if(agentNew == null){
- throw new BusinessException(ResultCode.AGENT_NEW_EMPTY);
- }
- if(param.getDownAddNum() <=0 || param.getMajorAddNum() <=0 || param.getHighAddNum() <=0 ){
- return;
- }
- LambdaUpdateWrapper<AgentNew> wrapper = new LambdaUpdateWrapper<>();
- wrapper.eq(AgentNew::getId,param.getId());
- if( param.getDownAddNum() >0){
- wrapper.set(AgentNew::getDownTotalNum,agentNew.getDownTotalNum() + param.getDownAddNum());
- }
- if(param.getHighAddNum() >0){
- wrapper.set(AgentNew::getHighTotalNum,agentNew.getHighTotalNum() + param.getHighAddNum());
- }
- if( param.getMajorAddNum() >0){
- wrapper.set(AgentNew::getMajorTotalNum,agentNew.getMajorTotalNum() + param.getMajorAddNum());
- }
- this.update(wrapper);
- }
- @Override
- public Object logList(AgentNewLogParam param) {
- CacheUtil.agentParam = param;
- return agentNewLogService.getVoList(param);
- }
- @Override
- public void export(HttpServletRequest req, HttpServletResponse resp) {
- AgentNewLogParam param = CacheUtil.agentParam;
- List<AgentNewLogVo> voList = agentNewLogService.getVoList(param);
- ExcelWriter excelWriter = null;
- try {
- excelWriter = EasyExcel.write(resp.getOutputStream(),AgentNewLogVo.class).build();
- excelService.commonExport(req,resp,"经销商结算统计",voList,excelWriter);
- }catch (Exception e){
- e.printStackTrace();
- }finally {
- if(excelWriter != null){
- excelWriter.finish();
- }
- }
- }
- }
|