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,6 +215,7 @@ void *FunPrintLable(void* lpParamter) ...@@ -215,6 +215,7 @@ void *FunPrintLable(void* lpParamter)
int statusCode; int statusCode;
std::string msg; std::string msg;
if(printObj.strCmd == "print_lable"){
nErrCode = dbOperation->PrintLable(printObj); nErrCode = dbOperation->PrintLable(printObj);
LOG(INFO)<<"---------------print result:"<<nErrCode; LOG(INFO)<<"---------------print result:"<<nErrCode;
if(nErrCode == EC_OK) if(nErrCode == EC_OK)
...@@ -226,6 +227,21 @@ void *FunPrintLable(void* lpParamter) ...@@ -226,6 +227,21 @@ void *FunPrintLable(void* lpParamter)
statusCode=101; statusCode=101;
msg = "print failed"; 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(),""); std::string strReturnJson = GetTakeawayResultJson(statusCode,msg.data(),"");
//发送返回数据 //发送返回数据
......
...@@ -276,6 +276,10 @@ bool GetTakeawayPrintInfo(const char* json, LableObj &print) ...@@ -276,6 +276,10 @@ bool GetTakeawayPrintInfo(const char* json, LableObj &print)
} }
else else
{ {
rapidjson::Value& fm_cmd = document["fm_cmd"];
print.strCmd =fm_cmd.GetString();
if(print.strCmd == "print_lable")
{
rapidjson::Value& strDevice = document["device"]; rapidjson::Value& strDevice = document["device"];
rapidjson::Value& iBaud = document["baud"]; rapidjson::Value& iBaud = document["baud"];
print.strDevice=strDevice.GetString(); print.strDevice=strDevice.GetString();
...@@ -296,5 +300,12 @@ bool GetTakeawayPrintInfo(const char* json, LableObj &print) ...@@ -296,5 +300,12 @@ bool GetTakeawayPrintInfo(const char* json, LableObj &print)
} }
} }
} }
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