liukangdong
2024-12-06 cb54e068db9d9816ae38f60f57ad0fe7ca10fca8
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwAccountServiceImpl.java
@@ -8,9 +8,11 @@
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.YwAccountMapper;
import com.doumee.dao.business.YwContractRevenueMapper;
import com.doumee.dao.business.dao.CompanyMapper;
import com.doumee.dao.business.model.Company;
import com.doumee.dao.business.model.YwAccount;
import com.doumee.dao.business.model.YwContractRevenue;
import com.doumee.dao.business.model.YwProject;
import com.doumee.service.business.YwAccountService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -18,6 +20,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -37,6 +40,8 @@
    private YwAccountMapper ywAccountMapper;
    @Autowired
    private CompanyMapper companyMapper;
    @Autowired
    private YwContractRevenueMapper ywContractRevenueMapper;
    @Override
    public Integer create(YwAccount model) {
@@ -49,6 +54,15 @@
                || !Constants.equalsInteger(ywProject.getType(),Constants.TWO)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的公司信息!");
        }
        if(StringUtils.isNotBlank(model.getTitle())){
            if(ywAccountMapper.selectCount(new QueryWrapper<YwAccount>().lambda()
                    .eq(YwAccount::getTitle,model.getTitle())
                    .eq(YwAccount::getIsdeleted,Constants.ZERO)) >0){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,收支条目不能重复~");
            }
        }
        model.setCreator(model.getLoginUserInfo().getId());
        model.setIsdeleted(Constants.ZERO);
        model.setCreateDate(new Date());
@@ -61,6 +75,9 @@
    @Override
    public void deleteById(Integer id, LoginUserInfo user) {
        if(ywContractRevenueMapper.selectCount(new QueryWrapper<YwContractRevenue>().lambda().eq(YwContractRevenue::getAccountId,id))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前收支账户已关联业务,不可删除");
        }
        YwAccount model = new YwAccount();
        model.setId(id);
        model.setIsdeleted(Constants.ONE);
@@ -95,6 +112,15 @@
                || !Constants.equalsInteger(ywProject.getType(),Constants.TWO)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的公司信息!");
        }
        if(StringUtils.isNotBlank(model.getTitle())){
            if(ywAccountMapper.selectCount(new QueryWrapper<YwAccount>().lambda()
                    .eq(YwAccount::getTitle,model.getTitle())
                    .ne(YwAccount::getId,model.getId())
                    .eq(YwAccount::getIsdeleted,Constants.ZERO)) >0){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,收支条目不能重复~");
            }
        }
        model.setEditDate(model.getCreateDate());
        model.setEditor(model.getCreator());
        ywAccountMapper.updateById(model);