Commit f3aa75b6 by 李定达

1.导出RES接口函数RESGetValue;2.修复已知bug

parent 74df51c9
No preview for this file type
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</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>Application</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define DES3_KEY "ABCD@#9876DFSAAWKLDEOPDD" #define DES3_KEY "ABCD@#9876DFSAAWKLDEOPDD"
#define CRET_FILE_NAME "client.p12" #define CRET_FILE_NAME "client.p12"
#define JSON_KEY_ONLY "partnerOrderId" #define JSON_KEY_ONLY "partnerOrderId"
#define JSON_KEY_FMTEST "test"
#define CFG_KEY "template" #define CFG_KEY "template"
#define TMP_JSON "json.ini" #define TMP_JSON "json.ini"
......
...@@ -259,7 +259,7 @@ bool Response0ToRES(const string &indata, string &outdata) ...@@ -259,7 +259,7 @@ bool Response0ToRES(const string &indata, string &outdata)
//paymentMethod //paymentMethod
json_t *paymentMethod = json_object_get(root, "paymentMethod"); json_t *paymentMethod = json_object_get(root, "paymentMethod");
if (message != NULL || json_is_string(paymentMethod)) if (paymentMethod != NULL || json_is_string(paymentMethod))
{ {
rsp.data[9] = json_string_value(paymentMethod); rsp.data[9] = json_string_value(paymentMethod);
} }
...@@ -551,7 +551,7 @@ bool Response71ToRES(const string &indata, string &outdata) ...@@ -551,7 +551,7 @@ bool Response71ToRES(const string &indata, string &outdata)
//paymentMethod //paymentMethod
json_t *paymentMethod = json_object_get(root, "paymentMethod"); json_t *paymentMethod = json_object_get(root, "paymentMethod");
if (message != NULL || json_is_string(paymentMethod)) if (paymentMethod != NULL || json_is_string(paymentMethod))
{ {
rsp.data[9] = json_string_value(paymentMethod); rsp.data[9] = json_string_value(paymentMethod);
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
int _reqType = -1; int _reqType = -1;
#define FM_TEST //#define FM_TEST
//#define FM_TESTS //#define FM_TESTS
#include "testdataprocess.h" #include "testdataprocess.h"
...@@ -418,6 +418,10 @@ int ProcessPosReqData(const char *indata, string &in, int *needrbk, int *reqType ...@@ -418,6 +418,10 @@ int ProcessPosReqData(const char *indata, string &in, int *needrbk, int *reqType
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()));
#ifdef FM_TEST
json_object_set(root, JSON_KEY_FMTEST, json_string("test"));
#endif
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);
...@@ -749,6 +753,56 @@ endflag: ...@@ -749,6 +753,56 @@ endflag:
return 1; return 1;
} }
} }
extern "C"
{
__declspec(dllexport) int _stdcall RESGetValue(char *indata, char *outdata)
{
char buf[MAX_BUF_LEN] = { 0 };
strcpy_s(buf, strlen(indata) + 1, indata);
string tmpin(buf);
string out;
LOG() << "get RES indata : " << indata;
if(!RESToJson(tmpin, out) && out.size() >= MAX_BUF_LEN)
{
string outstr;
JsonToRES(string(ERROR_INDATA), outstr);
strcpy(outdata, outstr.data());
LOG() << "send RES outdata : " << outdata;
return 0;
}
char bufin[MAX_BUF_LEN] = {0};
char bufout[MAX_BUF_LEN] = {0};
strcpy(bufin, out.data());
GetValue(bufin, bufout);
string strin(bufout);
string strout;
if(!JsonToRES(strin, strout) && strout.size() >= MAX_BUF_LEN)
{
string outstr;
JsonToRES(string(ERROR_OUTDATA), outstr);
strcpy(outdata, outstr.data());
LOG() << "send RES outdata : " << outdata;
return 0;
}
strcpy(outdata, strout.data());
LOG() << "send RES outdata : " << outdata;
return 1;
}
};
size_t GetDataForServer(void* buffer, size_t size, size_t nmemb, void *userdata) size_t GetDataForServer(void* buffer, size_t size, size_t nmemb, void *userdata)
{ {
unsigned int i = size * nmemb; unsigned int i = size * nmemb;
...@@ -1156,6 +1210,10 @@ void testinitclient() ...@@ -1156,6 +1210,10 @@ void testinitclient()
//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[] = "{\"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\": 71,\r\n \"partnerId\": 1443,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"12344\",\r\n \"operatorId\": \"9\",\r\n \"code\": \"adadadada\"\r\n}"; //char a[] = "{\r\n \"ver\": 1,\r\n \"reqType\": 71,\r\n \"partnerId\": 1443,\r\n \"stationId\": \"1\",\r\n \"storeId\": \"12344\",\r\n \"operatorId\": \"9\",\r\n \"code\": \"adadadada\"\r\n}";
char a[] = "{\r\n \"businessDate\": \"20170601\",\r\n \"code\": \"7310188850000277\",\r\n \"operatorId\": \"90001\",\r\n \"partnerId\": 1443,\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\": 102,\r\n \"stationId\": \"9\",\r\n \"storeId\": \"12344\",\r\n \"transAmount\": 29,\r\n \"transId\": \"1\",\r\n \"undiscountAmount\": 0,\r\n \"ver\": 1\r\n}"; char a[] = "{\r\n \"businessDate\": \"20170601\",\r\n \"code\": \"7310188850000277\",\r\n \"operatorId\": \"90001\",\r\n \"partnerId\": 1443,\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\": 102,\r\n \"stationId\": \"9\",\r\n \"storeId\": \"12344\",\r\n \"transAmount\": 29,\r\n \"transId\": \"1\",\r\n \"undiscountAmount\": 0,\r\n \"ver\": 1\r\n}";
char ls[] = "0|1443|99999|1|01|13245678998|END|";
char ls1[] = "3|1443|99999|1|01|13245678998|20170714||8888|END|";
char ls2[] = "71|1443|99999|1|01|13245678998|20170714||8888|END|";
void testCheckRollbackData() void testCheckRollbackData()
{ {
InitClient(); InitClient();
...@@ -1166,13 +1224,11 @@ int main() ...@@ -1166,13 +1224,11 @@ int main()
{ {
_reqType = 3; _reqType = 3;
TestRESToJson(); //TestRESToJson();
TestJsonToRES(); //TestJsonToRES();
char storeid[] = "12344"; char storeid[] = "12344";
char posno[] = "01"; char posno[] = "01";
//TestComplementJson(); //TestComplementJson();
//Test_RSASign(); //Test_RSASign();
...@@ -1187,6 +1243,8 @@ int main() ...@@ -1187,6 +1243,8 @@ int main()
char b[MAX_BUF_LEN]; char b[MAX_BUF_LEN];
RESGetValue(ls2, b);
//char c[MAX_BUF_LEN] = { 0 }; //char c[MAX_BUF_LEN] = { 0 };
//strcpy(c, TEST_CG); //strcpy(c, TEST_CG);
......
...@@ -10,9 +10,9 @@ using std::string; ...@@ -10,9 +10,9 @@ using std::string;
//char buf[] = "\{\"a\": 8}"; //char buf[] = "\{\"a\": 8}";
char buf[] = "{\n \"ext\": {\n \"hint\": \"shiping85zheyouhuiquan 7310183410017522691\"\n },\n \"paymentMethodCode\": \"80022\",\n \"actInfo\": {\n \"actId\": \"1402007\",\n \"actName\": \"zhekouquan20000451\",\n \"code\": \"7310183410017522691=4F28F2E86561C03F\"\n },\n \"fmId\": \"2691170714Z10000001\",\n \"ver\": 1,\n \"paymentMethod\": \"dianzhiquan-zhekoquan\",\n \"message\": \"chenggong\",\n \"type\": 3,\n \"statusCode\": 100\n}"; char buf[] = "{\n \"ext\": {\n \"hint\": \"shiping85zheyouhuiquan 7310183410017522691\"\n },\n \"paymentMethodCode\": \"80022\",\n \"actInfo\": {\n \"actId\": \"1402007\",\n \"actName\": \"zhekouquan20000451\",\n \"code\": \"7310183410017522691=4F28F2E86561C03F\"\n },\n \"fmId\": \"2691170714Z10000001\",\n \"ver\": 1,\n \"paymentMethod\": \"dianzhiquan-zhekoquan\",\n \"message\": \"chenggong\",\n \"type\": 3,\n \"statusCode\": 100\n}";
char ls[] = "0|1443|0001|FOE13|01|123456789987654321|END|"; static char ls[] = "0|1443|0001|FOE13|01|123456789987654321|END|";
char ls1[] = "3|1443|0001|FOE13|01|123456789987654321|20170714||8888|END|"; static char ls1[] = "3|1443|0001|FOE13|01|123456789987654321|20170714||8888|END|";
char ls2[] = "71|1443|0001|FOE13|01|123456789987654321|20170714||8888|END|"; static char ls2[] = "71|1443|0001|FOE13|01|123456789987654321|20170714||8888|END|";
void TestRESToJson() void TestRESToJson()
......
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