Jelajahi Sumber

机构账户提现审核操作

Qchen 2 tahun lalu
induk
melakukan
7d673775fd

+ 26 - 0
src/main/java/com/ydtech/constants/sys/SysDeptAccountStatus.java

@@ -0,0 +1,26 @@
+package com.ydtech.constants.sys;
+
+import com.ydtech.aop.request.DictEnum;
+import com.ydtech.constants.enums.dict.IBaseEnum;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+@DictEnum(key = "sysDeptAccountStatus", desc = "机构账户提现审核状态")
+public enum SysDeptAccountStatus implements IBaseEnum {
+    WAIT("0","待审核",0,1),
+
+    PASS("1","审核通过",0,1),
+
+    REJECT("2","审核驳回",0,1);
+
+    // 编号
+    private final String code;
+    //说明
+    private final String desc;
+    // 排序
+    private final Integer sort;
+    // 状态  0 启用  1 不启用
+    private final Integer status;
+}

+ 38 - 0
src/main/java/com/ydtech/modules/admin/controller/SysDeptAccountWithdrawController.java

@@ -0,0 +1,38 @@
+package com.ydtech.modules.admin.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo;
+import com.ydtech.modules.admin.service.SysDeptAccountWithdrawService;
+import com.ydtech.modules.base.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "机构账户审核")
+@RequestMapping("/sysDeptAccountWithdraw")
+@RestController
+public class SysDeptAccountWithdrawController extends BaseController {
+    @Autowired
+    private SysDeptAccountWithdrawService sysDeptAccountWithdrawService;
+
+    @PostMapping("/queryStatus")
+    @ApiOperation(value = "机构账户审核状态查询")
+    public HttpResult queryStatus(@RequestBody SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo){
+        IPage<SysDeptAccountWithdraw> getAnnualAuditOrderPage = sysDeptAccountWithdrawService.getList(sysDeptAccountWithdrawVo);
+        PageResult pageResult = buildPageResponse(getAnnualAuditOrderPage);
+        return HttpResult.ok(pageResult);
+    }
+
+    @PostMapping("/audit")
+    @ApiOperation(value = "机构账户审核")
+    public HttpResult audit(@RequestBody SysDeptAccountWithdraw sysDeptAccountWithdraw){
+        return HttpResult.ok(sysDeptAccountWithdrawService.updateByStatus(sysDeptAccountWithdraw));
+    }
+}

+ 11 - 0
src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountWithdrawMapper.java

@@ -0,0 +1,11 @@
+package com.ydtech.modules.admin.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
+import org.apache.ibatis.annotations.Mapper;
+
+
+
+@Mapper
+public interface SysDeptAccountWithdrawMapper extends BaseMapper<SysDeptAccountWithdraw> {
+}

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

@@ -106,25 +106,25 @@ public class SysDept implements Serializable {
     @ApiModelProperty(value = "子公司C,门店M,部门D")
     private String deptType;
 
-    @TableField(value = "management_fee")
-    @ApiModelProperty(value = "管理费比例%")
-    private double managementFee;
-
-    @TableField(value = "management_fee_second")
-    @ApiModelProperty(value = "二级机构管理费比例%")
-    private double managementFeeSecond;
-
-    @TableField(value = "management_fee_third")
-    @ApiModelProperty(value = "三级机构管理费比例%")
-    private double managementFeeThird;
-
-    @TableField(value = "management_fee_forth")
-    @ApiModelProperty(value = "四级机构管理费比例%")
-    private double managementFeeForth;
-
-    @TableField(value = "management_fee_fifth")
-    @ApiModelProperty(value = "五级机构管理费比例%")
-    private double managementFeeFifth;
+//    @TableField(value = "management_fee")
+//    @ApiModelProperty(value = "管理费比例%")
+//    private double managementFee;
+//
+//    @TableField(value = "management_fee_second")
+//    @ApiModelProperty(value = "二级机构管理费比例%")
+//    private double managementFeeSecond;
+//
+//    @TableField(value = "management_fee_third")
+//    @ApiModelProperty(value = "三级机构管理费比例%")
+//    private double managementFeeThird;
+//
+//    @TableField(value = "management_fee_forth")
+//    @ApiModelProperty(value = "四级机构管理费比例%")
+//    private double managementFeeForth;
+//
+//    @TableField(value = "management_fee_fifth")
+//    @ApiModelProperty(value = "五级机构管理费比例%")
+//    private double managementFeeFifth;
 
     @TableField(value = "management_source")
     @ApiModelProperty(value = "机构来源(渠道、个代)")

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -18,13 +19,22 @@ public class SysDeptAccount implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @TableId(value = "dept_id")
+    @ApiModelProperty(value = "机构Id")
     private String deptId;
 
+    @ApiModelProperty(value = "机构费用")
     @TableField(value = "management_fee")
     private BigDecimal managementFee;
 
+    @ApiModelProperty(value = "创建时间")
     @TableField(value = "create_time")
     private Date createTime;
 
+    @ApiModelProperty(value = "提现金额")
+    @TableField(exist = false)
+    private BigDecimal amount;
+
+
+
 
 }

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

@@ -0,0 +1,46 @@
+package com.ydtech.modules.admin.model;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+@Data
+@TableName(value = "sys_dept_account_withdraw")
+@ApiModel(value = "机构账户审核表")
+public class SysDeptAccountWithdraw implements Serializable {
+    @TableId(value = "id")
+    @ApiModelProperty(value = "主键id")
+    private String id;
+
+    @TableField(value = "dept_id")
+    @ApiModelProperty(value = "机构id")
+    private String deptId;
+
+    @TableField(value = "name")
+    @ApiModelProperty(value = "机构名称")
+    private String name;
+
+    @TableField(value = "amount")
+    @ApiModelProperty(value = "提现金额")
+    private BigDecimal amount;
+
+    @TableField(value = "status")
+    @ApiModelProperty(value = "提现状态")
+    private String status;
+
+    @TableField(value = "remark")
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @TableField(value = "create_time")
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+}

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

@@ -0,0 +1,50 @@
+package com.ydtech.modules.admin.model.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ydtech.core.page.PageRequest;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class SysDeptAccountWithdrawVo extends PageRequest implements Serializable {
+    @TableId(value = "id")
+    @ApiModelProperty(value = "主键id")
+    private String id;
+
+    @TableField(value = "dept_id")
+    @ApiModelProperty(value = "机构id")
+    private String deptId;
+
+    @TableField(value = "name")
+    @ApiModelProperty(value = "机构名称")
+    private String name;
+
+    @TableField(value = "amount")
+    @ApiModelProperty(value = "提现金额")
+    private BigDecimal amount;
+
+    @TableField(value = "status")
+    @ApiModelProperty(value = "提现状态")
+    private String status;
+
+    @TableField(value = "remark")
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @TableField(value = "create_time")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    @ApiModelProperty(value = "创建时间开始时间")
+    private Date createTimeStart;
+
+
+    @ApiModelProperty(value = "创建时间结束时间")
+    private Date createTimeEnd;
+
+}

+ 13 - 0
src/main/java/com/ydtech/modules/admin/service/SysDeptAccountWithdrawService.java

@@ -0,0 +1,13 @@
+package com.ydtech.modules.admin.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo;
+
+public interface SysDeptAccountWithdrawService extends IService<SysDeptAccountWithdraw> {
+    IPage<SysDeptAccountWithdraw> getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo);
+
+    HttpResult updateByStatus(SysDeptAccountWithdraw sysDeptAccountWithdraw);
+}

+ 49 - 6
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountServiceImpl.java

@@ -1,17 +1,18 @@
 package com.ydtech.modules.admin.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.modules.admin.dao.SysDeptAccountMapper;
-import com.ydtech.modules.admin.model.SysDeptAccount;
-import com.ydtech.modules.admin.model.SysDeptAccountHistory;
+import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.dto.SysDeptAccountDto;
 import com.ydtech.modules.admin.model.vo.SysDeptAccountByUserVo;
 import com.ydtech.modules.admin.model.vo.SysDeptAccountVO;
-import com.ydtech.modules.admin.service.SysDeptAccountService;
+import com.ydtech.modules.admin.service.*;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -28,9 +30,21 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
     @Autowired
     private SysDeptAccountService sysDeptAccountService;
 
+    @Autowired
+    private SysDeptAccountHistoryService sysDeptAccountHistoryService;
+
     @Autowired
     private SysDeptAccountMapper sysDeptAccountMapper;
 
+    @Autowired
+    private SysDeptAccountWithdrawService sysDeptAccountWithdrawService;
+
+    @Autowired
+    private SysDeptService sysDeptService;
+
+    @Autowired
+    private SysUserInfoService sysUserInfoService;
+
     @Override
     public BasePageResult<SysDeptAccount> queryByVo(SysDeptAccountVO sysDeptAccountVO) {
 
@@ -57,16 +71,45 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
 
     public HttpResult withdrawDeptAccount(SysDeptAccount sysDeptAccount) {
         SysDeptAccount deptAccount = sysDeptAccountMapper.selectById(sysDeptAccount.getDeptId());
+        //根据deptId查询提现人员相关信息
+        LambdaQueryWrapper<SysDept> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SysDept::getId, sysDeptAccount.getDeptId());
+        SysDept sysDept = sysDeptService.getOne(queryWrapper);
+
+        if (!BaseController.getUser().getId().equals(sysDept.getWithdrawUser())) {
+            return HttpResult.error("您不为该机构账户提现人员");
+        }
+        if (sysDeptAccount.getAmount().compareTo(deptAccount.getManagementFee()) > 0) {
+            return HttpResult.error("提现金额大于机构账户金额");
+        }
         // 减去提现金额
-        deptAccount.setManagementFee(deptAccount.getManagementFee().subtract(sysDeptAccount.getManagementFee()));
-        sysDeptAccountService.updateById(sysDeptAccount);
+        deptAccount.setManagementFee(deptAccount.getManagementFee().subtract(sysDeptAccount.getAmount()));
+        sysDeptAccountService.updateById(deptAccount);
         // 机构历史明细生成提现明细
         SysDeptAccountHistory sysDeptAccountHistory = new SysDeptAccountHistory();
         sysDeptAccountHistory.setId(IdGenerate.nextId());
         sysDeptAccountHistory.setDeptId(sysDeptAccount.getDeptId());
-        sysDeptAccountHistory.setAmount(sysDeptAccount.getManagementFee());
+        sysDeptAccountHistory.setAmount(sysDeptAccount.getAmount());
         sysDeptAccountHistory.setSurplusAmount(deptAccount.getManagementFee());
         sysDeptAccountHistory.setSuborder(null);
+        sysDeptAccountHistory.setDocumentary("1"); //提现
+        sysDeptAccountHistory.setFromBankCard(null);
+        sysDeptAccountHistory.setToBankCard(null);
+        sysDeptAccountHistory.setUserId(BaseController.getUser().getId());
+        sysDeptAccountHistory.setCreateTime(new Date());
+        sysDeptAccountHistory.setRemark("从" + sysDept.getName() + "机构账户中提现" + sysDeptAccountHistory.getAmount() + "元");
+        sysDeptAccountHistoryService.save(sysDeptAccountHistory);
+
+        // 生成提现审核数据
+        SysDeptAccountWithdraw sysDeptAccountWithdraw = new SysDeptAccountWithdraw();
+        sysDeptAccountWithdraw.setId(IdGenerate.nextId());
+        sysDeptAccountWithdraw.setDeptId(deptAccount.getDeptId());
+        sysDeptAccountWithdraw.setName(sysDept.getName());
+        sysDeptAccountWithdraw.setAmount(sysDeptAccount.getAmount());
+        sysDeptAccountWithdraw.setStatus(SysDeptAccountStatus.WAIT.getCode()); //待审核
+        sysDeptAccountWithdraw.setRemark("");
+        sysDeptAccountWithdraw.setCreateTime(new Date());
+        sysDeptAccountWithdrawService.save(sysDeptAccountWithdraw);
 
         return HttpResult.ok("", sysDeptAccount);
     }

+ 68 - 0
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountWithdrawServiceImpl.java

@@ -0,0 +1,68 @@
+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.modules.admin.dao.SysDeptAccountWithdrawMapper;
+import com.ydtech.modules.admin.model.SysDeptAccount;
+import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo;
+import com.ydtech.modules.admin.service.SysDeptAccountService;
+import com.ydtech.modules.admin.service.SysDeptAccountWithdrawService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl<SysDeptAccountWithdrawMapper, SysDeptAccountWithdraw> implements SysDeptAccountWithdrawService {
+
+    @Autowired
+    private SysDeptAccountWithdrawMapper sysDeptAccountWithdrawMapper;
+
+    @Autowired
+    private SysDeptAccountWithdrawService sysDeptAccountWithdrawService;
+    @Autowired
+    private SysDeptAccountService sysDeptAccountService;
+
+    @Override
+    public IPage<SysDeptAccountWithdraw> getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) {
+        PageRequest pageRequest = new PageRequest();
+        pageRequest.setPageNum(sysDeptAccountWithdrawVo.getPageNum());
+        pageRequest.setPageSize(sysDeptAccountWithdrawVo.getPageSize());
+        Page page = PageRequest.buildPageRequest(pageRequest);
+        LambdaQueryWrapper<SysDeptAccountWithdraw> queryWrapper = new LambdaQueryWrapper<>();
+        //审核状态
+        if (sysDeptAccountWithdrawVo.getStatus() != null && !"".equals(sysDeptAccountWithdrawVo.getStatus())) {
+            queryWrapper.eq(SysDeptAccountWithdraw::getStatus, sysDeptAccountWithdrawVo.getStatus());
+        }
+        //创建时间区间
+        if (sysDeptAccountWithdrawVo.getCreateTimeStart() != null && !"".equals(sysDeptAccountWithdrawVo.getCreateTimeStart())) {
+            queryWrapper.ge(SysDeptAccountWithdraw::getCreateTime, sysDeptAccountWithdrawVo.getCreateTimeStart());
+        }
+        if (sysDeptAccountWithdrawVo.getCreateTimeEnd() != null && !"".equals(sysDeptAccountWithdrawVo.getCreateTimeEnd())) {
+            queryWrapper.le(SysDeptAccountWithdraw::getCreateTime, sysDeptAccountWithdrawVo.getCreateTimeEnd());
+        }
+        Page pageData = sysDeptAccountWithdrawMapper.selectPage(page, queryWrapper);
+        return pageData;
+    }
+
+    @Override
+    public HttpResult updateByStatus(SysDeptAccountWithdraw sysDeptAccountWithdraw) {
+        if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.PASS.getCode())) {
+            SysDeptAccount sysDeptAccount = sysDeptAccountService.getById(sysDeptAccountWithdraw.getDeptId());
+            sysDeptAccount.setManagementFee(sysDeptAccount.getManagementFee().subtract(sysDeptAccountWithdraw.getAmount()));
+            sysDeptAccountService.updateById(sysDeptAccount);
+        }
+        if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.REJECT.getCode())) {
+            SysDeptAccount sysDeptAccount = sysDeptAccountService.getById(sysDeptAccountWithdraw.getDeptId());
+            sysDeptAccount.setManagementFee(sysDeptAccount.getManagementFee().add(sysDeptAccountWithdraw.getAmount()));
+            sysDeptAccountService.updateById(sysDeptAccount);
+        }
+        sysDeptAccountWithdrawService.updateById(sysDeptAccountWithdraw);
+        return HttpResult.ok("审核完成",sysDeptAccountWithdraw);
+    }
+}

+ 4 - 0
src/main/resources/mapper/modules/admin/SysDeptAccountWithdrawMapper.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ydtech.modules.admin.dao.SysDeptAccountWithdrawMapper">
+</mapper>