package com.ydtech.modules.admin.service.impl; 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.SysDeptAccountHistory; import com.ydtech.modules.admin.model.SysDeptAccountWithdraw; import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo; 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 java.util.Date; @Service public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl implements SysDeptAccountWithdrawService { @Autowired private SysDeptAccountWithdrawMapper sysDeptAccountWithdrawMapper; @Autowired private SysDeptAccountWithdrawService sysDeptAccountWithdrawService; @Autowired private SysDeptAccountService sysDeptAccountService; @Autowired private SysDeptAccountHistoryService sysDeptAccountHistoryService; @Override public IPage getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) { PageRequest pageRequest = new PageRequest(); pageRequest.setPageNum(sysDeptAccountWithdrawVo.getPageNo()); pageRequest.setPageSize(sysDeptAccountWithdrawVo.getPageSize()); Page page = PageRequest.buildPageRequest(pageRequest); Page iPage = sysDeptAccountWithdrawMapper.selectSysDeptAccountWithdraw(page,sysDeptAccountWithdrawVo); return iPage; } @Override public HttpResult updateByStatus(SysDeptAccountWithdraw sysDeptAccountWithdraw) { if (sysDeptAccountWithdraw.getStatus().equals(SysDeptAccountStatus.PASS.getCode())) { 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())); sysDeptAccountService.updateById(sysDeptAccount); } sysDeptAccountWithdraw.setAuditUserid(BaseController.getUser().getName()); sysDeptAccountWithdraw.setAuditName(BaseController.getUser().getId()); sysDeptAccountWithdrawService.updateById(sysDeptAccountWithdraw); return HttpResult.ok("审核完成",sysDeptAccountWithdraw); } }