jxprint
This commit is contained in:
@@ -962,6 +962,25 @@ func TranslateSoundSize(vendorID, soundPercentage int) (soundSize string) {
|
||||
if soundPercentage > 66 && soundPercentage <= 100 {
|
||||
soundSize = "3"
|
||||
}
|
||||
} else if vendorID == model.VendorIDJxprint {
|
||||
if soundPercentage == 0 {
|
||||
soundSize = "0"
|
||||
}
|
||||
if soundPercentage > 0 && soundPercentage <= 20 {
|
||||
soundSize = "1"
|
||||
}
|
||||
if soundPercentage > 20 && soundPercentage <= 40 {
|
||||
soundSize = "2"
|
||||
}
|
||||
if soundPercentage > 40 && soundPercentage <= 60 {
|
||||
soundSize = "3"
|
||||
}
|
||||
if soundPercentage > 60 && soundPercentage <= 80 {
|
||||
soundSize = "4"
|
||||
}
|
||||
if soundPercentage > 80 && soundPercentage <= 100 {
|
||||
soundSize = "5"
|
||||
}
|
||||
}
|
||||
return soundSize
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ const (
|
||||
VendorIDXiaoWM = 202 // 外卖管家打印机
|
||||
VendorIDYiLianYun = 203 // 易联云
|
||||
VendorIDZhongWu = 204 // 中午云打印
|
||||
VendorIDJxprint = 205 // 京西打印
|
||||
VendorIDPrinterEnd = 300
|
||||
|
||||
VendorIDOthersBegin = 301
|
||||
@@ -112,6 +113,7 @@ var (
|
||||
VendorIDXiaoWM: "外卖管家",
|
||||
VendorIDYiLianYun: "易联云",
|
||||
VendorIDZhongWu: "中午云",
|
||||
VendorIDJxprint: "京西云",
|
||||
|
||||
VendorIDWXMP: "微信公众号",
|
||||
VendorIDWXQRCode: "微信扫码",
|
||||
|
||||
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) {
|
||||
|
||||
@@ -295,6 +295,9 @@ fnAppID = "6a3e2073-1850-413b-9eb7-6c342ec36e1c"
|
||||
fnAppSecret = "a8248088-a742-4c33-a0db-03aeae00ca7d"
|
||||
fnCallbackURL = "http://callback.jxc4.com/fn/msg"
|
||||
|
||||
jxPrintAppID = "1000"
|
||||
jxPrintAppKey = "rfBd56ti2SMtYvSg"
|
||||
|
||||
[jxgy]
|
||||
httpport = 8088
|
||||
EnableDocs = false
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jxprintapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
||||
"time"
|
||||
|
||||
@@ -100,6 +101,7 @@ var (
|
||||
YilianyunAPI *yilianyunapi.API
|
||||
YilianyunAPI2 *yilianyunapi.API
|
||||
ZhongwuAPI *zhongwuapi.API
|
||||
JxPrintAPI *jxprintapi.API
|
||||
|
||||
PushAPI *unipushapi.API
|
||||
|
||||
@@ -278,6 +280,7 @@ func Init() {
|
||||
YilianyunAPI2 = yilianyunapi.New(beego.AppConfig.DefaultString("yilianyunClientID2", ""), beego.AppConfig.DefaultString("yilianyunClientSecret2", ""))
|
||||
ZhongwuAPI = zhongwuapi.New(beego.AppConfig.DefaultInt("zhongwuAppID", 0), beego.AppConfig.DefaultString("zhongwuAppSecret", ""))
|
||||
PushAPI = unipushapi.New(beego.AppConfig.DefaultString("pushAppID", ""), beego.AppConfig.DefaultString("pushAppKey", ""), beego.AppConfig.DefaultString("pushAppSecret", ""), beego.AppConfig.DefaultString("pushMasterSecret", ""))
|
||||
JxPrintAPI = jxprintapi.New(beego.AppConfig.DefaultString("jxPrintAppID", ""), beego.AppConfig.DefaultString("jxPrintAppKey", ""))
|
||||
|
||||
SMSClient = aliyunsmsclient.New("http://dysmsapi.aliyuncs.com/")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user