| | |
| | | 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.ruoyi.admin.entity.Franchisee; |
| | | import com.ruoyi.admin.entity.FranchiseeWithdraw; |
| | | import com.ruoyi.admin.entity.RecoveryServe; |
| | | import com.ruoyi.admin.entity.TFranchiseeBalanceChange; |
| | | import com.ruoyi.admin.entity.*; |
| | | import com.ruoyi.admin.request.AuditFranchiseeWithdrawDTO; |
| | | import com.ruoyi.admin.request.FranchiseeWithdrawDTO; |
| | | import com.ruoyi.admin.service.FranchiseeService; |
| | | import com.ruoyi.admin.service.SysUserService; |
| | | import com.ruoyi.admin.service.TFranchiseeBalanceChangeService; |
| | | import com.ruoyi.admin.service.TFranchiseeWithdrawService; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | @Resource |
| | | private TFranchiseeWithdrawService franchiseeWithdrawService; |
| | | |
| | | |
| | | @Resource |
| | | private SysUserService sysUserService; |
| | | |
| | | @PostMapping("/applyWithdraw") |
| | | @ApiOperation(value = "APP-加盟商申请提现", tags = {"提现"}) |
| | |
| | | if (loginUser==null){ |
| | | return R.fail("登录失效"); |
| | | } |
| | | Franchisee franchisee = franchiseeService.getById(loginUser.getUserid()); |
| | | SysUser user = sysUserService.getById(loginUser.getUserid()); |
| | | |
| | | Franchisee franchisee = franchiseeService.getById(user.getFranchiseeId()); |
| | | if (franchisee.getBalance().subtract(dto.getMoney()).compareTo(BigDecimal.ZERO)>=0){ |
| | | BigDecimal subtract = franchisee.getBalance().subtract(dto.getMoney()); |
| | | franchisee.setBalance(subtract); |
| | | franchiseeService.updateById(franchisee); |
| | | }else{ |
| | | return R.fail("余额不足"); |
| | | } |
| | |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | SysUser user = sysUserService.getById(loginWorker.getUserid()); |
| | | IPage<FranchiseeWithdraw> franchiseeWithdrawList = franchiseeWithdrawService |
| | | .lambdaQuery().eq(FranchiseeWithdraw::getFranchiseeId, loginWorker.getUserid()) |
| | | .lambdaQuery().eq(FranchiseeWithdraw::getFranchiseeId, user.getFranchiseeId()) |
| | | .orderByDesc(FranchiseeWithdraw::getCreateTime) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(franchiseeWithdrawList); |
| | |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | SysUser byId = sysUserService.getById(loginWorker.getUserid()); |
| | | |
| | | LambdaQueryWrapper<FranchiseeWithdraw> franchiseeWithdrawLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | franchiseeWithdrawLambdaQueryWrapper.eq(FranchiseeWithdraw::getFranchiseeId, loginWorker.getUserid()) |
| | | franchiseeWithdrawLambdaQueryWrapper |
| | | .orderByDesc(FranchiseeWithdraw::getCreateTime); |
| | | if (StringUtils.hasLength(franchiseeWithdrawDTO.getFranchiseeName())){ |
| | | List<Integer> ids = franchiseeService.lambdaQuery().like(Franchisee::getName, franchiseeWithdrawDTO.getFranchiseeName()).list() |
| | |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | SysUser byId = sysUserService.getById(loginWorker.getUserid()); |
| | | FranchiseeWithdraw franchiseeWithdraw = franchiseeWithdrawService.getById(auditFranchiseeWithdrawDTO.getId()); |
| | | franchiseeWithdraw.setStatus(auditFranchiseeWithdrawDTO.getStatus()); |
| | | franchiseeWithdraw.setResult(auditFranchiseeWithdrawDTO.getResult()); |
| | | franchiseeWithdraw.setImg(auditFranchiseeWithdrawDTO.getImg()); |
| | | franchiseeWithdraw.setUpdateBy(byId.getNickName()); |
| | | franchiseeWithdraw.setHandle(byId.getNickName()); |
| | | franchiseeWithdraw.setUpdateTime(new Date()); |
| | | franchiseeWithdrawService.updateById(franchiseeWithdraw); |
| | | Franchisee franchisee = franchiseeService.getById(franchiseeWithdraw.getFranchiseeId()); |
| | | if (auditFranchiseeWithdrawDTO.getStatus()==3){ |
| | | // 回退运营商余额 |
| | | TFranchiseeBalanceChange balanceChange = new TFranchiseeBalanceChange(); |
| | | balanceChange.setAmount(franchiseeWithdraw.getMoney()); |
| | | balanceChange.setIs_pay(1); |
| | | balanceChange.setFranchiseeName(franchisee.getName()); |
| | | balanceChange.setFranchiseeId(franchisee.getId()+""); |
| | | balanceChange.setRemark("余额提现回退"); |
| | | balanceChange.setType(4); |
| | | balanceChange.setIsDelete(0); |
| | | franchiseeBalanceChangeService.save(balanceChange); |
| | | BigDecimal add = franchisee.getBalance().add(franchiseeWithdraw.getMoney()); |
| | | franchisee.setBalance(add); |
| | | franchiseeService.updateById(franchisee); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |