Commit c955a8c9 by guanghui.cui

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

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