init
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package com.ruoyi.cai.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.CaiGoods;
|
||||
import com.ruoyi.cai.service.CaiGoodsService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 充值配置
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cai/goods")
|
||||
public class CaiGoodsController extends BaseController {
|
||||
|
||||
private final CaiGoodsService caiGoodsService;
|
||||
|
||||
/**
|
||||
* 查询充值配置列表
|
||||
*/
|
||||
@SaCheckPermission("cai:goods:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<CaiGoods> list(CaiGoods bo, PageQuery pageQuery) {
|
||||
Page<CaiGoods> page = caiGoodsService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充值配置详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("cai:goods:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<CaiGoods> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(caiGoodsService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增充值配置
|
||||
*/
|
||||
@SaCheckPermission("cai:goods:add")
|
||||
@Log(title = "充值配置", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody CaiGoods bo) {
|
||||
return toAjax(caiGoodsService.save(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改充值配置
|
||||
*/
|
||||
@SaCheckPermission("cai:goods:edit")
|
||||
@Log(title = "充值配置", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody CaiGoods bo) {
|
||||
return toAjax(caiGoodsService.updateById(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除充值配置
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cai:goods:remove")
|
||||
@Log(title = "充值配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(caiGoodsService.removeBatchByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ruoyi.cai.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.CaiWithdrawExchange;
|
||||
import com.ruoyi.cai.service.CaiWithdrawExchangeService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 提现 - 兑换配置
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cai/withdrawExchange")
|
||||
public class CaiWithdrawExchangeController extends BaseController {
|
||||
|
||||
private final CaiWithdrawExchangeService caiWithdrawExchangeService;
|
||||
|
||||
/**
|
||||
* 查询提现 - 兑换配置列表
|
||||
*/
|
||||
@SaCheckPermission("cai:withdrawExchange:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<CaiWithdrawExchange> list(CaiWithdrawExchange bo, PageQuery pageQuery) {
|
||||
Page<CaiWithdrawExchange> page = caiWithdrawExchangeService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现 - 兑换配置详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("cai:withdrawExchange:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<CaiWithdrawExchange> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(caiWithdrawExchangeService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增提现 - 兑换配置
|
||||
*/
|
||||
@SaCheckPermission("cai:withdrawExchange:add")
|
||||
@Log(title = "提现 - 兑换配置", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody CaiWithdrawExchange bo) {
|
||||
return toAjax(caiWithdrawExchangeService.save(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改提现 - 兑换配置
|
||||
*/
|
||||
@SaCheckPermission("cai:withdrawExchange:edit")
|
||||
@Log(title = "提现 - 兑换配置", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody CaiWithdrawExchange bo) {
|
||||
return toAjax(caiWithdrawExchangeService.updateById(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除提现 - 兑换配置
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cai:withdrawExchange:remove")
|
||||
@Log(title = "提现 - 兑换配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(caiWithdrawExchangeService.removeBatchByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
package com.ruoyi.cai.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.CaiAccountBankcard;
|
||||
import com.ruoyi.cai.domain.CaiAccountCash;
|
||||
import com.ruoyi.cai.domain.CaiAccountRecharge;
|
||||
import com.ruoyi.cai.dto.app.query.*;
|
||||
import com.ruoyi.cai.dto.app.vo.*;
|
||||
import com.ruoyi.cai.manager.CurrentUserManager;
|
||||
import com.ruoyi.cai.service.CaiAccountBankcardService;
|
||||
import com.ruoyi.cai.service.CaiAccountCashService;
|
||||
import com.ruoyi.cai.service.CaiAccountRechargeService;
|
||||
import com.ruoyi.cai.service.CaiUserAlbumService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -20,7 +30,31 @@ public class CaiCurrentUserAppController {
|
||||
@Autowired
|
||||
private CurrentUserManager currentUserManager;
|
||||
@Autowired
|
||||
private CaiAccountRechargeService caiAccountRechargeService;
|
||||
@Autowired
|
||||
private CaiAccountCashService accountCashService;
|
||||
@Autowired
|
||||
private CaiUserAlbumService userAlbumService;
|
||||
|
||||
@GetMapping("/user/aliInfo")
|
||||
public R<CaiAccountBankcard> aliInfo(){
|
||||
CaiAccountBankcard accountBankcard = currentUserManager.aliInfo();
|
||||
return R.ok(accountBankcard);
|
||||
}
|
||||
|
||||
@PostMapping("/user/save-or-update/ali")
|
||||
public R<Boolean> updateAli(AccountAliBankCardRes res){
|
||||
currentUserManager.saveOrUpdateAliInfo(res);
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@PostMapping("/user/withdraw/ali")
|
||||
public R<Boolean> withdraw(WithdrawRes res){
|
||||
res.setUserId(LoginHelper.getUserId());
|
||||
accountCashService.withdraw(res);
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@GetMapping("/user/info")
|
||||
public R<CurrentUserInfoVo> currentInfo(){
|
||||
return R.ok(currentUserManager.currentInfo());
|
||||
@@ -61,4 +95,22 @@ public class CaiCurrentUserAppController {
|
||||
public R<Boolean> userAlbumAdd(List<AlbumResetRes> res){
|
||||
return R.ok(userAlbumService.resetAlbum(res,LoginHelper.getUserId()));
|
||||
}
|
||||
|
||||
@GetMapping("/user/recharge/log")
|
||||
public TableDataInfo<AccountRechargeVo> rechargeLog(PageQuery query){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Page<CaiAccountRecharge> page = caiAccountRechargeService.page(query.build(), Wrappers.lambdaQuery(CaiAccountRecharge.class)
|
||||
.eq(CaiAccountRecharge::getUserId, userId)
|
||||
.orderByDesc(CaiAccountRecharge::getCreateTime));
|
||||
return TableDataInfo.build(page,AccountRechargeVo::new);
|
||||
}
|
||||
|
||||
@GetMapping("/user/cash/log")
|
||||
public TableDataInfo<AccountCashVo> cashLog(PageQuery query){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Page<CaiAccountCash> page = accountCashService.page(query.build(), Wrappers.lambdaQuery(CaiAccountCash.class)
|
||||
.eq(CaiAccountCash::getUserId, userId)
|
||||
.orderByDesc(CaiAccountCash::getCreateTime));
|
||||
return TableDataInfo.build(page,AccountCashVo::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.cai.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cai.domain.CaiGoods;
|
||||
import com.ruoyi.cai.domain.CaiWithdrawExchange;
|
||||
import com.ruoyi.cai.service.CaiGoodsService;
|
||||
import com.ruoyi.cai.service.CaiWithdrawExchangeService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/setting")
|
||||
public class CaiSettingAppController {
|
||||
|
||||
@Autowired
|
||||
private CaiGoodsService goodsService;
|
||||
@Autowired
|
||||
private CaiWithdrawExchangeService withdrawExchangeService;
|
||||
|
||||
@GetMapping("/goods")
|
||||
public R<List<CaiGoods>> goods(){
|
||||
List<CaiGoods> list = goodsService.list(Wrappers.lambdaQuery(CaiGoods.class)
|
||||
.eq(CaiGoods::getStatus,0)
|
||||
.orderByAsc(CaiGoods::getPrice));
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("/withdraw")
|
||||
public R<List<CaiWithdrawExchange>> withdraw(){
|
||||
List<CaiWithdrawExchange> list = withdrawExchangeService.list(Wrappers.lambdaQuery(CaiWithdrawExchange.class)
|
||||
.orderByAsc(CaiWithdrawExchange::getMoney));
|
||||
return R.ok(list);
|
||||
}
|
||||
}
|
||||
@@ -58,13 +58,9 @@ public class CaiAccountCash implements Serializable {
|
||||
*/
|
||||
private String cardAccount;
|
||||
/**
|
||||
* 0 删除 1 申请 2 审核通过 3 审核不通过 4 提现取消
|
||||
* 1 申请 2 审核通过 3 审核不通过 4 提现取消
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 实际到账金额(扣除了多付金额后的)
|
||||
*/
|
||||
private BigDecimal payMoney;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -77,22 +73,10 @@ public class CaiAccountCash implements Serializable {
|
||||
*
|
||||
*/
|
||||
private String verifyRemark;
|
||||
/**
|
||||
* 是否支付宝失败
|
||||
*/
|
||||
private Integer isFail;
|
||||
/**
|
||||
* 是否及时到账,0否 1是
|
||||
*/
|
||||
private Integer isImmediately;
|
||||
/**
|
||||
* 是否已打款,0否 1是
|
||||
*/
|
||||
private Integer isPay;
|
||||
/**
|
||||
* 付款时间,只有立即打款才有
|
||||
*/
|
||||
private LocalDateTime payTime;
|
||||
/**
|
||||
* 是否已导出
|
||||
*/
|
||||
|
||||
@@ -41,10 +41,6 @@ public class CaiAccountRecharge implements Serializable {
|
||||
* 订单名
|
||||
*/
|
||||
private String orderName;
|
||||
/**
|
||||
* 账户 1 金额 2 彩币
|
||||
*/
|
||||
private Integer accountType;
|
||||
/**
|
||||
* 充值类型 0 手工充值 1 线上充值
|
||||
*/
|
||||
@@ -53,6 +49,10 @@ public class CaiAccountRecharge implements Serializable {
|
||||
* 充值金额
|
||||
*/
|
||||
private BigDecimal rechargeMoney;
|
||||
/**
|
||||
* 充值的紫贝
|
||||
*/
|
||||
private Integer coinNum;
|
||||
/**
|
||||
* 状态 1 申请 2 审核通过 3,审核不通过
|
||||
*/
|
||||
|
||||
48
ruoyi-cai/src/main/java/com/ruoyi/cai/domain/CaiGoods.java
Normal file
48
ruoyi-cai/src/main/java/com/ruoyi/cai/domain/CaiGoods.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.ruoyi.cai.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 充值配置对象 cai_goods
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
@Data
|
||||
@TableName("cai_goods")
|
||||
public class CaiGoods implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long amount;
|
||||
/**
|
||||
* 状态 0 可用 1不可用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.cai.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 提现 - 兑换配置对象 cai_withdraw_exchange
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
@Data
|
||||
@TableName("cai_withdraw_exchange")
|
||||
public class CaiWithdrawExchange implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* 兑换金额
|
||||
*/
|
||||
private Integer money;
|
||||
/**
|
||||
* 所需货币数量
|
||||
*/
|
||||
private Integer coinNum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.cai.dto.app.query;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AccountAliBankCardRes {
|
||||
private Integer id;
|
||||
/**
|
||||
* 持卡人姓名
|
||||
*/
|
||||
private String cardName;
|
||||
/**
|
||||
* 卡号
|
||||
*/
|
||||
private String cardAccount;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.cai.dto.app.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WithdrawRes {
|
||||
|
||||
/**
|
||||
* 提现配置ID
|
||||
*/
|
||||
private Long withdrawSettingId;
|
||||
/**
|
||||
* 兑换金额
|
||||
*/
|
||||
private Long money;
|
||||
/**
|
||||
* 所需货币数量
|
||||
*/
|
||||
private Long coinNum;
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.cai.dto.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AccountCashVo {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 提现金额
|
||||
*/
|
||||
private BigDecimal cashMoney;
|
||||
/**
|
||||
* 真实提现金额
|
||||
*/
|
||||
private BigDecimal realCashMoney;
|
||||
/**
|
||||
* 提现手续费
|
||||
*/
|
||||
private BigDecimal cashFees;
|
||||
/**
|
||||
* 银行名称
|
||||
*/
|
||||
private String bank;
|
||||
/**
|
||||
* 账户名称
|
||||
*/
|
||||
private String cardName;
|
||||
/**
|
||||
* 账户
|
||||
*/
|
||||
private String cardAccount;
|
||||
/**
|
||||
* 1 申请 2 审核通过 3 审核不通过 4 提现取消
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private LocalDateTime verifyTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String verifyRemark;
|
||||
|
||||
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.cai.dto.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AccountRechargeVo {
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long goodsId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单名
|
||||
*/
|
||||
private String orderName;
|
||||
/**
|
||||
* 充值类型 0 手工充值 1 线上充值
|
||||
*/
|
||||
private Integer rechargeType;
|
||||
/**
|
||||
* 充值金额
|
||||
*/
|
||||
private BigDecimal rechargeMoney;
|
||||
/**
|
||||
* 充值的紫贝
|
||||
*/
|
||||
private Integer coinNum;
|
||||
/**
|
||||
* 充值平台类型
|
||||
*/
|
||||
private Long platformType;
|
||||
/**
|
||||
* 充值平台名称
|
||||
*/
|
||||
private String platformName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String payNo;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String operateIp;
|
||||
/**
|
||||
* 类型: 0积分(默认),1会员
|
||||
*/
|
||||
private Integer type;
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.cai.manager;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cai.domain.*;
|
||||
import com.ruoyi.cai.dto.app.query.AccountAliBankCardRes;
|
||||
import com.ruoyi.cai.dto.app.query.AnchorUpdateRes;
|
||||
import com.ruoyi.cai.dto.app.query.UserUpdateRes;
|
||||
import com.ruoyi.cai.dto.app.vo.*;
|
||||
@@ -27,6 +28,8 @@ public class CurrentUserManager {
|
||||
private CaiUserAlbumService userAlbumService;
|
||||
@Autowired
|
||||
private CaiAccountService accountService;
|
||||
@Autowired
|
||||
private CaiAccountBankcardService accountBankcardService;
|
||||
|
||||
public CurrentUserInfoVo currentInfo() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
@@ -100,4 +103,24 @@ public class CurrentUserManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public CaiAccountBankcard aliInfo() {
|
||||
CaiAccountBankcard one = accountBankcardService.getOne(Wrappers.lambdaQuery(CaiAccountBankcard.class)
|
||||
.eq(CaiAccountBankcard::getUserId, LoginHelper.getUserId())
|
||||
.last("limit 1"));
|
||||
return one;
|
||||
}
|
||||
|
||||
public void saveOrUpdateAliInfo(AccountAliBankCardRes res) {
|
||||
CaiAccountBankcard bankcard = new CaiAccountBankcard();
|
||||
bankcard.setId(res.getId());
|
||||
if(bankcard.getId() == null){
|
||||
bankcard.setType(1);
|
||||
bankcard.setBankCode("alipay");
|
||||
bankcard.setBank("支付宝");
|
||||
}
|
||||
bankcard.setCardName(res.getCardName());
|
||||
bankcard.setCardAccount(res.getCardAccount());
|
||||
accountBankcardService.saveOrUpdate(bankcard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,10 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface CaiAccountMapper extends BaseMapper<CaiAccount> {
|
||||
|
||||
boolean incs(@Param("userId") Long userId, @Param("value") Long value);
|
||||
long incs(@Param("userId") Long userId, @Param("value") Long value);
|
||||
|
||||
void incsCoin(@Param("userId") Long userId, @Param("coin") Long coin, @Param("incomeCoin") Long incomeCoin);
|
||||
|
||||
|
||||
long decrIncomeCoin(@Param("userId") Long userId, @Param("incomeCoin") Long incomeCoin);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cai.domain.CaiGoods;
|
||||
|
||||
/**
|
||||
* 充值配置Mapper接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
public interface CaiGoodsMapper extends BaseMapper<CaiGoods> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cai.domain.CaiWithdrawExchange;
|
||||
|
||||
/**
|
||||
* 提现 - 兑换配置Mapper接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
public interface CaiWithdrawExchangeMapper extends BaseMapper<CaiWithdrawExchange> {
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.CaiAccountCash;
|
||||
import com.ruoyi.cai.dto.app.query.WithdrawRes;
|
||||
|
||||
/**
|
||||
* 用户提现记录Service接口
|
||||
@@ -11,4 +12,5 @@ import com.ruoyi.cai.domain.CaiAccountCash;
|
||||
*/
|
||||
public interface CaiAccountCashService extends IService<CaiAccountCash> {
|
||||
|
||||
void withdraw(WithdrawRes res);
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ public interface CaiAccountService extends IService<CaiAccount> {
|
||||
boolean incs(Long userId, Long value);
|
||||
|
||||
boolean decr(Long userId, Long value);
|
||||
|
||||
boolean withdraw(Long userId, Long incomeCoin);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.CaiGoods;
|
||||
|
||||
/**
|
||||
* 充值配置Service接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
public interface CaiGoodsService extends IService<CaiGoods> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.CaiWithdrawExchange;
|
||||
|
||||
/**
|
||||
* 提现 - 兑换配置Service接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
public interface CaiWithdrawExchangeService extends IService<CaiWithdrawExchange> {
|
||||
|
||||
}
|
||||
@@ -1,11 +1,47 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.CaiAccountBankcard;
|
||||
import com.ruoyi.cai.domain.CaiAccountCash;
|
||||
import com.ruoyi.cai.dto.app.query.WithdrawRes;
|
||||
import com.ruoyi.cai.mapper.CaiAccountCashMapper;
|
||||
import com.ruoyi.cai.service.CaiAccountBankcardService;
|
||||
import com.ruoyi.cai.service.CaiAccountCashService;
|
||||
import com.ruoyi.cai.service.CaiAccountService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Service
|
||||
public class CaiAccountCashServiceImpl extends ServiceImpl<CaiAccountCashMapper, CaiAccountCash> implements CaiAccountCashService {
|
||||
@Autowired
|
||||
private CaiAccountBankcardService accountBankcardService;
|
||||
@Autowired
|
||||
private CaiAccountService accountService;
|
||||
@Override
|
||||
public void withdraw(WithdrawRes res) {
|
||||
CaiAccountBankcard one = accountBankcardService.getOne(Wrappers.lambdaQuery(CaiAccountBankcard.class)
|
||||
.eq(CaiAccountBankcard::getUserId, res.getUserId()).last("limit 1"));
|
||||
if(one == null){
|
||||
throw new ServiceException("请先配置支付宝提现账号");
|
||||
}
|
||||
Long coinNum = res.getCoinNum();
|
||||
boolean withdraw = accountService.withdraw(res.getUserId(), coinNum);
|
||||
if(!withdraw){
|
||||
throw new ServiceException("余额不足");
|
||||
}
|
||||
CaiAccountCash cash = new CaiAccountCash();
|
||||
cash.setUserId(res.getUserId());
|
||||
cash.setOrderNo("orderNo");
|
||||
cash.setCashMoney(BigDecimal.valueOf(res.getMoney()));
|
||||
cash.setRealCashMoney(BigDecimal.valueOf(res.getMoney()));
|
||||
cash.setCashFees(BigDecimal.ZERO);
|
||||
cash.setBank(one.getBank());
|
||||
cash.setCardName(one.getCardName());
|
||||
cash.setCardAccount(one.getCardAccount());
|
||||
this.save(cash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccou
|
||||
|
||||
@Override
|
||||
public boolean incs(Long userId, Long value) {
|
||||
return baseMapper.incs(userId,value);
|
||||
return baseMapper.incs(userId,value) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,8 +36,8 @@ public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccou
|
||||
if(account.getTotalCoin() < value){
|
||||
throw new ServiceException("余额不足");
|
||||
}
|
||||
boolean incs = baseMapper.incs(userId, -value);
|
||||
if(!incs){
|
||||
long incs = baseMapper.incs(userId, -value);
|
||||
if(incs <= 0){
|
||||
return false;
|
||||
}
|
||||
CaiAccount newAccount = this.getByUserId(userId);
|
||||
@@ -47,6 +47,20 @@ public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccou
|
||||
}else{
|
||||
baseMapper.incsCoin(userId, -newAccount.getCoin(), decrCoinFlag);
|
||||
}
|
||||
return incs;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean withdraw(Long userId, Long incomeCoin){
|
||||
CaiAccount account = this.getByUserId(userId);
|
||||
if(account.getIncomeCoin() < incomeCoin){
|
||||
throw new ServiceException("余额不足");
|
||||
}
|
||||
long incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(incs <= 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.CaiGoods;
|
||||
import com.ruoyi.cai.mapper.CaiGoodsMapper;
|
||||
import com.ruoyi.cai.service.CaiGoodsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 充值配置Service业务层处理
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class CaiGoodsServiceImpl extends ServiceImpl<CaiGoodsMapper,CaiGoods> implements CaiGoodsService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.CaiWithdrawExchange;
|
||||
import com.ruoyi.cai.mapper.CaiWithdrawExchangeMapper;
|
||||
import com.ruoyi.cai.service.CaiWithdrawExchangeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 提现 - 兑换配置Service业务层处理
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-24
|
||||
*/
|
||||
@Service
|
||||
public class CaiWithdrawExchangeServiceImpl extends ServiceImpl<CaiWithdrawExchangeMapper,CaiWithdrawExchange> implements CaiWithdrawExchangeService {
|
||||
}
|
||||
Reference in New Issue
Block a user