fix: 积分页支出明细不显示 + integral/list 支持 type 参数

- 前端 points.vue: 支出明细 type 过滤改为 Number(item.type)===2;onLoad 先 await loadUserInfo 再 loadPointsList;请求 getIntegralList 时传 type=2
- 后端 integral/list: 增加可选参数 type(1=收入,2=支出),UserIntegralRecordServiceImpl 支持按 type 筛选
- 新增 backend/shell/test-integral-list.sh 测试 integral/list 支出明细
- 新增 backend/shell/start-front-miao33.sh 使用 nohup 启动 crmeb-front(miao33)

Made-with: Cursor
This commit is contained in:
apple
2026-03-16 07:42:51 +08:00
parent e0e2f50806
commit fcb10e9bc7
8 changed files with 103 additions and 9 deletions

View File

@@ -220,11 +220,13 @@ public class UserController {
/**
* 积分记录
* @param type 可选记录类型1=收入2=支出,不传返回全部
*/
@ApiOperation(value = "积分记录")
@RequestMapping(value = "/integral/list", method = RequestMethod.GET)
public CommonResult<CommonPage<UserIntegralRecord>> getIntegralList(@Validated PageParamRequest pageParamRequest) {
return CommonResult.success(CommonPage.restPage(userCenterService.getUserIntegralRecordList(pageParamRequest)));
public CommonResult<CommonPage<UserIntegralRecord>> getIntegralList(@Validated PageParamRequest pageParamRequest,
@RequestParam(required = false) Integer type) {
return CommonResult.success(CommonPage.restPage(userCenterService.getUserIntegralRecordList(pageParamRequest, type)));
}
/**

View File

@@ -176,9 +176,10 @@ public interface UserCenterService extends IService<User> {
/**
* 用户积分记录列表
* @param pageParamRequest 分页参数
* @param type 可选记录类型1=收入2=支出null=全部
* @return List<UserIntegralRecord>
*/
List<UserIntegralRecord> getUserIntegralRecordList(PageParamRequest pageParamRequest);
List<UserIntegralRecord> getUserIntegralRecordList(PageParamRequest pageParamRequest, Integer type);
/**
* 微信app登录

View File

@@ -912,12 +912,13 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
* 用户积分记录列表
*
* @param pageParamRequest 分页参数
* @param type 可选记录类型1=收入2=支出null=全部
* @return List<UserIntegralRecord>
*/
@Override
public List<UserIntegralRecord> getUserIntegralRecordList(PageParamRequest pageParamRequest) {
public List<UserIntegralRecord> getUserIntegralRecordList(PageParamRequest pageParamRequest, Integer type) {
Integer uid = userService.getUserIdException();
return userIntegralRecordService.findUserIntegralRecordList(uid, pageParamRequest);
return userIntegralRecordService.findUserIntegralRecordList(uid, pageParamRequest, type);
}
/**

View File

@@ -62,6 +62,15 @@ public interface UserIntegralRecordService extends IService<UserIntegralRecord>
*/
List<UserIntegralRecord> findUserIntegralRecordList(Integer uid, PageParamRequest pageParamRequest);
/**
* H5用户积分列表按类型筛选
* @param uid 用户uid
* @param pageParamRequest 分页参数
* @param type 可选1=收入2=支出null=全部
* @return List
*/
List<UserIntegralRecord> findUserIntegralRecordList(Integer uid, PageParamRequest pageParamRequest, Integer type);
/**
* 获取用户冻结的积分
* @param uid 用户uid

View File

@@ -217,11 +217,19 @@ public class UserIntegralRecordServiceImpl extends ServiceImpl<UserIntegralRecor
*/
@Override
public List<UserIntegralRecord> findUserIntegralRecordList(Integer uid, PageParamRequest pageParamRequest) {
return findUserIntegralRecordList(uid, pageParamRequest, null);
}
@Override
public List<UserIntegralRecord> findUserIntegralRecordList(Integer uid, PageParamRequest pageParamRequest, Integer type) {
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
LambdaQueryWrapper<UserIntegralRecord> lqw = Wrappers.lambdaQuery();
lqw.select(UserIntegralRecord::getId, UserIntegralRecord::getTitle, UserIntegralRecord::getType, UserIntegralRecord::getIntegral, UserIntegralRecord::getUpdateTime);
lqw.eq(UserIntegralRecord::getUid, uid);
lqw.eq(UserIntegralRecord::getStatus, IntegralRecordConstants.INTEGRAL_RECORD_STATUS_COMPLETE);
if (type != null) {
lqw.eq(UserIntegralRecord::getType, type);
}
lqw.orderByDesc(UserIntegralRecord::getUpdateTime);
return dao.selectList(lqw);
}

View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# 使用 miao33 配置启动 crmeb-front 服务nohup 后台)
# 端口见 application-miao33.yml30031
set -e
BACKEND_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$BACKEND_DIR"
JAR="$BACKEND_DIR/crmeb-front/target/miao-front-2.2.jar"
LOG="${LOG:-$BACKEND_DIR/front-miao33.log}"
if [ ! -f "$JAR" ]; then
echo "未找到 jar请先执行: mvn clean package -pl crmeb-front -am -DskipTests"
exit 1
fi
echo "启动: nohup java -jar $JAR --spring.profiles.active=miao33 > $LOG 2>&1 &"
nohup java -jar "$JAR" --spring.profiles.active=miao33 >> "$LOG" 2>&1 &
echo "PID: $!"
echo "日志: $LOG"

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# 测试 api/front/integral/list 是否返回支出明细type=2
# 用法: BASE_URL=http://localhost:8081 ./test-integral-list.sh
# 或: ./test-integral-list.sh (默认 BASE_URL=http://localhost:8081)
set -e
BASE="${BASE_URL:-http://localhost:8081}"
USER="13739117991"
PASS="123456"
echo "=== 测试 integral/list 支出明细 (type=2) ==="
echo "BASE_URL=$BASE"
echo ""
echo "1. 登录 ($USER / $PASS) ..."
LOGIN=$(curl -s -X POST "$BASE/api/front/loginV2" \
-H "Content-Type: application/json" \
-d "{\"account\":\"$USER\",\"password\":\"$PASS\"}")
if echo "$LOGIN" | grep -qE '"code":\s*(0|200)'; then
echo " 登录成功"
else
echo " 登录失败 (若为「此账号未注册」请在本环境用已注册账号或本地起后端测试): $LOGIN"
exit 1
fi
TOKEN=$(echo "$LOGIN" | sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
if [ -z "$TOKEN" ]; then
echo " 未获取到 token"
exit 1
fi
echo " Token: ${TOKEN:0:24}..."
echo ""
echo "2. GET api/front/integral/list?page=1&limit=20&type=2 (支出明细) ..."
RES=$(curl -s -X GET "$BASE/api/front/integral/list?page=1&limit=20&type=2" \
-H "Content-Type: application/json" \
-H "Authori-zation: $TOKEN")
echo "$RES" | head -c 800
echo ""
echo ""
if echo "$RES" | grep -qE '"code":\s*(0|200)'; then
echo "3. 结果: 接口返回成功 (code=0/200)"
if echo "$RES" | grep -q '"list":'; then
echo " data.list 已返回;带 type=2 时仅包含支出明细,见上方 JSON。"
fi
exit 0
else
echo "3. 结果: 接口未成功 (需登录或 code 非 0/200)"
exit 1
fi

View File

@@ -204,7 +204,7 @@ export default {
}
this.getUserPoints()
this.loadUserInfo()
await this.loadUserInfo()
this.loadPointsList()
},
@@ -447,7 +447,8 @@ export default {
}),
getIntegralList({
page: this.page,
limit: this.limit
limit: this.limit,
type: 2
})
])
@@ -470,8 +471,8 @@ export default {
// 处理积分明细(使用 getIntegralList需要过滤出 type === 2 的支出记录)
if (pointsRes.code === 0 && pointsRes.data) {
// 过滤出支出记录type === 2
const expenseRecords = (pointsRes.data.list || []).filter(item => item.type === 2)
// 过滤出支出记录type === 2,兼容后端返回数字或字符串
const expenseRecords = (pointsRes.data.list || []).filter(item => Number(item.type) === 2)
pointsList = expenseRecords.map(item => ({
id: `points_${item.id}`,
source: 'points', // 标记来源:积分(与模板中的判断保持一致)