增加打印大字体的功能

This commit is contained in:
Rosy-zhudan
2019-08-19 18:09:03 +08:00
parent 59f07b567a
commit 10da91668f
9 changed files with 452 additions and 11 deletions

View File

@@ -59,9 +59,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
*
客户备注: *
<big>%s*
*
<S011>实际支付: %s*
*
商品明细: *
品名 数量 单价 小计
--------------------------------*
@@ -105,6 +103,80 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
return content
}
func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string) (content string) {
expectedDeliveryTime := order.ExpectedDeliveredTime
if utils.IsTimeZero(expectedDeliveryTime) {
expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<big>饿百取货码:%s**\n", jxutils.GetEbaiOrderGetCode(order))
}
buyerComment := order.BuyerComment
if buyerComment == "" {
buyerComment = " "
}
orderFmt := `
<big> %s**
手机买菜上京西*
极速到家送惊喜*
------------------------------*
<big>下单时间: %s**
<big>预计送达: %s**
<big>订单编号: %s*
*
<big>%s\#%d*
<qrcA4>%s*
` + getCode +
`<big>客户: %s*
<big>电话: %s*
<big>地址: %s*
*
<big>客户备注: *
<big>%s*
<big>实际支付: %s*
<big>商品明细: *
<big>品名数量单价小计*
--------------------------------*
`
orderParams := []interface{}{
globals.StoreName,
utils.Time2Str(order.OrderCreatedAt),
utils.Time2Str(expectedDeliveryTime),
order.VendorOrderID,
jxutils.GetVendorName(order.VendorID),
order.OrderSeq,
order.VendorOrderID,
order.ConsigneeName,
order.ConsigneeMobile,
order.ConsigneeAddress,
buyerComment,
jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
}
for _, sku := range order.Skus {
orderFmt += `<big>%s*`
orderFmt += `<big>%s %s %s*`
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
}
orderFmt += `
<big>共%d种%d件商品*
--------------------------------*
<S020>商品质量问题请联系:*
<S020>%s:%s*
*
<big>更多信息请关注官方微信: %s*
--------------------------------
--------------------------------
*<BEEP13500,3,2,1>*
`
// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, order.StoreName, storeTel, globals.StoreName)
content = fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), escapeString4Printer(orderParams)...)
// globals.SugarLogger.Debugf("xiaowm orderParams:%s\n", utils.Format4Output(orderParams, false))
// globals.SugarLogger.Debugf("xiaowm getOrderContent:%s\n", content)
return content
}
func (c *PrinterHandler) getOrderContent2(order *model.GoodsOrder, storeTel string) (content string) {
expectedDeliveryTime := order.ExpectedDeliveredTime
if utils.IsTimeZero(expectedDeliveryTime) {
@@ -223,7 +295,11 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store,
if isV500(store.PrinterSN) {
content = c.getOrderContent2(order, store.Tel1)
} else {
content = c.getOrderContent(order, store.Tel1)
if store.PrinterFontSize == partner.PrinterFontSizeBig {
content = c.getOrderContentBig(order, store.Tel1)
} else {
content = c.getOrderContent(order, store.Tel1)
}
}
return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
}