Commit 87e41dfc by guanghui.cui

1、设置主pos立即关闭当前长连接,发送请求 2、点取分离和扫码购 状态码与ods对接

parent 5f2c1796
...@@ -31,7 +31,15 @@ ...@@ -31,7 +31,15 @@
#define REQUEST_TYPE_POS_PRIORITY 1005 //设置POS优先级 #define REQUEST_TYPE_POS_PRIORITY 1005 //设置POS优先级
#define REQUEST_TYPE_STOCK_WARN 1006 //库存预警通知 #define REQUEST_TYPE_STOCK_WARN 1006 //库存预警通知
#define REQUEST_TYPE_COMMON_WARN 1007 //通用预警通知 #define REQUEST_TYPE_COMMON_WARN 1007 //通用预警通知
#define REQUEST_TYPE_QUERY_ORDER_STAUS 1020 //订单状态查询 #define REQUEST_TYPE_QUERY_ORDER_STAUS 1060 //订单状态查询
//点取分离和扫码购 插件向ods请求码
#define PLUGIN_TO_ODS_APPOINTMENT_MAKINGDONE 1020 //制作完成(点取分离)
#define PLUGIN_TO_ODS_APPOINTMENT_DONE 1021 //已完成(点取分离)
#define PLUGIN_TO_ODS_APPOINTMENT_REFUND 1022 //pos退款(点取分离)
#define PLUGIN_TO_ODS_APPOINTMENT_CONFIRM 1023 //确认接单(点取分离)
#define PLUGIN_TO_ODS_SCANCODE_DONE 1024 //已完成(扫码购)
#define PLUGIN_TO_ODS_SCANCODE_REFUND 1025 //pos退款(扫码购)
//配送类型对照表 //配送类型对照表
#define DELIVERY_TYPE_SELF "self" //自配送 #define DELIVERY_TYPE_SELF "self" //自配送
...@@ -69,7 +77,7 @@ ...@@ -69,7 +77,7 @@
#define OPERATION_POS_CANCEL 1012 //拒绝接单(外卖) #define OPERATION_POS_CANCEL 1012 //拒绝接单(外卖)
#define OPERATION_POS_REFUND_AGREE 1013 //同意退款(外卖) #define OPERATION_POS_REFUND_AGREE 1013 //同意退款(外卖)
#define OPERATION_POS_REFUND_DISAGREE 1014 //拒绝退款(外卖) #define OPERATION_POS_REFUND_DISAGREE 1014 //拒绝退款(外卖)
#define OPERATION_POS_APPOINTMENT_MAKEING 1015 //制作中(点取分离) //#define OPERATION_POS_APPOINTMENT_MAKEING 1015 //制作中(点取分离)
#define OPERATION_POS_APPOINTMENT_MAKEING_DONE 1016 //制作完成(点取分离) #define OPERATION_POS_APPOINTMENT_MAKEING_DONE 1016 //制作完成(点取分离)
#define OPERATION_POS_APPOINTMENT_DONE 1017 //已完成(点取分离) #define OPERATION_POS_APPOINTMENT_DONE 1017 //已完成(点取分离)
#define OPERATION_POS_APPOINTMENT_REFUND 1018 //pos退款(点取分离) #define OPERATION_POS_APPOINTMENT_REFUND 1018 //pos退款(点取分离)
......
...@@ -881,8 +881,7 @@ bool JsonModule::convertDataPos2Ods(const std::string &data, std::string &result ...@@ -881,8 +881,7 @@ bool JsonModule::convertDataPos2Ods(const std::string &data, std::string &result
result=_convertToQueryOrderStatusJson(data.data()); result=_convertToQueryOrderStatusJson(data.data());
rlt = true; rlt = true;
} }
else if (fm_cmd == OPERATION_POS_APPOINTMENT_MAKEING else if ( fm_cmd == OPERATION_POS_APPOINTMENT_MAKEING_DONE
|| fm_cmd == OPERATION_POS_APPOINTMENT_MAKEING_DONE
|| fm_cmd == OPERATION_POS_APPOINTMENT_DONE || fm_cmd == OPERATION_POS_APPOINTMENT_DONE
|| fm_cmd == OPERATION_POS_APPOINTMENT_REFUND || fm_cmd == OPERATION_POS_APPOINTMENT_REFUND
|| fm_cmd == OPERATION_POS_APPOINTMENT_CONFIRM || fm_cmd == OPERATION_POS_APPOINTMENT_CONFIRM
...@@ -1968,7 +1967,7 @@ std::string JsonModule::_convertToAppointmentAndScancodeReqJson(IN const char* j ...@@ -1968,7 +1967,7 @@ std::string JsonModule::_convertToAppointmentAndScancodeReqJson(IN const char* j
writer.StartObject(); writer.StartObject();
writer.Key("fm_cmd"); writer.Key("fm_cmd");
writer.Int(REQUEST_TYPE_QUERY_ORDER_STAUS); writer.Int(_getReqCodeByPOSReq(reqType));
writer.Key("channel"); writer.Key("channel");
writer.String(channel.c_str()); writer.String(channel.c_str());
...@@ -2085,9 +2084,6 @@ std::string JsonModule::_getODSTypeByPOSReq(int type) ...@@ -2085,9 +2084,6 @@ std::string JsonModule::_getODSTypeByPOSReq(int type)
std::string rlt = 0; std::string rlt = 0;
switch (type) switch (type)
{ {
case OPERATION_POS_APPOINTMENT_MAKEING:
rlt = "20007";
break;
case OPERATION_POS_APPOINTMENT_MAKEING_DONE: case OPERATION_POS_APPOINTMENT_MAKEING_DONE:
rlt = "20008"; rlt = "20008";
break; break;
...@@ -2256,4 +2252,33 @@ std::string JsonModule::_getCommonWarnStringByCode(int type) ...@@ -2256,4 +2252,33 @@ std::string JsonModule::_getCommonWarnStringByCode(int type)
rlt = charset_g2u(rlt); rlt = charset_g2u(rlt);
#endif // WIN32 #endif // WIN32
return rlt; return rlt;
}
int JsonModule::_getReqCodeByPOSReq(int fm_cmd)
{
int rlt = 0;
switch (fm_cmd)
{
case OPERATION_POS_APPOINTMENT_MAKEING_DONE:
rlt = PLUGIN_TO_ODS_APPOINTMENT_MAKINGDONE;
break;
case OPERATION_POS_APPOINTMENT_DONE:
rlt = PLUGIN_TO_ODS_APPOINTMENT_DONE;
break;
case OPERATION_POS_APPOINTMENT_REFUND:
rlt = PLUGIN_TO_ODS_APPOINTMENT_REFUND;
break;
case OPERATION_POS_APPOINTMENT_CONFIRM:
rlt = PLUGIN_TO_ODS_APPOINTMENT_CONFIRM;
break;
case OPERATION_POS_SCANCODE_DONE:
rlt = PLUGIN_TO_ODS_SCANCODE_DONE;
break;
case OPERATION_POS_SCANCODE_REFUND:
rlt = PLUGIN_TO_ODS_SCANCODE_REFUND;
break;
default:
break;
}
return rlt;
} }
\ No newline at end of file
...@@ -116,6 +116,8 @@ private: ...@@ -116,6 +116,8 @@ private:
int _getPOSOrderStatus(int status); int _getPOSOrderStatus(int status);
//POS请求类型转换为ODS需要类型 //POS请求类型转换为ODS需要类型
int _getODSStatusByPOSReq(int fm_cmd); int _getODSStatusByPOSReq(int fm_cmd);
//获取点取分离和扫码购请求码
int _getReqCodeByPOSReq(int fm_cmd);
//POS请求操作类型转换为中台需要类型 //POS请求操作类型转换为中台需要类型
std::string _getODSTypeByPOSReq(int type); std::string _getODSTypeByPOSReq(int type);
......
...@@ -141,9 +141,12 @@ bool TCPSocket::close() ...@@ -141,9 +141,12 @@ bool TCPSocket::close()
{ {
if ( m_sockfd == -1 ) if ( m_sockfd == -1 )
return false; return false;
#ifdef WIN32
#ifdef WIN32
shutdown(m_sockfd, SD_BOTH);
closesocket(m_sockfd); closesocket(m_sockfd);
#else #else
shutdown(m_sockfd, SHUT_RDWR);
::close(m_sockfd); ::close(m_sockfd);
#endif #endif
m_sockfd = -1; m_sockfd = -1;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
INITIALIZE_EASYLOGGINGPP INITIALIZE_EASYLOGGINGPP
#define VERSION "1.0.6 beta 5" //版本号 #define VERSION "1.0.6 beta 7" //版本号
std::string g_init_data; std::string g_init_data;
std::string g_init_data_ods_back; std::string g_init_data_ods_back;
...@@ -92,6 +92,11 @@ void* listen_pos_func(void* arg) ...@@ -92,6 +92,11 @@ void* listen_pos_func(void* arg)
LOG(INFO)<<"pos reqType:"<<reqType; LOG(INFO)<<"pos reqType:"<<reqType;
if(reqType==REQUEST_TYPE_INIT) if(reqType==REQUEST_TYPE_INIT)
{ {
if (bInitDone) {
LOG(INFO) << "set timeout 1";
longConnectionOds.setSocketTimeout(1);
longConnectionOds.close(); //关闭长连接,等待重连
}
bInitDone=false; bInitDone=false;
if( jsonTool.checkInitData(posRequestData, pos_listen_port) ) if( jsonTool.checkInitData(posRequestData, pos_listen_port) )
{ {
...@@ -101,7 +106,6 @@ void* listen_pos_func(void* arg) ...@@ -101,7 +106,6 @@ void* listen_pos_func(void* arg)
jsonTool.convertInitDataPos2Ods(posRequestData,g_init_data); jsonTool.convertInitDataPos2Ods(posRequestData,g_init_data);
//jsonTool.getPosResponseData(100, "successful!", responseData); //jsonTool.getPosResponseData(100, "successful!", responseData);
LOG(INFO) <<"INIT PLUGIN ===>> ODS:"<<g_init_data.c_str(); LOG(INFO) <<"INIT PLUGIN ===>> ODS:"<<g_init_data.c_str();
longConnectionOds.close(); //关闭长连接,等待重连
//等待ods返回初始化结果 //等待ods返回初始化结果
while(true){ while(true){
if(!g_init_data_ods_back.empty()){ if(!g_init_data_ods_back.empty()){
...@@ -150,7 +154,6 @@ void* listen_pos_func(void* arg) ...@@ -150,7 +154,6 @@ void* listen_pos_func(void* arg)
|| OPERATION_POS_CANCEL == reqType || OPERATION_POS_CANCEL == reqType
|| OPERATION_POS_REFUND_AGREE == reqType || OPERATION_POS_REFUND_AGREE == reqType
|| OPERATION_POS_REFUND_DISAGREE == reqType || OPERATION_POS_REFUND_DISAGREE == reqType
|| OPERATION_POS_APPOINTMENT_MAKEING == reqType
|| OPERATION_POS_APPOINTMENT_MAKEING_DONE == reqType || OPERATION_POS_APPOINTMENT_MAKEING_DONE == reqType
|| OPERATION_POS_APPOINTMENT_DONE == reqType || OPERATION_POS_APPOINTMENT_DONE == reqType
|| OPERATION_POS_APPOINTMENT_REFUND == reqType || OPERATION_POS_APPOINTMENT_REFUND == reqType
......
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