- 美团外卖v500打印机适配
This commit is contained in:
@@ -92,6 +92,69 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), escapeString4Printer(orderParams)...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) getOrderContent2(order *model.GoodsOrder, storeTel string) (content string) {
|
||||
expectedDeliveryTime := order.ExpectedDeliveredTime
|
||||
if utils.IsTimeZero(expectedDeliveryTime) {
|
||||
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
|
||||
}
|
||||
orderFmt := `
|
||||
|7 京西菜市
|
||||
|5 手机买菜上京西
|
||||
|5 极速到家送惊喜
|
||||
|5--------------------------------
|
||||
|5下单时间: %s
|
||||
|5预计送达: %s
|
||||
|5订单编号: %s
|
||||
|5
|
||||
|7%s\#%d
|
||||
|5
|
||||
|2%s
|
||||
|5客户: %s
|
||||
|5电话: %s
|
||||
|5地址: %s
|
||||
|5
|
||||
|5客户备注:
|
||||
|7%s
|
||||
|5
|
||||
|6实际支付: %s
|
||||
|5
|
||||
|5商品明细:
|
||||
|5品名 数量 单价 小计
|
||||
|5--------------------------------
|
||||
`
|
||||
orderParams := []interface{}{
|
||||
utils.Time2Str(order.OrderCreatedAt),
|
||||
utils.Time2Str(expectedDeliveryTime),
|
||||
order.VendorOrderID,
|
||||
jxutils.GetVendorName(order.VendorID),
|
||||
order.OrderSeq,
|
||||
order.VendorOrderID,
|
||||
order.ConsigneeName,
|
||||
order.ConsigneeMobile,
|
||||
order.ConsigneeAddress,
|
||||
order.BuyerComment,
|
||||
jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
|
||||
}
|
||||
for _, sku := range order.Skus {
|
||||
orderFmt += `%s*`
|
||||
orderFmt += `%8s%10s%10s*`
|
||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||
}
|
||||
orderFmt += `
|
||||
|5
|
||||
|6共%d种%d件商品
|
||||
|5--------------------------------
|
||||
|5商品质量问题请联系:
|
||||
|5%s:%s
|
||||
|5
|
||||
|5更多信息请关注官方微信: 京西菜市
|
||||
|5--------------------------------
|
||||
|5--------------------------------
|
||||
`
|
||||
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel)
|
||||
return fmt.Sprintf(orderFmt, escapeString4Printer(orderParams)...)
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetVendorID() int {
|
||||
return model.VendorIDXiaoWM
|
||||
}
|
||||
@@ -131,10 +194,20 @@ func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerNumber,
|
||||
|
||||
func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("xiaowm PrintOrderByOrder orderID:%s", order.VendorOrderID)
|
||||
content := c.getOrderContent(order, store.Tel1)
|
||||
var content string
|
||||
if isV500(store.PrinterSN) {
|
||||
content = c.getOrderContent2(order, store.Tel1)
|
||||
} else {
|
||||
content = c.getOrderContent(order, store.Tel1)
|
||||
}
|
||||
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
|
||||
}
|
||||
|
||||
func isV500(printerNo string) bool {
|
||||
printerNoNum := utils.Str2Int64WithDefault("1"+printerNo, 0)
|
||||
return printerNoNum > 1000000000
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerNumber, notUsed, printerName string) (newID1, printerToken string, err error) {
|
||||
globals.SugarLogger.Debugf("xiaowm RegisterPrinter printerNumber:%s", printerNumber)
|
||||
if printerNumber == "" { //len(printerNumber) != len("7JizmSyiXNzkggaqU") {
|
||||
|
||||
Reference in New Issue
Block a user