| | |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import com.yuanchu.mom.pojo.FansSubmit; |
| | | import com.yuanchu.mom.pojo.FinanceSubmit; |
| | | import com.yuanchu.mom.service.DataReportingService; |
| | | import com.yuanchu.mom.service.FinanceSubmitService; |
| | | import com.yuanchu.mom.mapper.FinanceSubmitMapper; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | @Override |
| | | public int updateFinanceSubmit(FinanceSubmit financeSubmit) { |
| | | DataReporting reporting = dataReportingMapper.selectById(financeSubmit.getDataId()); |
| | | reporting.setId(financeSubmit.getDataId()); |
| | | reporting.setAgentRebate(financeSubmit.getEmployeeRebate()); |
| | | try { |
| | | reporting.setDiscountedConsumption(reporting.getConsumption().divide(reporting.getAgentRebate(), 2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){} |
| | | dataReportingMapper.updateById(reporting); |
| | | return financeSubmitMapper.updateById(financeSubmit); |
| | | } |
| | | |
| | | @Override |
| | | public int addFinanceSubmit(FinanceSubmit financeSubmit, String date) { |
| | | if(date == null) date = getYesterday(); |
| | | DataReporting dataReporting = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getAgent, financeSubmit.getCompany()).eq(DataReporting::getName, financeSubmit.getName()).like(DataReporting::getCreateTime, date)); |
| | | DataReporting dataReporting = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getAgent, financeSubmit.getCompany()).eq(DataReporting::getName, financeSubmit.getName()).eq(DataReporting::getCreateUser, getLook.selectPowerByMethodAndUserId("selectRegistrantCountDtoPageList").get("userId")).like(DataReporting::getCreateTime, date)); |
| | | if(ObjectUtil.isEmpty(dataReporting)){ |
| | | throw new ErrorException(date+" 账户:"+financeSubmit.getName()+" 的代理商:"+financeSubmit.getCompany()+" 并未上报过"); |
| | | throw new ErrorException(date+" 账户:"+financeSubmit.getName()+" 代理商:"+financeSubmit.getCompany()+" 并未上报过"); |
| | | } |
| | | dataReporting.setAgentRebate(financeSubmit.getEmployeeRebate()); |
| | | try { |
| | | dataReporting.setDiscountedConsumption(dataReporting.getConsumption().divide(dataReporting.getAgentRebate(), 2, RoundingMode.HALF_UP)); |
| | | }catch (Exception e){} |
| | | dataReportingMapper.updateById(dataReporting); |
| | | financeSubmit.setDataId(dataReporting.getId()); |
| | | return financeSubmitMapper.insert(financeSubmit); |