Commit 1753cf58 by guanghui.cui

订单推送报文字段修改

parent fa21788b
......@@ -49,38 +49,38 @@ struct payment
std::vector<paymentDetail> vecDetail; //付款明细数组
};
//订单积分详情
struct bonusDetail
{
int type=0; //积分类型
std::string desc; //积分奖励描述
int point=0; //积分奖励数值
std::string sku; //积分商品
};
// //订单积分详情
// struct bonusDetail
// {
// int type=0; //积分类型
// std::string desc; //积分奖励描述
// int point=0; //积分奖励数值
// std::string sku; //积分商品
// };
//订单积分
struct bonus
{
std::string summary; //积分奖励总和
std::vector<bonusDetail> vecDetail; //付款明细数组
};
// //订单积分
// struct bonus
// {
// std::string summary; //积分奖励总和
// std::vector<bonusDetail> vecDetail; //付款明细数组
// };
//促销明细
struct promotionsDetail
{
std::string pro_id; //促销编码
int type=0; //促销类型
std::string desc; //促销描述
int offer=0; //促销金额
std::string sku; //促销商品
};
// //促销明细
// struct promotionsDetail
// {
// std::string pro_id; //促销编码
// int type=0; //促销类型
// std::string desc; //促销描述
// int offer=0; //促销金额
// std::string sku; //促销商品
// };
//促销
struct promotions
{
std::string summary; //促销金额总和
std::vector<promotionsDetail> vecDetail; //付款明细数组
};
// //促销
// struct promotions
// {
// std::string summary; //促销金额总和
// std::vector<promotionsDetail> vecDetail; //付款明细数组
// };
//响应结果
struct responseRlt
......@@ -119,6 +119,47 @@ struct customer
std::string account_level; //顾客账号等级
};
//促销
struct promotions
{
std::string pcode; //优惠码
std::string proType; //类型: 00快速积点 ,20售价促销,30进价+售价促销,40组合促销,50整单促销,60厂区促销,70会员卡充值促销, 80电子点标
std::string type; //优惠子类型
std::string desc; //优惠明细
std::string name; //名称
std::string sku; //商品编号
int originalPrice=0; //原始价格
int discount=0; //折扣
int prmotionPrice=0; //优惠价格
std::string giftSku; //赠品的编码
int giftQty=0; //赠品的数量
};
//积分
struct bonus
{
std::string pcode; //优惠码
std::string proType; //类型: 00快速积点 ,20售价促销,30进价+售价促销,40组合促销,50整单促销,60厂区促销,70会员卡充值促销, 80电子点标
std::string type; //优惠子类型
std::string desc; //优惠明细
std::string name; //名称
std::string sku; //商品编号
int bonus=0; //获得积分
};
//电子点标
struct ecoupon
{
std::string pcode; //优惠码
std::string proType; //类型: 00快速积点 ,20售价促销,30进价+售价促销,40组合促销,50整单促销,60厂区促销,70会员卡充值促销, 80电子点标
std::string type; //优惠子类型
std::string desc; //优惠明细
std::string name; //名称
std::string sku; //商品编号
std::string ecouponNumber; //电子点标号码
int ecouponQty=0; //电子点标数量
};
//订单结构体
struct orderObj
{
......@@ -135,6 +176,9 @@ struct orderObj
int total_price=0; //订单总价
int delivery_price=0; //配送费
int reduced_price=0; //折扣总金额
int wmDiscount=0; //外卖优惠金额
int wmPtSharedDiscount=0; //外卖平台承担的优惠金额
int wmSjSharedDiscount=0; //外卖商家承担的优惠金额
std::string pickup_code; //自取订单取餐码
std::string pickup_point; //自取订单取餐处
std::string invoice_pickup_code; //订单发票提出码
......@@ -144,8 +188,9 @@ struct orderObj
customer customerInfo; //顾客信息
std::vector<productAttr> vecProducts; //商品列表
payment payInfo; //付款明细
bonus bonusInfo; //消费积分
promotions promotionInfo; //促销列表
std::vector<bonus> vecBonus; //消费积分
std::vector<promotions> vecPromotions; //促销列表
std::vector<ecoupon> vecEcoupon; //电子点标
};
//订单状态
......
......@@ -214,6 +214,10 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order.total_price = GetJsonIntSafe(orderContent_obj,"totalAmount")-GetJsonIntSafe(orderContent_obj,"deliveryFee");
}
order.wmDiscount=GetJsonIntSafe(orderContent_obj,"wmDiscount");
order.wmPtSharedDiscount=GetJsonIntSafe(orderContent_obj,"wmPtSharedDiscount");
order.wmSjSharedDiscount=GetJsonIntSafe(orderContent_obj,"wmSjSharedDiscount");
//订单信息
if(orderContent_obj.HasMember("orders"))
......@@ -305,14 +309,55 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
}
GetJsonStringSafe(orderContent_obj,"payType");
//优惠信息
if(orderContent_obj.HasMember("promotions"))
{
rapidjson::Value& promotions_obj = orderContent_obj["promotions"];
if(promotions_obj.IsObject())
{
GetJsonIntSafe(promotions_obj,"totalDiscount");
GetJsonIntSafe(promotions_obj,"totalOriginalPrice");
GetJsonIntSafe(promotions_obj,"totalPrmotionPrice");
//优惠信息详情
if(promotions_obj.HasMember("promtionDetails"))
{
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];
promotions detail;
detail.pcode = GetJsonStringSafe(promtionDetails_obj,"pcode");
detail.proType = GetJsonStringSafe(promtionDetails_obj,"type");
detail.desc = GetJsonStringSafe(promtionDetails_obj,"desc");
detail.sku = GetJsonStringSafe(promtionDetails_obj,"sku");
detail.originalPrice = GetJsonIntSafe(promtionDetails_obj,"originalPrice");
detail.prmotionPrice = GetJsonIntSafe(promtionDetails_obj,"prmotionPrice");
detail.discount = GetJsonIntSafe(promtionDetails_obj,"discount");
if(promtionDetails_obj.HasMember("gifts")){
rapidjson::Value& gifts_obj = orderContent_obj["gifts"];
if(gifts_obj.IsObject()){
detail.giftSku = GetJsonStringSafe(gifts_obj,"sku");
detail.giftQty = GetJsonIntSafe(gifts_obj,"qty");
}
}
order.vecPromotions.push_back(detail);
}
}
}
}
}
//积分信息
if(orderContent_obj.HasMember("points"))
{
rapidjson::Value& points_obj = orderContent_obj["points"];
if(points_obj.IsObject())
{
order.bonusInfo.summary = std::to_string(GetJsonIntSafe(points_obj,"totalPoint"));
std::to_string(GetJsonIntSafe(points_obj,"totalPoint"));
//积分信息详情
if(points_obj.HasMember("pointDetails"))
{
......@@ -322,61 +367,113 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
for(unsigned int i=0;i<pointDetails_array.Size();i++){
rapidjson::Value& pointDetails_obj = pointDetails_array[i];
bonusDetail detail;
GetJsonStringSafe(pointDetails_obj,"bomId");
GetJsonStringSafe(pointDetails_obj,"comboId");
bonus detail;
detail.pcode = GetJsonStringSafe(pointDetails_obj,"pcode");
detail.desc = GetJsonStringSafe(pointDetails_obj,"desc");
GetJsonStringSafe(pointDetails_obj,"groupId");
detail.point = GetJsonIntSafe(pointDetails_obj,"point");
detail.bonus = GetJsonIntSafe(pointDetails_obj,"point");
detail.sku = GetJsonStringSafe(pointDetails_obj,"sku");
detail.type = atoi(GetJsonStringSafe(pointDetails_obj,"type"));
detail.proType = GetJsonStringSafe(pointDetails_obj,"type");
order.bonusInfo.vecDetail.push_back(detail);
order.vecBonus.push_back(detail);
}
}
}
}
}
//优惠信息
if(orderContent_obj.HasMember("promotions"))
{
rapidjson::Value& promotions_obj = orderContent_obj["promotions"];
if(promotions_obj.IsObject())
{
order.promotionInfo.summary=GetJsonIntSafe(promotions_obj,"totalDiscount");
GetJsonIntSafe(promotions_obj,"totalOriginalPrice");
GetJsonIntSafe(promotions_obj,"totalPrmotionPrice");
//优惠信息详情
if(promotions_obj.HasMember("promtionDetails"))
//电子点标
if(orderContent_obj.HasMember("ecouponVos"))
{
rapidjson::Value& promtionDetails_array = promotions_obj["promtionDetails"];
if(promtionDetails_array.IsArray())
rapidjson::Value& ecouponVos_array = orderContent_obj["ecouponVos"];
if(ecouponVos_array.IsArray())
{
for(unsigned int i=0;i<promtionDetails_array.Size();i++){
rapidjson::Value& promtionDetails_obj = promtionDetails_array[i];
promotionsDetail detail;
detail.pro_id = GetJsonStringSafe(promtionDetails_obj,"proId");
GetJsonStringSafe(promtionDetails_obj,"bomId");
GetJsonStringSafe(promtionDetails_obj,"comboId");
detail.desc = GetJsonStringSafe(promtionDetails_obj,"desc");
detail.offer = GetJsonIntSafe(promtionDetails_obj,"discount");
GetJsonStringSafe(promtionDetails_obj,"groupId");
GetJsonIntSafe(promtionDetails_obj,"originalPrice");
GetJsonStringSafe(promtionDetails_obj,"pcode");
GetJsonIntSafe(promtionDetails_obj,"prmotionPrice");
detail.sku = GetJsonStringSafe(promtionDetails_obj,"sku");
detail.type = atoi(GetJsonStringSafe(promtionDetails_obj,"type"));
for(unsigned int i=0;i<ecouponVos_array.Size();i++){
rapidjson::Value& ecouponVos_obj = ecouponVos_array[i];
ecoupon detail;
detail.ecouponNumber = GetJsonStringSafe(ecouponVos_obj,"couponNumber");
detail.name = GetJsonStringSafe(ecouponVos_obj,"name");
detail.pcode = GetJsonStringSafe(ecouponVos_obj,"pcode");
detail.proType = GetJsonStringSafe(ecouponVos_obj,"type");
detail.ecouponQty = GetJsonIntSafe(ecouponVos_obj,"qty");
order.promotionInfo.vecDetail.push_back(detail);
}
order.vecEcoupon.push_back(detail);
}
}
}
}
//积分信息
// if(orderContent_obj.HasMember("points"))
// {
// rapidjson::Value& points_obj = orderContent_obj["points"];
// if(points_obj.IsObject())
// {
// order.bonusInfo.summary = std::to_string(GetJsonIntSafe(points_obj,"totalPoint"));
// //积分信息详情
// if(points_obj.HasMember("pointDetails"))
// {
// 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;
// GetJsonStringSafe(pointDetails_obj,"bomId");
// GetJsonStringSafe(pointDetails_obj,"comboId");
// detail.desc = GetJsonStringSafe(pointDetails_obj,"desc");
// GetJsonStringSafe(pointDetails_obj,"groupId");
// detail.point = GetJsonIntSafe(pointDetails_obj,"point");
// detail.sku = GetJsonStringSafe(pointDetails_obj,"sku");
// detail.type = atoi(GetJsonStringSafe(pointDetails_obj,"type"));
// order.bonusInfo.vecDetail.push_back(detail);
// }
// }
// }
// }
// }
//优惠信息
// if(orderContent_obj.HasMember("promotions"))
// {
// rapidjson::Value& promotions_obj = orderContent_obj["promotions"];
// if(promotions_obj.IsObject())
// {
// order.promotionInfo.summary=GetJsonIntSafe(promotions_obj,"totalDiscount");
// GetJsonIntSafe(promotions_obj,"totalOriginalPrice");
// GetJsonIntSafe(promotions_obj,"totalPrmotionPrice");
// //优惠信息详情
// if(promotions_obj.HasMember("promtionDetails"))
// {
// 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];
// promotionsDetail detail;
// detail.pro_id = GetJsonStringSafe(promtionDetails_obj,"proId");
// GetJsonStringSafe(promtionDetails_obj,"bomId");
// GetJsonStringSafe(promtionDetails_obj,"comboId");
// detail.desc = GetJsonStringSafe(promtionDetails_obj,"desc");
// detail.offer = GetJsonIntSafe(promtionDetails_obj,"discount");
// GetJsonStringSafe(promtionDetails_obj,"groupId");
// GetJsonIntSafe(promtionDetails_obj,"originalPrice");
// GetJsonStringSafe(promtionDetails_obj,"pcode");
// GetJsonIntSafe(promtionDetails_obj,"prmotionPrice");
// detail.sku = GetJsonStringSafe(promtionDetails_obj,"sku");
// detail.type = atoi(GetJsonStringSafe(promtionDetails_obj,"type"));
// order.promotionInfo.vecDetail.push_back(detail);
// }
// }
// }
// }
// }
GetJsonStringSafe(orderContent_obj,"sessionId");
order.reduced_price = GetJsonIntSafe(orderContent_obj,"totalDiscount");
......@@ -654,7 +751,8 @@ std::string JsonModule::_convertToOrderOperationReponseJson(IN const char* json)
rapidjson::Value& result_obj = document["result"];
if(result_obj.IsObject())
{
status = atoi(GetJsonStringSafe(result_obj,"status"));
int iStatus=atoi(GetJsonStringSafe(result_obj,"status"));
status = _getPOSOrderStatus(iStatus);
status_desc = GetJsonStringSafe(result_obj,"status_desc");
}
}
......@@ -873,6 +971,15 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer.Key("reduced_price");
writer.Int(obj.reduced_price);
writer.Key("wmDiscount");
writer.Int(obj.wmDiscount);
writer.Key("wmPtSharedDiscount");
writer.Int(obj.wmPtSharedDiscount);
writer.Key("wmSjSharedDiscount");
writer.Int(obj.wmSjSharedDiscount);
writer.Key("pickup_code");
writer.String(obj.pickup_code.c_str());
......@@ -1051,74 +1158,189 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
//----------------消费积分----------------
writer.Key("bonus");
writer.StartObject();
writer.Key("summary");
writer.String(obj.bonusInfo.summary.c_str());
//-----------------start 积分详情------------------
writer.Key("details");
writer.StartArray();
for(unsigned int i=0;i<obj.bonusInfo.vecDetail.size();i++)
for(unsigned int i=0;i<obj.vecBonus.size();i++)
{
writer.StartObject();
writer.Key("pcode");
writer.String(obj.vecBonus[i].pcode.c_str());
writer.Key("proType");
writer.String(obj.vecBonus[i].proType.c_str());
writer.Key("type");
writer.Int(obj.bonusInfo.vecDetail[i].type);
writer.String(obj.vecBonus[i].type.c_str());
writer.Key("desc");
writer.String(obj.bonusInfo.vecDetail[i].desc.c_str());
writer.String(obj.vecBonus[i].desc.c_str());
writer.Key("point");
writer.Int(obj.bonusInfo.vecDetail[i].point);
writer.Key("name");
writer.String(obj.vecBonus[i].name.c_str());
writer.Key("sku");
writer.String(obj.bonusInfo.vecDetail[i].sku.c_str());
writer.String(obj.vecBonus[i].sku.c_str());
writer.Key("bonus");
writer.Int(obj.vecBonus[i].bonus);
writer.EndObject();
}
writer.EndArray();
//-----------------end 积分详情--------------------
writer.EndObject();
//----------------消费积分 结束-----------
//----------------促销列表----------------
//----------------促销----------------
writer.Key("promotions");
writer.StartArray();
for(unsigned int i=0;i<obj.vecPromotions.size();i++)
{
writer.StartObject();
writer.Key("summary");
writer.String(obj.promotionInfo.summary.c_str());
writer.Key("pcode");
writer.String(obj.vecPromotions[i].pcode.c_str());
//-----------------start 促销详情------------------
writer.Key("details");
writer.Key("proType");
writer.String(obj.vecPromotions[i].proType.c_str());
writer.Key("type");
writer.String(obj.vecPromotions[i].type.c_str());
writer.Key("desc");
writer.String(obj.vecPromotions[i].desc.c_str());
writer.Key("name");
writer.String(obj.vecPromotions[i].name.c_str());
writer.Key("sku");
writer.String(obj.vecPromotions[i].sku.c_str());
writer.Key("originalPrice");
writer.Int(obj.vecPromotions[i].originalPrice);
writer.Key("discount");
writer.Int(obj.vecPromotions[i].discount);
writer.Key("prmotionPrice");
writer.Int(obj.vecPromotions[i].prmotionPrice);
writer.Key("giftSku");
writer.String(obj.vecPromotions[i].giftSku.c_str());
writer.Key("giftQty");
writer.Int(obj.vecPromotions[i].giftQty);
writer.EndObject();
}
writer.EndArray();
//----------------促销 结束-----------
//----------------电子点标----------------
writer.Key("ecoupon");
writer.StartArray();
for(unsigned int i=0;i<obj.promotionInfo.vecDetail.size();i++)
for(unsigned int i=0;i<obj.vecEcoupon.size();i++)
{
writer.StartObject();
writer.Key("pro_id");
writer.String(obj.promotionInfo.vecDetail[i].pro_id.c_str());
writer.Key("pcode");
writer.String(obj.vecEcoupon[i].pcode.c_str());
writer.Key("proType");
writer.String(obj.vecEcoupon[i].proType.c_str());
writer.Key("type");
writer.Int(obj.promotionInfo.vecDetail[i].type);
writer.String(obj.vecEcoupon[i].type.c_str());
writer.Key("desc");
writer.String(obj.promotionInfo.vecDetail[i].desc.c_str());
writer.String(obj.vecEcoupon[i].desc.c_str());
writer.Key("offer");
writer.Int(obj.promotionInfo.vecDetail[i].offer);
writer.Key("name");
writer.String(obj.vecEcoupon[i].name.c_str());
writer.Key("sku");
writer.String(obj.promotionInfo.vecDetail[i].sku.c_str());
writer.String(obj.vecEcoupon[i].sku.c_str());
writer.Key("ecouponNumber");
writer.String(obj.vecEcoupon[i].ecouponNumber.c_str());
writer.Key("ecouponQty");
writer.Int(obj.vecEcoupon[i].ecouponQty);
writer.EndObject();
}
writer.EndArray();
//-----------------end 促销详情--------------------
//----------------电子点标 结束-----------
writer.EndObject();
//----------------促销列表 结束-----------
// //----------------消费积分----------------
// writer.Key("bonus");
// writer.StartObject();
// writer.Key("summary");
// writer.String(obj.bonusInfo.summary.c_str());
// //-----------------start 积分详情------------------
// writer.Key("details");
// writer.StartArray();
// for(unsigned int i=0;i<obj.bonusInfo.vecDetail.size();i++)
// {
// writer.StartObject();
// writer.Key("type");
// writer.Int(obj.bonusInfo.vecDetail[i].type);
// writer.Key("desc");
// writer.String(obj.bonusInfo.vecDetail[i].desc.c_str());
// writer.Key("point");
// writer.Int(obj.bonusInfo.vecDetail[i].point);
// writer.Key("sku");
// writer.String(obj.bonusInfo.vecDetail[i].sku.c_str());
// writer.EndObject();
// }
// writer.EndArray();
// //-----------------end 积分详情--------------------
// writer.EndObject();
// //----------------消费积分 结束-----------
// //----------------促销列表----------------
// writer.Key("promotions");
// writer.StartObject();
// writer.Key("summary");
// writer.String(obj.promotionInfo.summary.c_str());
// //-----------------start 促销详情------------------
// writer.Key("details");
// writer.StartArray();
// for(unsigned int i=0;i<obj.promotionInfo.vecDetail.size();i++)
// {
// writer.StartObject();
// writer.Key("pro_id");
// writer.String(obj.promotionInfo.vecDetail[i].pro_id.c_str());
// writer.Key("type");
// writer.Int(obj.promotionInfo.vecDetail[i].type);
// writer.Key("desc");
// writer.String(obj.promotionInfo.vecDetail[i].desc.c_str());
// writer.Key("offer");
// writer.Int(obj.promotionInfo.vecDetail[i].offer);
// writer.Key("sku");
// writer.String(obj.promotionInfo.vecDetail[i].sku.c_str());
// writer.EndObject();
// }
// writer.EndArray();
// //-----------------end 促销详情--------------------
// writer.EndObject();
// //----------------促销列表 结束-----------
writer.EndObject();
......
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