用户反馈农贸市场成交列表接口 matchexchangeList.list 没有数据,需要检查和修复相关问题。
通过 php artisan debug:reproduce-error 68995486 重现请求,发现:
检查请求参数发现:
{
"requestUnid": "request_1750297251803",
"matchexchangeList": {
"itemId": "3",
"page": {
"page": "1"
}
}
}
请求指定了 itemId: 3,只查询商品ID为3的成交记录。
SELECT COUNT(*) FROM kku_mex_transactions WHERE item_id = 3 AND is_admin_operation = 0;
-- 结果:只有1条记录
问题不是接口逻辑错误,而是测试数据不足:
为了丰富成交列表,添加了更多测试数据:
INSERT INTO kku_mex_transactions (
buy_order_id, sell_order_id, buyer_id, seller_id, item_id, currency_type,
quantity, price, total_amount, transaction_type, is_admin_operation, created_at
) VALUES
(NULL, NULL, 39068, 1, 3, 2, 50, 10.50000, 525.00000, 'USER_BUY', 0, '2025-06-19 09:30:00'),
(NULL, NULL, 39068, 1, 3, 2, 75, 12.00000, 900.00000, 'USER_BUY', 0, '2025-06-19 09:25:00'),
(NULL, NULL, 1, 39068, 4, 2, 200, 5.50000, 1100.00000, 'USER_SELL', 0, '2025-06-19 09:20:00'),
(NULL, NULL, 39068, 1, 4, 2, 150, 6.00000, 900.00000, 'USER_BUY', 0, '2025-06-19 09:15:00');
添加数据后,接口返回结果:
{
"matchexchangeList": {
"page": {
"currentPage": "1",
"perPage": "20",
"lastPage": "1",
"total": "3"
},
"list": [
{
"id": "10",
"userId": "39068",
"itemId": "3",
"price": 8,
"times": "1750297160",
"status": "MEX_STATUS_FINISHED",
"num": "100",
"direction": "SELL"
},
{
"id": "11",
"userId": "39068",
"itemId": "3",
"price": 10.5,
"times": "1750296600",
"status": "MEX_STATUS_FINISHED",
"num": "50",
"direction": "BUY"
},
{
"id": "12",
"userId": "39068",
"itemId": "3",
"price": 12,
"times": "1750296300",
"status": "MEX_STATUS_FINISHED",
"num": "75",
"direction": "BUY"
}
]
}
}
$result = MexTransactionLogic::getPublicTransactions(1, 20, 3);
// 返回3条记录,逻辑正常
// 不指定itemId,查询所有商品
$result = MexTransactionLogic::getPublicTransactions(1, 20, null);
// 返回5条记录,包括不同商品的成交记录
total: 3MEX_STATUS_FINISHED、SELL/BUYMexTransactionService::getPublicTransactions 方法工作正常ListHandler 数据转换正确is_admin_operation = 0 正确执行itemId 时,只返回该商品的成交记录itemId 时,返回所有商品的成交记录USER_SELL 显示为 SELL 方向,用户ID为卖方IDUSER_BUY 显示为 BUY 方向,用户ID为买方ID问题已解决:
原因总结:
建议: