Commit 15320fc4 by wuyang.zou

fix New Feature :

Add familyRice Column Filed
Support Run Windows Get Convert Test Order Local testOrderJson.json Test File
Version: 1.2.4
parent cc4c73da
...@@ -199,6 +199,7 @@ struct orderObj ...@@ -199,6 +199,7 @@ struct orderObj
int totalCouponDiscount = 0; //使用优惠券发生的折扣 int totalCouponDiscount = 0; //使用优惠券发生的折扣
int totalExcessiveCharge = 0; //使用优惠券发生的溢收 int totalExcessiveCharge = 0; //使用优惠券发生的溢收
int zhxPoint = 0; //甄会选积分 int zhxPoint = 0; //甄会选积分
int familyRice = 0; //米粒數
// Berry 新增3个积分字段,全家模式下注释这3个字段; // Berry 新增3个积分字段,全家模式下注释这3个字段;
/* /*
......
{
"channel":"207",
"cityId":"",
"delivery":{
"basicPrice":0,
"customerAddress":"上海市闵行区龙茗路2710号",
"customerName":"某",
"customerPhone":"13020144745-413",
"deliveryId":"",
"deliveryTime":"20201224180000",
"distancePrice":0,
"logisticsPhysicalCompany":"",
"name":"",
"phone":"",
"type":"2"
},
"invoice":null,
"offlinePoints":false,
"orderContent":{
"appointmentVO":{
"appointmentTime":"",
"isAppointment":0
},
"createTime":"20201224172736",
"customer":[
{
"accountId":"13020144745-413",
"accountType":"1",
"cardNo":"",
"dyCode":"",
"level":"",
"mobileNo":""
}
],
"deliveryFee":0,
"ecoupons":[
],
"orderCoupons":[
],
"orders":{
"cancelStatus":"",
"deliveryStatus":"",
"deliveryStatusDesc":"",
"id":195035867550581001,
"orderId":"5015398442799490083",
"orderType":"",
"parentId":"",
"pickupCode":"36",
"pickupPoint":"5015398442799490083",
"products":[
{
"attributes":"",
"catgId":"",
"couponQty":0,
"groupIndex":"",
"groupName":"",
"name":"M&M's花生牛奶巧克力",
"originalPrice":580,
"price":580,
"productCode":"",
"productType":"",
"qty":1,
"sku":"20097868",
"source":"",
"specs":[
],
"status":""
},
{
"attributes":"",
"catgId":"",
"couponQty":0,
"groupIndex":"",
"groupName":"",
"name":"M&M's牛奶巧克力",
"originalPrice":580,
"price":580,
"productCode":"",
"productType":"",
"qty":1,
"sku":"20097851",
"source":"",
"specs":[
],
"status":""
},
{
"attributes":"",
"catgId":"",
"couponQty":0,
"groupIndex":"",
"groupName":"",
"name":"包材",
"originalPrice":90,
"price":90,
"productCode":"",
"productType":"",
"qty":1,
"sku":"20823436",
"source":"",
"specs":[
],
"status":""
}
],
"reason":"",
"reasonForFailure":"",
"remark":"自提, 提货时间:2020-12-24 18:00:00 , 饿了么订单号:5015398442799490083 0",
"status":"6",
"statusDesc":"已完成",
"storeType":1
},
"payInfos":[
{
"accountId":"",
"amount":1250,
"fmId":"",
"payCode":"",
"payType":"00002",
"transNum":""
}
],
"payType":"00002",
"points":{
"basicPoint":195,
"extraPoint":0,
"nkbBasicPoint":0,
"nkbExtraPoint":0,
"otherBrandPoint":0,
"pointDetails":[],
"remainingBrandPoint":0,
"remainingNkbPoint":0,
"totalPoint":195,
"zhxPoint":0,
"familyRice":999
},
"promotions":{
"promtionDetails":[
],
"totalDiscount":0,
"totalOriginalPrice":0,
"totalPromotionPrice":0
},
"sessionId":"",
"totalAmount":290,
"totalCouponDiscount":0,
"totalDiscount":960,
"totalExcessiveCharge":0,
"wmDiscount":960,
"wmPtSharedDiscount":960,
"wmSjSharedDiscount":0
},
"orderIds":[
],
"pcId":"",
"sellerInfo":null,
"shopInfo":{
"barCounter":"",
"child_store_id":"",
"operator":"",
"posId":"1",
"selfHelpMac":null,
"storeId":"201081",
"store_type":""
},
"token":"",
"ver":1
}
\ No newline at end of file
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "../3rdParty/rapidjson/writer.h" #include "../3rdParty/rapidjson/writer.h"
#include "../3rdParty/rapidjson/stringbuffer.h" #include "../3rdParty/rapidjson/stringbuffer.h"
#include "../3rdParty/easylogging/easylogging++.h" #include "../3rdParty/easylogging/easylogging++.h"
#include <iostream> #include <iostream>
std::string g_store_id = ""; std::string g_store_id = "";
...@@ -335,6 +334,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order) ...@@ -335,6 +334,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order.bonus_extra_nkb = GetJsonIntSafe(points_obj, "nkbExtraPoint"); order.bonus_extra_nkb = GetJsonIntSafe(points_obj, "nkbExtraPoint");
order.bonus_basic_nkb = GetJsonIntSafe(points_obj, "nkbBasicPoint"); order.bonus_basic_nkb = GetJsonIntSafe(points_obj, "nkbBasicPoint");
order.zhxPoint = GetJsonIntSafe(points_obj, "zhxPoint"); order.zhxPoint = GetJsonIntSafe(points_obj, "zhxPoint");
order.familyRice = GetJsonIntSafe(points_obj, "familyRice");
// Berry 新增3个积分字段,全家模式下注释这3个字段; // Berry 新增3个积分字段,全家模式下注释这3个字段;
//order.otherPoint = GetJsonIntSafe(points_obj, "otherBrandPoint"); //order.otherPoint = GetJsonIntSafe(points_obj, "otherBrandPoint");
...@@ -1155,6 +1155,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj) ...@@ -1155,6 +1155,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer.Int(obj.bonus_total); writer.Int(obj.bonus_total);
writer.Key("zhxPoint"); writer.Key("zhxPoint");
writer.Int(obj.zhxPoint); writer.Int(obj.zhxPoint);
writer.Key("familyRice");
writer.Int(obj.familyRice);
// Berry 新增3个积分字段,全家模式下注释这3个字段; // Berry 新增3个积分字段,全家模式下注释这3个字段;
/* /*
writer.Key("otherPoint"); writer.Key("otherPoint");
...@@ -2112,6 +2115,46 @@ void JsonModule::setInitData(IN const char* data) ...@@ -2112,6 +2115,46 @@ void JsonModule::setInitData(IN const char* data)
g_pos_ismaster = document["is_master"].GetBool(); g_pos_ismaster = document["is_master"].GetBool();
} }
std::string JsonModule::getTestOrderJson() {
std::string strBinPath = GetProcDir();
std::string strTestOrderFile = strBinPath += "testOrderJson.json";
std::ifstream fileStream(strTestOrderFile.c_str(), std::ios::binary | std::ios::in | std::ios::ate );
if (!fileStream.is_open()) {
LOG(ERROR) << "Open File: testOrderJson.json Failed, May Be Not Exist "<<"";
return "";
}
char * buffer = nullptr; long size;
size = fileStream.tellg();
fileStream.seekg(0, std::ios::beg);
buffer = new char[size+1];
fileStream.read(buffer , size);
buffer[size] = '\0';
std::string testOrderData = buffer;
delete[] buffer; buffer = nullptr;
rapidjson::Document doc;
doc.Parse( testOrderData.c_str() );
if (doc.HasParseError()) {
LOG(ERROR) << "Rapidjson Parse Error :"<< doc.GetParseError();
return "";
}
return testOrderData;
}
std::string JsonModule::getConvertOrderJson(std::string & originOrderData) {
orderObj tempOrder;
std::string result;
bool rlt = getPushOrders(originOrderData.c_str(), tempOrder);
if (rlt) {
result = _convertToNewOrderJson(tempOrder);
}
return result;
}
int JsonModule::_getODSStatusByPOSReq(int fm_cmd) int JsonModule::_getODSStatusByPOSReq(int fm_cmd)
{ {
int rlt=0; int rlt=0;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "../utility/utility.h"
#include "../base/CommonStruct.h" #include "../base/CommonStruct.h"
#include "../base/BaseDefine.h" #include "../base/BaseDefine.h"
...@@ -11,7 +12,7 @@ extern std::string g_pos_id; ...@@ -11,7 +12,7 @@ extern std::string g_pos_id;
extern bool g_pos_ismaster; extern bool g_pos_ismaster;
#define VERSION "1.2.3 RC" //版本号; #define VERSION "1.2.4 RC" //版本号;
class JsonModule class JsonModule
...@@ -113,6 +114,14 @@ public: ...@@ -113,6 +114,14 @@ public:
* */ * */
void setInitData(IN const char* data); void setInitData(IN const char* data);
/* 功能: Win32 模式 读取 本地测试订单数据
* 参数:
* 返回: testOrderJson.json 文件的报文数据;
* */
std::string getTestOrderJson();
std::string getConvertOrderJson(std::string & originOrderData);
private: private:
std::string _store_id; //门店号 std::string _store_id; //门店号
std::string _pos_id; //POS编号; // 后期使用过程中,大多会使用新栈对象,导致暂存的数据丢失; std::string _pos_id; //POS编号; // 后期使用过程中,大多会使用新栈对象,导致暂存的数据丢失;
......
...@@ -312,6 +312,16 @@ int main(int argc,char *argv[]) ...@@ -312,6 +312,16 @@ int main(int argc,char *argv[])
kill_origin_process(); //如果已有进程,杀掉 kill_origin_process(); //如果已有进程,杀掉
#ifdef WIN32 #ifdef WIN32
// Test Add New Feature Convert Result: Column Field
std::string testOrderJson = jsonToolTemp.getTestOrderJson();
std::string convertTestOrderJson = jsonToolTemp.getConvertOrderJson(testOrderJson);
if (testOrderJson.length() && convertTestOrderJson.length() ) {
LOG(INFO) << "----------- Plugin Read&Convert Local Test Order File Success ------------";
LOG(INFO) << charset_u2g(convertTestOrderJson);
} else {
LOG(INFO) << "----------- Plugin Read&Convert Local Test Order File Failed------------";
}
HANDLE hTakeway = CreateThread(NULL, 0, listen_pos_func, NULL, 0, NULL); HANDLE hTakeway = CreateThread(NULL, 0, listen_pos_func, NULL, 0, NULL);
#else #else
// 监听POS请求的线程 // 监听POS请求的线程
...@@ -506,6 +516,7 @@ bool order_send_to_pos(IN std::string &order_json,IN std::string &ods_json,OUT s ...@@ -506,6 +516,7 @@ bool order_send_to_pos(IN std::string &order_json,IN std::string &ods_json,OUT s
return rlt; return rlt;
} }
void getIpByDns(IN std::string &ods_ip) { void getIpByDns(IN std::string &ods_ip) {
if (ods_ip.front() < '0' || ods_ip.front() > '9') { if (ods_ip.front() < '0' || ods_ip.front() > '9') {
......
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