Merge remote-tracking branch 'origin/mark' into lcw
This commit is contained in:
@@ -384,6 +384,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
store.PrinterSN = ""
|
||||
store.PrinterKey = ""
|
||||
store.PrinterVendorID = printerVendorID
|
||||
valid["printerSN"], valid["printerKey"] = store.PrinterSN, store.PrinterKey
|
||||
}
|
||||
}
|
||||
if valid["printerSN"] != nil || valid["printerKey"] != nil {
|
||||
@@ -400,6 +401,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
if err = handler.RegisterPrinter(ctx, store, valid["printerSN"].(string), valid["printerKey"].(string)); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
valid["printerSN"], valid["printerKey"] = store.PrinterSN, store.PrinterKey
|
||||
}
|
||||
|
||||
for _, v := range []string{
|
||||
|
||||
@@ -115,15 +115,14 @@ func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msg string)
|
||||
return printerStatus, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, id1, id2 string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
sn := id1
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrintResult: partner.PrintResultSuccess,
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerSN, printerKey string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
if printerStatus.PrinterStatus, err = api.FeieAPI.QueryPrinterStatus(printerSN); err == nil {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrintResult: partner.PrintResultSuccess,
|
||||
}
|
||||
printerStatus.Printed, printerStatus.Waiting, err = api.FeieAPI.QueryOrderInfoByDate(printerSN, time.Now())
|
||||
}
|
||||
if printerStatus.PrinterStatus, err = api.FeieAPI.QueryPrinterStatus(sn); err == nil {
|
||||
printerStatus.Printed, printerStatus.Waiting, err = api.FeieAPI.QueryOrderInfoByDate(sn, time.Now())
|
||||
}
|
||||
return printerStatus, nil
|
||||
return printerStatus, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/xiaowmapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -100,11 +102,11 @@ func (c *PrinterHandler) GetVendorID() int {
|
||||
return model.VendorIDXiaoWM
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msg string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintMsg id1:%s", id1)
|
||||
if id1 != "" {
|
||||
if _, err = api.XiaoWMAPI.SendMsg(id1, id2, msg); err == nil {
|
||||
printerStatus, err = c.GetPrinterStatus(ctx, id1, id2)
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, printerNumber, printerToken, msg string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintMsg printerNumber:%s", printerNumber)
|
||||
if printerNumber != "" {
|
||||
if _, err = api.XiaoWMAPI.SendMsg(printerNumber, printerToken, msg); err == nil {
|
||||
printerStatus, err = c.GetPrinterStatus(ctx, printerNumber, printerToken)
|
||||
}
|
||||
} else {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
@@ -114,7 +116,22 @@ func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msg string)
|
||||
return printerStatus, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, id1, id2 string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerNumber, printerToken string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
runningState, paperState, err := api.XiaoWMAPI.GetPrinterStatus(printerNumber, printerToken)
|
||||
if err == nil {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrintResult: partner.PrintResultSuccess,
|
||||
}
|
||||
if runningState == xiaowmapi.RunningStateOffline {
|
||||
printerStatus.PrinterStatus = partner.PrinterStatusOffline
|
||||
} else {
|
||||
if paperState == xiaowmapi.PaperStateLackPaper {
|
||||
printerStatus.PrinterStatus = partner.PrinterStatusOnlineAbnormal
|
||||
} else {
|
||||
printerStatus.PrinterStatus = partner.PrinterStatusOnlineOK
|
||||
}
|
||||
}
|
||||
}
|
||||
return printerStatus, err
|
||||
}
|
||||
|
||||
@@ -124,16 +141,17 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, content)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, store *model.Store, id1, id2 string) (err error) {
|
||||
if store.PrinterSN != "" && (store.PrinterSN != id1 || store.PrinterKey != id2) {
|
||||
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, store *model.Store, printerNumber, notUsed string) (err error) {
|
||||
if store.PrinterSN != "" && store.PrinterSN != printerNumber {
|
||||
err = c.UnregisterPrinter(ctx, store)
|
||||
}
|
||||
if true { //err == nil {
|
||||
if id1 != "" {
|
||||
// if err = addNetPrinter(id1, id2, store.Name); err == nil {
|
||||
// store.PrinterSN = id1
|
||||
// store.PrinterKey = id2
|
||||
// }
|
||||
if printerNumber != "" {
|
||||
var printerToken string
|
||||
if printerToken, err = api.XiaoWMAPI.AuthPrinter(printerNumber, "", ""); err == nil {
|
||||
store.PrinterSN = printerNumber
|
||||
store.PrinterKey = printerToken
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
@@ -141,7 +159,7 @@ func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, store *model.St
|
||||
|
||||
func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, store *model.Store) (err error) {
|
||||
if store.PrinterSN != "" {
|
||||
// _, _, err = api.FeieAPI.PrinterDelList([]string{store.PrinterSN})
|
||||
err = api.XiaoWMAPI.DelPrinter(store.PrinterSN, store.PrinterKey)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user