fix: 修复移动端跟单配置管理和重试订单日志
- 移动端跟单配置管理添加Switch开关,支持开启/停用跟单 - 在移动端卡片布局中添加Switch组件 - 与桌面端功能保持一致 - 优化重试订单的日志记录逻辑 - 第一次失败时不记录日志,静默重试 - 只在重试后仍然失败时才记录日志 - 减少不必要的日志输出,提高日志质量
This commit is contained in:
@@ -661,10 +661,12 @@ class CopyOrderTrackingService(
|
|||||||
if (!orderResponse.isSuccessful || orderResponse.body() == null) {
|
if (!orderResponse.isSuccessful || orderResponse.body() == null) {
|
||||||
lastError = Exception("创建订单失败: code=${orderResponse.code()}, message=${orderResponse.message()}")
|
lastError = Exception("创建订单失败: code=${orderResponse.code()}, message=${orderResponse.message()}")
|
||||||
if (attempt < 2) {
|
if (attempt < 2) {
|
||||||
logger.warn("创建订单失败,准备重试(重新签名): copyTradingId=$copyTradingId, tradeId=$tradeId, attempt=$attempt")
|
// 第一次失败不记录日志,静默重试
|
||||||
delay(1000) // 重试前等待1秒
|
delay(1000) // 重试前等待1秒
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// 重试后仍然失败,记录日志
|
||||||
|
logger.warn("创建订单失败(重试后仍失败): copyTradingId=$copyTradingId, tradeId=$tradeId, attempt=$attempt, code=${orderResponse.code()}, message=${orderResponse.message()}")
|
||||||
return Result.failure(lastError!!)
|
return Result.failure(lastError!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,10 +674,12 @@ class CopyOrderTrackingService(
|
|||||||
if (!response.success || response.orderId == null) {
|
if (!response.success || response.orderId == null) {
|
||||||
lastError = Exception("创建订单失败: errorMsg=${response.errorMsg}")
|
lastError = Exception("创建订单失败: errorMsg=${response.errorMsg}")
|
||||||
if (attempt < 2) {
|
if (attempt < 2) {
|
||||||
logger.warn("创建订单失败,准备重试(重新签名): copyTradingId=$copyTradingId, tradeId=$tradeId, attempt=$attempt, errorMsg=${response.errorMsg}")
|
// 第一次失败不记录日志,静默重试
|
||||||
delay(1000) // 重试前等待1秒
|
delay(1000) // 重试前等待1秒
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// 重试后仍然失败,记录日志
|
||||||
|
logger.warn("创建订单失败(重试后仍失败): copyTradingId=$copyTradingId, tradeId=$tradeId, attempt=$attempt, errorMsg=${response.errorMsg}")
|
||||||
return Result.failure(lastError!!)
|
return Result.failure(lastError!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,10 +688,12 @@ class CopyOrderTrackingService(
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
lastError = e
|
lastError = e
|
||||||
if (attempt < 2) {
|
if (attempt < 2) {
|
||||||
logger.warn("调用创建订单API异常,准备重试(重新签名): copyTradingId=$copyTradingId, tradeId=$tradeId, attempt=$attempt", e)
|
// 第一次失败不记录日志,静默重试
|
||||||
delay(1000) // 重试前等待1秒
|
delay(1000) // 重试前等待1秒
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// 重试后仍然失败,记录日志
|
||||||
|
logger.warn("调用创建订单API异常(重试后仍失败): copyTradingId=$copyTradingId, tradeId=$tradeId, attempt=$attempt", e)
|
||||||
return Result.failure(e)
|
return Result.failure(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,10 +464,17 @@ const CopyTradingList: React.FC = () => {
|
|||||||
}}>
|
}}>
|
||||||
{record.templateName}
|
{record.templateName}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px', alignItems: 'center' }}>
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<Tag color={record.enabled ? 'green' : 'red'}>
|
<Tag color={record.enabled ? 'green' : 'red'}>
|
||||||
{record.enabled ? '启用' : '禁用'}
|
{record.enabled ? '启用' : '禁用'}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
<Switch
|
||||||
|
checked={record.enabled}
|
||||||
|
onChange={() => handleToggleStatus(record)}
|
||||||
|
checkedChildren="开启"
|
||||||
|
unCheckedChildren="停止"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user