This commit is contained in:
suyl
2021-07-21 17:44:52 +08:00
parent 975c150a57
commit b572c36868

View File

@@ -264,7 +264,7 @@ func printFail() (err error) {
c net.Conn
)
if printMsg != nil {
if err = checkPrintMsg(printMsg); err == nil {
if err = checkPrintMsg(db, printMsg); err == nil {
tcpClient.s.RLock()
if tcpClient.Clients[printMsg.PrintNo] != nil {
if tcpClient.Clients[printMsg.PrintNo].Status == printerStatusOnline {
@@ -355,7 +355,7 @@ func HandleTcpMessages() {
c net.Conn
)
if printMsg != nil {
if err = checkPrintMsg(printMsg); err == nil {
if err = checkPrintMsg(db, printMsg); err == nil {
tcpClient.s.RLock()
if tcpClient.Clients[printMsg.PrintNo] != nil {
if tcpClient.Clients[printMsg.PrintNo].Status == printerStatusOnline {
@@ -556,7 +556,7 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
return result
}
func checkPrintMsg(printMsg *model.PrintMsg) (err error) {
func checkPrintMsg(db *dao.DaoDB, printMsg *model.PrintMsg) (err error) {
if printMsg.Content == "" {
return fmt.Errorf("此打印信息内容为空printMsg printNo:[%v], orderNo :[%v]", printMsg.PrintNo, printMsg.OrderNo)
}
@@ -566,6 +566,13 @@ func checkPrintMsg(printMsg *model.PrintMsg) (err error) {
if printMsg.OrderNo == 0 {
return fmt.Errorf("此打印信息订单序号为空printMsg printNo:[%v], orderNo :[%v]", printMsg.PrintNo, printMsg.OrderNo)
}
if printer, err := dao.GetPrinter(db, printMsg.PrintNo); err == nil {
if printer != nil {
if printer.FlowFlag == 1 {
return fmt.Errorf("此打印机当月流量已用完请及时充值printNo:[%v]", printMsg.PrintNo)
}
}
}
return err
}