| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | public R<UserAccountVo> getUserAccount() { |
| | | UserAccountVo userAccountVo = new UserAccountVo(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | |
| | | TbUser user = userService.getById(loginUser.getUserId()); |
| | | userAccountVo.setBalance(user.getBalance()); |
| | | |
| | |
| | | @GetMapping("/getUserAccountDetail") |
| | | public R<Page<TbAccountDetail>> getUserAccountDetail(UserAccountDetailQuery query) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | LambdaQueryWrapper<TbAccountDetail> wrapper = new LambdaQueryWrapper<>(); |
| | | if(StringUtils.isNotEmpty(query.getTime())){ |
| | | wrapper.likeRight(TbAccountDetail::getCreateTime,query.getTime()); |
| | |
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
| | | public R<?> withdrawal(@RequestBody @Valid UserWithdrawalDto dto) { |
| | | if(dto.getAmount()<=0){ |
| | | return R.fail("提现金额不能小于0"); |
| | | return R.fail("提现金额不能小于等于0"); |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | TbUser user = userService.getById(loginUser.getUserId()); |
| | | // 判断是否有卡 |
| | | List<TbBank> list = bankService.list(new LambdaQueryWrapper<TbBank>().eq(TbBank::getUserId, loginUser.getUserId()).eq(TbBank::getIsDelete, 0)); |
| | |
| | | @GetMapping("/getUserBank") |
| | | public R<TbBank> getUserBank() { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | TbBank tbBank = bankService.getOne(new LambdaQueryWrapper<TbBank>().eq(TbBank::getUserId, loginUser.getUserId()).eq(TbBank::getIsDelete, 0)); |
| | | return R.ok(tbBank); |
| | | } |
| | |
| | | @PostMapping("/saveUserBank") |
| | | public R<?> getUserBank(@Valid @RequestBody SaveUserBankDto dto) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | TbBank tbBank = bankService.getOne(new LambdaQueryWrapper<TbBank>().eq(TbBank::getUserId, loginUser.getUserId()).eq(TbBank::getIsDelete, 0)); |
| | | if(tbBank==null){ |
| | | tbBank = new TbBank(); |