From 2ba52666860b04bedff1da95af0f6445315e6128 Mon Sep 17 00:00:00 2001
From: zhangmei <645025773@qq.com>
Date: 星期二, 11 二月 2025 14:27:52 +0800
Subject: [PATCH] Merge branch 'xizang-changyun' of https://gitee.com/xiaochen991015/xizang into xizang-changyun

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
index 3a0bdc6..390106e 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -4,17 +4,23 @@
 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;
 
@@ -35,6 +41,10 @@
     @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);
@@ -42,17 +52,32 @@
     }
 
 
-
     /**
      * 传的金额
      * @param tBill
      * @return
      */
-    public Boolean checkAndUpdateBill(TBill tBill){
+    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);
+            }
+        }
+    }
 
 
 }

--
Gitblit v1.7.1