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.CaiGuardLog;
|
||||
import com.ruoyi.cai.service.CaiGuardLogService;
|
||||
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-30
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cai/guardLog")
|
||||
public class CaiGuardLogController extends BaseController {
|
||||
|
||||
private final CaiGuardLogService iCaiGuardLogService;
|
||||
|
||||
/**
|
||||
* 查询守护赠送流水列表
|
||||
*/
|
||||
@SaCheckPermission("cai:guardLog:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<CaiGuardLog> list(CaiGuardLog bo, PageQuery pageQuery) {
|
||||
Page<CaiGuardLog> page = iCaiGuardLogService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取守护赠送流水详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("cai:guardLog:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<CaiGuardLog> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(iCaiGuardLogService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增守护赠送流水
|
||||
*/
|
||||
@SaCheckPermission("cai:guardLog:add")
|
||||
@Log(title = "守护赠送流水", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody CaiGuardLog bo) {
|
||||
return toAjax(iCaiGuardLogService.save(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改守护赠送流水
|
||||
*/
|
||||
@SaCheckPermission("cai:guardLog:edit")
|
||||
@Log(title = "守护赠送流水", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody CaiGuardLog bo) {
|
||||
return toAjax(iCaiGuardLogService.updateById(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除守护赠送流水
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cai:guardLog:remove")
|
||||
@Log(title = "守护赠送流水", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iCaiGuardLogService.removeBatchByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -80,24 +80,4 @@ public class UserAppController {
|
||||
return R.ok(userAlbumService.resetAlbum(res,LoginHelper.getUserId()));
|
||||
}
|
||||
|
||||
@GetMapping("/recharge/log")
|
||||
@Operation(summary = "充值记录-分页")
|
||||
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("/cash/log")
|
||||
@Operation(summary = "提现记录-分页")
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +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.AccountAliBankCardRes;
|
||||
import com.ruoyi.cai.dto.app.query.WithdrawReq;
|
||||
import com.ruoyi.cai.dto.app.vo.AccountCashVo;
|
||||
import com.ruoyi.cai.dto.app.vo.AccountRechargeVo;
|
||||
import com.ruoyi.cai.manager.CurrentUserManager;
|
||||
import com.ruoyi.cai.service.CaiAccountCashService;
|
||||
import com.ruoyi.cai.service.CaiAccountRechargeService;
|
||||
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 io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -21,6 +30,8 @@ public class WalletController {
|
||||
private CurrentUserManager currentUserManager;
|
||||
@Autowired
|
||||
private CaiAccountCashService accountCashService;
|
||||
@Autowired
|
||||
private CaiAccountRechargeService accountRechargeService;
|
||||
|
||||
@GetMapping("/aliInfo")
|
||||
@Operation(summary = "获取绑定支付宝信息")
|
||||
@@ -44,4 +55,24 @@ public class WalletController {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@GetMapping("/recharge/log")
|
||||
@Operation(summary = "充值记录-分页")
|
||||
public TableDataInfo<AccountRechargeVo> rechargeLog(PageQuery query){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Page<CaiAccountRecharge> page = accountRechargeService.page(query.build(), Wrappers.lambdaQuery(CaiAccountRecharge.class)
|
||||
.eq(CaiAccountRecharge::getUserId, userId)
|
||||
.orderByDesc(CaiAccountRecharge::getCreateTime));
|
||||
return TableDataInfo.build(page,AccountRechargeVo::new);
|
||||
}
|
||||
|
||||
@GetMapping("/cash/log")
|
||||
@Operation(summary = "提现记录-分页")
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class CaiAccountCash implements Serializable {
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 提现紫贝
|
||||
*/
|
||||
private Long withdrawCoin;
|
||||
/**
|
||||
* 提现金额
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 守护赠送流水对象 cai_guard_log
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-30
|
||||
*/
|
||||
@Data
|
||||
@TableName("cai_guard_log")
|
||||
public class CaiGuardLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* 女神
|
||||
*/
|
||||
private Long fromUserId;
|
||||
/**
|
||||
* 赠送人
|
||||
*/
|
||||
private Long toUserId;
|
||||
/**
|
||||
* 赠送个数
|
||||
*/
|
||||
private Long guardNum;
|
||||
/**
|
||||
* 守护值
|
||||
*/
|
||||
private Long guardValue;
|
||||
/**
|
||||
* 流水ID
|
||||
*/
|
||||
private Long consumeLogId;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -29,11 +29,11 @@ public class CaiWithdrawExchange implements Serializable {
|
||||
* 兑换金额
|
||||
*/
|
||||
@Schema(description = "兑换金额")
|
||||
private Integer money;
|
||||
private Long money;
|
||||
/**
|
||||
* 所需货币数量
|
||||
*/
|
||||
@Schema(description = "所需货币")
|
||||
private Integer coinNum;
|
||||
private Long coinNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,22 +6,11 @@ import lombok.Data;
|
||||
@Data
|
||||
@Schema(description = "提现入参")
|
||||
public class WithdrawReq {
|
||||
|
||||
/**
|
||||
* 提现配置ID
|
||||
*/
|
||||
@Schema(description = "提现配置ID")
|
||||
private Long withdrawSettingId;
|
||||
/**
|
||||
* 兑换金额
|
||||
*/
|
||||
@Schema(description = "兑换金额")
|
||||
private Long money;
|
||||
/**
|
||||
* 所需货币数量
|
||||
*/
|
||||
@Schema(description = "所需货币数量")
|
||||
private Long coinNum;
|
||||
@Schema(description = "当前用户ID",accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private Long userId;
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cai.domain.CaiGuardLog;
|
||||
|
||||
/**
|
||||
* 守护赠送流水Mapper接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-30
|
||||
*/
|
||||
public interface CaiGuardLogMapper extends BaseMapper<CaiGuardLog> {
|
||||
|
||||
}
|
||||
@@ -16,5 +16,5 @@ public interface CaiAccountService extends IService<CaiAccount> {
|
||||
|
||||
CaiConsumeLog decr(CaiConsumeLog log);
|
||||
|
||||
boolean withdraw(Long userId, Long incomeCoin);
|
||||
void 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.CaiGuardLog;
|
||||
|
||||
/**
|
||||
* 守护赠送流水Service接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-30
|
||||
*/
|
||||
public interface CaiGuardLogService extends IService<CaiGuardLog> {
|
||||
|
||||
}
|
||||
@@ -4,11 +4,13 @@ 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.domain.CaiWithdrawExchange;
|
||||
import com.ruoyi.cai.dto.app.query.WithdrawReq;
|
||||
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.cai.service.CaiWithdrawExchangeService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -21,6 +23,8 @@ public class CaiAccountCashServiceImpl extends ServiceImpl<CaiAccountCashMapper,
|
||||
private CaiAccountBankcardService accountBankcardService;
|
||||
@Autowired
|
||||
private CaiAccountService accountService;
|
||||
@Autowired
|
||||
private CaiWithdrawExchangeService withdrawExchangeService;
|
||||
@Override
|
||||
public void withdraw(WithdrawReq res) {
|
||||
CaiAccountBankcard one = accountBankcardService.getOne(Wrappers.lambdaQuery(CaiAccountBankcard.class)
|
||||
@@ -28,16 +32,18 @@ public class CaiAccountCashServiceImpl extends ServiceImpl<CaiAccountCashMapper,
|
||||
if(one == null){
|
||||
throw new ServiceException("请先配置支付宝提现账号");
|
||||
}
|
||||
Long coinNum = res.getCoinNum();
|
||||
boolean withdraw = accountService.withdraw(res.getUserId(), coinNum);
|
||||
if(!withdraw){
|
||||
throw new ServiceException("余额不足");
|
||||
CaiWithdrawExchange withdrawExchange = withdrawExchangeService.getById(res.getWithdrawSettingId());
|
||||
if(withdrawExchange == null){
|
||||
throw new ServiceException("参数不正确");
|
||||
}
|
||||
Long coinNum = withdrawExchange.getCoinNum();
|
||||
accountService.withdraw(res.getUserId(), coinNum);
|
||||
CaiAccountCash cash = new CaiAccountCash();
|
||||
cash.setUserId(res.getUserId());
|
||||
cash.setOrderNo("orderNo");
|
||||
cash.setCashMoney(BigDecimal.valueOf(res.getMoney()));
|
||||
cash.setRealCashMoney(BigDecimal.valueOf(res.getMoney()));
|
||||
cash.setWithdrawCoin(coinNum);
|
||||
cash.setCashMoney(BigDecimal.valueOf(withdrawExchange.getMoney()));
|
||||
cash.setRealCashMoney(BigDecimal.valueOf(withdrawExchange.getMoney()));
|
||||
cash.setCashFees(BigDecimal.ZERO);
|
||||
cash.setBank(one.getBank());
|
||||
cash.setCardName(one.getCardName());
|
||||
|
||||
@@ -155,15 +155,17 @@ public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccou
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean withdraw(Long userId, Long incomeCoin){
|
||||
public void withdraw(Long userId, Long incomeCoin){
|
||||
CaiAccount account = this.getByUserId(userId);
|
||||
if(account == null){
|
||||
throw new ServiceException("无效账号");
|
||||
}
|
||||
if(account.getIncomeCoin() < incomeCoin){
|
||||
throw new ServiceException("余额不足");
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
long incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(incs <= 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.CaiGuardLog;
|
||||
import com.ruoyi.cai.mapper.CaiGuardLogMapper;
|
||||
import com.ruoyi.cai.service.CaiGuardLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 守护赠送流水Service业务层处理
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-30
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class CaiGuardLogServiceImpl extends ServiceImpl<CaiGuardLogMapper,CaiGuardLog> implements CaiGuardLogService {
|
||||
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class CaiGuardTotalServiceImpl extends ServiceImpl<CaiGuardTotalMapper,Ca
|
||||
consumeLog.setAmount(guardValue);
|
||||
consumeLog.setTargetRate(anchor.getGuardRate());
|
||||
consumeLog = accountService.decr(consumeLog);
|
||||
// TODO 增加守护流水
|
||||
|
||||
CaiGuardTotal one = this.getOne(Wrappers.lambdaQuery(CaiGuardTotal.class)
|
||||
.eq(CaiGuardTotal::getToUserId, query.getToUserId())
|
||||
.eq(CaiGuardTotal::getFromUserId, fromUserId));
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.cai.mapper.CaiGuardLogMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.cai.domain.CaiGuardLog" id="CaiGuardLogResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="fromUserId" column="from_user_id"/>
|
||||
<result property="toUserId" column="to_user_id"/>
|
||||
<result property="guardNum" column="guard_num"/>
|
||||
<result property="guardValue" column="guard_value"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="consumeLogId" column="consume_log_id"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user