package com.highdatas.srs.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.highdatas.srs.entity.Scheme; import com.highdatas.srs.entity.SchemeBill; import com.highdatas.srs.mapper.SchemeMapper; import com.highdatas.srs.service.ISchemeBillService; import com.highdatas.srs.service.ISchemeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.List; /** *

* 服务实现类 *

* * @author kimi * @since 2020-01-15 */ @Service public class SchemeServiceImpl extends ServiceImpl implements ISchemeService { @Autowired ISchemeBillService billService; @Override public Scheme refreshBudget(String schemeId) { Scheme scheme = selectById(schemeId); if (scheme == null) { return null; } BigDecimal decimal = new BigDecimal(0); List parent_id = billService.selectList(new EntityWrapper().eq("parent_id", schemeId)); if (parent_id != null) { for (SchemeBill schemeBill : parent_id) { BigDecimal money = schemeBill.getMoney(); if (money != null) { decimal = decimal.add(money); } } scheme.setBudget(decimal).updateById(); } return scheme; } @Override public Scheme refreshCheckMoney(String schemeId) { Scheme scheme = selectById(schemeId); if (scheme == null) { return null; } BigDecimal decimal = new BigDecimal(0); List parent_id = billService.selectList(new EntityWrapper().eq("parent_id", schemeId)); if (parent_id != null) { for (SchemeBill schemeBill : parent_id) { BigDecimal money = schemeBill.getMoney(); Boolean checked = schemeBill.getChecked(); if (money != null && checked != null && checked) { decimal = decimal.add(money); } } scheme.setPayMoney(decimal).updateById(); } return scheme; } }