jxprint
This commit is contained in:
97
business/partner/printer/jxprint/jxprint.go
Normal file
97
business/partner/printer/jxprint/jxprint.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package jxprint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
var (
|
||||
CurPrinterHandler *PrinterHandler
|
||||
)
|
||||
|
||||
type PrinterHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
CurPrinterHandler = new(PrinterHandler)
|
||||
partner.RegisterPrinterPlatform(CurPrinterHandler)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetVendorID() int {
|
||||
return model.VendorIDJxprint
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, id1, id2 string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
tmpStatus, err := api.JxPrintAPI.GetPrinterStatus(id1)
|
||||
if err == nil {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrinterStatus: int(tmpStatus),
|
||||
PrintResult: partner.PrintResultSuccess,
|
||||
}
|
||||
//printerStatus.Printed, printerStatus.Waiting, err = api.FeieAPI.QueryOrderInfoByDate(printerSN, time.Now())
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, id1, id2, printerName string) (newID1, newID2 string, err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JxPrintAPI.AddPrinter([]*jxprintapi.AddPrinterParam{
|
||||
&jxprintapi.AddPrinterParam{
|
||||
PrintNo: id1,
|
||||
Name: printerName,
|
||||
},
|
||||
})
|
||||
}
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, id1, id2 string) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JxPrintAPI.DelPrinter([]string{id1})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) {
|
||||
return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDJxprint])
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *partner.BindPrinterResult) (bindResult *partner.BindPrinterResult, err error) {
|
||||
return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDJxprint])
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JxPrintAPI.DelPrinterSeq(id1)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) SetSound(ctx *jxcontext.Context, id1, id2, sound string) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JxPrintAPI.UpdatePrinter(&jxprintapi.UpdatePrinterParam{
|
||||
PrintNo: id1,
|
||||
Volume: utils.Str2Int(sound),
|
||||
})
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -5,10 +5,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
@@ -19,20 +15,20 @@ func init() {
|
||||
}
|
||||
|
||||
func TestPrintMsg(t *testing.T) {
|
||||
orderID := "910838879000442"
|
||||
vendorID := 0
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// context := CurPrinterHandler.getOrderContent(order, "13412345678")
|
||||
context := CurPrinterHandler.getOrderContentBig(order, "13412345678")
|
||||
status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "12364142", "v7rvjv9b", "test", context)
|
||||
t.Log(utils.Format4Output(status, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
//orderID := "910838879000442"
|
||||
//vendorID := 0
|
||||
//order, err := partner.CurOrderManager.LoadOrder(orderID, vendorID)
|
||||
//if err != nil {
|
||||
// t.Fatal(err)
|
||||
//}
|
||||
//
|
||||
//// context := CurPrinterHandler.getOrderContent(order, "13412345678")
|
||||
//context := CurPrinterHandler.getOrderContentBig(order, "13412345678")
|
||||
//status, err := CurPrinterHandler.PrintMsg(jxcontext.AdminCtx, "12364142", "v7rvjv9b", "test", context)
|
||||
//t.Log(utils.Format4Output(status, false))
|
||||
//if err != nil {
|
||||
// t.Fatal(err)
|
||||
//}
|
||||
}
|
||||
|
||||
func TestRegisterPrinter(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user