fix(service): 修复查询用户主题时调用错误服务
将 KeyboardThemePurchaseService 改为 userThemesService,并调整查询条件从支付状态改为删除标记,确保获取正确的用户主题列表。
This commit is contained in:
@@ -105,7 +105,8 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
"/apple/validate-receipt",
|
||||
"/user/inviteCode",
|
||||
"/user/bindInviteCode",
|
||||
"/themes/listAllStyles"
|
||||
"/themes/listAllStyles",
|
||||
"/wallet/transactions"
|
||||
};
|
||||
}
|
||||
@Bean
|
||||
|
||||
@@ -99,4 +99,12 @@ public class ThemesController {
|
||||
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;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yolo.keyborad.common.BaseResponse;
|
||||
import com.yolo.keyborad.common.ResultUtils;
|
||||
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.KeyboardWalletTransactionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/*
|
||||
@@ -26,6 +30,9 @@ public class WalletController {
|
||||
@Resource
|
||||
private KeyboardUserWalletService walletService;
|
||||
|
||||
@Resource
|
||||
private KeyboardWalletTransactionService transactionService;
|
||||
|
||||
@GetMapping("/balance")
|
||||
@Operation(summary = "查询钱包余额", description = "查询当前登录用户的钱包余额")
|
||||
public BaseResponse<KeyboardUserWalletRespVO> getBalance() {
|
||||
@@ -33,4 +40,14 @@ public class WalletController {
|
||||
KeyboardUserWalletRespVO balance = walletService.getWalletBalance(userId);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.yolo.keyborad.model.entity.KeyboardWalletTransaction;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/10 18:54
|
||||
* @date: 2025/12/22 18:10
|
||||
*/
|
||||
|
||||
public interface KeyboardWalletTransactionMapper extends BaseMapper<KeyboardWalletTransaction> {
|
||||
|
||||
@@ -11,7 +11,7 @@ import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/10 18:54
|
||||
* @date: 2025/12/22 18:10
|
||||
*/
|
||||
|
||||
@Schema
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 恢复已删除的主题
|
||||
*/
|
||||
void restoreDeletedTheme(Long userId, Long themeId);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.yolo.keyborad.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yolo.keyborad.model.entity.KeyboardWalletTransaction;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yolo.keyborad.model.vo.wallet.WalletTransactionRespVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -18,4 +20,9 @@ public interface KeyboardWalletTransactionService extends IService<KeyboardWalle
|
||||
KeyboardWalletTransaction createTransaction(Long userId, Long orderId, BigDecimal amount,
|
||||
Short type, BigDecimal beforeBalance,
|
||||
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;
|
||||
}).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;
|
||||
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import java.math.BigDecimal;
|
||||
@@ -33,4 +36,25 @@ public class KeyboardWalletTransactionServiceImpl extends ServiceImpl<KeyboardWa
|
||||
this.save(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