门店增加可调节打印机声音

This commit is contained in:
苏尹岚
2020-04-21 14:08:19 +08:00
parent febda332ad
commit 2a1863c144
5 changed files with 42 additions and 3 deletions

View File

@@ -762,7 +762,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
delete(valid, "printerKey")
}
// 网络打印机处理
if valid["printerVendorID"] != nil || valid["printerSN"] != nil || valid["printerKey"] != nil {
if valid["printerVendorID"] != nil || valid["printerSN"] != nil || valid["printerKey"] != nil || valid["soundPercentage"] != nil {
if valid["printerVendorID"] == nil {
valid["printerVendorID"] = store.PrinterVendorID
}
@@ -788,6 +788,12 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
if newID2 != "" {
valid["printerKey"] = newID2
}
if valid["soundPercentage"] != nil {
err = handler.SetSound(ctx, store.PrinterSN, store.PrinterKey, jxutils.TranslateSoundSize(printerVendorID, valid["soundPercentage"].(int)))
if err != nil {
return 0, err
}
}
} else {
valid["printerVendorID"] = 0
valid["printerSN"] = ""

View File

@@ -823,3 +823,21 @@ func TranslateStorePriceType(storePriceType int8) int8 {
}
return storePriceType
}
func TranslateSoundSize(vendorID, soundPercentage int) (soundSize string) {
if vendorID == model.VendorIDYiLianYun || vendorID == model.VendorIDFeiE {
if soundPercentage == 0 {
soundSize = "0"
}
if soundPercentage > 0 && soundPercentage <= 33 {
soundSize = "1"
}
if soundPercentage > 33 && soundPercentage <= 66 {
soundSize = "2"
}
if soundPercentage > 66 && soundPercentage <= 100 {
soundSize = "3"
}
}
return soundSize
}

View File

@@ -20,8 +20,8 @@ const (
)
const (
PrinterFontSizeNormal = int8(0)//正常大小
PrinterFontSizeBig = int8(1)//两倍大小
PrinterFontSizeNormal = int8(0) //正常大小
PrinterFontSizeBig = int8(1) //两倍大小
)
var (
@@ -62,6 +62,7 @@ type IPrinterHandler interface {
EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error)
PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *PrinterStatus, err error)
SetSound(ctx *jxcontext.Context, id1, id2, sound string) (err error)
}
var (

View File

@@ -269,3 +269,10 @@ func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string)
func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
return c.GetPrinterStatus(ctx, id1, id2)
}
func (c *PrinterHandler) SetSound(ctx *jxcontext.Context, id1, id2, sound string) (err error) {
if globals.EnableStoreWrite {
err = api.FeieAPI.SetSound(id1, sound)
}
return err
}

View File

@@ -281,3 +281,10 @@ func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, tex
}
return nil, err
}
func (c *PrinterHandler) SetSound(ctx *jxcontext.Context, id1, id2, sound string) (err error) {
if globals.EnableStoreWrite {
err = api.YilianyunAPI.SetSound(id1, sound)
}
return err
}