fix(service): 修复查询用户主题时调用错误服务
将 KeyboardThemePurchaseService 改为 userThemesService,并调整查询条件从支付状态改为删除标记,确保获取正确的用户主题列表。
This commit is contained in:
@@ -105,7 +105,8 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||||||
"/apple/validate-receipt",
|
"/apple/validate-receipt",
|
||||||
"/user/inviteCode",
|
"/user/inviteCode",
|
||||||
"/user/bindInviteCode",
|
"/user/bindInviteCode",
|
||||||
"/themes/listAllStyles"
|
"/themes/listAllStyles",
|
||||||
|
"/wallet/transactions"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -99,4 +99,12 @@ public class ThemesController {
|
|||||||
return ResultUtils.success(result);
|
return ResultUtils.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/restore")
|
||||||
|
@Operation(summary = "恢复已删除的主题", description = "将用户已删除的主题重新展示")
|
||||||
|
public BaseResponse<Void> restoreTheme(@RequestParam Long themeId) {
|
||||||
|
Long userId = StpUtil.getLoginIdAsLong();
|
||||||
|
themePurchaseService.restoreDeletedTheme(userId, themeId);
|
||||||
|
return ResultUtils.success(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package com.yolo.keyborad.controller;
|
package com.yolo.keyborad.controller;
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.yolo.keyborad.common.BaseResponse;
|
import com.yolo.keyborad.common.BaseResponse;
|
||||||
import com.yolo.keyborad.common.ResultUtils;
|
import com.yolo.keyborad.common.ResultUtils;
|
||||||
import com.yolo.keyborad.model.vo.wallet.KeyboardUserWalletRespVO;
|
import com.yolo.keyborad.model.vo.wallet.KeyboardUserWalletRespVO;
|
||||||
|
import com.yolo.keyborad.model.vo.wallet.WalletTransactionRespVO;
|
||||||
import com.yolo.keyborad.service.KeyboardUserWalletService;
|
import com.yolo.keyborad.service.KeyboardUserWalletService;
|
||||||
|
import com.yolo.keyborad.service.KeyboardWalletTransactionService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -26,6 +30,9 @@ public class WalletController {
|
|||||||
@Resource
|
@Resource
|
||||||
private KeyboardUserWalletService walletService;
|
private KeyboardUserWalletService walletService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private KeyboardWalletTransactionService transactionService;
|
||||||
|
|
||||||
@GetMapping("/balance")
|
@GetMapping("/balance")
|
||||||
@Operation(summary = "查询钱包余额", description = "查询当前登录用户的钱包余额")
|
@Operation(summary = "查询钱包余额", description = "查询当前登录用户的钱包余额")
|
||||||
public BaseResponse<KeyboardUserWalletRespVO> getBalance() {
|
public BaseResponse<KeyboardUserWalletRespVO> getBalance() {
|
||||||
@@ -33,4 +40,14 @@ public class WalletController {
|
|||||||
KeyboardUserWalletRespVO balance = walletService.getWalletBalance(userId);
|
KeyboardUserWalletRespVO balance = walletService.getWalletBalance(userId);
|
||||||
return ResultUtils.success(balance);
|
return ResultUtils.success(balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/transactions")
|
||||||
|
@Operation(summary = "分页查询钱包交易记录", description = "分页查询当前用户的钱包交易记录")
|
||||||
|
public BaseResponse<IPage<WalletTransactionRespVO>> getTransactions(
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||||
|
Long userId = StpUtil.getLoginIdAsLong();
|
||||||
|
IPage<WalletTransactionRespVO> transactions = transactionService.getUserTransactions(userId, pageNum, pageSize);
|
||||||
|
return ResultUtils.success(transactions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.yolo.keyborad.model.entity.KeyboardWalletTransaction;
|
import com.yolo.keyborad.model.entity.KeyboardWalletTransaction;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author: ziin
|
* @author: ziin
|
||||||
* @date: 2025/12/10 18:54
|
* @date: 2025/12/22 18:10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface KeyboardWalletTransactionMapper extends BaseMapper<KeyboardWalletTransaction> {
|
public interface KeyboardWalletTransactionMapper extends BaseMapper<KeyboardWalletTransaction> {
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @author: ziin
|
* @author: ziin
|
||||||
* @date: 2025/12/10 18:54
|
* @date: 2025/12/22 18:10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Schema
|
@Schema
|
||||||
@@ -22,62 +22,62 @@ public class KeyboardWalletTransaction {
|
|||||||
* 主键 Id
|
* 主键 Id
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
@Schema(description="主键 Id")
|
@Schema(description = "主键 Id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户 Id
|
* 用户 Id
|
||||||
*/
|
*/
|
||||||
@TableField(value = "user_id")
|
@TableField(value = "user_id")
|
||||||
@Schema(description="用户 Id")
|
@Schema(description = "用户 Id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单 Id
|
* 订单 Id
|
||||||
*/
|
*/
|
||||||
@TableField(value = "order_id")
|
@TableField(value = "order_id")
|
||||||
@Schema(description="订单 Id")
|
@Schema(description = "订单 Id")
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 金额
|
* 金额
|
||||||
*/
|
*/
|
||||||
@TableField(value = "amount")
|
@TableField(value = "amount")
|
||||||
@Schema(description="金额")
|
@Schema(description = "金额")
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 变动类型
|
* 变动类型
|
||||||
*/
|
*/
|
||||||
@TableField(value = "\"type\"")
|
@TableField(value = "\"type\"")
|
||||||
@Schema(description="变动类型")
|
@Schema(description = "变动类型")
|
||||||
private Short type;
|
private Short type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 变动前余额
|
* 变动前余额
|
||||||
*/
|
*/
|
||||||
@TableField(value = "before_balance")
|
@TableField(value = "before_balance")
|
||||||
@Schema(description="变动前余额")
|
@Schema(description = "变动前余额")
|
||||||
private BigDecimal beforeBalance;
|
private BigDecimal beforeBalance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 变动后余额
|
* 变动后余额
|
||||||
*/
|
*/
|
||||||
@TableField(value = "after_balance")
|
@TableField(value = "after_balance")
|
||||||
@Schema(description="变动后余额")
|
@Schema(description = "变动后余额")
|
||||||
private BigDecimal afterBalance;
|
private BigDecimal afterBalance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
@TableField(value = "description")
|
@TableField(value = "description")
|
||||||
@Schema(description="描述")
|
@Schema(description = "描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@TableField(value = "created_at")
|
@TableField(value = "created_at")
|
||||||
@Schema(description="创建时间")
|
@Schema(description = "创建时间")
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.yolo.keyborad.model.vo.wallet;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "钱包交易记录响应")
|
||||||
|
public class WalletTransactionRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "交易ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "金额")
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@Schema(description = "变动类型")
|
||||||
|
private Short type;
|
||||||
|
|
||||||
|
@Schema(description = "变动前余额")
|
||||||
|
private BigDecimal beforeBalance;
|
||||||
|
|
||||||
|
@Schema(description = "变动后余额")
|
||||||
|
private BigDecimal afterBalance;
|
||||||
|
|
||||||
|
@Schema(description = "描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createdAt;
|
||||||
|
}
|
||||||
@@ -29,4 +29,9 @@ public interface KeyboardThemePurchaseService extends IService<KeyboardThemePurc
|
|||||||
* 查询用户已购买的主题列表
|
* 查询用户已购买的主题列表
|
||||||
*/
|
*/
|
||||||
List<KeyboardThemesRespVO> getUserPurchasedThemes(Long userId);
|
List<KeyboardThemesRespVO> getUserPurchasedThemes(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复已删除的主题
|
||||||
|
*/
|
||||||
|
void restoreDeletedTheme(Long userId, Long themeId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.yolo.keyborad.service;
|
package com.yolo.keyborad.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.yolo.keyborad.model.entity.KeyboardWalletTransaction;
|
import com.yolo.keyborad.model.entity.KeyboardWalletTransaction;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.yolo.keyborad.model.vo.wallet.WalletTransactionRespVO;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@@ -18,4 +20,9 @@ public interface KeyboardWalletTransactionService extends IService<KeyboardWalle
|
|||||||
KeyboardWalletTransaction createTransaction(Long userId, Long orderId, BigDecimal amount,
|
KeyboardWalletTransaction createTransaction(Long userId, Long orderId, BigDecimal amount,
|
||||||
Short type, BigDecimal beforeBalance,
|
Short type, BigDecimal beforeBalance,
|
||||||
BigDecimal afterBalance, String description);
|
BigDecimal afterBalance, String description);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询用户钱包交易记录
|
||||||
|
*/
|
||||||
|
IPage<WalletTransactionRespVO> getUserTransactions(Long userId, Integer pageNum, Integer pageSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,4 +242,19 @@ public class KeyboardThemePurchaseServiceImpl extends ServiceImpl<KeyboardThemeP
|
|||||||
return vo;
|
return vo;
|
||||||
}).collect(java.util.stream.Collectors.toList());
|
}).collect(java.util.stream.Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreDeletedTheme(Long userId, Long themeId) {
|
||||||
|
KeyboardUserThemes userTheme = userThemesService.lambdaQuery()
|
||||||
|
.eq(KeyboardUserThemes::getUserId, userId)
|
||||||
|
.eq(KeyboardUserThemes::getThemeId, themeId)
|
||||||
|
.one();
|
||||||
|
|
||||||
|
if (userTheme == null) {
|
||||||
|
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
userTheme.setViewDeleted(false);
|
||||||
|
userThemesService.updateById(userTheme);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.yolo.keyborad.service.impl;
|
package com.yolo.keyborad.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yolo.keyborad.model.vo.wallet.WalletTransactionRespVO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -33,4 +36,25 @@ public class KeyboardWalletTransactionServiceImpl extends ServiceImpl<KeyboardWa
|
|||||||
this.save(transaction);
|
this.save(transaction);
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<WalletTransactionRespVO> getUserTransactions(Long userId, Integer pageNum, Integer pageSize) {
|
||||||
|
Page<KeyboardWalletTransaction> page = new Page<>(pageNum, pageSize);
|
||||||
|
IPage<KeyboardWalletTransaction> transactionPage = this.lambdaQuery()
|
||||||
|
.eq(KeyboardWalletTransaction::getUserId, userId)
|
||||||
|
.orderByDesc(KeyboardWalletTransaction::getCreatedAt)
|
||||||
|
.page(page);
|
||||||
|
|
||||||
|
return transactionPage.convert(transaction -> {
|
||||||
|
WalletTransactionRespVO vo = new WalletTransactionRespVO();
|
||||||
|
vo.setId(transaction.getId());
|
||||||
|
vo.setAmount(transaction.getAmount());
|
||||||
|
vo.setType(transaction.getType());
|
||||||
|
vo.setBeforeBalance(transaction.getBeforeBalance());
|
||||||
|
vo.setAfterBalance(transaction.getAfterBalance());
|
||||||
|
vo.setDescription(transaction.getDescription());
|
||||||
|
vo.setCreatedAt(transaction.getCreatedAt());
|
||||||
|
return vo;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user