package com.ruoyi.system.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ruoyi.common.basic.PageInfo;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.system.dto.TBillDto;
|
import com.ruoyi.system.dto.TbillSaveDto;
|
import com.ruoyi.system.mapper.TBillMapper;
|
import com.ruoyi.system.model.TBill;
|
import com.ruoyi.system.model.TBillDetail;
|
import com.ruoyi.system.model.TContract;
|
import com.ruoyi.system.model.THouse;
|
import com.ruoyi.system.query.TBillQuery;
|
import com.ruoyi.system.service.TBillDetailService;
|
import com.ruoyi.system.service.TBillService;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import io.jsonwebtoken.lang.Assert;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.time.LocalDateTime;
|
|
/**
|
* <p>
|
* 租金账单 服务实现类
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2025-01-17
|
*/
|
@Service
|
public class TBillServiceImpl extends ServiceImpl<TBillMapper, TBill> implements TBillService {
|
|
@Autowired
|
RedisCache redisCache;
|
|
@Autowired
|
TBillMapper tBillMapper;
|
|
@Autowired
|
TBillDetailService tBillDetailService;
|
|
|
public PageInfo<TBillDto> queryPage(TBillQuery query){
|
PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
|
PageInfo<TBillDto> info = tBillMapper.page(pageInfo, query);
|
return info;
|
}
|
|
|
/**
|
* 传的金额
|
* @param tBill
|
* @return
|
*/
|
public Boolean lockAndUpdateInfo(TBill tBill){
|
if (StringUtils.isEmpty(tBill.getId())){
|
throw new ServiceException("账单主键ID不能为空");
|
}
|
return true;
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void saveBill(TbillSaveDto bill) {
|
save(bill);
|
if (bill.getBillType().equals("3")){
|
if (bill.getDetails()==null || bill.getDetails().size()==0){
|
throw new ServiceException("生活费用列表不能为空");
|
}
|
for (TBillDetail detail : bill.getDetails()) {
|
detail.setBillId(bill.getId());
|
tBillDetailService.save(detail);
|
}
|
}
|
}
|
|
|
}
|