Commit 2483b050 by guanghui.cui

格式修改

parent d746014e
...@@ -133,7 +133,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -133,7 +133,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order.create_time = createTime.GetString(); order.create_time = createTime.GetString();
//用户信息 //用户信息
//TODO 顾客信息为数组 因接口改版目前只有一个顾客信息 //TODO 顾客信息为数组 因接口改版目前只有一个顾客信息
rapidjson::Value& customer_array = orderContent_obj["customer"]; rapidjson::Value& customer_array = orderContent_obj["customer"];
if(customer_array.IsArray()) if(customer_array.IsArray())
{ {
...@@ -276,10 +276,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -276,10 +276,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
{ {
rapidjson::Value& points_obj = orderContent_obj["points"]; rapidjson::Value& points_obj = orderContent_obj["points"];
rapidjson::Value& totalPoint= points_obj["totalPoint"]; rapidjson::Value& totalPoint= points_obj["totalPoint"];
char temp[20]={0}; order.bonusInfo.summary = std::to_string(totalPoint.GetInt());
int iPoint=totalPoint.GetInt();
sprintf(temp, "%d", iPoint);
order.bonusInfo.summary = temp;
//积分信息详情 //积分信息详情
{ {
......
...@@ -108,16 +108,16 @@ bool TCPServer::doListen(unsigned short int port, const char *ip, int backlog) ...@@ -108,16 +108,16 @@ bool TCPServer::doListen(unsigned short int port, const char *ip, int backlog)
if ( reuseaddr() ) if ( reuseaddr() )
if ( bind(port, ip) ) if ( bind(port, ip) )
if ( listen(backlog) ) if ( listen(backlog) )
{ {
return true; return true;
} }
return false; return false;
} }
bool TCPServer::accept(TCPSocket &clientSocket) const bool TCPServer::accept(TCPSocket &clientSocket) const
{ {
return TCPSocket::accept(clientSocket); return TCPSocket::accept(clientSocket);
} }
/** client端特有的send/receive **/ /** client端特有的send/receive **/
...@@ -147,7 +147,7 @@ bool TCPClient::send(const std::string& message) ...@@ -147,7 +147,7 @@ bool TCPClient::send(const std::string& message)
if (writen(m_sockfd, &buf, sizeof(buf.msgLen)+message.length()) == -1) if (writen(m_sockfd, &buf, sizeof(buf.msgLen)+message.length()) == -1)
{ {
m_bValid = false; m_bValid = false;
return false; return false;
} }
return true; return true;
} }
...@@ -190,7 +190,7 @@ bool TCPClient::read(void *buf, size_t count) ...@@ -190,7 +190,7 @@ bool TCPClient::read(void *buf, size_t count)
if (readBytes == -1) if (readBytes == -1)
{ {
m_bValid = false; m_bValid = false;
return false; return false;
} }
return true; return true;
} }
...@@ -200,7 +200,7 @@ bool TCPClient::write(const char *msg) ...@@ -200,7 +200,7 @@ bool TCPClient::write(const char *msg)
if( ::write(m_sockfd, msg, strlen(msg)) == -1 ) if( ::write(m_sockfd, msg, strlen(msg)) == -1 )
{ {
m_bValid = false; m_bValid = false;
return false; return false;
} }
return true; return true;
} }
......
...@@ -50,14 +50,14 @@ public: ...@@ -50,14 +50,14 @@ public:
/* 该函数会强制删除现有socket重新创建连接 */ /* 该函数会强制删除现有socket重新创建连接 */
bool doConnect(unsigned short port, const char *ip); bool doConnect(unsigned short port, const char *ip);
bool read(void *buf, size_t count); bool read(void *buf, size_t count);
bool write(const char *msg); bool write(const char *msg);
bool receive(std::string& message); bool receive(std::string& message);
bool send(const std::string& message); bool send(const std::string& message);
bool isValid(){ return m_bValid; } bool isValid(){ return m_bValid; }
private: private:
bool m_bValid; bool m_bValid;
}; };
/** TCP Server **/ /** TCP Server **/
...@@ -66,10 +66,10 @@ class TCPServer : public TCPSocket ...@@ -66,10 +66,10 @@ class TCPServer : public TCPSocket
public: public:
TCPServer(){} TCPServer(){}
~TCPServer(){} ~TCPServer(){}
/* 该函数会强制删除现有socket重新创建监听 */ /* 该函数会强制删除现有socket重新创建监听 */
bool doListen(unsigned short int port, const char *ip = NULL, int backlog = SOMAXCONN); bool doListen(unsigned short int port, const char *ip = NULL, int backlog = SOMAXCONN);
bool accept(TCPSocket &clientSocket) const; bool accept(TCPSocket &clientSocket) const;
}; };
#endif #endif
...@@ -67,6 +67,7 @@ void* listen_pos_func(void* arg) ...@@ -67,6 +67,7 @@ void* listen_pos_func(void* arg)
{ {
g_init_data = posRequestData; g_init_data = posRequestData;
jsonTool.getPosResponseData(100, "successful!", responseData); jsonTool.getPosResponseData(100, "successful!", responseData);
LOG(INFO) <<"POS init data:"<<g_init_data.c_str();
}else }else
{ {
jsonTool.getPosResponseData(101, "invalid initdata!", responseData); jsonTool.getPosResponseData(101, "invalid initdata!", responseData);
...@@ -122,14 +123,14 @@ void* listen_pos_func(void* arg) ...@@ -122,14 +123,14 @@ void* listen_pos_func(void* arg)
int main() int main()
{ {
/* Mark /* Mark
* 与ODS通信全部加数据头(长度) * 与ODS通信全部加数据头(长度)
* 与POS通信全部不加数据头 * 与POS通信全部不加数据头
* end*/ * end*/
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
// 初始化日志 // 初始化日志
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck); el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
std::string strBinPath = GetProcDir(); std::string strBinPath = GetProcDir();
...@@ -141,7 +142,7 @@ int main() ...@@ -141,7 +142,7 @@ int main()
/// 注册回调函数 /// 注册回调函数
el::Helpers::installPreRollOutCallback(logRolloutHandler); el::Helpers::installPreRollOutCallback(logRolloutHandler);
LOG(INFO)<<"---------程序启动---------"; LOG(INFO)<<"---------software start---------";
// 读取配置文件信息 // 读取配置文件信息
std::string strIniPath(strBinPath.data()); std::string strIniPath(strBinPath.data());
...@@ -213,12 +214,12 @@ int main() ...@@ -213,12 +214,12 @@ int main()
if( ods.receive(odsPushData) ) if( ods.receive(odsPushData) )
{ {
LOG(INFO) << "----------------recved ODS data------------------"; LOG(INFO) << "----------------recved ODS data------------------";
LOG(INFO) << odsPushData; LOG(INFO) << odsPushData;
if( jsonTool.convertDataOds2Pos(odsPushData, pushPosData) ) if( jsonTool.convertDataOds2Pos(odsPushData, pushPosData) )
{ {
LOG(INFO) << "********convert data to pos************"; LOG(INFO) << "********convert data to pos************";
LOG(INFO) << pushPosData; LOG(INFO) << pushPosData;
TCPClient pos; TCPClient pos;
if( pos.doConnect(pos_listen_port, pos_ip.c_str()) ) if( pos.doConnect(pos_listen_port, pos_ip.c_str()) )
{ {
......
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