admin
8 天以前 6cd92a169cbc0db35042f243a09d976fd3e1445c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <string>
#include "../common/NetworkApi.h"
#include "../common/JsonUtil.h"
#include "DataStruct.h"
class MyApi {
 
public:
    static list<SellRule> listSellRules() {
        string result = NetworkApi::list_sell_rules();
        auto doc = JsonUtil::parseUTF16(result);
        if (doc.IsObject()) {
            if (doc[L"code"].GetInt() == 0) {
                auto array = doc[L"data"].GetArray();
                list<SellRule> rules;
                for (int i = 0; i < array.Size(); i++) {
                    SellRule rule;
                    rule.code = array[i][L"code"].GetString();
                    rule.id_ = array[i][L"id_"].GetString();
                    rule.buy1_volume = array[i][L"buy1_volume"].GetInt() / 100;
                    rule.buy1_price = array[i][L"buy1_price"].GetString();
                    rule.sell_volume = array[i][L"sell_volume"].GetInt();
                    rule.sell_price_type = array[i][L"sell_price_type"].GetInt();
                    rule.create_time = array[i][L"create_time"].GetString();
                    rule.excuted = array[i][L"excuted"].GetInt();
                    rule.end_time = array[i][L"end_time"].GetString();
                    rule.type = array[i][L"type"].GetInt();
                    rules.push_back(rule);
                }
                return rules;
            }
            else {
                throw CString(doc[L"msg"].GetString());
            }
        }
        else {
            throw CString("ÍøÂçÇëÇó³ö´í");
        }
    }
 
    static Buy1Info getBuy1Info(string code) {
        string result = NetworkApi::get_buy1_info(code);
        auto doc = JsonUtil::parseUTF16(result);
        if (doc.IsObject()) {
            if (doc[L"code"].GetInt() == 0) {
            
                    int volume = doc[L"data"][L"volume"].GetInt();
                    double price = doc[L"data"][L"price"].GetDouble();
                    return Buy1Info({volume, price});
                
            }
            else {
                throw CString(doc[L"msg"].GetString());
            }
        }
        else {
            throw CString("ÍøÂçÇëÇó³ö´í");
        }
    }
 
 
};