| | |
| | | package com.highdatas.srs.service.impl; |
| | | |
| | | import com.highdatas.srs.entity.Scheme; |
| | | import com.highdatas.srs.mapper.SchemeMapper; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | 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; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, Scheme> 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<SchemeBill> parent_id = billService.selectList(new EntityWrapper<SchemeBill>().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<SchemeBill> parent_id = billService.selectList(new EntityWrapper<SchemeBill>().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; |
| | | } |
| | | } |