Browse Source

Merge branch '5.0' of https://gitserver.xunjoy.com/zhangyang/zhipuzi_pos_windows into 5.0

张洋 1 month ago
parent
commit
62dec53983

+ 52 - 1
zhipuzi_pos_windows/helper/CLewaimaiString.cpp

@@ -10,7 +10,6 @@
 
 using namespace boost::archive::iterators;
 
-
 unsigned char ToHex(unsigned char x)
 {
     return  x > 9 ? x + 55 : x + 48;
@@ -662,3 +661,55 @@ std::string CLewaimaiString::GenerateRandomStr(size_t len, bool useTimeSeed)
 
 	return result;
 }
+
+std::string CLewaimaiString::TrimDecimalZero(const std::string& str)
+{
+	std::string result = str;
+
+	size_t dotPos = result.find('.');
+	if (dotPos == std::string::npos)
+	{
+		return result;
+	}
+
+	size_t lastNotZero = result.find_last_not_of('0');
+	if (lastNotZero == std::string::npos)
+	{
+		return result;
+	}
+
+	result.erase(lastNotZero + 1);
+
+	if (!result.empty() && result[result.length() - 1] == '.')
+	{
+		result.erase(result.length() - 1);
+	}
+
+	return result;
+}
+
+std::wstring CLewaimaiString::TrimDecimalZero(const std::wstring& str)
+{
+	std::wstring result = str;
+
+	size_t dotPos = result.find(L'.');
+	if (dotPos == std::wstring::npos)
+	{
+		return result;
+	}
+
+	size_t lastNotZero = result.find_last_not_of(L'0');
+	if (lastNotZero == std::wstring::npos)
+	{
+		return result;
+	}
+
+	result.erase(lastNotZero + 1);
+
+	if (!result.empty() && result[result.length() - 1] == L'.')
+	{
+		result.erase(result.length() - 1);
+	}
+
+	return result;
+}

+ 5 - 1
zhipuzi_pos_windows/helper/CLewaimaiString.h

@@ -57,7 +57,7 @@ public:
 
 	//在字符串old的左边,补num个字符 zifu
 	static std::string BuZifuLeft(std::string old, int num, const char zifu);
-
+	
 	//用于条码标签秤,把Unicode格式的字符串(可以中英文混写)转换成用于条码秤的区位码
 	static std::string GetQuweima(std::wstring input);
 
@@ -76,4 +76,8 @@ public:
 	// 生成随机字符串函数
 	// len: 字符串长度  useTimeSeed: 是否使用时间种子(默认开启)
 	static std::string GenerateRandomStr(size_t len, bool useTimeSeed = true);
+
+	//去除小数点后多余的0,比如1.00变成1,1.10变成1.1,1.01不变
+	static std::string TrimDecimalZero(const std::string& str);
+	static std::wstring TrimDecimalZero(const std::wstring& str);
 };

+ 3 - 0
zhipuzi_pos_windows/pch/pch.h

@@ -39,6 +39,9 @@
 #include <winioctl.h>
 #include <setupapi.h>
 #include <winuser.h>
+#include <stdio.h>
+#include <atlbase.h>
+#include <atlcom.h>
 
 //boost库的头文件
 #include <boost/asio.hpp>

+ 3 - 8
zhipuzi_pos_windows/tool/CSpeech.cpp

@@ -2,15 +2,10 @@
 #include "CSpeech.h"
 
 #include "tts/TtsClient.h"
-
-#include <cstdlib>
-#include <iostream>
-#include <string>
-
-#ifdef _WIN32
 #include "tts/PcmPlayer.h"
 #include "tts/StreamTtsPlayer.h"
-#endif
+
+#include <sapi.h>
 
 CSpeech::CSpeech()
 {
@@ -29,7 +24,7 @@ void CSpeech::TTSSpeak(std::string speakContent)
 	}
 	else
 	{
-		CSpeech::TXSpeak(speakContent);
+		CSpeech::MSSSpeak(speakContent);
 	}
 }
 

+ 0 - 7
zhipuzi_pos_windows/tool/CSpeech.h

@@ -1,12 +1,5 @@
 #pragma once
 
-#include <stdio.h>
-#include <atlbase.h>
-#include <atlcom.h>
-
-#include <sapi.h>
-
-
 /**
  * 语音合成类,实现文字转语音的功能
  */

+ 3 - 2
zhipuzi_pos_windows/wnd/CFulikaShoukuanWnd.cpp

@@ -1290,7 +1290,8 @@ void CFulikaShoukuanWnd::HandleCancelShoukuan()
 
 void CFulikaShoukuanWnd::ReadShoukuanValue()
 {
-	CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
+	CSpeech::TTSSpeak("福利卡收款成功" + CLewaimaiString::TrimDecimalZero(CLewaimaiString::UnicodeToUTF8(m_money)) + "元");
+	//CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
 }
 
 //处理键盘捕捉结果
@@ -1302,4 +1303,4 @@ void CFulikaShoukuanWnd::HandleTextCapture(std::string content)
 
 		StartShoukuan();
 	}
-}
+}

+ 2 - 1
zhipuzi_pos_windows/wnd/CHuiyuanChongzhiWnd.cpp

@@ -1354,7 +1354,8 @@ void CHuiyuanChongzhiWnd::StartClose()
 
 void CHuiyuanChongzhiWnd::ReadShoukuanValue()
 {
-	CSpeech::SpeakNum(1, m_chongzhi);
+	CSpeech::TTSSpeak("充值成功" + CLewaimaiString::TrimDecimalZero(m_chongzhi) + "元");
+	//CSpeech::SpeakNum(1, m_chongzhi);
 }
 
 void CHuiyuanChongzhiWnd::HandleTextCapture(std::string content)

+ 3 - 2
zhipuzi_pos_windows/wnd/CHuiyuanShoukuanWnd.cpp

@@ -688,7 +688,8 @@ void CHuiyuanShoukuanWnd::HandleCancelShoukuan()
 
 void CHuiyuanShoukuanWnd::ReadShoukuanValue()
 {
-	CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
+	CSpeech::TTSSpeak("会员收款成功" + CLewaimaiString::TrimDecimalZero(CLewaimaiString::UnicodeToUTF8(m_money)) + "元");
+	//CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
 }
 
 //处理键盘捕捉结果
@@ -710,4 +711,4 @@ void CHuiyuanShoukuanWnd::SetMemberInfo(std::string member_id, std::string card_
 	m_pm.FindControl(L"huiyuan_name")->SetText((L"会员姓名:" + CLewaimaiString::UTF8ToUnicode(m_name)).c_str());
 	m_pm.FindControl(L"huiyuan_levelname")->SetText((L"会员级别:" + CLewaimaiString::UTF8ToUnicode(m_member_level_name)).c_str());
 	m_pm.FindControl(L"huiyuan_yue")->SetText((L"当前余额:" + CLewaimaiString::UTF8ToUnicode(m_member_balance)).c_str());
-}
+}

+ 3 - 2
zhipuzi_pos_windows/wnd/CWeixinzhifuShoukuanWnd.cpp

@@ -1008,7 +1008,8 @@ bool CWeixinzhifuShoukuanWnd::IsCanClose()
 
 void CWeixinzhifuShoukuanWnd::ReadShoukuanValue()
 {
-	CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
+	CSpeech::TTSSpeak("微信支付收款成功" + CLewaimaiString::TrimDecimalZero(CLewaimaiString::UnicodeToUTF8(m_money)) + "元");
+	//CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
 }
 
 //处理键盘捕捉结果
@@ -1020,4 +1021,4 @@ void CWeixinzhifuShoukuanWnd::HandleTextCapture(std::string content)
 	{
 		StartShoukuan();
 	}
-}
+}

+ 1 - 1
zhipuzi_pos_windows/wnd/CXianjinShoukuanWnd.cpp

@@ -1086,7 +1086,7 @@ void CXianjinShoukuanWnd::StartClose()
 
 void CXianjinShoukuanWnd::ReadShoukuanValue()
 {
-	CSpeech::TTSSpeak("你好,收款成功" + CLewaimaiString::UnicodeToUTF8(m_money) + "元");
+	CSpeech::TTSSpeak("现金收款成功" + CLewaimaiString::TrimDecimalZero(CLewaimaiString::UnicodeToUTF8(m_money)) + "元");
 	//CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
 }
 

+ 2 - 1
zhipuzi_pos_windows/wnd/CZidingyiShoukuanWnd.cpp

@@ -870,7 +870,8 @@ void CZidingyiShoukuanWnd::StartClose()
 
 void CZidingyiShoukuanWnd::ReadShoukuanValue()
 {
-	CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
+	CSpeech::TTSSpeak("收款成功" + CLewaimaiString::TrimDecimalZero(CLewaimaiString::UnicodeToUTF8(m_money)) + "元");
+	//CSpeech::SpeakNum(1, CLewaimaiString::UnicodeToUTF8(m_money));
 }
 
 void CZidingyiShoukuanWnd::SetZidingyiName(std::wstring name)