浏览代码

撤单信息打印 移除撤单中状态

JiahengHe 1 年之前
父节点
当前提交
b9546c06e4
共有 3 个文件被更改,包括 18 次插入28 次删除
  1. 14 25
      standard/src/htx_swap.rs
  2. 2 2
      standard/src/htx_swap_handle.rs
  3. 2 1
      strategy/src/htx_usdt_swap.rs

+ 14 - 25
standard/src/htx_swap.rs

@@ -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()

+ 2 - 2
standard/src/htx_swap_handle.rs

@@ -53,9 +53,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()

+ 2 - 1
strategy/src/htx_usdt_swap.rs

@@ -114,7 +114,8 @@ async fn on_private_data(core_arc_clone: Arc<Mutex<Core>>,
                 error!("htx_usdt_swap 未识别的订单状态:{:?}", response);
                 continue;
             }
-            let order_info = OrderInfo::parse_order_to_order_info(&mut order);
+            let mut order_info = OrderInfo::parse_order_to_order_info(&mut order);
+            order_info.trace_stack.source = "htx_usdt_swap 118".to_string();
             order_infos.push(order_info);
         }