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:
|
||||
final statusCode = error.response?.statusCode;
|
||||
final data = error.response?.data;
|
||||
debugPrint('[ApiClient] ▼▼▼ badResponse: status=$statusCode, data=$data, dataType=${data.runtimeType}');
|
||||
final rawMsg = data is Map ? data['message'] : null;
|
||||
debugPrint('[ApiClient] ▼▼▼ rawMsg=$rawMsg, rawMsgType=${rawMsg.runtimeType}');
|
||||
final message = rawMsg is List
|
||||
? (rawMsg as List).join(', ')
|
||||
: (rawMsg?.toString() ?? '请求失败');
|
||||
|
|
|
|||
|
|
@ -348,12 +348,14 @@ class _PrePlantingPurchasePageState
|
|||
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(
|
||||
portionCount: _quantity,
|
||||
// 首次购买时传省市信息,续购时后端自动复用
|
||||
provinceCode: _isFirstPurchase ? _selectedProvinceCode : _position?.provinceCode,
|
||||
provinceCode: pc,
|
||||
provinceName: _isFirstPurchase ? _selectedProvinceName : _position?.provinceName,
|
||||
cityCode: _isFirstPurchase ? _selectedCityCode : _position?.cityCode,
|
||||
cityCode: cc,
|
||||
cityName: _isFirstPurchase ? _selectedCityName : _position?.cityName,
|
||||
);
|
||||
|
||||
|
|
@ -376,8 +378,9 @@ class _PrePlantingPurchasePageState
|
|||
// 返回上一页(Profile 页面会自动刷新)
|
||||
context.pop(true);
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('[PrePlantingPurchase] 购买失败: $e');
|
||||
} catch (e, stack) {
|
||||
debugPrint('[PrePlantingPurchase] ★ 购买失败 type=${e.runtimeType}: $e');
|
||||
debugPrint('[PrePlantingPurchase] ★ stackTrace: $stack');
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
|
|
|||
Loading…
Reference in New Issue