Jelajahi Sumber

继续做正餐打印

张洋 3 tahun lalu
induk
melakukan
473d35c729

+ 1 - 1
zhipuzi_pos_windows/page/CZhengcanDiandanPageUI.cpp

@@ -4191,7 +4191,7 @@ void CZhengcanDiandanPageUI::StartWorkAfterShoukuan(std::string shoukuan_type, s
 	CZhengcanOrder order = this->GetPrintOrderinfoJiesuan(shoukuan_type, balance, member_number);
 
 	CPosPrinter printer;
-	printer.PrintZhengcanOrderXiadan(order);
+	printer.PrintZhengcanOrderJiesuan(order);
 
 	//结账成功了,返回到桌子列表
 	m_pMainWnd->SwitchPage(CMainWnd::ZHENGCAN);

+ 17 - 0
zhipuzi_pos_windows/print/CPosPrinter.cpp

@@ -225,6 +225,23 @@ void CPosPrinter::PrintZhengcanOrderYulan(CZhengcanOrder& order)
 	}
 }
 
+//完成所有打印一个正餐结算的打印操作(不等待,立即返回)
+void CPosPrinter::PrintZhengcanOrderJiesuan(CZhengcanOrder& order)
+{
+	if (CSetting::GetInstance()->GetParam("setting_is_new_diannei_printer") == "1")
+	{
+		//执行收银小票打印操作
+		CPosPrinterData printData;
+
+		std::string data = printData.PrintZhengcanOrderJiesuanShouyin(order);
+
+		if (data.length() > 0)
+		{
+			CPosPrinterQueue::GetInstance()->AddShouyinPrinter(data);
+		}
+	}
+}
+
 void CPosPrinter::PirntJiaobanOrder(CJiaobaoOrder& order)
 {
 	CPosPrinterData printData;

+ 3 - 0
zhipuzi_pos_windows/print/CPosPrinter.h

@@ -33,6 +33,9 @@ public:
 	//完成所有打印一个正餐预览的打印操作(不等待,立即返回)
 	void PrintZhengcanOrderYulan(CZhengcanOrder& order);
 
+	//完成所有打印一个正餐结算的打印操作(不等待,立即返回)
+	void PrintZhengcanOrderJiesuan(CZhengcanOrder& order);
+
 	//打印交班单
 	void PirntJiaobanOrder(CJiaobaoOrder& order);
 

+ 419 - 0
zhipuzi_pos_windows/print/CPosPrinterData.cpp

@@ -3538,6 +3538,425 @@ std::string CPosPrinterData::PrintZhengcanOrderYulanShouyin(CZhengcanOrder& orde
 	return m_print_content;
 }
 
+std::string CPosPrinterData::PrintZhengcanOrderJiesuanShouyin(CZhengcanOrder& order)
+{
+	//读取当前收银打印机的设置
+	std::string guige = CSetting::GetInstance()->GetParam("setting_printer_guige");
+	std::string lianshu = CSetting::GetInstance()->GetParam("setting_printer_lianshu");
+	int n_lianshu = atoi(lianshu.c_str());
+
+	//正式开始打印
+	for (int i = 0; i < n_lianshu; i++)
+	{
+		POS_Reset();
+
+		//判断是否打印顶部logo
+		if (CShopinfo::GetInstance()->m_machine_logo_open == "1")
+		{
+			std::wstring imagePath = CShopinfo::GetInstance()->GetImageTmpPathFromUrl(CShopinfo::GetInstance()->m_machine_logo_url);
+
+			POS_OutBmp(imagePath);
+			POS_FeedLine();
+		}
+
+		//打印店铺名字
+		string shop_name = CLewaimaiString::UTF8ToANSI(order.shopname);
+		POS_TextOut(shop_name, true, true, 1);
+
+		POS_FeedLine();
+		POS_FeedLine();
+
+		//打印点菜单
+		string diancaidan = "结算单";
+		POS_TextOut(diancaidan, false, false, 1);
+
+		POS_FeedLine();
+		POS_FeedLine();
+
+		//打印桌位
+		string date = "桌位:" + CLewaimaiString::UTF8ToANSI(order.table_name);
+		POS_TextOut(date, true, true, 0);
+
+		POS_FeedLine();
+		POS_FeedLine();
+
+		//订单号
+		bool setting_printer_dingdanhao_big = false;
+		if (CSetting::GetInstance()->GetParam("setting_printer_dingdanhao_big") == "1")
+		{
+			setting_printer_dingdanhao_big = true;
+		}
+
+		string order_num = "订 单 号:" + CLewaimaiString::UTF8ToANSI(order.show_trade_no);
+		POS_TextOut(order_num, false, setting_printer_dingdanhao_big);
+		POS_FeedLine();
+
+		//订单来源
+		if (order.order_from == 1)
+		{
+			string from_type = "订单来源:收银系统";
+			POS_TextOut(from_type);
+			POS_FeedLine();
+		}
+		else if (order.order_from == 2)
+		{
+			string from_type = "订单来源:商家app";
+			POS_TextOut(from_type);
+			POS_FeedLine();
+		}
+		else if (order.order_from == 3)
+		{
+			string from_type = "订单来源:扫码下单";
+			POS_TextOut(from_type);
+			POS_FeedLine();
+		}
+
+		//下单时间
+		bool setting_printer_xiadanshijian_big = false;
+
+		if (CSetting::GetInstance()->GetParam("setting_printer_xiadanshijian_big") == "1")
+		{
+			setting_printer_xiadanshijian_big = true;
+		}
+
+		string order_date = "打印时间:" + CLewaimaiString::UTF8ToANSI(order.init_time);
+		POS_TextOut(order_date, false, setting_printer_xiadanshijian_big);
+		POS_FeedLine();
+
+		string shouyinyuan = "收银员:" + CLewaimaiString::UTF8ToANSI(CSetting::GetInstance()->getUsername());
+		POS_TextOut(shouyinyuan, false, false);
+		POS_FeedLine();
+
+		//准备开始打印商品详情
+		string lines;
+
+		if (guige == "58")
+		{
+			lines = "--------------------------------";
+		}
+		else
+		{
+			lines = "------------------------------------------------";
+		}
+
+		POS_TextOut(lines);
+		POS_FeedLine();
+
+		//商品标题
+		bool setting_printer_shangpin_big = false;
+
+		if (CSetting::GetInstance()->GetParam("setting_printer_shangpin_big") == "1")
+		{
+			setting_printer_shangpin_big = true;
+		}
+
+		if (guige == "58")
+		{
+			POS_TextOut("商品           单价   数量  金额", false, setting_printer_shangpin_big);
+		}
+		else
+		{
+			POS_TextOut("商品                         单价    数量   金额", false, setting_printer_shangpin_big);
+		}
+
+		POS_FeedLine();
+
+		int n_fenshu = 0;
+
+		//商品内容
+		for (std::vector<CZhengcanOrderItemPrint>::iterator it = order.m_items_print.begin(); it != order.m_items_print.end(); it++)
+		{
+			if (it->is_taocan_item == true)
+			{
+				//套餐的item,收银小票不打印
+				continue;
+			}
+
+			std::string food_name = (*it).m_food_name;
+			std::string food_price = (*it).m_item_price;
+			std::string quantity = (*it).m_quantity;
+
+			if (atof(quantity.c_str()) - atoi(quantity.c_str()) > 0.00001)
+			{
+				//数量为小数,称重商品
+				n_fenshu += 1;
+			}
+			else
+			{
+				n_fenshu += atoi(quantity.c_str());
+			}
+
+			//计算总价
+			double item_price = atof(food_price.c_str()) * atof(quantity.c_str());
+			std::string food_total_price = CLewaimaiString::DoubleToString(item_price, 2);
+
+			if (food_total_price == "0.00")
+			{
+				//这里是特殊处理满赠的展示
+				food_total_price = "";
+			}
+
+			food_name = CLewaimaiString::UTF8ToANSI(food_name);
+
+			//先输出商品名字
+			std::vector<string> m_names;
+
+			if (guige == "58")
+			{
+				m_names = HandleFoodname(food_name, 1);
+			}
+			else
+			{
+				m_names = HandleFoodname(food_name, 2);
+			}
+
+			std::string firstLine = m_names[0];
+			int nGuige;
+
+			if (guige == "58")
+			{
+				nGuige = 1;
+			}
+			else
+			{
+				nGuige = 2;
+			}
+
+			std::string priceShow = HandleFoodItemPrice(food_price, nGuige);
+			std::string quantityShow = HandleFoodQuantity(quantity, nGuige);
+			std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, nGuige);
+			std::string firstLineShow = firstLine + priceShow + quantityShow + priceTotalShow;
+
+			POS_TextOut(firstLineShow, false, setting_printer_shangpin_big);
+			POS_FeedLine();
+
+			for (std::vector<string>::iterator it = m_names.begin() + 1; it != m_names.end(); it++)
+			{
+				POS_TextOut((*it), false, setting_printer_shangpin_big);
+				POS_FeedLine();
+			}
+		}
+
+		//判断是否有备注
+		if (order.m_memo.length() > 0)
+		{
+			bool setting_printer_memo_big = false;
+
+			if (CSetting::GetInstance()->GetParam("setting_printer_memo_big") == "1")
+			{
+				setting_printer_memo_big = true;
+			}
+
+			POS_FeedLine();
+			string address = "整单备注:" + CLewaimaiString::UTF8ToANSI(order.m_memo);
+			POS_TextOut(address, false, setting_printer_memo_big);
+			POS_FeedLine();
+		}
+
+		//结束商品详情打印
+		POS_TextOut(lines);
+		POS_FeedLine();
+
+		//开始打印其他的费用
+		bool is_other_money = false;
+		bool setting_printer_price_big = false;
+
+		if (CSetting::GetInstance()->GetParam("setting_printer_price_big") == "1")
+		{
+			setting_printer_price_big = true;
+		}
+
+		if (atof(order.m_dabao_money.c_str()) > 0)
+		{
+			string dabao = "打包费:" + CLewaimaiString::UTF8ToANSI(order.m_dabao_money);
+			POS_TextOut(dabao, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_chawei_money.c_str()) > 0)
+		{
+			string dabao = "茶位费:" + CLewaimaiString::UTF8ToANSI(order.m_chawei_money);
+			POS_TextOut(dabao, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_kaitai_money.c_str()) > 0)
+		{
+			string dabao = "开台费:" + CLewaimaiString::UTF8ToANSI(order.m_kaitai_money);
+			POS_TextOut(dabao, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		//开始显示增值服务费
+		/*
+		if (order.m_addservie.size() > 0)
+		{
+			for (std::vector<CWaimaiOrderField>::iterator it = order.m_addservie.begin(); it != order.m_addservie.end(); it++)
+			{
+				string addservice = CLewaimaiString::UTF8ToANSI((*it).name) + ":" + CLewaimaiString::DoubleToString((double)atof((*it).value.c_str()), 2);
+				POS_TextOut(addservice, false, setting_printer_price_big);
+				POS_FeedLine();
+				is_other_money = true;
+			}
+
+			is_other_money = true;
+		}
+		}*/
+
+		if (atof(order.m_shangpinquan_youhui.c_str()) > 0)
+		{
+			string youhui = "商品券优惠:" + order.m_shangpinquan_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_cika_youhui.c_str()) > 0)
+		{
+			string youhui = "次卡优惠:" + order.m_cika_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_total_member_youhui.c_str()) > 0)
+		{
+			string youhui = "商品会员价优惠:" + order.m_total_member_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_zhekou_youhui.c_str()) > 0)
+		{
+			string youhui = "整单折扣优惠:" + order.m_zhekou_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_member_zhekou_youhui.c_str()) > 0)
+		{
+			string youhui = "会员整单折扣优惠:" + order.m_member_zhekou_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_quanyika_youhui.c_str()) > 0)
+		{
+			string youhui = "权益卡优惠:" + order.m_quanyika_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_manjian_youhui.c_str()) > 0)
+		{
+			string youhui = "满减优惠:" + order.m_manjian_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_youhuiquan_youhui.c_str()) > 0)
+		{
+			string youhui = "优惠券优惠:" + order.m_youhuiquan_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_rengong_youhui.c_str()) > 0)
+		{
+			string youhui = "人工优惠:" + order.m_rengong_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (atof(order.m_moling_youhui.c_str()) > 0)
+		{
+			string youhui = "抹零优惠:" + order.m_moling_youhui + "元";
+			POS_TextOut(youhui, false, setting_printer_price_big);
+			POS_FeedLine();
+			is_other_money = true;
+		}
+
+		if (is_other_money)
+		{
+			POS_TextOut(lines);
+			POS_FeedLine();
+		}
+
+		//最后显示总价
+		POS_TextOut("总计:" + order.m_total_price + "元", false, setting_printer_price_big, 2);
+		POS_FeedLine();
+
+		//显示付款方式
+		bool setting_printer_pay_big = false;
+
+		if (CSetting::GetInstance()->GetParam("setting_printer_pay_big") == "1")
+		{
+			setting_printer_pay_big = true;
+		}
+
+		POS_TextOut("支付方式:" + CLewaimaiString::UTF8ToANSI(order.shoukuan_type), false, setting_printer_pay_big, 2);
+		POS_FeedLine();
+
+		if (order.shoukuan_type == CLewaimaiString::UnicodeToUTF8(L"会员支付"))
+		{
+			POS_TextOut("会员余额:" + CLewaimaiString::UTF8ToANSI(order.balance), false, false, 2);
+			POS_FeedLine();
+
+			POS_TextOut("会员编号:" + CLewaimaiString::UTF8ToANSI(order.member_number), false, false, 2);
+			POS_FeedLine();
+		}
+
+		POS_FeedLine();
+		POS_FeedLine();
+
+		//是否打印底部二维码
+		if (CShopinfo::GetInstance()->m_machine_qrcode_open == "1")
+		{
+			POS_OutQRCode(CLewaimaiString::UTF8ToANSI(CShopinfo::GetInstance()->m_machine_qrcode_url));
+			POS_FeedLine();
+
+			POS_TextOut(CLewaimaiString::UTF8ToANSI(CShopinfo::GetInstance()->m_machine_qrcode_title), false, false, 1);
+			POS_FeedLine();
+			POS_FeedLine();
+		}
+
+		if (CShopinfo::GetInstance()->m_self_defined_open == "1")
+		{
+			POS_TextOut(CLewaimaiString::UTF8ToANSI(CShopinfo::GetInstance()->m_self_defined_content1), false, false, 1);
+			POS_FeedLine();
+			POS_FeedLine();
+
+			POS_TextOut(CLewaimaiString::UTF8ToANSI(CShopinfo::GetInstance()->m_self_defined_content2), false, false, 1);
+			POS_FeedLine();
+			POS_FeedLine();
+		}
+
+		//走纸几行再切
+		POS_FeedLine();
+		POS_FeedLine();
+		POS_FeedLine();
+		POS_FeedLine();
+		POS_FeedLine();
+
+		POS_CutPaper();
+	}
+
+	//还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
+	POS_Reset();
+
+	return m_print_content;
+}
+
 std::string CPosPrinterData::PrintJiaobanOrder(CJiaobaoOrder& order)
 {
 	//读取当前收银打印机的设置

+ 3 - 0
zhipuzi_pos_windows/print/CPosPrinterData.h

@@ -38,6 +38,9 @@ public:
 	//预览单小票
 	std::string PrintZhengcanOrderYulanShouyin(CZhengcanOrder& order);
 
+	//结算单小票
+	std::string PrintZhengcanOrderJiesuanShouyin(CZhengcanOrder& order);
+
 	std::string PrintJiaobanOrder(CJiaobaoOrder& order);
 
 	std::string PrintHuiyuanchongzhiOrder(CHuiyuanchongzhiOrder& order);