소스 검색

coinex 查单remove添加

JiahengHe 1 년 전
부모
커밋
8757f10755
1개의 변경된 파일12개의 추가작업 그리고 15개의 파일을 삭제
  1. 12 15
      standard/src/coinex_swap.rs

+ 12 - 15
standard/src/coinex_swap.rs

@@ -339,7 +339,7 @@ impl Platform for CoinexSwap {
             res_data = self.request.get_order_details(order_id.to_string(), symbol).await;
         } else if custom_id != "" {
             // 通过客户端id查询  只有未完成的订单才能查询出来
-            res_data = self.request.get_pending_order(format!("t-{}", custom_id)).await;
+            res_data = self.request.get_pending_order(custom_id.to_string()).await;
             status = "open";
         } else {
             return Err(Error::new(ErrorKind::Other, format!("订单id和客户端id都为空,查询失败!order_id :{}, custom_id: {}", order_id, custom_id)));
@@ -373,12 +373,6 @@ impl Platform for CoinexSwap {
                 result.id = order_id.to_string();
                 Ok(result)
             }
-        } else if res_data.code == -1 && res_data.message.contains("3103:order not exists") { // 未成交已取消的订单会报不存在
-            let mut order = Order::new();
-            order.id = order_id.to_string();
-            order.custom_id = custom_id.to_string();
-            order.status = "REMOVE".to_string();
-            Ok(order)
         } else {
             Err(Error::new(ErrorKind::Other, res_data.to_string()))
         }
@@ -523,12 +517,6 @@ impl Platform for CoinexSwap {
                 result.id = order_id.to_string();
             }
             Ok(result)
-        } else if res_data.code == -1 && res_data.message.contains("3103:order not exists") { // 未成交已取消的订单会报不存在
-            let mut order = Order::new();
-            order.id = order_id.to_string();
-            order.custom_id = custom_id.to_string();
-            order.status = "REMOVE".to_string();
-            Ok(order)
         } else {
             let message = format!("撤单HTTP请求失败  order_id: {}, custom_id: {}, res_data: {:?}", order_id, custom_id, res_data);
             Err(Error::new(ErrorKind::Other, message))
@@ -666,7 +654,16 @@ impl Platform for CoinexSwap {
                                 self_clone.order_sender.send(order).await.unwrap();
                             }
                             Err(err) => {
-                                warn!("撤单失败,而且查单也失败了,Coinex_io_swap,oid={}, cid={} err={:?}", order_id.clone(), custom_id.clone(), err);
+                                // 未成交已取消的订单会报不存在
+                                if err.to_string().contains("3103:order not exists") {
+                                    let mut order = Order::new();
+                                    order.id = order_id.to_string();
+                                    order.custom_id = custom_id.to_string();
+                                    order.status = "REMOVE".to_string();
+                                    self_clone.order_sender.send(order).await.unwrap();
+                                } else {
+                                    warn!("撤单失败,而且查单也失败了,Coinex_io_swap,oid={}, cid={} err={:?}", order_id.clone(), custom_id.clone(), err);
+                                }
                                 // panic!("撤单失败,而且查单也失败了,Coinex_io_swap,oid={}, cid={}。", order_id.clone(), custom_id.clone());
                             }
                         }
@@ -765,7 +762,7 @@ pub fn format_order_item(order: Value, ct_val: Decimal, status: &str) -> Order {
     };
     let rst_order = Order {
         id: order["order_id"].to_string(),
-        custom_id: text.replace("t-my-custom-id_", "").replace("t-", ""),
+        custom_id: text.to_string(),
         price: Decimal::from_str(order["price"].as_str().unwrap()).unwrap(),
         amount,
         deal_amount,