Commit c955a8c9 by guanghui.cui

json字段为空处理,库存预警部分加入

parent ec0875eb
...@@ -128,6 +128,7 @@ struct orderObj ...@@ -128,6 +128,7 @@ struct orderObj
std::string create_time; //订单创建时间 std::string create_time; //订单创建时间
std::string delivery_time; //订单期望送达时间 std::string delivery_time; //订单期望送达时间
int status=0; //订单状态 int status=0; //订单状态
int ods_status=0; //ods订单状态
std::string status_desc; //订单状态描述 std::string status_desc; //订单状态描述
int total_price=0; //订单总价 int total_price=0; //订单总价
int delivery_price=0; //配送费 int delivery_price=0; //配送费
...@@ -183,6 +184,7 @@ struct productWarn ...@@ -183,6 +184,7 @@ struct productWarn
struct stockWarnObj struct stockWarnObj
{ {
int fm_cmd=0; //请求类型(1006) int fm_cmd=0; //请求类型(1006)
std::string alertTime; //时间戳
std::vector<productWarn> vecProducts; //商品数组 std::vector<productWarn> vecProducts; //商品数组
}; };
......
...@@ -219,6 +219,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -219,6 +219,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
remark.GetString(); remark.GetString();
rapidjson::Value& status = orders_obj["status"]; rapidjson::Value& status = orders_obj["status"];
order.status = atoi(status.GetString()); order.status = atoi(status.GetString());
order.ods_status=order.status;
rapidjson::Value& statusDesc = orders_obj["statusDesc"]; rapidjson::Value& statusDesc = orders_obj["statusDesc"];
order.status_desc = statusDesc.GetString(); order.status_desc = statusDesc.GetString();
...@@ -319,6 +320,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -319,6 +320,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
//积分信息 //积分信息
{ {
rapidjson::Value& points_obj = orderContent_obj["points"]; rapidjson::Value& points_obj = orderContent_obj["points"];
if(points_obj.IsObject())
{
rapidjson::Value& totalPoint= points_obj["totalPoint"]; rapidjson::Value& totalPoint= points_obj["totalPoint"];
order.bonusInfo.summary = std::to_string(totalPoint.GetInt()); order.bonusInfo.summary = std::to_string(totalPoint.GetInt());
...@@ -357,9 +360,13 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -357,9 +360,13 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
} }
} }
} }
}
//优惠信息 //优惠信息
{ {
rapidjson::Value& promotions_obj = orderContent_obj["promotions"]; rapidjson::Value& promotions_obj = orderContent_obj["promotions"];
if(promotions_obj.IsObject())
{
rapidjson::Value& totalDiscount= promotions_obj["totalDiscount"]; rapidjson::Value& totalDiscount= promotions_obj["totalDiscount"];
totalDiscount.GetInt(); totalDiscount.GetInt();
rapidjson::Value& totalOriginalPrice= promotions_obj["totalOriginalPrice"]; rapidjson::Value& totalOriginalPrice= promotions_obj["totalOriginalPrice"];
...@@ -408,6 +415,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -408,6 +415,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
} }
} }
} }
}
rapidjson::Value& sessionId = orderContent_obj["sessionId"]; rapidjson::Value& sessionId = orderContent_obj["sessionId"];
sessionId.GetString(); sessionId.GetString();
...@@ -439,28 +448,39 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -439,28 +448,39 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
//门店信息 //门店信息
{ {
rapidjson::Value& shopInfo_obj = document["shopInfo"]; rapidjson::Value& shopInfo_obj = document["shopInfo"];
if(shopInfo_obj.IsObject()){
if(shopInfo_obj.HasMember("barCounter")){
rapidjson::Value& barCounter = shopInfo_obj["barCounter"]; rapidjson::Value& barCounter = shopInfo_obj["barCounter"];
barCounter.GetString(); barCounter.GetString();
}
if(shopInfo_obj.HasMember("operator")){
rapidjson::Value& vOperator = shopInfo_obj["operator"]; rapidjson::Value& vOperator = shopInfo_obj["operator"];
vOperator.GetString(); vOperator.GetString();
}
if(shopInfo_obj.HasMember("posId")){
rapidjson::Value& posId = shopInfo_obj["posId"]; rapidjson::Value& posId = shopInfo_obj["posId"];
order.storeInfo.pos_id = posId.GetString(); order.storeInfo.pos_id = posId.GetString();
}
if(shopInfo_obj.HasMember("storeId")){
rapidjson::Value& storeId = shopInfo_obj["storeId"]; rapidjson::Value& storeId = shopInfo_obj["storeId"];
order.storeInfo.store_id = storeId.GetString(); order.storeInfo.store_id = storeId.GetString();
}
//自助机信息 //自助机信息
rapidjson::Value& selfHelpMac_obj = shopInfo_obj["selfHelpMac"]; rapidjson::Value& selfHelpMac_obj = shopInfo_obj["selfHelpMac"];
if(selfHelpMac_obj.IsObject()){
rapidjson::Value& id = selfHelpMac_obj["id"]; rapidjson::Value& id = selfHelpMac_obj["id"];
order.storeInfo.vem_id = id.GetString(); order.storeInfo.vem_id = id.GetString();
rapidjson::Value& shelf = selfHelpMac_obj["shelf"]; rapidjson::Value& shelf = selfHelpMac_obj["shelf"];
order.storeInfo.vem_shelf = shelf.GetString(); order.storeInfo.vem_shelf = shelf.GetString();
} }
}
}
} }
return true; return true;
...@@ -610,9 +630,9 @@ bool JsonModule::getOdsResponseData(const std::string &posResponse, const std::s ...@@ -610,9 +630,9 @@ bool JsonModule::getOdsResponseData(const std::string &posResponse, const std::s
if(fm_cmd==REQUEST_TYPE_NEWORDER_PUSH){ if(fm_cmd==REQUEST_TYPE_NEWORDER_PUSH){
rlt=_getOrderResponseJson(posResponse,orderData,result); rlt=_getOrderResponseJson(posResponse,orderData,result);
} }
// else if(fm_cmd==REQUEST_TYPE_STOCK_WARN){ else if(fm_cmd==REQUEST_TYPE_STOCK_WARN){
// rlt=_getStockWarnResponseJson(posResponse,orderData,result); rlt=_getStockWarnResponseJson(posResponse,orderData,result);
// } }
return rlt; return rlt;
} }
...@@ -680,6 +700,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj) ...@@ -680,6 +700,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer.Key("status"); writer.Key("status");
writer.Int(_getPOSOrderStatus(obj.status)); writer.Int(_getPOSOrderStatus(obj.status));
writer.Key("ods_status");
writer.Int(obj.ods_status);
writer.Key("status_desc"); writer.Key("status_desc");
writer.String(obj.status_desc.c_str()); writer.String(obj.status_desc.c_str());
...@@ -1358,7 +1381,7 @@ bool JsonModule::_getOrderResponseJson(IN const std::string& posResponse, IN con ...@@ -1358,7 +1381,7 @@ bool JsonModule::_getOrderResponseJson(IN const std::string& posResponse, IN con
if( !document.HasMember("status_code") if( !document.HasMember("status_code")
|| !document1.HasMember("order_id") || !document1.HasMember("order_id")
|| !document1.HasMember("status") || !document1.HasMember("ods_status")
|| !document1.HasMember("channel") ) || !document1.HasMember("channel") )
{ {
LOG(INFO)<<"Don't have needed parames"; LOG(INFO)<<"Don't have needed parames";
...@@ -1369,7 +1392,7 @@ bool JsonModule::_getOrderResponseJson(IN const std::string& posResponse, IN con ...@@ -1369,7 +1392,7 @@ bool JsonModule::_getOrderResponseJson(IN const std::string& posResponse, IN con
std::string msg = document["msg"].GetString(); std::string msg = document["msg"].GetString();
std::string order_id = document1["order_id"].GetString(); std::string order_id = document1["order_id"].GetString();
int status = document1["status"].GetInt(); int status = document1["ods_status"].GetInt();
std::string channel = document1["channel"].GetString(); std::string channel = document1["channel"].GetString();
rapidjson::StringBuffer buffer; rapidjson::StringBuffer buffer;
...@@ -1407,7 +1430,7 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN ...@@ -1407,7 +1430,7 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
document.Parse(posResponse.c_str()); document.Parse(posResponse.c_str());
document1.Parse(orderData.c_str()); document1.Parse(orderData.c_str());
if( !document.HasMember("status_code") || !document1.HasMember("channel") ) if( !document.HasMember("status_code") || !document1.HasMember("channel") || !document1.HasMember("alertTime") )
{ {
LOG(INFO)<<"Don't have needed parames"; LOG(INFO)<<"Don't have needed parames";
return false; return false;
...@@ -1418,6 +1441,7 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN ...@@ -1418,6 +1441,7 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
std::string channel = document1["channel"].GetString(); std::string channel = document1["channel"].GetString();
std::string alertTime = document1["alertTime"].GetString();
rapidjson::StringBuffer buffer; rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
...@@ -1429,6 +1453,9 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN ...@@ -1429,6 +1453,9 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
writer.Key("channel"); writer.Key("channel");
writer.String(channel.c_str()); writer.String(channel.c_str());
writer.Key("alertTime");
writer.String(alertTime.c_str());
writer.Key("status_code"); writer.Key("status_code");
writer.Int(status_code); writer.Int(status_code);
......
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