Commit ae18c821 by guanghui.cui

更新pos打印计数

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