debug(pre-planting): 添加购买流程详细日志以排查 List cast 错误
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
606d3c0b22
commit
9b6effe63d
|
|
@ -384,7 +384,9 @@ class ApiClient {
|
||||||
case DioExceptionType.badResponse:
|
case DioExceptionType.badResponse:
|
||||||
final statusCode = error.response?.statusCode;
|
final statusCode = error.response?.statusCode;
|
||||||
final data = error.response?.data;
|
final data = error.response?.data;
|
||||||
|
debugPrint('[ApiClient] ▼▼▼ badResponse: status=$statusCode, data=$data, dataType=${data.runtimeType}');
|
||||||
final rawMsg = data is Map ? data['message'] : null;
|
final rawMsg = data is Map ? data['message'] : null;
|
||||||
|
debugPrint('[ApiClient] ▼▼▼ rawMsg=$rawMsg, rawMsgType=${rawMsg.runtimeType}');
|
||||||
final message = rawMsg is List
|
final message = rawMsg is List
|
||||||
? (rawMsg as List).join(', ')
|
? (rawMsg as List).join(', ')
|
||||||
: (rawMsg?.toString() ?? '请求失败');
|
: (rawMsg?.toString() ?? '请求失败');
|
||||||
|
|
|
||||||
|
|
@ -348,12 +348,14 @@ class _PrePlantingPurchasePageState
|
||||||
final prePlantingService = ref.read(prePlantingServiceProvider);
|
final prePlantingService = ref.read(prePlantingServiceProvider);
|
||||||
|
|
||||||
// 创建预种订单(后端自动完成:扣款 → 分配权益 → 检查合并)
|
// 创建预种订单(后端自动完成:扣款 → 分配权益 → 检查合并)
|
||||||
|
final pc = _isFirstPurchase ? _selectedProvinceCode : _position?.provinceCode;
|
||||||
|
final cc = _isFirstPurchase ? _selectedCityCode : _position?.cityCode;
|
||||||
|
debugPrint('[PrePlantingPurchase] ★ createOrder: qty=$_quantity, isFirst=$_isFirstPurchase, provinceCode=$pc, cityCode=$cc');
|
||||||
final response = await prePlantingService.createOrder(
|
final response = await prePlantingService.createOrder(
|
||||||
portionCount: _quantity,
|
portionCount: _quantity,
|
||||||
// 首次购买时传省市信息,续购时后端自动复用
|
provinceCode: pc,
|
||||||
provinceCode: _isFirstPurchase ? _selectedProvinceCode : _position?.provinceCode,
|
|
||||||
provinceName: _isFirstPurchase ? _selectedProvinceName : _position?.provinceName,
|
provinceName: _isFirstPurchase ? _selectedProvinceName : _position?.provinceName,
|
||||||
cityCode: _isFirstPurchase ? _selectedCityCode : _position?.cityCode,
|
cityCode: cc,
|
||||||
cityName: _isFirstPurchase ? _selectedCityName : _position?.cityName,
|
cityName: _isFirstPurchase ? _selectedCityName : _position?.cityName,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -376,8 +378,9 @@ class _PrePlantingPurchasePageState
|
||||||
// 返回上一页(Profile 页面会自动刷新)
|
// 返回上一页(Profile 页面会自动刷新)
|
||||||
context.pop(true);
|
context.pop(true);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e, stack) {
|
||||||
debugPrint('[PrePlantingPurchase] 购买失败: $e');
|
debugPrint('[PrePlantingPurchase] ★ 购买失败 type=${e.runtimeType}: $e');
|
||||||
|
debugPrint('[PrePlantingPurchase] ★ stackTrace: $stack');
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue