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,94 +320,102 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -319,94 +320,102 @@ 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"]; if(points_obj.IsObject())
order.bonusInfo.summary = std::to_string(totalPoint.GetInt());
//积分信息详情
{ {
rapidjson::Value& pointDetails_array = points_obj["pointDetails"]; rapidjson::Value& totalPoint= points_obj["totalPoint"];
if(pointDetails_array.IsArray()) order.bonusInfo.summary = std::to_string(totalPoint.GetInt());
//积分信息详情
{ {
for(unsigned int i=0;i<pointDetails_array.Size();i++){ rapidjson::Value& pointDetails_array = points_obj["pointDetails"];
rapidjson::Value& pointDetails_obj = pointDetails_array[i]; if(pointDetails_array.IsArray())
{
for(unsigned int i=0;i<pointDetails_array.Size();i++){
rapidjson::Value& pointDetails_obj = pointDetails_array[i];
bonusDetail detail; bonusDetail detail;
rapidjson::Value& bomId= pointDetails_obj["bomId"]; rapidjson::Value& bomId= pointDetails_obj["bomId"];
bomId.GetString(); bomId.GetString();
rapidjson::Value& comboId = pointDetails_obj["comboId"]; rapidjson::Value& comboId = pointDetails_obj["comboId"];
comboId.GetString(); comboId.GetString();
rapidjson::Value& desc = pointDetails_obj["desc"]; rapidjson::Value& desc = pointDetails_obj["desc"];
detail.desc = desc.GetString(); detail.desc = desc.GetString();
rapidjson::Value& groupId = pointDetails_obj["groupId"]; rapidjson::Value& groupId = pointDetails_obj["groupId"];
groupId.GetString(); groupId.GetString();
rapidjson::Value& point = pointDetails_obj["point"]; rapidjson::Value& point = pointDetails_obj["point"];
detail.point = point.GetInt(); detail.point = point.GetInt();
rapidjson::Value& sku = pointDetails_obj["sku"]; rapidjson::Value& sku = pointDetails_obj["sku"];
detail.sku = sku.GetString(); detail.sku = sku.GetString();
rapidjson::Value& type = pointDetails_obj["type"]; rapidjson::Value& type = pointDetails_obj["type"];
detail.type = atoi(type.GetString()); detail.type = atoi(type.GetString());
order.bonusInfo.vecDetail.push_back(detail); order.bonusInfo.vecDetail.push_back(detail);
}
} }
} }
} }
} }
//优惠信息 //优惠信息
{ {
rapidjson::Value& promotions_obj = orderContent_obj["promotions"]; rapidjson::Value& promotions_obj = orderContent_obj["promotions"];
rapidjson::Value& totalDiscount= promotions_obj["totalDiscount"]; if(promotions_obj.IsObject())
totalDiscount.GetInt();
rapidjson::Value& totalOriginalPrice= promotions_obj["totalOriginalPrice"];
totalOriginalPrice.GetInt();
rapidjson::Value& totalPrmotionPrice= promotions_obj["totalPrmotionPrice"];
totalPrmotionPrice.GetInt();
//优惠信息详情
{ {
rapidjson::Value& promtionDetails_array = promotions_obj["promtionDetails"]; rapidjson::Value& totalDiscount= promotions_obj["totalDiscount"];
if(promtionDetails_array.IsArray()) totalDiscount.GetInt();
rapidjson::Value& totalOriginalPrice= promotions_obj["totalOriginalPrice"];
totalOriginalPrice.GetInt();
rapidjson::Value& totalPrmotionPrice= promotions_obj["totalPrmotionPrice"];
totalPrmotionPrice.GetInt();
//优惠信息详情
{ {
for(unsigned int i=0;i<promtionDetails_array.Size();i++){ rapidjson::Value& promtionDetails_array = promotions_obj["promtionDetails"];
rapidjson::Value& promtionDetails_obj = promtionDetails_array[i]; if(promtionDetails_array.IsArray())
{
for(unsigned int i=0;i<promtionDetails_array.Size();i++){
rapidjson::Value& promtionDetails_obj = promtionDetails_array[i];
rapidjson::Value& bomId= promtionDetails_obj["bomId"]; rapidjson::Value& bomId= promtionDetails_obj["bomId"];
bomId.GetString(); bomId.GetString();
rapidjson::Value& comboId = promtionDetails_obj["comboId"]; rapidjson::Value& comboId = promtionDetails_obj["comboId"];
comboId.GetString(); comboId.GetString();
rapidjson::Value& desc = promtionDetails_obj["desc"]; rapidjson::Value& desc = promtionDetails_obj["desc"];
desc.GetString(); desc.GetString();
rapidjson::Value& discount = promtionDetails_obj["discount"]; rapidjson::Value& discount = promtionDetails_obj["discount"];
discount.GetInt(); discount.GetInt();
rapidjson::Value& groupId = promtionDetails_obj["groupId"]; rapidjson::Value& groupId = promtionDetails_obj["groupId"];
groupId.GetString(); groupId.GetString();
rapidjson::Value& originalPrice = promtionDetails_obj["originalPrice"]; rapidjson::Value& originalPrice = promtionDetails_obj["originalPrice"];
originalPrice.GetInt(); originalPrice.GetInt();
rapidjson::Value& pcode = promtionDetails_obj["pcode"]; rapidjson::Value& pcode = promtionDetails_obj["pcode"];
pcode.GetString(); pcode.GetString();
rapidjson::Value& prmotionPrice = promtionDetails_obj["prmotionPrice"]; rapidjson::Value& prmotionPrice = promtionDetails_obj["prmotionPrice"];
prmotionPrice.GetInt(); prmotionPrice.GetInt();
rapidjson::Value& sku = promtionDetails_obj["sku"]; rapidjson::Value& sku = promtionDetails_obj["sku"];
sku.GetString(); sku.GetString();
rapidjson::Value& type = promtionDetails_obj["type"]; rapidjson::Value& type = promtionDetails_obj["type"];
type.GetString(); type.GetString();
}
} }
} }
} }
} }
rapidjson::Value& sessionId = orderContent_obj["sessionId"]; rapidjson::Value& sessionId = orderContent_obj["sessionId"];
sessionId.GetString(); sessionId.GetString();
...@@ -439,27 +448,38 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -439,27 +448,38 @@ 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()){
rapidjson::Value& barCounter = shopInfo_obj["barCounter"]; if(shopInfo_obj.HasMember("barCounter")){
barCounter.GetString(); rapidjson::Value& barCounter = shopInfo_obj["barCounter"];
barCounter.GetString();
}
rapidjson::Value& vOperator = shopInfo_obj["operator"]; if(shopInfo_obj.HasMember("operator")){
vOperator.GetString(); rapidjson::Value& vOperator = shopInfo_obj["operator"];
vOperator.GetString();
}
rapidjson::Value& posId = shopInfo_obj["posId"]; if(shopInfo_obj.HasMember("posId")){
order.storeInfo.pos_id = posId.GetString(); rapidjson::Value& posId = shopInfo_obj["posId"];
order.storeInfo.pos_id = posId.GetString();
}
rapidjson::Value& storeId = shopInfo_obj["storeId"]; if(shopInfo_obj.HasMember("storeId")){
order.storeInfo.store_id = storeId.GetString(); rapidjson::Value& storeId = shopInfo_obj["storeId"];
order.storeInfo.store_id = storeId.GetString();
}
//自助机信息
rapidjson::Value& selfHelpMac_obj = shopInfo_obj["selfHelpMac"];
rapidjson::Value& id = selfHelpMac_obj["id"]; //自助机信息
order.storeInfo.vem_id = id.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"]; rapidjson::Value& shelf = selfHelpMac_obj["shelf"];
order.storeInfo.vem_shelf = shelf.GetString(); order.storeInfo.vem_shelf = shelf.GetString();
}
}
} }
} }
...@@ -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;
} }
...@@ -678,7 +698,10 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj) ...@@ -678,7 +698,10 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer.String(obj.delivery_time.c_str()); writer.String(obj.delivery_time.c_str());
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