- 飞鹅打印机支持
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/feieapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -367,8 +368,27 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
syncStatus := model.SyncFlagModifiedMask
|
||||
if valid["name"] != nil {
|
||||
valid["name"] = jxutils.FormalizeName(valid["name"].(string))
|
||||
store.Name = valid["name"].(string)
|
||||
syncStatus |= model.SyncFlagStoreName
|
||||
}
|
||||
// 网络打印机处理
|
||||
if valid["printerSN"] != nil || valid["printerKey"] != nil {
|
||||
originalPrinterSN := store.PrinterSN
|
||||
if valid["printerSN"] != nil {
|
||||
store.PrinterSN = valid["printerSN"].(string)
|
||||
}
|
||||
if valid["printerKey"] != nil {
|
||||
store.PrinterKey = valid["printerKey"].(string)
|
||||
}
|
||||
if store.PrinterSN != "" {
|
||||
if err = addNetPrinter(store.PrinterSN, store.PrinterKey, store.Name); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
} else if originalPrinterSN != "" {
|
||||
api.FeieAPI.PrinterDelList([]string{originalPrinterSN})
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range []string{
|
||||
"lng",
|
||||
"lat",
|
||||
@@ -437,6 +457,11 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
||||
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
|
||||
store.Name = jxutils.FormalizeName(store.Name)
|
||||
store.DeliveryRange = strings.Trim(store.DeliveryRange, ";")
|
||||
if store.PrinterSN != "" {
|
||||
if err = addNetPrinter(store.PrinterSN, store.PrinterKey, store.Name); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(store, userName)
|
||||
store.ID = existingID
|
||||
if err = dao.CreateEntity(nil, store); err == nil {
|
||||
@@ -446,6 +471,27 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func addNetPrinter(sn, key, storeName string) (err error) {
|
||||
name := storeName
|
||||
_, no, err := api.FeieAPI.PrinterAddList([]*feieapi.PrinterInfo{
|
||||
&feieapi.PrinterInfo{
|
||||
SN: sn,
|
||||
Key: key,
|
||||
Name: name,
|
||||
},
|
||||
})
|
||||
if err == nil {
|
||||
if no[sn] != "" {
|
||||
if no[sn] == feieapi.ErrMsgAlredyAdded {
|
||||
api.FeieAPI.PrinterEdit(sn, name, "")
|
||||
} else {
|
||||
err = fmt.Errorf("添加打印机出错:%s", no[sn])
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetStoreVendorMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*model.StoreMap, err error) {
|
||||
cond := map[string]interface{}{
|
||||
model.FieldStoreID: storeID,
|
||||
|
||||
Reference in New Issue
Block a user