Commit fa21788b by guanghui.cui

修复金额计算bug

parent f10cf669
...@@ -68,6 +68,7 @@ struct bonus ...@@ -68,6 +68,7 @@ struct bonus
//促销明细 //促销明细
struct promotionsDetail struct promotionsDetail
{ {
std::string pro_id; //促销编码
int type=0; //促销类型 int type=0; //促销类型
std::string desc; //促销描述 std::string desc; //促销描述
int offer=0; //促销金额 int offer=0; //促销金额
......
...@@ -150,6 +150,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -150,6 +150,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
GetJsonStringSafe(document,"ver"); GetJsonStringSafe(document,"ver");
//配送信息 //配送信息
std::string delivery_type;
if(document.HasMember("delivery")) if(document.HasMember("delivery"))
{ {
rapidjson::Value& delivery_obj = document["delivery"]; rapidjson::Value& delivery_obj = document["delivery"];
...@@ -162,6 +163,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -162,6 +163,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order.deliveryInfo.driver_name=GetJsonStringSafe(delivery_obj,"name"); order.deliveryInfo.driver_name=GetJsonStringSafe(delivery_obj,"name");
order.deliveryInfo.driver_phone=GetJsonStringSafe(delivery_obj,"phone"); order.deliveryInfo.driver_phone=GetJsonStringSafe(delivery_obj,"phone");
order.deliveryInfo.type=GetJsonStringSafe(delivery_obj,"type"); order.deliveryInfo.type=GetJsonStringSafe(delivery_obj,"type");
delivery_type=GetJsonStringSafe(delivery_obj,"type");
} }
} }
...@@ -202,7 +204,16 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -202,7 +204,16 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
} }
} }
order.delivery_price = GetJsonIntSafe(orderContent_obj,"deliveryFee"); //自配送
if("2"==delivery_type){
order.delivery_price = GetJsonIntSafe(orderContent_obj,"deliveryFee");
order.total_price = GetJsonIntSafe(orderContent_obj,"totalAmount");
}
else{
order.delivery_price=0;
order.total_price = GetJsonIntSafe(orderContent_obj,"totalAmount")-GetJsonIntSafe(orderContent_obj,"deliveryFee");
}
//订单信息 //订单信息
if(orderContent_obj.HasMember("orders")) if(orderContent_obj.HasMember("orders"))
...@@ -213,7 +224,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -213,7 +224,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order.deliveryInfo.status_desc = GetJsonStringSafe(orders_obj,"deliveryStatusDesc"); order.deliveryInfo.status_desc = GetJsonStringSafe(orders_obj,"deliveryStatusDesc");
order.order_id = GetJsonStringSafe(orders_obj,"orderId"); order.order_id = GetJsonStringSafe(orders_obj,"orderId");
order.pickup_code= GetJsonStringSafe(orders_obj,"pickupCode"); std::string pickupcode= GetJsonStringSafe(orders_obj,"pickupCode");
order.pickup_code= _getPickupCodeString(order.channel,pickupcode);
order.pickup_point = GetJsonStringSafe(orders_obj,"pickupPoint"); order.pickup_point = GetJsonStringSafe(orders_obj,"pickupPoint");
GetJsonStringSafe(orders_obj,"remark"); GetJsonStringSafe(orders_obj,"remark");
...@@ -332,7 +344,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -332,7 +344,7 @@ 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()) if(promotions_obj.IsObject())
{ {
GetJsonIntSafe(promotions_obj,"totalDiscount"); order.promotionInfo.summary=GetJsonIntSafe(promotions_obj,"totalDiscount");
GetJsonIntSafe(promotions_obj,"totalOriginalPrice"); GetJsonIntSafe(promotions_obj,"totalOriginalPrice");
GetJsonIntSafe(promotions_obj,"totalPrmotionPrice"); GetJsonIntSafe(promotions_obj,"totalPrmotionPrice");
...@@ -345,17 +357,21 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -345,17 +357,21 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
for(unsigned int i=0;i<promtionDetails_array.Size();i++){ for(unsigned int i=0;i<promtionDetails_array.Size();i++){
rapidjson::Value& promtionDetails_obj = promtionDetails_array[i]; rapidjson::Value& promtionDetails_obj = promtionDetails_array[i];
promotionsDetail detail;
detail.pro_id = GetJsonStringSafe(promtionDetails_obj,"proId");
GetJsonStringSafe(promtionDetails_obj,"bomId"); GetJsonStringSafe(promtionDetails_obj,"bomId");
GetJsonStringSafe(promtionDetails_obj,"comboId"); GetJsonStringSafe(promtionDetails_obj,"comboId");
GetJsonStringSafe(promtionDetails_obj,"desc"); detail.desc = GetJsonStringSafe(promtionDetails_obj,"desc");
GetJsonIntSafe(promtionDetails_obj,"discount"); detail.offer = GetJsonIntSafe(promtionDetails_obj,"discount");
GetJsonStringSafe(promtionDetails_obj,"groupId"); GetJsonStringSafe(promtionDetails_obj,"groupId");
GetJsonIntSafe(promtionDetails_obj,"originalPrice"); GetJsonIntSafe(promtionDetails_obj,"originalPrice");
GetJsonStringSafe(promtionDetails_obj,"pcode"); GetJsonStringSafe(promtionDetails_obj,"pcode");
GetJsonIntSafe(promtionDetails_obj,"prmotionPrice"); GetJsonIntSafe(promtionDetails_obj,"prmotionPrice");
GetJsonStringSafe(promtionDetails_obj,"sku"); detail.sku = GetJsonStringSafe(promtionDetails_obj,"sku");
GetJsonStringSafe(promtionDetails_obj,"type"); detail.type = atoi(GetJsonStringSafe(promtionDetails_obj,"type"));
}
order.promotionInfo.vecDetail.push_back(detail);
}
} }
} }
} }
...@@ -363,7 +379,6 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -363,7 +379,6 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
} }
GetJsonStringSafe(orderContent_obj,"sessionId"); GetJsonStringSafe(orderContent_obj,"sessionId");
order.total_price = GetJsonIntSafe(orderContent_obj,"totalAmount");
order.reduced_price = GetJsonIntSafe(orderContent_obj,"totalDiscount"); order.reduced_price = GetJsonIntSafe(orderContent_obj,"totalDiscount");
} }
...@@ -1082,6 +1097,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj) ...@@ -1082,6 +1097,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
{ {
writer.StartObject(); writer.StartObject();
writer.Key("pro_id");
writer.String(obj.promotionInfo.vecDetail[i].pro_id.c_str());
writer.Key("type"); writer.Key("type");
writer.Int(obj.promotionInfo.vecDetail[i].type); writer.Int(obj.promotionInfo.vecDetail[i].type);
...@@ -1426,7 +1444,7 @@ std::string JsonModule::_convertPosOperationToOdsJson(orderOperationObj &operati ...@@ -1426,7 +1444,7 @@ std::string JsonModule::_convertPosOperationToOdsJson(orderOperationObj &operati
writer.Key("orderId"); writer.Key("orderId");
writer.String(operation_obj.order_id.c_str()); writer.String(operation_obj.order_id.c_str());
writer.Key("code"); writer.Key("orderDealCode");
int reqType=_getODSStatusByPOSReq(operation_obj.fm_cmd); int reqType=_getODSStatusByPOSReq(operation_obj.fm_cmd);
writer.Int(reqType); writer.Int(reqType);
...@@ -1835,4 +1853,40 @@ bool JsonModule::getSetPosPriorityBackData(IN const char* inJson,OUT std::string ...@@ -1835,4 +1853,40 @@ bool JsonModule::getSetPosPriorityBackData(IN const char* inJson,OUT std::string
{ {
//缺接口 //缺接口
return true; return true;
}
std::string JsonModule::_getPickupCodeString(std::string &channel,std::string &pickup_code)
{
std::string rlt;
if("101"==channel){
rlt="普通单"+pickup_code+"号";
}
else if("102"==channel){
rlt="易果分销"+pickup_code+"号";
}
else if("201"==channel){
rlt="贩卖机"+pickup_code+"号";
}
else if("202"==channel){
rlt="洗衣机"+pickup_code+"号";
}
else if("203"==channel){
rlt="扫码购"+pickup_code+"号";
}
else if("204"==channel){
rlt="线上易果分销"+pickup_code+"号";
}
else if("205"==channel){
rlt="美团外卖"+pickup_code+"号";
}
else if("206"==channel){
rlt="百度外卖"+pickup_code+"号";
}
else if("207"==channel){
rlt="饿了么"+pickup_code+"号";
}
else if("208"==channel){
rlt="京东到家"+pickup_code+"号";
}
return rlt;
} }
\ No newline at end of file
...@@ -110,6 +110,7 @@ private: ...@@ -110,6 +110,7 @@ private:
int _getPOSOrderStatus(int status); int _getPOSOrderStatus(int status);
//POS请求类型转换为ODS需要类型 //POS请求类型转换为ODS需要类型
int _getODSStatusByPOSReq(int fm_cmd); int _getODSStatusByPOSReq(int fm_cmd);
std::string _getPickupCodeString(std::string &channel,std::string &pickup_code);
void _getStatusObj(IN orderObj &order_obj,OUT orderStatusObj &status_obj); void _getStatusObj(IN orderObj &order_obj,OUT orderStatusObj &status_obj);
void _getRefundObj(IN orderObj &order_obj,OUT refundObj &refund_obj); void _getRefundObj(IN orderObj &order_obj,OUT refundObj &refund_obj);
......
...@@ -128,6 +128,11 @@ void* listen_pos_func(void* arg) ...@@ -128,6 +128,11 @@ void* listen_pos_func(void* arg)
} }
} }
else if(reqType==REQUEST_TYPE_GOODS_CHANGE){
std::string posReq = charset_g2u(posRequestData);
LOG(INFO)<<"POS send goods change data:"<<posReq.data();
jsonTool.getPosResponseData(100, "success", responseData);
}
else else
{ {
LOG(INFO)<<"POS send data:"<<posRequestData.data(); LOG(INFO)<<"POS send data:"<<posRequestData.data();
......
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