订单配送,打印机

This commit is contained in:
邹宗楠
2022-06-01 15:36:08 +08:00
parent 1eae9e6ba4
commit b5a0ab5757
6 changed files with 100 additions and 30 deletions

View File

@@ -79,7 +79,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
\n
\n
商品明细: \n
品名 数量 单价 小计\n
品名 数量 小计\n
--------------------------------\n`
// <FB>实际支付:</FB>%s\n
orderParams = append(orderParams,
@@ -98,8 +98,9 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
for _, sku := range order.Skus {
orderFmt += `%s\n`
orderFmt += `%8s%10s%10s\n`
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
orderFmt += `%6s%8s%8s\n`
//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
//标品需要打印条形码
if sku.Upc != "" {
orderFmt += `upc码 %s\n`
@@ -164,7 +165,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
\n
\n
<FS2>商品明细: \n</FS2>
<FS2>品名数量单价小计\n</FS2>
品名 数量 小计\n
--------------------------------\n`
// <FS2><FB>实际支付:</FB>%s\n</FS2>
orderParams = append(orderParams,
@@ -183,8 +184,10 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
for _, sku := range order.Skus {
orderFmt += `<FS2>%s\n</FS2>`
orderFmt += `<FS2>%s %s %s\n\n</FS2>`
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
//orderFmt += `<FS2>%s %s %s\n\n</FS2>`
orderFmt += `<FH><FB>%s %s %s\n\n</FB></FH>`
//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
//标品需要打印条形码
if sku.Upc != "" {
orderFmt += `<FS2>upc码 %s\n</FS2>`
@@ -250,12 +253,22 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
return
}
content := ""
if store.PrinterFontSize == partner.PrinterFontSizeBig {
if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
content = c.getOrderContentBig(order, store.Tel1, storeDetail)
} else {
content = c.getOrderContent(order, store.Tel1, storeDetail)
}
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
var count = 0
for {
printerStatus, err := c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
if (store.PrinterFontSize == partner.PrinterFontSizeBig2 || store.PrinterFontSize == partner.PrinterFontSizeNormal2) && count < 1 {
count = count + 1
continue
} else {
return printerStatus, err
}
}
}
func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, machineCode, secret, printerName string) (notUsed1, notUsed2 string, err error) {