|
@@ -1,17 +1,18 @@
|
|
|
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.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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.core.page.HttpResult;
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.modules.admin.dao.SysDeptAccountMapper;
|
|
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.dto.SysDeptAccountDto;
|
|
|
import com.ydtech.modules.admin.model.vo.SysDeptAccountByUserVo;
|
|
import com.ydtech.modules.admin.model.vo.SysDeptAccountByUserVo;
|
|
|
import com.ydtech.modules.admin.model.vo.SysDeptAccountVO;
|
|
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.base.controller.BaseController;
|
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
import com.ydtech.modules.protocol.utils.AssertionUtils;
|
|
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.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -28,9 +30,21 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SysDeptAccountService sysDeptAccountService;
|
|
private SysDeptAccountService sysDeptAccountService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysDeptAccountHistoryService sysDeptAccountHistoryService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SysDeptAccountMapper sysDeptAccountMapper;
|
|
private SysDeptAccountMapper sysDeptAccountMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysDeptAccountWithdrawService sysDeptAccountWithdrawService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysDeptService sysDeptService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserInfoService sysUserInfoService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public BasePageResult<SysDeptAccount> queryByVo(SysDeptAccountVO sysDeptAccountVO) {
|
|
public BasePageResult<SysDeptAccount> queryByVo(SysDeptAccountVO sysDeptAccountVO) {
|
|
|
|
|
|
|
@@ -57,16 +71,45 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
|
|
|
|
|
|
|
|
public HttpResult withdrawDeptAccount(SysDeptAccount sysDeptAccount) {
|
|
public HttpResult withdrawDeptAccount(SysDeptAccount sysDeptAccount) {
|
|
|
SysDeptAccount deptAccount = sysDeptAccountMapper.selectById(sysDeptAccount.getDeptId());
|
|
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 sysDeptAccountHistory = new SysDeptAccountHistory();
|
|
|
sysDeptAccountHistory.setId(IdGenerate.nextId());
|
|
sysDeptAccountHistory.setId(IdGenerate.nextId());
|
|
|
sysDeptAccountHistory.setDeptId(sysDeptAccount.getDeptId());
|
|
sysDeptAccountHistory.setDeptId(sysDeptAccount.getDeptId());
|
|
|
- sysDeptAccountHistory.setAmount(sysDeptAccount.getManagementFee());
|
|
|
|
|
|
|
+ sysDeptAccountHistory.setAmount(sysDeptAccount.getAmount());
|
|
|
sysDeptAccountHistory.setSurplusAmount(deptAccount.getManagementFee());
|
|
sysDeptAccountHistory.setSurplusAmount(deptAccount.getManagementFee());
|
|
|
sysDeptAccountHistory.setSuborder(null);
|
|
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);
|
|
return HttpResult.ok("", sysDeptAccount);
|
|
|
}
|
|
}
|