| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.io.file.FileReader; |
| | |
| | | import com.yuanchu.mom.dto.DataReportingPageDto; |
| | | import com.yuanchu.mom.dto.ProductCountDto; |
| | | import com.yuanchu.mom.dto.RegistrantCountDto; |
| | | import com.yuanchu.mom.mapper.AuthMapper; |
| | | import com.yuanchu.mom.mapper.FansSubmitMapper; |
| | | import com.yuanchu.mom.mapper.FinanceSubmitMapper; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | |
| | | @Resource |
| | | private FinanceSubmitMapper financeSubmitMapper; |
| | | |
| | | @Resource |
| | | private AuthMapper authMapper; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectDataReportingList(IPage<DataReportingPageDto> page, DataReportingPageDto dataReportingPageDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectDataReportingList"); |
| | | if (map1.get("look") == 1) dataReportingPageDto.setCreateUser(map1.get("userId")); |
| | | if (map1.get("look") == 1) dataReportingPageDto.setUpdateUser(map1.get("userId")); |
| | | Integer power = authMapper.isPower(map1.get("userId"), "dataReportingPower"); |
| | | if (power == 1) { |
| | | dataReportingPageDto.setDepartment(dataReportingMapper.getUserDepartmentById(map1.get("userId"))); |
| | | } |
| | | map.put("head", PrintChina.printChina(DataReportingPageDto.class)); |
| | | map.put("body", dataReportingMapper.selectDataReportingDtoPageList(page, QueryWrappers.queryWrappers(dataReportingPageDto))); |
| | | return map; |
| | |
| | | for (FansSubmit fansSubmit : fansSubmits) { |
| | | sum += fansSubmit.getFansAdd(); |
| | | } |
| | | dataReporting2.setFansAdd(sum); |
| | | if (dataReporting.getFansAdd() != null || dataReporting.getFansAdd() != 0) { |
| | | dataReporting2.setFansAdd(dataReporting.getFansAdd()); |
| | | } else { |
| | | dataReporting2.setFansAdd(sum); |
| | | } |
| | | return dataReportingMapper.updateById(dataReporting2); |
| | | } |
| | | |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(RegistrantCountDto.class)); |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectRegistrantCountDtoPageList"); |
| | | if (map1.get("look") == 1) registrantCountDto.setCreateUser(map1.get("userId")); |
| | | map.put("body", dataReportingMapper.selectRegistrantCountDtoPageList(page, QueryWrappers.queryWrappers(registrantCountDto))); |
| | | if (map1.get("look") == 1) { |
| | | String name = dataReportingMapper.getUserNameById(map1.get("userId")); |
| | | registrantCountDto.setName2(name); |
| | | } |
| | | ; |
| | | String department = dataReportingMapper.getUserDepartmentById(map1.get("userId")); |
| | | registrantCountDto.setDepartment(department); |
| | | map.put("body", dataReportingMapper.selectRegistrantCountDtoPageList(page, QueryWrappers.queryWrappers(registrantCountDto), registrantCountDto.getStartTime(), registrantCountDto.getEndTime())); |
| | | return map; |
| | | } |
| | | |
| | |
| | | public void addDataReporting(List<DataReporting> list, String date, String param) { |
| | | int userId = Integer.parseInt(JSONUtil.parseObj(new Jwt().readJWT(ServletUtils.getRequest().getHeader("token")).get("data")).get("id") + ""); |
| | | Map<String, String> map = dataReportingMapper.selectUser(userId); |
| | | String date2 = date; |
| | | if (date == null) { |
| | | date2 = fansSubmitService.getYesterday(); |
| | | date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } else |
| | | date = LocalDateTime.parse(date + "T00:00:00").plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | for (DataReporting dataReporting : list) { |
| | | String date2 = date; |
| | | if(date == null) { |
| | | date2 = fansSubmitService.getYesterday(); |
| | | date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } else date = LocalDateTime.parse(date+"T00:00:00").plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | // List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, dataReporting.getProduct()).eq(FansSubmit::getVx, param).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, date)); |
| | | FinanceSubmit financeSubmit = financeSubmitMapper.selectOne(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getCompany, dataReporting.getAgent()).eq(FinanceSubmit::getName, dataReporting.getName()).select(FinanceSubmit::getEmployeeRebate).like(FinanceSubmit::getCreateTime, date).orderByDesc(FinanceSubmit::getId).last("limit 1")); |
| | | // Integer sum = 0; |
| | | // for (FansSubmit fansSubmit : fansSubmits) { |
| | | // sum += fansSubmit.getFansAdd(); |
| | | // } |
| | | // dataReporting.setFansAdd(sum); |
| | | if(ObjectUtil.isNotEmpty(financeSubmit)){ |
| | | if (ObjectUtil.isNotEmpty(financeSubmit)) { |
| | | dataReporting.setAgentRebate(financeSubmit.getEmployeeRebate()); |
| | | } |
| | | if (dataReporting.getName() == null || dataReporting.getName().equals("")) |
| | |
| | | dataReporting.setRemark(dataReporting.getConsumption().subtract(dataReporting.getRebateConsumption())); |
| | | } catch (Exception e) { |
| | | } |
| | | // dataReporting.setVxCard(param); |
| | | // if (ObjectUtil.isEmpty(one)) { |
| | | dataReporting.setRegistrant(map.get("name")); |
| | | dataReporting.setDepartment(map.get("department")); |
| | | dataReporting.setCreateTime(LocalDateTime.parse(date2 + " " + new SimpleDateFormat("HH:mm:ss").format(new Date()), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | dataReportingMapper.insert(dataReporting); |
| | | // } else { |
| | | // dataReporting.setId(one.getId()); |
| | | // dataReporting.setName(null); |
| | | // dataReportingMapper.updateById(dataReporting); |
| | | // } |
| | | DataReporting dataReporting1 = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery() |
| | | .eq(DataReporting::getName, dataReporting.getName()) |
| | | .eq(DataReporting::getAccountConsumption, dataReporting.getAccountConsumption()) |
| | | .eq(DataReporting::getShowNum, dataReporting.getShowNum()) |
| | | .eq(DataReporting::getClick, dataReporting.getClick())); |
| | | if (BeanUtil.isNotEmpty(dataReporting1)) { |
| | | dataReporting.setId(dataReporting1.getId()); |
| | | dataReportingMapper.updateById(dataReporting); |
| | | } else { |
| | | dataReportingMapper.insert(dataReporting); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer delDataReporting(Integer id) { |
| | | /*List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getDataId, id).select(FansSubmit::getId)); |
| | | if(fansSubmits.size()>0)fansSubmitMapper.deleteBatchIds(fansSubmits); |
| | | List<FinanceSubmit> financeSubmits = financeSubmitMapper.selectList(Wrappers.<FinanceSubmit>lambdaQuery().eq(FinanceSubmit::getDataId, id).select(FinanceSubmit::getId)); |
| | | if(financeSubmits.size()>0)financeSubmitMapper.deleteBatchIds(financeSubmits);*/ |
| | | return dataReportingMapper.deleteById(id); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<String> selectDataReportingForProduct(String time) { |
| | | return dataReportingMapper.selectDataReportingForProduct(time.split(" ")[0]); |
| | | } |
| | | |
| | | @Override |
| | | public int updateVxCards(List<DataReporting> list) { |
| | | for (DataReporting reporting : list) { |
| | | updateDataReporting(reporting); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | } |
| | | |
| | | |