- IPrinterHandler添加EmptyPrintList与PlayText

- 易联云打印机播放:用户申请取消订单请注意查看,收到新的售后单请查看
This commit is contained in:
gazebo
2019-07-19 17:09:56 +08:00
parent 09da354c85
commit 3c94651b2b
8 changed files with 73 additions and 0 deletions

View File

@@ -348,6 +348,7 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
if status.Status == model.OrderStatusApplyCancel {
utils.CallFuncAsync(func() {
weixinmsg.NotifyUserApplyCancel(savedOrderInfo.order, status.Remark)
netprinter.NofityOrderStatus(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), order.VendorOrderID, netprinter.PrinterNotifyUserApplyCancel)
})
}
msghub.OnKeyOrderStatusChanged(savedOrderInfo.order)

View File

@@ -1,6 +1,9 @@
package defsch
import (
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/msghub"
@@ -11,6 +14,7 @@ func (s *DefScheduler) OnAfsOrderNew(order *model.AfsOrder, isPending bool) (err
if !isPending {
msghub.OnNewWait4ApproveAfsOrder(order)
weixinmsg.NotifyAfsOrderStatus(order)
netprinter.NofityOrderStatus(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromAfsOrder(order), order.VendorOrderID, netprinter.PrinterNotifyNewAfsOrder)
}
}
return err

View File

@@ -22,6 +22,18 @@ const (
realTestOrderVendorID = model.VendorIDJD
)
const (
PrinterNotifyUserApplyCancel = 1
PrinterNotifyNewAfsOrder = 2
)
var (
printerMsgMap = map[int]string{
PrinterNotifyUserApplyCancel: "用户申请取消订单请注意查看",
PrinterNotifyNewAfsOrder: "收到新的售后单请查看",
}
)
func PrintOrder(ctx *jxcontext.Context, vendorOrderID string, vendorID int) (printResult *partner.PrinterStatus, err error) {
storeID := vendorID
if vendorOrderID == testVendorOrderID {
@@ -182,3 +194,20 @@ func RebindAllPrinters(ctx *jxcontext.Context, isForce, isAsync bool) (hint stri
}
return hint, err
}
func NofityOrderStatus(ctx *jxcontext.Context, storeID int, orderID string, notifyID int) (err error) {
if printerMsgMap[notifyID] != "" {
db := dao.GetDB()
store := &model.Store{}
store.ID = storeID
if err = dao.GetEntity(db, store); err == nil {
handler, err := GetHandlerFromStore(store)
if err == nil {
if globals.EnableStoreWrite {
_, err = handler.PlayText(ctx, store.PrinterSN, store.PrinterKey, orderID, printerMsgMap[notifyID])
}
}
}
}
return err
}

View File

@@ -26,6 +26,9 @@ type IPrinterHandler interface {
RebindPrinter(ctx *jxcontext.Context, lastBindResult *BindPrinterResult) (bindResult *BindPrinterResult, err error)
PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *PrinterStatus, err error)
EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error)
PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *PrinterStatus, err error)
}
var (

View File

@@ -169,3 +169,12 @@ func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]
func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *partner.BindPrinterResult) (bindResult *partner.BindPrinterResult, err error) {
return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDFeiE])
}
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
err = api.FeieAPI.DelPrinterSqs(id1)
return err
}
func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
return c.GetPrinterStatus(ctx, id1, id2)
}

View File

@@ -267,3 +267,11 @@ func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]
func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *partner.BindPrinterResult) (bindResult *partner.BindPrinterResult, err error) {
return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDXiaoWM])
}
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
return err
}
func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
return c.GetPrinterStatus(ctx, id1, id2)
}

View File

@@ -182,3 +182,13 @@ func getApiByToken(possibleToken string) *yilianyunapi.API {
}
return api.YilianyunAPI
}
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
err = api.YilianyunAPI.CancelAll(id1, id2)
return err
}
func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
err = api.YilianyunAPI.PlayText(id1, orderID, text, id2)
return nil, err
}

View File

@@ -164,3 +164,12 @@ func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]
func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *partner.BindPrinterResult) (bindResult *partner.BindPrinterResult, err error) {
return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDZhongWu])
}
func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
_, err = api.ZhongwuAPI.EmptyPrintQueue(id1, id2)
return err
}
func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
return c.GetPrinterStatus(ctx, id1, id2)
}