|
|
@@ -352,7 +352,7 @@ impl Platform for HtxSwap {
|
|
|
if response.code != 200 || response.data["errors"].as_array().unwrap_or(&vec![]).len() > 0 {
|
|
|
return Err(Error::new(ErrorKind::NotFound, format!("htx_swap 取消订单异常{:?}", response).to_string()));
|
|
|
}
|
|
|
-
|
|
|
+ info!("取消订单完成 order_id {} custom_id {} 响应体 {:?}", order_id, custom_id, response);
|
|
|
let res_data_json = response.data;
|
|
|
let mut id = order_id.to_string();
|
|
|
let mut custom_id = custom_id.to_string();
|
|
|
@@ -471,6 +471,8 @@ impl Platform for HtxSwap {
|
|
|
let mut err_order = Order::new();
|
|
|
err_order.custom_id = cid.clone();
|
|
|
err_order.status = "REMOVE".to_string();
|
|
|
+ ts.source = "htx_swap 474".to_string();
|
|
|
+ err_order.trace_stack = ts;
|
|
|
|
|
|
self_clone.order_sender.send(err_order).await.unwrap();
|
|
|
self_clone.error_sender.send(error).await.unwrap();
|
|
|
@@ -497,33 +499,20 @@ impl Platform for HtxSwap {
|
|
|
// result_sd.send(result).await.unwrap();
|
|
|
}
|
|
|
Err(error) => {
|
|
|
- // 取消失败去查订单。
|
|
|
- let query_rst = self_clone.get_order_detail(&order_id, &custom_id).await;
|
|
|
- match query_rst {
|
|
|
- Ok(order) => {
|
|
|
- self_clone.order_sender.send(order).await.unwrap();
|
|
|
- }
|
|
|
- Err(err) => {
|
|
|
- // 订单id查不到的 remove掉
|
|
|
- if err.to_string().contains("Order doesnt exist.") {
|
|
|
- let order = Order {
|
|
|
- id: order_id,
|
|
|
- custom_id,
|
|
|
- price: Decimal::ZERO,
|
|
|
- amount: Decimal::ZERO,
|
|
|
- deal_amount: Decimal::ZERO,
|
|
|
- avg_price: Decimal::ZERO,
|
|
|
- status: "REMOVE".to_string(),
|
|
|
- order_type: "".to_string(),
|
|
|
- trace_stack: TraceStack::new(0, Instant::now()).on_special("374 htx_swap".to_string()),
|
|
|
- };
|
|
|
+ // 已经取消的订单不去撤单了
|
|
|
+ if !error.to_string().contains("Your order has been canceled") {
|
|
|
+ // 取消失败去查订单。
|
|
|
+ let query_rst = self_clone.get_order_detail(&order_id, &custom_id).await;
|
|
|
+ match query_rst {
|
|
|
+ Ok(order) => {
|
|
|
self_clone.order_sender.send(order).await.unwrap();
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ Err(err) => {
|
|
|
error!("撤单失败,而且查单也失败了,htx_swap,oid={}, cid={}, err={:?}。", order_id.clone(), custom_id.clone(), err);
|
|
|
}
|
|
|
}
|
|
|
+ self_clone.error_sender.send(error).await.unwrap();
|
|
|
}
|
|
|
- self_clone.error_sender.send(error).await.unwrap();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -587,9 +576,9 @@ pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
|
|
|
|
|
|
let status = order["status"].to_string();
|
|
|
|
|
|
- let custom_status = if ["6", "7", "11"].contains(&&**&status) {
|
|
|
+ let custom_status = if ["5", "6", "7"].contains(&&**&status) {
|
|
|
"REMOVE".to_string()
|
|
|
- } else if ["1", "2", "3", "4", "5"].contains(&&**&status) {
|
|
|
+ } else if ["1", "2", "3", "4"].contains(&&**&status) {
|
|
|
"NEW".to_string()
|
|
|
} else {
|
|
|
"NULL".to_string()
|