Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sbkclient
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李定达
sbkclient
Commits
e6d84eeb
Commit
e6d84eeb
authored
Apr 23, 2018
by
xiaoqing.gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、增加获取mac地址的方法 2、增加请求头host可配置字段
parent
7abe9394
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
110 additions
and
25 deletions
+110
-25
ZH_Client.suo
+0
-0
ZH_Client/Release/ZH_Client.log
+4
-4
ZH_Client/ZH_Client.vcxproj
+2
-2
ZH_Client/dataprocess.h
+0
-0
ZH_Client/filesystem.h
+2
-1
ZH_Client/fmglobal.h
+11
-2
ZH_Client/fmtool.h
+49
-2
ZH_Client/sbk_client.cpp
+42
-14
No files found.
ZH_Client.suo
View file @
e6d84eeb
No preview for this file type
ZH_Client/Release/ZH_Client.log
View file @
e6d84eeb
生成启动时间为 2018/
3/30 15:38:32
。
1>项目“D:\FM\sbkClient\ZH_Client\ZH_Client.vcxproj”在节点 2 上(
re
build 个目标)。
生成启动时间为 2018/
4/18 16:53:17
。
1>项目“D:\FM\sbkClient\ZH_Client\ZH_Client.vcxproj”在节点 2 上(build 个目标)。
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(518,5): error MSB8008: 指定的平台工具集(v110)未安装或无效。请确保选择受支持的 PlatformToolset 值。
1>已完成生成项目“D:\FM\sbkClient\ZH_Client\ZH_Client.vcxproj”(
re
build 个目标)的操作 - 失败。
1>已完成生成项目“D:\FM\sbkClient\ZH_Client\ZH_Client.vcxproj”(build 个目标)的操作 - 失败。
生成失败。
已用时间 00:00:00.0
1
已用时间 00:00:00.0
6
ZH_Client/ZH_Client.vcxproj
View file @
e6d84eeb
...
...
@@ -18,14 +18,14 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>
Application
</ConfigurationType>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>
Application
</ConfigurationType>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
...
...
ZH_Client/dataprocess.h
View file @
e6d84eeb
ZH_Client/filesystem.h
View file @
e6d84eeb
...
...
@@ -4,9 +4,10 @@
#include <string>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Winbase.h>
#include <winsock.h>
#include <winsock
2
.h>
#include <DbgHelp.h>
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "fmcrypt.lib")
...
...
ZH_Client/fmglobal.h
View file @
e6d84eeb
...
...
@@ -10,8 +10,17 @@
#define MAX_SIGN_LEN 256
#define CFG_FILE_NAME "fmclient.cfg"
#define RBG_FILE_NAME "fmclient.rbk"
#define REQUEST_CRET "{\r\n \"ver\": 1,\r\n \"reqType\": 99,\r\n \"partnerId\":%d,\r\n \"storeId\":\"%s\",\r\n \"stationId\": \"%s\"\r\n}"
#define DES3_KEY "ABCD@#9876DFSAAWKLDEOPDD"
#define REQUEST_CRET "{\"ver\": 1,\"reqType\": 99,\"partnerId\":%d,\"storeId\":\"%s\",\"stationId\": \"%s\",\"mac\":\"%s\",\"posType\":%d}"
//#define REQUEST_CRET "{\"ver\": 1,\"reqType\": 99,\"partnerId\":%d,\"storeId\":\"%s\",\"stationId\": \"%s\",\"mac\":\"%s\"}"
//GC
//#define DES3_KEY "ABCD@#9876DFSAAWKLDEOPDD"
//EC
#define DES3_KEY "DDDDEEEE45LPODDCXZZLKDDO"
#define CRET_FILE_NAME "client.p12"
#define JSON_KEY_ONLY "partnerOrderId"
...
...
ZH_Client/fmtool.h
View file @
e6d84eeb
...
...
@@ -10,17 +10,64 @@
#include <rapidjson\prettywriter.h>
#include <rapidjson\stringbuffer.h>
#include <Windows.h>
#include "fmglobal.h"
#include "fmlog.h"
#include "filesystem.h"
#include <winsock2.h>
#include <iphlpapi.h>
#pragma comment(lib, "IPHLPAPI.lib")
using
namespace
rapidjson
;
class
Tool
{
public
:
static
int
GetMacByGetAdaptersAddresses
(
std
::
string
&
macOUT
)
{
bool
ret
=
0
;
ULONG
outBufLen
=
sizeof
(
IP_ADAPTER_ADDRESSES
);
PIP_ADAPTER_ADDRESSES
pAddresses
=
(
IP_ADAPTER_ADDRESSES
*
)
malloc
(
outBufLen
);
if
(
pAddresses
==
NULL
)
return
0
;
// Make an initial call to GetAdaptersAddresses to get the necessary size into the ulOutBufLen variable
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
0
,
NULL
,
pAddresses
,
&
outBufLen
)
==
ERROR_BUFFER_OVERFLOW
)
{
free
(
pAddresses
);
pAddresses
=
(
IP_ADAPTER_ADDRESSES
*
)
malloc
(
outBufLen
);
if
(
pAddresses
==
NULL
)
return
0
;
}
if
(
GetAdaptersAddresses
(
AF_UNSPEC
,
0
,
NULL
,
pAddresses
,
&
outBufLen
)
==
NO_ERROR
)
{
// If successful, output some information from the data we received
for
(
PIP_ADAPTER_ADDRESSES
pCurrAddresses
=
pAddresses
;
pCurrAddresses
!=
NULL
;
pCurrAddresses
=
pCurrAddresses
->
Next
)
{
// 确保MAC地址的长度为 00-00-00-00-00-00
if
(
pCurrAddresses
->
PhysicalAddressLength
!=
6
)
continue
;
char
acMAC
[
32
];
sprintf
(
acMAC
,
"%02X-%02X-%02X-%02X-%02X-%02X"
,
int
(
pCurrAddresses
->
PhysicalAddress
[
0
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
1
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
2
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
3
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
4
]),
int
(
pCurrAddresses
->
PhysicalAddress
[
5
]));
macOUT
=
acMAC
;
ret
=
1
;
break
;
}
}
free
(
pAddresses
);
return
ret
;
}
static
int
ReadTMPForType
(
char
*
tplt
,
int
reqType
)
{
char
tmp
[
MAX_BUF_LEN
]
=
{
0
};
...
...
ZH_Client/sbk_client.cpp
View file @
e6d84eeb
...
...
@@ -21,7 +21,7 @@ using namespace std;
#include "fmtool.h"
#include "fmdatabase.h"
#define FM_TEST
//
#define FM_TEST
//#define FM_TESTS
#include "testdataprocess.h"
...
...
@@ -61,6 +61,10 @@ typedef struct
int
isrollback
;
//是否需要查询
int
ischeck
;
//区分simphony
int
posType
;
//host
string
host
;
}
BaseInfo
;
...
...
@@ -323,8 +327,11 @@ int InitClient()
global_info
.
shrottimeout
=
atoi
(
tmp
.
c_str
());
getline
(
istm
,
tmp
);
global_info
.
useRSA
=
atoi
(
tmp
.
c_str
());
getline
(
istm
,
tmp
);
global_info
.
posType
=
atoi
(
tmp
.
c_str
());
getline
(
istm
,
global_info
.
host
);
istm
.
close
();
LOG
()
<<
"cretserverurl:"
<<
global_info
.
cretserverurl
<<
";serverurl:"
<<
global_info
.
serverurl
<<
";longtime:"
<<
global_info
.
longtimeout
<<
";shortime:"
<<
global_info
.
shrottimeout
<<
";useRSA:"
<<
global_info
.
useRSA
;
LOG
()
<<
"cretserverurl:"
<<
global_info
.
cretserverurl
<<
";serverurl:"
<<
global_info
.
serverurl
<<
";longtime:"
<<
global_info
.
longtimeout
<<
";shortime:"
<<
global_info
.
shrottimeout
<<
";useRSA:"
<<
global_info
.
useRSA
<<
";posType:"
<<
global_info
.
posType
;
LOG
()
<<
"key: "
<<
global_info
.
localprivatekey
<<
global_info
.
serverpublickey
;
if
(
global_info
.
serverpublickey
.
empty
()
||
global_info
.
localprivatekey
.
empty
())
...
...
@@ -1248,6 +1255,8 @@ int SendMsg(const std::string &text, const string &url, int iscret)
headers
=
curl_slist_append
(
headers
,
"Content-Type:text/json;charset=utf-8"
);
headers
=
curl_slist_append
(
headers
,
"Accept:application/json"
);
headers
=
curl_slist_append
(
headers
,
"Authorization: Basic dXBzLWNsaWVudDo2VGk4TjBXNzRyb1A="
);
headers
=
curl_slist_append
(
headers
,
string
(
"Host:"
).
append
(
global_info
.
host
).
c_str
());
}
else
{
...
...
@@ -1255,6 +1264,7 @@ int SendMsg(const std::string &text, const string &url, int iscret)
headers
=
curl_slist_append
(
headers
,
"Content-Type:text;charset=utf-8"
);
headers
=
curl_slist_append
(
headers
,
"Accept:text"
);
headers
=
curl_slist_append
(
headers
,
"Authorization: Basic dXBzLWNsaWVudDo2VGk4TjBXNzRyb1A="
);
headers
=
curl_slist_append
(
headers
,
string
(
"Host:"
).
append
(
global_info
.
host
).
c_str
());
}
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
...
...
@@ -1412,6 +1422,10 @@ int CheckCret()
//json_decref(root);
return
1
;
}
/******************************************
*GetCret :从签名服务获取************/
...
...
@@ -1437,9 +1451,26 @@ int CheckCret()
return
1
;
}
//获取mac地址
std
::
string
macOut
;
Tool
::
GetMacByGetAdaptersAddresses
(
macOut
);
LOG
()
<<
macOut
;
char
outmsg
[
MAX_BUF_LEN
]
=
{
0
};
int
legth
=
0
;
if
((
legth
=
DataProcess
::
DES3Encode
((
const
unsigned
char
*
)
DES3_KEY
,
macOut
.
c_str
(),
macOut
.
length
(),
(
unsigned
char
*
)
outmsg
,
MAX_BUF_LEN
))
==
0
)
{
LOG
()
<<
"3DES encode failed"
;
return
0
;
}
LOG
()
<<
"3DES Encode(base64):"
<<
outmsg
;
char
request
[
MAX_BUF_LEN
]
=
{
0
};
sprintf_s
(
request
,
MAX_BUF_LEN
,
REQUEST_CRET
,
partnerId
,
storeID
,
posNo
);
sprintf_s
(
request
,
MAX_BUF_LEN
,
REQUEST_CRET
,
partnerId
,
storeID
,
posNo
,
outmsg
,
global_info
.
posType
);
LOG
()
<<
request
;
...
...
@@ -1448,18 +1479,13 @@ int CheckCret()
//if(GetRealJson(req, std::string(request)) == 0)
// return 0;
char
outmsg
[
MAX_BUF_LEN
]
=
{
0
};
int
legth
=
0
;
if
((
legth
=
DataProcess
::
DES3Encode
((
const
unsigned
char
*
)
DES3_KEY
,
req
.
c_str
(),
req
.
length
(),
(
unsigned
char
*
)
outmsg
,
MAX_BUF_LEN
))
==
0
)
{
LOG
()
<<
"3DES encode failed"
;
return
0
;
}
LOG
()
<<
"3DES Encode(base64):"
<<
outmsg
;
#ifndef FM_TESTS
if
(
SendMsg
(
string
(
outmsg
),
global_info
.
cretserverurl
,
1
)
==
0
)
if
(
SendMsg
(
string
(
request
),
global_info
.
cretserverurl
,
1
)
==
0
)
{
LOG
()
<<
"recive data from:"
<<
global_info
.
cretserverurl
<<
" failed"
;
return
0
;
...
...
@@ -1516,9 +1542,11 @@ void testinitclient()
//char a[] = "{\"ver\":1,\"partnerId\":1234,\"reqType\": 62,\"coupon\": \"122222222222\",\"stationId\": \"1\",\"storeId\": \"999999\",\"operator_id\": \"00000002\" }";
//char a[] = "{\r\n \"pay_transId\":\"2017052600001162504297\",\r\n \"total_amount\":1,\r\n \"mcoupon_amount\":0,\r\n \"alipay_amount\":1,\r\n \"pay_ebcode\":\"10010\",\r\n \"ver\":1,\r\n \"fmId\":\"SXA1377O27012186844\",\r\n \"pay_date\":\"2017-05-26 17:01:16.004\",\r\n \"statusCode\":100\r\n}";
//char a[] = "{\"businessDate\":\"20170526\",\"code\":\"7310180009462033\",\"operatorId\":\"90001\",\"partnerId\":1443,\"products\":[{\"consume_num\":1,\"discount\":0,\"name\":\"Coffee\",\"number\":0,\"payment\":null,\"pid\":\"3488\",\"price\":3100,\"priceAct\":0,\"salesType\":\"Normal\",\"scope\":null}],\"promotionTag\":null,\"reqType\":71,\"stationId\":\"3\",\"storeId\":\"1713\",\"transAmount\":3100,\"transId\":\"6460\",\"undiscountAmount\":0,\"ver\":1}";
//char a[] = "{\r\n \"ver\": \"1\",\r\n \"reqType\": 0,\r\n \"partnerId\": 1443,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"16171\",\r\n \"operatorId\": \"9\",\r\n \"code\": \"120983475638559\"\r\n}";
char
a
[]
=
"{
\r\n
\"
ver
\"
: 1,
\r\n
\"
reqType
\"
: 0,
\r\n
\"
partnerId
\"
: 1443,
\r\n
\"
stationId
\"
:
\"
1
\"
,
\r\n
\"
storeId
\"
:
\"
16171
\"
,
\r\n
\"
operatorId
\"
:
\"
9
\"
,
\r\n
\"
code
\"
:
\"
120520219319771
\"\r\n
}"
;
//char a[] = "{\r\n \"transAmount\": 100,\r\n \"ver\": 1,\r\n \"reqType\": 0,\r\n \"partnerId\": 1446,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"160205\",\r\n \"operatorId\": \"9\",\r\n \"code\": \"231911841939438065993\",\r\n \"action\":\"101\",\r\n \"products\":[\r\n {\r\n \"number\":0,\r\n \"priceAct\": 0,\r\n \"price\": 1,\r\n \"name\":\"Coffee\",\r\n \"discount\": 0,\r\n \"pid\":\"1112134\",\r\n \"consumeNum\":0,\r\n \"categoryId\":\"11\",\r\n \"selected\":\"1\"\r\n }\r\n ]\r\n}";
//char a[] = "{\r\n \"ver\": \"1\",\r\n \"reqType\": 71,\r\n \"partnerId\": 1443,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"16171\",\r\n \"operatorId\": \"9\",\r\n \"code\": \"120884658694630\",\r\n \"transId\":\"333388\",\r\n \"businessDate\":\"20180402\",\r\n \"partnerOrderId\":\"144316171120180402094813\"\r\n}";
char
a
[]
=
"{
\r\n
\"
ver
\"
:
\"
1
\"
,
\r\n
\"
reqType
\"
: 100,
\r\n
\"
partnerId
\"
: 1443,
\r\n
\"
stationId
\"
:
\"
1
\"
,
\r\n
\"
storeId
\"
:
\"
16171
\"
,
\r\n
\"
operatorId
\"
:
\"
9
\"
,
\r\n
\"
code
\"
:
\"
120884658694630
\"
,
\r\n
\"
transId
\"
:
\"
144316171920180402061907
\"
,
\r\n
\"
businessDate
\"
:
\"
20180402
\"\r\n
}"
;
//char a[] = "{\r\n \"ver\": \"1\",\r\n \"reqType\": 100,\r\n \"partnerId\": 1446,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"160205
\",\r\n \"operatorId\": \"9\",\r\n \"code\": \"120884658694630\",\r\n \"transId\":\"144316171920180402061907\",\r\n \"businessDate\":\"20180402\"\r\n}";
//char a[] = "{\r\n \"businessDate\": \"20170601\",\r\n \"code\": \"120522852861225\",\r\n \"operatorId\": \"90001\",\r\n \"partnerId\": 1438,\r\n \"partnerOrderId\": \"1443171223323\",\r\n \"products\": [\r\n {\r\n \"consume_num\": 1,\r\n \"discount\": 0,\r\n \"name\": \"Coffee\",\r\n \"number\": 0,\r\n \"payment\": null,\r\n \"pid\": \"3488\",\r\n \"price\": 3100,\r\n \"priceAct\": 0,\r\n \"salesType\": \"Normal\",\r\n \"scope\": null\r\n }\r\n ],\r\n \"promotionTag\": null,\r\n \"reqType\": 0,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"16171\",\r\n \"transAmount\": 29,\r\n \"transId\": \"1\",\r\n \"undiscountAmount\": 0,\r\n \"ver\": 1\r\n}";
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment