hardware_cmd.h
3.42 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#ifndef ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED
#define ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <vector>
class HardwareCmd
{
// Return a boost ptree node as a reply data, we don't return reply as "std::string" type because
// it will cause some trouble when construct a result JSON string if the data is alreay a JSON string.
// It will add redundant back slash character ("\") in the JSON string.
typedef boost::property_tree::ptree ReplyData;
public:
struct Reply
{
ReplyData data;
std::string error_code;
};
//卡片安全等级
enum SecurityLevel
{
SL_0 = 0, // 0表示最低级,不替换秘钥,不写入业务信息,不做安全认证
SL_1, // 等级1需要替换秘钥,写入业务信息,不做安全认证
SL_2 // 等级2需要替换秘钥,写入业务信息,需要安全认证
};
//秘钥加密方式
enum EncryptType
{
ET_PWM = 0, //加密机方式加密
ET_DES = 1 //des算法加密
};
virtual ~HardwareCmd() {}
/*Exception will be thrown if any error happens.*/
virtual Reply Execute(const std::string& input) = 0;
};
class ReadPINPadCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class ReadIDCardCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class ActivateDILICardCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class ResetDILICardCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class ReadDILICardBasicInfoCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class ReadDILICardServiceInfoCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class WriteDILICardServiceInfoCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
class ReadBankCardNumCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
//中央结算特殊需求,一个接口先刷园区卡再刷银行卡
class ReadDILIAndBankCardNumCmd : public HardwareCmd
{
public:
virtual Reply Execute(const std::string& input) override;
};
//
//针式打印机接口
class StylusPrinterCmd : public HardwareCmd
{
struct CommInfo
{
long comm_id;
CString comm_name;
CString price;
CString count;
CString total_money;
};
struct OrderInfo
{
CString doc_name;
CString statements_no;
CString trade_time;
CString buyer_name;
CString seller_name;
CString settlement_clerk;
CString total_money;
std::vector<CommInfo> comm_vector;
};
public:
virtual Reply Execute(const std::string& input) override;
private:
std::string ParseInput(std::string &input, std::vector<OrderInfo> &order_vector);
std::string Print(std::vector<OrderInfo> &order_vector);
};
//
//分发打印接口
class DistributePrinterCmd : public HardwareCmd
{
struct CommInfo
{
CString product_name;
CString amount;
CString place;
CString brand;
};
struct OrderInfo
{
CString title;
CString reg_id;
CString sheet_id;
CString entry_fee;
CString seller_name;
CString dis_name;
CString dis_date;
std::vector<CommInfo> comm_vector;
};
public:
virtual Reply Execute(const std::string& input) override;
private:
std::string ParseInput(const std::string &input, std::vector<OrderInfo> &order_vector);
std::string Print(std::vector<OrderInfo> &order_vector);
};
//
#endif // ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED