|
@@ -1,25 +1,30 @@
|
|
|
package com.ydtech.modules.admin.service.impl;
|
|
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.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.constants.sys.SysDeptAccountStatus;
|
|
import com.ydtech.constants.sys.SysDeptAccountStatus;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.core.page.PageRequest;
|
|
import com.ydtech.core.page.PageRequest;
|
|
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.dao.SysDeptAccountWithdrawMapper;
|
|
import com.ydtech.modules.admin.dao.SysDeptAccountWithdrawMapper;
|
|
|
import com.ydtech.modules.admin.model.SysDeptAccount;
|
|
import com.ydtech.modules.admin.model.SysDeptAccount;
|
|
|
import com.ydtech.modules.admin.model.SysDeptAccountHistory;
|
|
import com.ydtech.modules.admin.model.SysDeptAccountHistory;
|
|
|
import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
|
|
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.model.vo.SysDeptAccountWithdrawVo;
|
|
|
|
|
+import com.ydtech.modules.admin.service.SysAmountAuditingDeptHistoryService;
|
|
|
import com.ydtech.modules.admin.service.SysDeptAccountHistoryService;
|
|
import com.ydtech.modules.admin.service.SysDeptAccountHistoryService;
|
|
|
import com.ydtech.modules.admin.service.SysDeptAccountService;
|
|
import com.ydtech.modules.admin.service.SysDeptAccountService;
|
|
|
import com.ydtech.modules.admin.service.SysDeptAccountWithdrawService;
|
|
import com.ydtech.modules.admin.service.SysDeptAccountWithdrawService;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
|
-import com.ydtech.utils.idgen.IdGenerate;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -36,6 +41,13 @@ public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl<SysDeptAccoun
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SysDeptAccountHistoryService sysDeptAccountHistoryService;
|
|
private SysDeptAccountHistoryService sysDeptAccountHistoryService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysAmountAuditingDeptHistoryService sysAmountAuditingDeptHistoryService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<SysDeptAccountWithdraw> getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) {
|
|
public IPage<SysDeptAccountWithdraw> getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) {
|
|
|
PageRequest pageRequest = new PageRequest();
|
|
PageRequest pageRequest = new PageRequest();
|
|
@@ -47,35 +59,69 @@ public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl<SysDeptAccoun
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
public HttpResult updateByStatus(SysDeptAccountWithdraw sysDeptAccountWithdraw) {
|
|
public HttpResult updateByStatus(SysDeptAccountWithdraw sysDeptAccountWithdraw) {
|
|
|
- if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.PASS.getCode())) {
|
|
|
|
|
|
|
+ try{
|
|
|
|
|
+ //查询账户表金额
|
|
|
SysDeptAccount sysDeptAccount = sysDeptAccountService.getById(sysDeptAccountWithdraw.getDeptId());
|
|
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);
|
|
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);
|
|
return HttpResult.ok("审核完成",sysDeptAccountWithdraw);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|