Commit ae18c821 by guanghui.cui

更新pos打印计数

parent f531d5aa
......@@ -106,8 +106,10 @@ struct LableItem
struct LableObj
{
std::string strCmd; //命令类型
std::string strDevice; //设备
int iBaud; //波特率
std::string strOrderId; //订单id
std::vector<LableItem> vecItem; //打印内容
};
......
......@@ -53,7 +53,10 @@ public:
//获取套餐信息(套餐包含项目)
virtual std::map<std::string, std::vector<SetMenuItem>>& GetSetMenu()=0;
//打印小票
virtual int PrintLable(LableObj &print)=0;
//更新打印计数
virtual int updatePrintCount(LableObj &print)=0;
};
#ifdef WIN32
......
......@@ -261,7 +261,7 @@ int COrderInfo::SetTakeawayOrder(IN TakeawayOrder &order,OUT std::string &posOrd
snprintf(mysql->sqlStr,SQL_BUFFER_SIZE, "INSERT INTO tbl_Check(`Date`,`Check`,BarCode,Outlet,`Floor`,TableNo,Cover,OpenTime,OpenPeriod,OpenStation,\
OpenStationRef,OpenEmp,CloseTime,ClosePeriod,CloseStation,CloseEmp,PrintCount,LastPrintTime,CheckTot,ItemTot,DiscBefore,PayTot,IsPaid,SCRate1,\
IsModified,LastModifiedTime)\
VALUES('%s',%d,'%s',%d,1,'1',1,'%s',3,99,99,4,'%s',4,99,4,1,'%s',%.2f,%.2f,%.2f,%.2f,'1',0.1,1,'%s')", \
VALUES('%s',%d,'%s',%d,1,'1',1,'%s',3,99,99,4,'%s',4,99,4,0,'%s',%.2f,%.2f,%.2f,%.2f,'1',0.1,1,'%s')", \
strDate.data(),orderId,orderIdStr,iOutlet,chTime,chTime,chTime,merchantTot,order.shop_fee/100.00,-discount,merchantTot,chTime);
nErrCode = mysql->insert();
if(nErrCode != EC_OK)
......@@ -803,6 +803,17 @@ int COrderInfo::PrintLable(LableObj &printObj)
return EC_OK;
}
int COrderInfo::updatePrintCount(LableObj &printObj)
{
int nErrCode=EC_OK;
snprintf(mysql->sqlStr,SQL_BUFFER_SIZE,"UPDATE tbl_Check SET PrintCount=PrintCount+1,LastPrintTime=NOW() WHERE `Check`=%d;",atoi(printObj.strOrderId.data()));
LOG(INFO) << mysql->sqlStr;
nErrCode = mysql->update();
return nErrCode;
}
int COrderInfo::charset_convert(const char* charset_from, const char* charset_to
, const std::string& string_from, std::string& string_to)
{
......
......@@ -73,6 +73,7 @@ public:
//小票打印
int PrintLable(LableObj &print);
int updatePrintCount(LableObj &print);
std::string m_FMPay;
......
......@@ -215,18 +215,34 @@ void *FunPrintLable(void* lpParamter)
int statusCode;
std::string msg;
nErrCode = dbOperation->PrintLable(printObj);
LOG(INFO)<<"---------------print result:"<<nErrCode;
if(nErrCode == EC_OK)
{
statusCode = 100;
msg = "";
if(printObj.strCmd == "print_lable"){
nErrCode = dbOperation->PrintLable(printObj);
LOG(INFO)<<"---------------print result:"<<nErrCode;
if(nErrCode == EC_OK)
{
statusCode = 100;
msg = "";
}
else{
statusCode=101;
msg = "print failed";
}
}
else{
statusCode=101;
msg = "print failed";
else if(printObj.strCmd == "update_count"){
nErrCode = dbOperation->updatePrintCount(printObj);
LOG(INFO)<<"update print count result:"<<nErrCode;
if(nErrCode == EC_OK)
{
statusCode = 100;
msg = "";
}
else{
statusCode=101;
msg = "update print count failed";
}
}
std::string strReturnJson = GetTakeawayResultJson(statusCode,msg.data(),"");
//发送返回数据
int result = socketSendData(strReturnJson.data(), connect_fd);
......
......@@ -276,25 +276,36 @@ bool GetTakeawayPrintInfo(const char* json, LableObj &print)
}
else
{
rapidjson::Value& strDevice = document["device"];
rapidjson::Value& iBaud = document["baud"];
print.strDevice=strDevice.GetString();
print.iBaud=iBaud.GetInt();
rapidjson::Value& printObjs= document["print"];
if(printObjs.IsArray()){
for(unsigned int i=0;i<printObjs.Size();i++){
LableItem obj;
rapidjson::Value& printValue = printObjs[i];
rapidjson::Value& vText = printValue["text"];
rapidjson::Value& vType = printValue["type"];
obj.strText =vText.GetString();
obj.type=vType.GetInt();
print.vecItem.push_back(obj);
rapidjson::Value& fm_cmd = document["fm_cmd"];
print.strCmd =fm_cmd.GetString();
if(print.strCmd == "print_lable")
{
rapidjson::Value& strDevice = document["device"];
rapidjson::Value& iBaud = document["baud"];
print.strDevice=strDevice.GetString();
print.iBaud=iBaud.GetInt();
rapidjson::Value& printObjs= document["print"];
if(printObjs.IsArray()){
for(unsigned int i=0;i<printObjs.Size();i++){
LableItem obj;
rapidjson::Value& printValue = printObjs[i];
rapidjson::Value& vText = printValue["text"];
rapidjson::Value& vType = printValue["type"];
obj.strText =vText.GetString();
obj.type=vType.GetInt();
print.vecItem.push_back(obj);
}
}
}
else if(print.strCmd == "update_count"){
rapidjson::Value& orderId = document["order_id"];
print.strOrderId=orderId.GetString();
}
}
return true;
}
\ No newline at end of file
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