Commit a56f48b1 by xiaoqing.gu

修改处理数据后字段为空的bug

parent 9130a764
No preview for this file type
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>Static</UseOfMfc>
<PlatformToolset>v100</PlatformToolset> <PlatformToolset>v100</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
......
...@@ -21,7 +21,7 @@ using namespace std; ...@@ -21,7 +21,7 @@ using namespace std;
#include "fmtool.h" #include "fmtool.h"
#include "fmdatabase.h" #include "fmdatabase.h"
//#define FM_TEST #define FM_TEST
//#define FM_TESTS //#define FM_TESTS
#include "testdataprocess.h" #include "testdataprocess.h"
...@@ -368,7 +368,7 @@ time_t subDay(time_t time1,int days) ...@@ -368,7 +368,7 @@ time_t subDay(time_t time1,int days)
// //
//} //}
int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqType_i) int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqType_i, string &in)
{ {
LOG() << "ProcessPosReqData" << indata; LOG() << "ProcessPosReqData" << indata;
...@@ -378,7 +378,7 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy ...@@ -378,7 +378,7 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy
//json_t *root, *reqtype, *partnerId, *storeId, *stationId, *code, *transId, *businessDate; //json_t *root, *reqtype, *partnerId, *storeId, *stationId, *code, *transId, *businessDate;
//json_error_t error; //json_error_t error;
Document root; Document root, tmproot;
Value reqtype, partnerId, storeId, stationId, code, transId, businessDate; Value reqtype, partnerId, storeId, stationId, code, transId, businessDate;
string codestr; string codestr;
...@@ -397,6 +397,13 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy ...@@ -397,6 +397,13 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy
// return 0; // return 0;
//} //}
tmproot.Parse(indata);
if(tmproot.HasParseError())
{
LOG() << "error request json data!";
return 0;
}
root.Parse(indata); root.Parse(indata);
if(root.HasParseError()) if(root.HasParseError())
{ {
...@@ -540,7 +547,7 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy ...@@ -540,7 +547,7 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy
{ {
initflag = 1; initflag = 1;
} }
/*
time_t tt = time(NULL); time_t tt = time(NULL);
tm *t = localtime(&tt); tm *t = localtime(&tt);
tmps << t->tm_year + 1900 << std::setw(2) << std::setfill('0') << t->tm_mon + 1; tmps << t->tm_year + 1900 << std::setw(2) << std::setfill('0') << t->tm_mon + 1;
...@@ -556,8 +563,12 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy ...@@ -556,8 +563,12 @@ int ProcessPosReqData(const char *indata, int /**needrbk*/*needcheck, int *reqTy
if(type != 3) if(type != 3)
//json_object_set(root, JSON_KEY_ONLY, json_string(tmps.str().c_str())); //json_object_set(root, JSON_KEY_ONLY, json_string(tmps.str().c_str()));
root.AddMember(JSON_KEY_ONLY, string(tmps.str().c_str()), root.GetAllocator()); tmproot.AddMember(JSON_KEY_ONLY, Value().SetString(tmps.str().c_str(), strlen(tmps.str().c_str()), root.GetAllocator()), root.GetAllocator());
in = Tool::DocumentToString(tmproot);
LOG() << "*****:" << in;
/*
if(type == 71) if(type == 71)
{ {
tmpkey << codestr << transIdstr << json_integer_value(partnerId) << json_string_value(storeId) << json_string_value(stationId); tmpkey << codestr << transIdstr << json_integer_value(partnerId) << json_string_value(storeId) << json_string_value(stationId);
...@@ -938,20 +949,23 @@ __declspec(dllexport) int __stdcall GetValue(char *indata, char *outdata) ...@@ -938,20 +949,23 @@ __declspec(dllexport) int __stdcall GetValue(char *indata, char *outdata)
strcpy_s(buf, strlen(indata) + 1, indata); strcpy_s(buf, strlen(indata) + 1, indata);
LOG() << "BUF: " << buf; LOG() << "BUF: " << buf;
string tmpin(buf, MAX_BUF_LEN); string in(buf, MAX_BUF_LEN);
string tmpin;
LOG() << "tmpin: " << tmpin.c_str(); LOG() << "tmpin: " << tmpin.c_str();
int needcheck = 0; int needcheck = 0;
//POS请求数据的验证 //POS请求数据的验证
if(ProcessPosReqData(tmpin.c_str(), &needcheck, &reqType_i) != 1) if(ProcessPosReqData(in.c_str(), &needcheck, &reqType_i, tmpin) != 1)
{ {
strcpy(outdata, ERROR_INDATA); strcpy(outdata, ERROR_INDATA);
LOG() << "return error message to pos :" << outdata ; LOG() << "return error message to pos :" << outdata ;
return 0; return 0;
} }
LOG() << "ProcessPosReqData : " << tmpin;
//验证证书 //验证证书
if(global_info.useRSA == 1 && (global_info.serverpublickey.empty() || global_info.localprivatekey.empty())) if(global_info.useRSA == 1 && (global_info.serverpublickey.empty() || global_info.localprivatekey.empty()))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment