From 98c94b182ebbd0b17c82926a90cd042f37760e65 Mon Sep 17 00:00:00 2001
From: heheng <heheng@123456>
Date: 星期五, 17 一月 2025 08:39:38 +0800
Subject: [PATCH] 特种作业缴费版本

---
 exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayServiceImpl.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayServiceImpl.java b/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayServiceImpl.java
index f090935..c0f46c7 100644
--- a/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayServiceImpl.java
+++ b/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayServiceImpl.java
@@ -1,13 +1,21 @@
 package com.gkhy.exam.pay.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gkhy.exam.pay.dto.req.NonCoalPayCategoryReqDto;
+import com.gkhy.exam.pay.dto.req.NonCoalPayReqDto;
 import com.gkhy.exam.pay.entity.NonCoalPay;
+import com.gkhy.exam.pay.entity.NonCoalPayCategory;
 import com.gkhy.exam.pay.mapper.NonCoalPayMapper;
+import com.gkhy.exam.pay.service.NonCoalPayCategoryService;
 import com.gkhy.exam.pay.service.NonCoalPayService;
-import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 
 
@@ -21,6 +29,8 @@
 public class NonCoalPayServiceImpl extends ServiceImpl<NonCoalPayMapper, NonCoalPay> implements NonCoalPayService {
     @Resource
     private NonCoalPayMapper nonCoalPayMapper;
+    @Resource
+    private NonCoalPayCategoryService nonCoalPayCategoryService;
 
     /**
      * 查询【请填写功能名称】
@@ -32,6 +42,7 @@
     public NonCoalPay selectNonCoalPayById(Long id) {
         return nonCoalPayMapper.selectNonCoalPayById(id);
     }
+
 
     /**
      * 查询【请填写功能名称】列表
@@ -51,9 +62,29 @@
      * @return 结果
      */
     @Override
-    public int insertNonCoalPay(NonCoalPay nonCoalPay) {
-        nonCoalPay.setCreateTime(DateUtils.getNowDate());
-        return nonCoalPayMapper.insertNonCoalPay(nonCoalPay);
+    @Transactional
+    public int insertNonCoalPay(NonCoalPayReqDto nonCoalPay) {
+        //todo 校验
+        NonCoalPay nonCoalPay1 = new NonCoalPay();
+        BeanUtils.copyProperties(nonCoalPay, nonCoalPay1);
+        nonCoalPay1.setCreateBy(SecurityUtils.getUsername());
+
+        int i = nonCoalPayMapper.insertNonCoalPay(nonCoalPay1);
+        if (i > 0) {
+            saveNonCoalPayCategory(nonCoalPay.getNonCoalPayCategoryList());
+        }
+        return i;
+    }
+
+    private void saveNonCoalPayCategory(List<NonCoalPayCategoryReqDto> nonCoalPayCategoryList) {
+        List<NonCoalPayCategory> nonCoalPayCategories = new ArrayList<>();
+        for (NonCoalPayCategoryReqDto nonCoalPayCategory : nonCoalPayCategoryList) {
+            NonCoalPayCategory nonCoalPayCategory1 = new NonCoalPayCategory();
+            BeanUtils.copyProperties(nonCoalPayCategory, nonCoalPayCategory1);
+            nonCoalPayCategory1.setCreateBy(SecurityUtils.getUsername());
+            nonCoalPayCategories.add(nonCoalPayCategory1);
+        }
+        nonCoalPayCategoryService.saveBacth(nonCoalPayCategories);
     }
 
     /**
@@ -63,9 +94,21 @@
      * @return 结果
      */
     @Override
-    public int updateNonCoalPay(NonCoalPay nonCoalPay) {
-        nonCoalPay.setUpdateTime(DateUtils.getNowDate());
-        return nonCoalPayMapper.updateNonCoalPay(nonCoalPay);
+    @Transactional
+    public int updateNonCoalPay(NonCoalPayReqDto nonCoalPay) {
+        //todo 校验
+        NonCoalPay nonCoalPay1 = new NonCoalPay();
+        BeanUtils.copyProperties(nonCoalPay, nonCoalPay1);
+        nonCoalPay1.setUpdateBy(SecurityUtils.getUsername());
+        int i = nonCoalPayMapper.updateNonCoalPay(nonCoalPay1);
+        if (i > 0) {
+            int i1 = nonCoalPayCategoryService.deleteNonCoalPayCategoryByPayId(nonCoalPay.getId());
+            if (i1 < 1) {
+                throw new ServiceException("更新失败");
+            }
+            saveNonCoalPayCategory(nonCoalPay.getNonCoalPayCategoryList());
+        }
+        return i;
     }
 
     /**

--
Gitblit v1.9.2