Explorar o código

添加机构提现中添加审核时间,账户表添加提现字段,
历史表添加板块、支付方式、审核id
添加部门审核轨迹表

hxl13994548489 %!s(int64=2) %!d(string=hai) anos
pai
achega
2641106eb1

+ 24 - 0
sql/Online.sql

@@ -0,0 +1,24 @@
+--  add by  hxl  2024-07-05  部门提现表添加审核时间
+ALTER TABLE `sys_dept_account_withdraw` ADD COLUMN `auditing_time` datetime DEFAULT NULL COMMENT '部门提现审核时间';
+
+--  add  by  hxl  机构账户表添加
+ALTER TABLE `sys_dept_account` ADD COLUMN `sum_amount_withdrawal` decimal(10,2) DEFAULT 0 COMMENT '提现总金额';
+ALTER TABLE `sys_dept_account` ADD COLUMN `sum_amount_account` decimal(10,2) DEFAULT 0 COMMENT '已到账总金额';
+ALTER TABLE `sys_dept_account` ADD COLUMN `sum_amount_payment` decimal(10,2) DEFAULT 0 COMMENT '支付中总金额';
+--  add  by hxl   部门账户历史表添加部门提现审核id
+ALTER TABLE `sys_dept_account_history` ADD COLUMN `auditing_id`  varchar(30) DEFAULT NULL COMMENT '部门提现审核Id';
+ALTER TABLE `sys_dept_account_history` ADD COLUMN `business_eegments_type` int DEFAULT NULL COMMENT '业务版块';
+ALTER TABLE `sys_dept_account_history` ADD COLUMN `property` int DEFAULT NULL COMMENT '金钱属性  5退款 6 提现';
+-- add by hxl  部门审核轨迹表
+DROP TABLE IF EXISTS `sys_amount_auditing_dept_history`;
+CREATE TABLE `sys_amount_auditing_dept_history`  (
+                                                     `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                                                     `amount_auding_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审核表id',
+                                                     `amount` decimal(10, 2) NOT NULL COMMENT '提现金额',
+                                                     `dept_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '机构Id',
+                                                     `create_time` datetime NOT NULL COMMENT '创建时间',
+                                                     `auditing_status` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '审核状态 1 提现申请  2.处理中 3.驳回  4.提现成功',
+                                                     `amount_status` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '金额类型 1 提现',
+                                                     `history_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '历史记录表id',
+                                                     PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '部门审核轨迹表' ROW_FORMAT = Dynamic;

+ 18 - 0
src/main/java/com/ydtech/modules/admin/dao/SysAmountAuditingDeptHistoryMapper.java

@@ -0,0 +1,18 @@
+package com.ydtech.modules.admin.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingDeptHistory;
+
+/**
+* @author Administrator
+* @description 针对表【sys_amount_auditing_dept_history(部门审核轨迹表)】的数据库操作Mapper
+* @createDate 2024-07-05 09:41:44
+* @Entity generator.domain.SysAmountAuditingDeptHistory
+*/
+public interface SysAmountAuditingDeptHistoryMapper extends BaseMapper<SysAmountAuditingDeptHistory> {
+
+}
+
+
+
+

+ 19 - 0
src/main/java/com/ydtech/modules/admin/model/SysDeptAccount.java

@@ -34,6 +34,25 @@ public class SysDeptAccount implements Serializable {
     @TableField(exist = false)
     private BigDecimal amount;
 
+    // add by  hxl   2024-07-05
+    /**
+     * 提现总金额
+     */
+    @TableField(value = "sum_amount_withdrawal")
+    private BigDecimal sumAmountWithdrawal;
+
+    /**
+     * 已到账总金额
+     */
+    @TableField(value = "sum_amount_account")
+    private BigDecimal sumAmountAccount;
+
+    /**
+     * 支付中总金额
+     */
+    @TableField(value = "sum_amount_payment")
+    private BigDecimal sumAmountPayment;
+
 
 
 

+ 18 - 0
src/main/java/com/ydtech/modules/admin/model/SysDeptAccountHistory.java

@@ -57,5 +57,23 @@ public class SysDeptAccountHistory implements Serializable{
         @TableField(value = "remark")
         private String remark;
 
+        // add by  hxl  2024-07-05
+        @ApiModelProperty(value = "审核表id")
+        @TableField(value = "auditing_id")
+        private String auditingId;
+
+        /**
+         * 金钱属性  5 为 退款  6.提现
+         */
+        @TableField(value = "property")
+        private Integer property;
+        /**
+         *  @version
+         *  @author: hxl
+         *  @Date: 2024/6/19 9:22
+         *  @Description:  业务板块类型    1. 车险
+         */
+        @TableField(value = "business_eegments_type")
+        private Integer  businessSegmentsType;
 
 }

+ 8 - 0
src/main/java/com/ydtech/modules/admin/model/SysDeptAccountWithdraw.java

@@ -10,6 +10,7 @@ import lombok.Data;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 
 @Data
@@ -66,4 +67,11 @@ public class SysDeptAccountWithdraw implements Serializable {
     @TableField(value = "pic_id")
     @ApiModelProperty(value = "图片id")
     private String picId;
+
+    /***
+     *  审核时间    add  by hxl  2024-07-05
+     */
+    @TableField(value = "auditing_time")
+    @ApiModelProperty(value = "审核时间")
+    private Date auditingTime;
 }

+ 139 - 0
src/main/java/com/ydtech/modules/admin/model/po/SysAmountAuditingDeptHistory.java

@@ -0,0 +1,139 @@
+package com.ydtech.modules.admin.model.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 部门审核轨迹表
+ * @TableName sys_amount_auditing_dept_history
+ */
+@TableName(value ="sys_amount_auditing_dept_history")
+@Data
+public class SysAmountAuditingDeptHistory implements Serializable {
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 审核表id
+     */
+    @TableField(value = "amount_auding_id")
+    private String amountAudingId;
+
+    /**
+     * 提现金额
+     */
+    @TableField(value = "amount")
+    private BigDecimal amount;
+
+    /**
+     * 机构Id
+     */
+    @TableField(value = "dept_id")
+    private String deptId;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private Date createTime;
+
+    /**
+     * 审核状态 1 提现申请  2.处理中 3.驳回  4.提现成功
+     */
+    @TableField(value = "auditing_status")
+    private String auditingStatus;
+
+    /**
+     * 金额类型 1 提现
+     */
+    @TableField(value = "amount_status")
+    private String amountStatus;
+
+    /**
+     * 金额类型 1 提现
+     */
+    @TableField(value = "history_id")
+    private String historyId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        SysAmountAuditingDeptHistory other = (SysAmountAuditingDeptHistory) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getAmountAudingId() == null ? other.getAmountAudingId() == null : this.getAmountAudingId().equals(other.getAmountAudingId()))
+            && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
+            && (this.getDeptId() == null ? other.getDeptId() == null : this.getDeptId().equals(other.getDeptId()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+            && (this.getAuditingStatus() == null ? other.getAuditingStatus() == null : this.getAuditingStatus().equals(other.getAuditingStatus()))
+            && (this.getAmountStatus() == null ? other.getAmountStatus() == null : this.getAmountStatus().equals(other.getAmountStatus()))
+            && (this.getHistoryId() == null ? other.getHistoryId() == null : this.getHistoryId().equals(other.getHistoryId()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getAmountAudingId() == null) ? 0 : getAmountAudingId().hashCode());
+        result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
+        result = prime * result + ((getDeptId() == null) ? 0 : getDeptId().hashCode());
+        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        result = prime * result + ((getAuditingStatus() == null) ? 0 : getAuditingStatus().hashCode());
+        result = prime * result + ((getAmountStatus() == null) ? 0 : getAmountStatus().hashCode());
+        result = prime * result + ((getHistoryId() == null) ? 0 : getHistoryId().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", amountAudingId=").append(amountAudingId);
+        sb.append(", amount=").append(amount);
+        sb.append(", deptId=").append(deptId);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", auditingStatus=").append(auditingStatus);
+        sb.append(", amountStatus=").append(amountStatus);
+        sb.append(", historyId=").append(historyId);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+
+    public SysAmountAuditingDeptHistory() {
+    }
+
+    public SysAmountAuditingDeptHistory(String amountAudingId, BigDecimal amount, String deptId, Date createTime, String auditingStatus, String amountStatus, String historyId) {
+        this.amountAudingId = amountAudingId;
+        this.amount = amount;
+        this.deptId = deptId;
+        this.createTime = createTime;
+        this.auditingStatus = auditingStatus;
+        this.amountStatus = amountStatus;
+        this.historyId = historyId;
+    }
+}

+ 6 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountWithdrawVo.java

@@ -7,6 +7,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 @Data
 public class SysDeptAccountWithdrawVo implements Serializable {
@@ -71,5 +72,10 @@ public class SysDeptAccountWithdrawVo implements Serializable {
     private int pageNo;
 
     private int pageSize;
+    /***
+     *  审核时间    add  by hxl  2024-07-05
+     */
+    @ApiModelProperty(value = "审核时间")
+    private Date auditingTime;
 
 }

+ 14 - 0
src/main/java/com/ydtech/modules/admin/service/SysAmountAuditingDeptHistoryService.java

@@ -0,0 +1,14 @@
+package com.ydtech.modules.admin.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingDeptHistory;
+
+
+/**
+* @author Administrator
+* @description 针对表【sys_amount_auditing_dept_history(部门审核轨迹表)】的数据库操作Service
+* @createDate 2024-07-05 09:41:44
+*/
+public interface SysAmountAuditingDeptHistoryService extends IService<SysAmountAuditingDeptHistory> {
+
+}

+ 22 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysAmountAuditingDeptHistoryServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ydtech.modules.admin.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.admin.dao.SysAmountAuditingDeptHistoryMapper;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingDeptHistory;
+import com.ydtech.modules.admin.service.SysAmountAuditingDeptHistoryService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author Administrator
+* @description 针对表【sys_amount_auditing_dept_history(部门审核轨迹表)】的数据库操作Service实现
+* @createDate 2024-07-05 09:41:44
+*/
+@Service
+public class SysAmountAuditingDeptHistoryServiceImpl extends ServiceImpl<SysAmountAuditingDeptHistoryMapper, SysAmountAuditingDeptHistory>
+    implements SysAmountAuditingDeptHistoryService {
+
+}
+
+
+
+

+ 44 - 2
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountServiceImpl.java

@@ -10,8 +10,12 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysDeptAccountMapper;
-import com.ydtech.modules.admin.model.*;
+import com.ydtech.modules.admin.model.SysDept;
+import com.ydtech.modules.admin.model.SysDeptAccount;
+import com.ydtech.modules.admin.model.SysDeptAccountHistory;
+import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
 import com.ydtech.modules.admin.model.dto.SysDeptAccountDto;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingDeptHistory;
 import com.ydtech.modules.admin.model.vo.SysDeptAccountByUserVo;
 import com.ydtech.modules.admin.model.vo.SysDeptAccountVO;
 import com.ydtech.modules.admin.service.*;
@@ -27,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -49,6 +54,9 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
     @Autowired
     private SysUserInfoService sysUserInfoService;
 
+    @Autowired
+    private SysAmountAuditingDeptHistoryService  sysAmountAuditingDeptHistoryService;
+
     @Override
     public BasePageResult<SysDeptAccount> queryByVo(SysDeptAccountVO sysDeptAccountVO) {
 
@@ -74,6 +82,7 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
         return deptAccountByUserList;
     }
 
+    @Transactional
     public HttpResult withdrawDeptAccount(SysDeptAccount sysDeptAccount) {
         SysDeptAccount deptAccount = sysDeptAccountMapper.selectById(sysDeptAccount.getDeptId());
         //根据deptId查询提现人员相关信息
@@ -87,8 +96,15 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
         if (sysDeptAccount.getAmount().equals(new BigDecimal(BigInteger.ZERO))) {
             throw new SystemException("提现金额不能为0");
         }
+        BigDecimal accountAmount = deptAccount.getManagementFee().subtract(sysDeptAccount.getAmount());
         // 减去提现金额
-        deptAccount.setManagementFee(deptAccount.getManagementFee().subtract(sysDeptAccount.getAmount()));
+        deptAccount.setManagementFee(accountAmount);
+        //计算两个金额
+        //支付中总金额 = 原先的支付金额 + 提现的金额
+        deptAccount.setSumAmountPayment((deptAccount.getSumAmountPayment()==null?BigDecimal.ZERO:deptAccount.getSumAmountPayment()).add(sysDeptAccount.getAmount()));
+        //提现的总金额 = 原先的提现总金额 + 提现的金额
+        deptAccount.setSumAmountWithdrawal((deptAccount.getSumAmountWithdrawal()==null?BigDecimal.ZERO:deptAccount.getSumAmountWithdrawal().add(sysDeptAccount.getAmount())));
+
         sysDeptAccountService.updateById(deptAccount);
 
         // 生成提现审核数据
@@ -104,6 +120,32 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
         sysDeptAccountWithdraw.setCreateTime(LocalDateTime.now());
         sysDeptAccountWithdrawService.save(sysDeptAccountWithdraw);
 
+        //插入机构历史表
+        // 机构历史明细生成提现明细
+        SysDeptAccountHistory sysDeptAccountHistory = new SysDeptAccountHistory();
+        sysDeptAccountHistory.setId(IdGenerate.nextId());
+        sysDeptAccountHistory.setDeptId(sysDeptAccount.getDeptId());
+        sysDeptAccountHistory.setAmount(sysDeptAccountWithdraw.getAmount());
+        sysDeptAccountHistory.setSurplusAmount(accountAmount);
+        sysDeptAccountHistory.setSuborder(sysDeptAccountWithdraw.getId());
+        sysDeptAccountHistory.setDocumentary("1");
+        sysDeptAccountHistory.setProperty(6);
+        sysDeptAccountHistory.setBusinessSegmentsType(1);
+        sysDeptAccountHistory.setFromBankCard(null);
+        sysDeptAccountHistory.setToBankCard(null);
+        sysDeptAccountHistory.setUserId(BaseController.getUser().getId());
+        sysDeptAccountHistory.setCreateTime(new Date());
+         //  add by  hxl  2024 -07-05  插入审核表Id
+        sysDeptAccountHistory.setAuditingId(sysDeptAccountWithdraw.getId());
+        sysDeptAccountHistory.setRemark("从" + sysDeptAccountWithdraw.getName() + "机构账户中提现" + sysDeptAccountWithdraw.getAmount() + "元");
+        sysDeptAccountHistoryService.save(sysDeptAccountHistory);
+
+        // 提现审核插入轨迹表   待审核数据 和审核处理中的数据
+        Date date = new Date();
+        SysAmountAuditingDeptHistory sysAmountAuditingDeptHistory =new SysAmountAuditingDeptHistory(sysDeptAccountWithdraw.getId(), sysDeptAccountWithdraw.getAmount(), deptAccount.getDeptId(),date,"1", "1",sysDeptAccountHistory.getId());
+        SysAmountAuditingDeptHistory sysAmountAuditingDeptHistoryTwo =new SysAmountAuditingDeptHistory(sysDeptAccountWithdraw.getId(), sysDeptAccountWithdraw.getAmount(), deptAccount.getDeptId(),date, "2", "1",sysDeptAccountHistory.getId());
+        sysAmountAuditingDeptHistoryService.save(sysAmountAuditingDeptHistory);
+        sysAmountAuditingDeptHistoryService.save(sysAmountAuditingDeptHistoryTwo);
         return HttpResult.ok("", sysDeptAccount);
     }
 

+ 72 - 26
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountWithdrawServiceImpl.java

@@ -1,25 +1,30 @@
 package com.ydtech.modules.admin.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.constants.sys.SysDeptAccountStatus;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysDeptAccountWithdrawMapper;
 import com.ydtech.modules.admin.model.SysDeptAccount;
 import com.ydtech.modules.admin.model.SysDeptAccountHistory;
 import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
+import com.ydtech.modules.admin.model.po.SysAmountAuditingDeptHistory;
 import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo;
+import com.ydtech.modules.admin.service.SysAmountAuditingDeptHistoryService;
 import com.ydtech.modules.admin.service.SysDeptAccountHistoryService;
 import com.ydtech.modules.admin.service.SysDeptAccountService;
 import com.ydtech.modules.admin.service.SysDeptAccountWithdrawService;
 import com.ydtech.modules.base.controller.BaseController;
-import com.ydtech.utils.idgen.IdGenerate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 
@@ -36,6 +41,13 @@ public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl<SysDeptAccoun
 
     @Autowired
     private SysDeptAccountHistoryService sysDeptAccountHistoryService;
+
+
+    @Autowired
+    private SysAmountAuditingDeptHistoryService sysAmountAuditingDeptHistoryService;
+
+
+
     @Override
     public IPage<SysDeptAccountWithdraw> getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) {
         PageRequest pageRequest = new PageRequest();
@@ -47,35 +59,69 @@ public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl<SysDeptAccoun
     }
 
     @Override
+    @Transactional
     public HttpResult updateByStatus(SysDeptAccountWithdraw sysDeptAccountWithdraw) {
-        if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.PASS.getCode())) {
+        try{
+            //查询账户表金额
             SysDeptAccount sysDeptAccount = sysDeptAccountService.getById(sysDeptAccountWithdraw.getDeptId());
-            sysDeptAccount.setManagementFee(sysDeptAccount.getManagementFee());
-            sysDeptAccountService.updateById(sysDeptAccount);
-            // 机构历史明细生成提现明细
-            SysDeptAccountHistory sysDeptAccountHistory = new SysDeptAccountHistory();
-            sysDeptAccountHistory.setId(IdGenerate.nextId());
-            sysDeptAccountHistory.setDeptId(sysDeptAccount.getDeptId());
-            sysDeptAccountHistory.setAmount(sysDeptAccountWithdraw.getAmount());
-            sysDeptAccountHistory.setSurplusAmount(sysDeptAccount.getManagementFee());
-            sysDeptAccountHistory.setSuborder(sysDeptAccountWithdraw.getId());
-            sysDeptAccountHistory.setDocumentary("1"); //提现
-            sysDeptAccountHistory.setFromBankCard(null);
-            sysDeptAccountHistory.setToBankCard(null);
-            sysDeptAccountHistory.setUserId(BaseController.getUser().getId());
-            sysDeptAccountHistory.setCreateTime(new Date());
-            sysDeptAccountHistory.setRemark("从" + sysDeptAccountWithdraw.getName() + "机构账户中提现" + sysDeptAccountWithdraw.getAmount() + "元");
-            sysDeptAccountHistoryService.save(sysDeptAccountHistory);
-        }
-        if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.REJECT.getCode())) {
-            SysDeptAccount sysDeptAccount = sysDeptAccountService.getById(sysDeptAccountWithdraw.getDeptId());
-            sysDeptAccount.setManagementFee(sysDeptAccount.getManagementFee().add(sysDeptAccountWithdraw.getAmount()));
+            sysDeptAccountWithdraw.setVoucherId(sysDeptAccountWithdraw.getVoucherId());
+            sysDeptAccountWithdraw.setAuditUserid(BaseController.getUser().getId());
+            sysDeptAccountWithdraw.setAuditName(BaseController.getUser().getName());
+            BigDecimal  afterAmount = BigDecimal.ZERO;
+            //  add by  hxl  2024 -07-05  插入审核时间
+            sysDeptAccountWithdraw.setAuditingTime(new Date());
+            String auditingStatus="";
+            if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.PASS.getCode())) {
+                //sysDeptAccount.setManagementFee(sysDeptAccount.getManagementFee());
+                //sysDeptAccountService.updateById(sysDeptAccount);
+                //已到账金额 =  原先的到账金额+ 已到账的金额
+                sysDeptAccount.setSumAmountAccount((sysDeptAccount.getSumAmountAccount()==null? BigDecimal.ZERO:sysDeptAccount.getSumAmountAccount()).add(sysDeptAccountWithdraw.getAmount()));
+                //支付中的金额 = 原先的支付金额 -去提现的金额
+                sysDeptAccount.setSumAmountPayment((sysDeptAccount.getSumAmountPayment()==null?BigDecimal.ZERO:sysDeptAccount.getSumAmountPayment()).subtract(sysDeptAccountWithdraw.getAmount()));
+                auditingStatus="4";
+            }
+
+            if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.REJECT.getCode())) {
+                //驳回,将金额退回
+                //提现前的金额
+                BigDecimal beforeAmount = sysDeptAccount.getManagementFee()==null?BigDecimal.ZERO:sysDeptAccount.getManagementFee();
+                //提现后的金额
+                afterAmount = beforeAmount.add(sysDeptAccountWithdraw.getAmount());
+                sysDeptAccount.setManagementFee(afterAmount);
+                //提现的总金额 = 原先的提现总金额 - 提现的金额
+                sysDeptAccount.setSumAmountWithdrawal((sysDeptAccount.getSumAmountWithdrawal()==null?BigDecimal.ZERO:sysDeptAccount.getSumAmountWithdrawal().subtract(sysDeptAccountWithdraw.getAmount())));
+                //支付中的金额 = 原先的支付金额 -去提现的金额
+                sysDeptAccount.setSumAmountPayment((sysDeptAccount.getSumAmountPayment()==null?BigDecimal.ZERO:sysDeptAccount.getSumAmountPayment()).subtract(sysDeptAccountWithdraw.getAmount()));
+                auditingStatus="3";
+            }
+            sysDeptAccountWithdrawService.updateById(sysDeptAccountWithdraw);
+            //通过审核表id查询历史记录表
+            LambdaQueryWrapper<SysDeptAccountHistory> lqw = new LambdaQueryWrapper<>();
+            lqw.eq(SysDeptAccountHistory::getAuditingId, sysDeptAccountWithdraw.getId());
+            lqw.eq(SysDeptAccountHistory::getDeptId, sysDeptAccountWithdraw.getDeptId());
+            //插入轨迹表审核成功数据
+            SysDeptAccountHistory  sysDeptAccountHistory = sysDeptAccountHistoryService.getBaseMapper().selectOne(lqw);
+            //插入轨迹表
+            SysAmountAuditingDeptHistory sysAmountAuditingDeptHistory =new SysAmountAuditingDeptHistory(sysDeptAccountWithdraw.getId(), sysDeptAccountWithdraw.getAmount(), sysDeptAccountWithdraw.getDeptId(),new Date(),auditingStatus, "1",sysDeptAccountHistory.getId());
+            sysAmountAuditingDeptHistoryService.save(sysAmountAuditingDeptHistory);
+            //跟新账户金额
             sysDeptAccountService.updateById(sysDeptAccount);
+            //插入退款记录
+            if("3".equals(auditingStatus)){
+                //将收入支出状态台改为收入  2插入历史表中历史表
+                sysDeptAccountHistory.setId(null);
+                sysDeptAccountHistory.setDocumentary("2");
+                sysDeptAccountHistory.setProperty(5);
+                sysDeptAccountHistory.setBusinessSegmentsType(2);
+                sysDeptAccountHistory.setCreateTime(new Date());
+                sysDeptAccountHistory.setSurplusAmount(afterAmount);
+                sysDeptAccountHistoryService.getBaseMapper().insert(sysDeptAccountHistory);
+            }
+
+
+        }catch(Exception e){
+              throw new SystemException("提现错误");
         }
-        sysDeptAccountWithdraw.setVoucherId(sysDeptAccountWithdraw.getVoucherId());
-        sysDeptAccountWithdraw.setAuditUserid(BaseController.getUser().getId());
-        sysDeptAccountWithdraw.setAuditName(BaseController.getUser().getName());
-        sysDeptAccountWithdrawService.updateById(sysDeptAccountWithdraw);
         return HttpResult.ok("审核完成",sysDeptAccountWithdraw);
     }
 }