无关风月
2024-11-09 111652d23733d04e379c2454c8b39171596a6b50
xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWithdrawController.java
@@ -14,6 +14,7 @@
import com.xinquan.common.security.service.TokenService;
import com.xinquan.course.api.domain.Course;
import com.xinquan.order.api.domain.Order;
import com.xinquan.system.api.domain.AppUserWalletRecord;
import com.xinquan.user.api.domain.dto.OrderListDTO;
import com.xinquan.system.api.domain.AppUser;
import com.xinquan.system.api.domain.AppUserBank;
@@ -22,6 +23,7 @@
import com.xinquan.user.domain.export.WithdrawExport;
import com.xinquan.user.service.AppUserBankService;
import com.xinquan.user.service.AppUserService;
import com.xinquan.user.service.AppUserWalletRecordService;
import com.xinquan.user.service.AppUserWithdrawService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -63,9 +65,11 @@
    private AppUserBankService appUserBankService;
    @Autowired
    private TokenService tokenService;
    @Resource
    private AppUserWalletRecordService appUserWalletRecordService;
    @PostMapping("/withdrawList")
    @ApiOperation(value = "提现列表-分页", tags = {"管理后台=提现管理"})
    @ApiOperation(value = "提现列表-分页", tags = {"管理后台-提现管理"})
    public R<PageDTO<AppUserWithdraw>> withdrawList(@RequestBody OrderListDTO courseDTO) {
        LambdaQueryWrapper<AppUserWithdraw> wrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasLength(courseDTO.getBuyContent())){
@@ -75,6 +79,10 @@
            List<Long> collect = appUserService.lambdaQuery().like(AppUser::getCellPhone, courseDTO.getUserNameOrPhone())
                    .list().stream().map(AppUser::getId)
                    .collect(Collectors.toList());
            List<Long> collect1 = appUserService.lambdaQuery().like(AppUser::getNickname, courseDTO.getUserNameOrPhone())
                    .list().stream().map(AppUser::getId)
                    .collect(Collectors.toList());
            collect.addAll(collect1);
            if (collect.isEmpty())collect.add(-1L);
            wrapper.in(AppUserWithdraw::getAppUserId,collect);
        }
@@ -90,8 +98,8 @@
            String startTime =null;
            String endTime =null;
            String[] split = courseDTO.getTime().split(" - ");
            startTime = split[0]+"00:00:00";
            endTime = split[1]+"23:59:59";
            startTime = split[0]+" 00:00:00";
            endTime = split[1]+" 23:59:59";
            wrapper.between(AppUserWithdraw::getWithdrawTime,startTime,endTime);
        }
        Page<AppUserWithdraw> list = withdrawService.page(new Page<>(courseDTO.getPageCurr(), courseDTO.getPageSize()), wrapper);
@@ -249,6 +257,12 @@
            return R.tokenError("登录失效");
        }
        Long userId = loginUser.getUserid();
        AppUser byId = appUserService.getById(userId);
        if (byId.getBalance().compareTo(new BigDecimal(money))<0){
            return R.fail("提现金额不能超过钱包余额");
        }
        byId.setBalance(byId.getBalance().subtract(new BigDecimal(money)));
        appUserService.updateById(byId);
        BigDecimal bigDecimal = new BigDecimal(money);
        AppUserWithdraw appUserWithdraw = new AppUserWithdraw();
        appUserWithdraw.setAppUserId(userId);
@@ -262,6 +276,15 @@
        appUserWithdraw.setWithdrawTime(LocalDateTime.now());
        appUserWithdraw.setCreateTime(LocalDateTime.now());
        withdrawService.save(appUserWithdraw);
        // 先扣去余额
        AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord();
        appUserWalletRecord.setAppUserId(userId);
        appUserWalletRecord.setChangeType(2);
        appUserWalletRecord.setReason("提现");
        appUserWalletRecord.setOrderId(appUserWithdraw.getId());
        appUserWalletRecord.setAmount(new BigDecimal(money));
        appUserWalletRecordService.save(appUserWalletRecord);
        return R.ok();
    }
    @PostMapping("/addBank")