| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.DataReportingPageDto; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.mapper.DataReportingMapper; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.yuanchu.mom.service.FansSubmitService; |
| | | import com.yuanchu.mom.mapper.FansSubmitMapper; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.utils.ServletUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | private GetLook getLook; |
| | | |
| | | private DataReportingMapper dataReportingMapper; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectFansSubmitList(IPage<FansSubmit> page, FansSubmit fansSubmit) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | return map; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int delFansSubmit(Integer id) { |
| | | FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, id).select(FansSubmit::getFansAdd, FansSubmit::getDataId)); |
| | | DataReporting dataReporting = dataReportingMapper.selectById(fansSubmit.getDataId()); |
| | | dataReporting.setFansAdd(dataReporting.getFansAdd() - fansSubmit.getFansAdd()); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | return fansSubmitMapper.deleteById(id); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int updateFansSubmit(FansSubmit fansSubmit) { |
| | | DataReporting dataReporting = dataReportingMapper.selectById(fansSubmit.getDataId()); |
| | | dataReporting.setFansAdd(dataReporting.getFansAdd() + fansSubmit.getFansAdd() - fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, fansSubmit.getId()).select(FansSubmit::getFansAdd)).getFansAdd()); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | return fansSubmitMapper.updateById(fansSubmit); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int addFansSubmit(FansSubmit fansSubmit) { |
| | | public int addFansSubmit(FansSubmit fansSubmit, String date) { |
| | | if(date == null) date = getYesterday(); |
| | | DataReporting dataReporting = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getName, fansSubmit.getCustom()).eq(DataReporting::getProduct, fansSubmit.getProduct()).like(DataReporting::getCreateTime, date)); |
| | | if(ObjectUtil.isEmpty(dataReporting)){ |
| | | throw new ErrorException(date+" 客户:"+fansSubmit.getCustom()+" 并未上报过 "+fansSubmit.getProduct()+" 项目"); |
| | | } |
| | | dataReporting.setFansAdd((dataReporting.getFansAdd()==null?0:dataReporting.getFansAdd()) + fansSubmit.getFansAdd()); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | fansSubmit.setDataId(dataReporting.getId()); |
| | | return fansSubmitMapper.insert(fansSubmit); |
| | | } |
| | | |
| | | public String getYesterday(){ |
| | | return LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | } |
| | | |
| | | |