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