Kaynağa Gözat

coinex 订单详情格式化完善

JiahengHe 1 yıl önce
ebeveyn
işleme
ef3c73975a
1 değiştirilmiş dosya ile 24 ekleme ve 15 silme
  1. 24 15
      standard/src/coinex_swap.rs

+ 24 - 15
standard/src/coinex_swap.rs

@@ -344,25 +344,34 @@ impl Platform for CoinexSwap {
         }
 
         if res_data.code == 200 {
-            let res_data_json = res_data.data.as_array().unwrap();
-            if res_data_json.len() == 0 { // 已取消或已成交
-                return Ok(Order{
-                    id: order_id.to_string(),
-                    custom_id: custom_id.to_string(),
-                    price: Default::default(),
-                    amount: Default::default(),
-                    deal_amount: Default::default(),
-                    avg_price: Default::default(),
-                    status: "REMOVE".to_string(),
-                    order_type: "".to_string(),
-                    trace_stack: TraceStack::new(0, Instant::now()).on_special("358 coinex_swap".to_string()),
-                })
-            } else { // 待成交
-                let mut result = format_order_item(res_data_json[0].clone(), ct_val, status);
+            info!("order_detail {}", res_data.data);
+            if res_data.data.is_array() {
+                let res_data_json = res_data.data.as_array().unwrap();
+                if res_data_json.len() == 0 { // 已取消或已成交
+                    return Ok(Order{
+                        id: order_id.to_string(),
+                        custom_id: custom_id.to_string(),
+                        price: Default::default(),
+                        amount: Default::default(),
+                        deal_amount: Default::default(),
+                        avg_price: Default::default(),
+                        status: "REMOVE".to_string(),
+                        order_type: "".to_string(),
+                        trace_stack: TraceStack::new(0, Instant::now()).on_special("358 coinex_swap".to_string()),
+                    })
+                } else { // 待成交
+                    let mut result = format_order_item(res_data_json[0].clone(), ct_val, status);
+                    result.custom_id = custom_id.to_string();
+                    result.id = order_id.to_string();
+                    Ok(result)
+                }
+            } else {
+                let mut result = format_order_item(res_data.data, ct_val, status);
                 result.custom_id = custom_id.to_string();
                 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();