| | |
| | | package com.xinquan.user.controller.client; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.util.UUIDUtils; |
| | | import com.alibaba.nacos.common.utils.UuidUtils; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.datascope.annotation.DataScope; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.AppUserBank; |
| | | import com.xinquan.system.api.domain.AppUserWithdraw; |
| | | import com.xinquan.system.api.domain.vo.UpdateAppUserDTO; |
| | | import com.xinquan.system.api.domain.vo.WalletVO; |
| | | import com.xinquan.user.service.AppUserBankService; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import com.xinquan.user.service.AppUserWithdrawService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/client/app-user-withdraw") |
| | | public class ClientAppUserWithdrawController { |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private AppUserWithdrawService withdrawService; |
| | | @Resource |
| | | private AppUserBankService appUserBankService; |
| | | @PostMapping("/withdraw") |
| | | @ApiOperation(value = "提现", tags = {"钱包"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "bankId", value = "银行卡id", dataType = "Long", required = true), |
| | | @ApiImplicitParam(name = "money", value = "提现金额", dataType = "String", required = true) |
| | | }) |
| | | public R withdraw(Long bankId,String money) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | BigDecimal bigDecimal = new BigDecimal(money); |
| | | AppUserWithdraw appUserWithdraw = new AppUserWithdraw(); |
| | | appUserWithdraw.setAppUserId(userId); |
| | | appUserWithdraw.setBankId(bankId); |
| | | appUserWithdraw.setAmount(bigDecimal); |
| | | appUserWithdraw.setWithdrawType(1); |
| | | appUserWithdraw.setWithdrawStatus(0); |
| | | // todo 提现流水号 |
| | | appUserWithdraw.setSerialNo(UuidUtils.generateUuid()); |
| | | appUserWithdraw.setWithdrawTime(LocalDateTime.now()); |
| | | appUserWithdraw.setCreateTime(LocalDateTime.now()); |
| | | withdrawService.save(appUserWithdraw); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/addBank") |
| | | @ApiOperation(value = "提现-添加银行卡", tags = {"钱包"}) |
| | | public R wallet(@RequestBody AppUserBank appUserWithdraw) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | appUserWithdraw.setAppUserId(userId); |
| | | appUserBankService.save(appUserWithdraw); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/deleteBank") |
| | | @ApiOperation(value = "提现-删除银行卡", tags = {"钱包"}) |
| | | public R deleteBank(Long id) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | appUserBankService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | @PostMapping("/bankList") |
| | | @ApiOperation(value = "提现-获取银行卡列表", tags = {"钱包"}) |
| | | public R<List<AppUserBank>> bankList() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId==0)return R.tokenError("登录失效"); |
| | | List<AppUserBank> list = appUserBankService.lambdaQuery() |
| | | .eq(AppUserBank::getAppUserId, userId).list(); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | } |
| | | |